From 73e2aa711af82f47304e88ddd539857b48baf7b6 Mon Sep 17 00:00:00 2001 From: Antonino Porcino Date: Tue, 31 May 2016 12:44:36 +0200 Subject: [PATCH 01/14] Turned into NPM package --- RiotTS.csproj | 15 +- RiotTS.csproj.user | 2 +- RiotTS.sln | 11 +- Test/Gruntfile.js | 19 -- Test/Test.csproj | 82 ----- Test/Test.csproj.user | 30 -- Test/app.js | 27 -- Test/app.js.map | 1 - Test/bower.json | 20 -- Test/elements/specElements.js | 159 ---------- Test/elements/specElements.js.map | 1 - Test/elements/specElements.ts | 140 --------- Test/elements/template-cache.js | 25 -- Test/elements/test-template.html | 3 - Test/elements/timer.html | 14 - Test/elements/timer.js | 52 ---- Test/elements/timer.js.map | 1 - Test/elements/timer.ts | 52 ---- Test/index.html | 29 -- Test/index.js | 5 - Test/index.js.map | 1 - Test/index.ts | 9 - Test/precompiled-tags.js | 2 - Test/specRunner.html | 31 -- Test/specRunner.js | 167 ---------- Test/specRunner.js.map | 1 - Test/specRunner.ts | 231 -------------- Test/tsconfig.json | 14 - Test/tsd.json | 12 - Test/typings/jasmine/jasmine.d.ts | 496 ------------------------------ Test/typings/tsd.d.ts | 1 - Test/web.Debug.config | 31 -- Test/web.Release.config | 32 -- Test/web.config | 16 - bower.json | 20 -- package.json | 22 ++ riot-ts.d.ts | 120 +++----- riot-ts.js | 203 ++++++------ riot-ts.js.map | 2 +- riot-ts.ts | 266 +++++++--------- riot.d.ts | 47 +++ riot.js | 0 riot.js.map | 1 + riot.ts | 63 ++++ tsconfig.json | 11 + types.d.ts | 22 ++ types.js | 1 + types.js.map | 1 + types.ts | 27 ++ 49 files changed, 450 insertions(+), 2088 deletions(-) delete mode 100644 Test/Gruntfile.js delete mode 100644 Test/Test.csproj delete mode 100644 Test/Test.csproj.user delete mode 100644 Test/app.js delete mode 100644 Test/app.js.map delete mode 100644 Test/bower.json delete mode 100644 Test/elements/specElements.js delete mode 100644 Test/elements/specElements.js.map delete mode 100644 Test/elements/specElements.ts delete mode 100644 Test/elements/template-cache.js delete mode 100644 Test/elements/test-template.html delete mode 100644 Test/elements/timer.html delete mode 100644 Test/elements/timer.js delete mode 100644 Test/elements/timer.js.map delete mode 100644 Test/elements/timer.ts delete mode 100644 Test/index.html delete mode 100644 Test/index.js delete mode 100644 Test/index.js.map delete mode 100644 Test/index.ts delete mode 100644 Test/precompiled-tags.js delete mode 100644 Test/specRunner.html delete mode 100644 Test/specRunner.js delete mode 100644 Test/specRunner.js.map delete mode 100644 Test/specRunner.ts delete mode 100644 Test/tsconfig.json delete mode 100644 Test/tsd.json delete mode 100644 Test/typings/jasmine/jasmine.d.ts delete mode 100644 Test/typings/tsd.d.ts delete mode 100644 Test/web.Debug.config delete mode 100644 Test/web.Release.config delete mode 100644 Test/web.config delete mode 100644 bower.json create mode 100644 package.json create mode 100644 riot.d.ts create mode 100644 riot.js create mode 100644 riot.js.map create mode 100644 riot.ts create mode 100644 tsconfig.json create mode 100644 types.d.ts create mode 100644 types.js create mode 100644 types.js.map create mode 100644 types.ts diff --git a/RiotTS.csproj b/RiotTS.csproj index cfd6ff1..3fa31be 100644 --- a/RiotTS.csproj +++ b/RiotTS.csproj @@ -10,7 +10,7 @@ v4.5.2 full true - 1.7 + 1.8 true @@ -22,11 +22,14 @@ + + + web.config @@ -66,13 +69,14 @@ ES5 True False - None + CommonJS True True + None true @@ -84,10 +88,7 @@ - copy "$(SolutionDir)riot-ts.ts" "$(SolutionDir)\Test\bower_components\riot-ts" -copy "$(SolutionDir)riot-ts.js" "$(SolutionDir)\Test\bower_components\riot-ts" -copy "$(SolutionDir)riot-ts.js.map" "$(SolutionDir)\Test\bower_components\riot-ts" -copy "$(SolutionDir)riot-ts.d.ts" "$(SolutionDir)\Test\bower_components\riot-ts" - + + \ No newline at end of file diff --git a/RiotTS.csproj.user b/RiotTS.csproj.user index c66da1a..ba4ef37 100644 --- a/RiotTS.csproj.user +++ b/RiotTS.csproj.user @@ -1,7 +1,7 @@  - 1.7 + 1.8 diff --git a/RiotTS.sln b/RiotTS.sln index 8f1898c..3d023f4 100644 --- a/RiotTS.sln +++ b/RiotTS.sln @@ -1,14 +1,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.23107.0 +VisualStudioVersion = 14.0.25029.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RiotTS", "RiotTS.csproj", "{C24611C6-0BE4-47B9-B298-13962D2CBF9F}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{38ABA33D-B4FA-4BAD-8E3D-C706B0E6B27B}" - ProjectSection(ProjectDependencies) = postProject - {C24611C6-0BE4-47B9-B298-13962D2CBF9F} = {C24611C6-0BE4-47B9-B298-13962D2CBF9F} - EndProjectSection -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -19,10 +14,6 @@ Global {C24611C6-0BE4-47B9-B298-13962D2CBF9F}.Debug|Any CPU.Build.0 = Debug|Any CPU {C24611C6-0BE4-47B9-B298-13962D2CBF9F}.Release|Any CPU.ActiveCfg = Release|Any CPU {C24611C6-0BE4-47B9-B298-13962D2CBF9F}.Release|Any CPU.Build.0 = Release|Any CPU - {38ABA33D-B4FA-4BAD-8E3D-C706B0E6B27B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {38ABA33D-B4FA-4BAD-8E3D-C706B0E6B27B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {38ABA33D-B4FA-4BAD-8E3D-C706B0E6B27B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {38ABA33D-B4FA-4BAD-8E3D-C706B0E6B27B}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Test/Gruntfile.js b/Test/Gruntfile.js deleted file mode 100644 index b50b2f8..0000000 --- a/Test/Gruntfile.js +++ /dev/null @@ -1,19 +0,0 @@ - -module.exports = function(grunt) { - - grunt.initConfig({ - - // reads all tags in "elements/" and writes to "precompiled-tags.js" - precompileTags: { - src: ['elements/**/*.html'], - dest: 'precompiled-tags.js' - } - - }); - - grunt.registerTask('default', ['precompileTags']); - grunt.registerTask('clean', ['precompileTags:off']); - - grunt.loadNpmTasks('grunt-riotts-precompile'); - -}; diff --git a/Test/Test.csproj b/Test/Test.csproj deleted file mode 100644 index d4a4277..0000000 --- a/Test/Test.csproj +++ /dev/null @@ -1,82 +0,0 @@ - - - - - Debug - {38ABA33D-B4FA-4BAD-8E3D-C706B0E6B27B} - {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} - Library - bin - v4.5.2 - full - true - 1.7 - true - - - - - - - - - - - - - - - - - - - - - - - - - web.config - - - web.config - - - - 12.0 - - - Test - - - - - - - - True - True - 4021 - / - http://localhost:4021/ - False - False - - - False - - - - - - false - true - true - - - true - false - true - - - \ No newline at end of file diff --git a/Test/Test.csproj.user b/Test/Test.csproj.user deleted file mode 100644 index 4946c9b..0000000 --- a/Test/Test.csproj.user +++ /dev/null @@ -1,30 +0,0 @@ - - - - 1.7 - - - - - - specRunner.html - SpecificPage - True - False - False - False - - - - - - - - - True - True - - - - - \ No newline at end of file diff --git a/Test/app.js b/Test/app.js deleted file mode 100644 index d5f0f7e..0000000 --- a/Test/app.js +++ /dev/null @@ -1,27 +0,0 @@ -/// -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; -function main() { - riot.route(function (id, username) { - console.log("hash changed to: " + id + "/" + username); - }); - riot.route.start(); - riot.mount('*'); - riot.route("welcome/nino.porcino"); - var p = new Car(); - p.trigger("start"); -} -var Car = (function (_super) { - __extends(Car, _super); - function Car() { - _super.call(this); - this.on('start', function () { - console.log("car started!"); - }); - } - return Car; -})(Riot.Observable); -//# sourceMappingURL=app.js.map \ No newline at end of file diff --git a/Test/app.js.map b/Test/app.js.map deleted file mode 100644 index 8e2033e..0000000 --- a/Test/app.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"app.js","sourceRoot":"","sources":["app.ts"],"names":["main","Car","Car.constructor"],"mappings":"AAAA,8DAA8D;;;;;;AAE9D;IACGA,IAAIA,CAACA,KAAKA,CAACA,UAACA,EAAEA,EAACA,QAAQA;QAEpBA,OAAOA,CAACA,GAAGA,CAACA,mBAAmBA,GAACA,EAAEA,GAACA,GAAGA,GAACA,QAAQA,CAACA,CAACA;IACpDA,CAACA,CAACA,CAACA;IACHA,IAAIA,CAACA,KAAKA,CAACA,KAAKA,EAAEA,CAACA;IAEnBA,IAAIA,CAACA,KAAKA,CAACA,GAAGA,CAACA,CAACA;IAEhBA,IAAIA,CAACA,KAAKA,CAACA,sBAAsBA,CAACA,CAACA;IAEnCA,IAAIA,CAACA,GAAGA,IAAIA,GAAGA,EAAEA,CAACA;IAElBA,CAACA,CAACA,OAAOA,CAACA,OAAOA,CAACA,CAACA;AACtBA,CAACA;AAED;IAAkBC,uBAAeA;IAE9BA;QAEGC,iBAAOA,CAACA;QAERA,IAAIA,CAACA,EAAEA,CAACA,OAAOA,EAAEA;YAEdA,OAAOA,CAACA,GAAGA,CAACA,cAAcA,CAACA,CAACA;QAC/BA,CAACA,CAACA,CAACA;IACNA,CAACA;IACJD,UAACA;AAADA,CAACA,AAXD,EAAkB,IAAI,CAAC,UAAU,EAWhC"} \ No newline at end of file diff --git a/Test/bower.json b/Test/bower.json deleted file mode 100644 index f63acad..0000000 --- a/Test/bower.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "riot-ts-test", - "version": "0.0.0", - "homepage": "https://github.com/nippur72/RiotTS", - "authors": [ - "Antonino Porcino " - ], - "license": "MIT", - "ignore": [ - "**/.*", - "node_modules", - "bower_components", - "test", - "tests" - ], - "dependencies": { - "jasmine": "~2.3.4", - "riot-ts": "*" - } -} diff --git a/Test/elements/specElements.js b/Test/elements/specElements.js deleted file mode 100644 index 806be5e..0000000 --- a/Test/elements/specElements.js +++ /dev/null @@ -1,159 +0,0 @@ -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; -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 test1 = (function (_super) { - __extends(test1, _super); - function test1() { - _super.apply(this, arguments); - } - test1 = __decorate([ - template("\n\n\n
test1 element
\n
\n\n") - ], test1); - return test1; -})(Riot.Element); -var test2 = (function (_super) { - __extends(test2, _super); - function test2() { - _super.apply(this, arguments); - } - test2 = __decorate([ - template('
test2 element
') - ], test2); - return test2; -})(Riot.Element); -var test_template_from_url = (function (_super) { - __extends(test_template_from_url, _super); - function test_template_from_url() { - _super.apply(this, arguments); - } - test_template_from_url = __decorate([ - template("elements/test-template.html") - ], test_template_from_url); - return test_template_from_url; -})(Riot.Element); -var testNoTagName = (function (_super) { - __extends(testNoTagName, _super); - function testNoTagName() { - _super.apply(this, arguments); - } - testNoTagName = __decorate([ - template("") - ], testNoTagName); - return testNoTagName; -})(Riot.Element); -var testDoubleRegister = (function (_super) { - __extends(testDoubleRegister, _super); - function testDoubleRegister() { - _super.apply(this, arguments); - } - testDoubleRegister = __decorate([ - template("
") - ], testDoubleRegister); - return testDoubleRegister; -})(Riot.Element); -var test_lifecycle = (function (_super) { - __extends(test_lifecycle, _super); - function test_lifecycle() { - _super.apply(this, arguments); - this.sequence = ""; - } - test_lifecycle.prototype.mounted = function () { - this.sequence += "3"; - }; - test_lifecycle.prototype.unmounted = function () { - this.sequence += "4"; - }; - test_lifecycle.prototype.updating = function () { - this.sequence += "1"; - }; - test_lifecycle.prototype.updated = function () { - this.sequence += "2"; - }; - test_lifecycle = __decorate([ - template("
this is test-lifecycle
") - ], test_lifecycle); - return test_lifecycle; -})(Riot.Element); -var test_options = (function (_super) { - __extends(test_options, _super); - function test_options(options) { - _super.call(this); - //this.bar = options.bar !== undefined ? options.bar : "default bar"; - this.bar = options.bar || "default bar"; - this.foo = options.foo || "default foo"; - } - test_options = __decorate([ - template("
") - ], test_options); - return test_options; -})(Riot.Element); -var TestGetterSetter = (function (_super) { - __extends(TestGetterSetter, _super); - function TestGetterSetter() { - _super.apply(this, arguments); - this.a = 42; - } - Object.defineProperty(TestGetterSetter.prototype, "myval", { - get: function () { - return this.a; - }, - set: function (v) { - this.a = v; - this.update(); - }, - enumerable: true, - configurable: true - }); - TestGetterSetter = __decorate([ - template("
getter={myval}
") - ], TestGetterSetter); - return TestGetterSetter; -})(Riot.Element); -var TestObservable = (function (_super) { - __extends(TestObservable, _super); - function TestObservable() { - _super.apply(this, arguments); - } - TestObservable.prototype.doSomething = function () { - this.trigger("something-done"); - }; - return TestObservable; -})(Riot.Observable); -var MixinPlainObject = { - method1: function () { return "ok1"; } -}; -var MixinClass = (function () { - function MixinClass() { - } - MixinClass.prototype.method2 = function () { - return "ok2"; - }; - return MixinClass; -})(); -var TestMixins = (function (_super) { - __extends(TestMixins, _super); - function TestMixins() { - _super.call(this); - this.mixin(MixinPlainObject); - this.mixin(MixinClass.prototype); - } - TestMixins.prototype.check1 = function () { - return this.method1(); - }; - TestMixins.prototype.check2 = function () { - return this.method2(); - }; - TestMixins = __decorate([ - template("") - ], TestMixins); - return TestMixins; -})(Riot.Element); -//# sourceMappingURL=specElements.js.map \ No newline at end of file diff --git a/Test/elements/specElements.js.map b/Test/elements/specElements.js.map deleted file mode 100644 index 05f0f7b..0000000 --- a/Test/elements/specElements.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"specElements.js","sourceRoot":"","sources":["specElements.ts"],"names":["test1","test1.constructor","test2","test2.constructor","test_template_from_url","test_template_from_url.constructor","testNoTagName","testNoTagName.constructor","testDoubleRegister","testDoubleRegister.constructor","test_lifecycle","test_lifecycle.constructor","test_lifecycle.mounted","test_lifecycle.unmounted","test_lifecycle.updating","test_lifecycle.updated","test_options","test_options.constructor","TestGetterSetter","TestGetterSetter.constructor","TestGetterSetter.myval","TestObservable","TestObservable.constructor","TestObservable.doSomething","MixinClass","MixinClass.constructor","MixinClass.method2","TestMixins","TestMixins.constructor","TestMixins.check1","TestMixins.check2"],"mappings":";;;;;;;;;;;AAAA;IAOoBA,yBAAYA;IAPhCA;QAOoBC,8BAAYA;IAGhCA,CAACA;IAVDD;QAACA,QAAQA,CAACA,yEAMTA,CAACA;cAIDA;IAADA,YAACA;AAADA,CAACA,AAVD,EAOoB,IAAI,CAAC,OAAO,EAG/B;AAGD;IACoBE,yBAAYA;IADhCA;QACoBC,8BAAYA;IAGhCA,CAACA;IAJDD;QAACA,QAAQA,CAACA,wDAAwDA,CAACA;cAIlEA;IAADA,YAACA;AAADA,CAACA,AAJD,EACoB,IAAI,CAAC,OAAO,EAG/B;AAGD;IACqCE,0CAAYA;IADjDA;QACqCC,8BAAYA;IAGjDA,CAACA;IAJDD;QAACA,QAAQA,CAACA,6BAA6BA,CAACA;+BAIvCA;IAADA,6BAACA;AAADA,CAACA,AAJD,EACqC,IAAI,CAAC,OAAO,EAGhD;AAGD;IAC4BE,iCAAYA;IADxCA;QAC4BC,8BAAYA;IAGxCA,CAACA;IAJDD;QAACA,QAAQA,CAACA,0CAA0CA,CAACA;sBAIpDA;IAADA,oBAACA;AAADA,CAACA,AAJD,EAC4B,IAAI,CAAC,OAAO,EAGvC;AAED;IACiCE,sCAAYA;IAD7CA;QACi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;aAEDF,UAAUA,CAACA;YAERE,IAAIA,CAACA,CAACA,GAAGA,CAACA,CAACA;YACXA,IAAIA,CAACA,MAAMA,EAAEA,CAACA;QACjBA,CAACA;;;OANAF;IARJA;QAACA,QAAQA,CAACA,iEAAiEA,CAACA;yBAe3EA;IAADA,uBAACA;AAADA,CAACA,AAfD,EAC+B,IAAI,CAAC,OAAO,EAc1C;AAGD;IAA6BG,kCAAeA;IAA5CA;QAA6BC,8BAAeA;IAM5CA,CAACA;IAJED,oCAAWA,GAAXA;QAEGE,IAAIA,CAACA,OAAOA,CAACA,gBAAgBA,CAACA,CAACA;IAClCA,CAACA;IACJF,qBAACA;AAADA,CAACA,AAND,EAA6B,IAAI,CAAC,UAAU,EAM3C;AAED,IAAI,gBAAgB,GACpB;IACG,OAAO,EAAE,cAAa,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;CACvC,CAAA;AAED;IAAAG;IAMAC,CAACA;IAJED,4BAAOA,GAAPA;QAEGE,MAAMA,CAACA,KAAKA,CAACA;IAChBA,CAACA;IACJF,iBAACA;AAADA,CAACA,AAND,IAMC;AAED;IACyBG,8BAAYA;IAKlCA;QAEGC,iBAAOA,CAACA;QACRA,IAAIA,CAACA,KAAKA,CAACA,gBAAgBA,CAACA,CAACA;QAC7BA,IAAIA,CAACA,KAAKA,CAACA,UAAUA,CAACA,SAASA,CAACA,CAACA;IACpCA,CAACA;IAEDD,2BAAMA,GAANA;QAEGE,MAAMA,CAACA,IAAIA,CAACA,OAAOA,EAAEA,CAACA;IACzBA,CAACA;IAEDF,2BAAMA,GAANA;QAEGG,MAAMA,CAACA,IAAIA,CAACA,OAAOA,EAAEA,CAACA;IACzBA,CAACA;IArBJH;QAACA,QAAQA,CAACA,eAAeA,CAACA;mBAsBzBA;IAADA,iBAACA;AAADA,CAACA,AAtBD,EACyB,IAAI,CAAC,OAAO,EAqBpC"} \ No newline at end of file diff --git a/Test/elements/specElements.ts b/Test/elements/specElements.ts deleted file mode 100644 index e1a8bbd..0000000 --- a/Test/elements/specElements.ts +++ /dev/null @@ -1,140 +0,0 @@ -@template(` - - -
test1 element
-
- -`) -class test1 extends Riot.Element -{ - -} - - -@template('
test2 element
') -class test2 extends Riot.Element -{ - -} - - -@template("elements/test-template.html") -class test_template_from_url extends Riot.Element -{ - -} - - -@template("") -class testNoTagName extends Riot.Element -{ - -} - -@template("
") -class testDoubleRegister extends Riot.Element -{ - -} - -@template("
this is test-lifecycle
") -class test_lifecycle extends Riot.Element -{ - sequence = ""; - - mounted() { - this.sequence += "3"; - } - - unmounted() { - this.sequence += "4"; - } - - updating() { - this.sequence += "1"; - } - - updated() { - this.sequence += "2"; - } -} - -@template("
") -class test_options extends Riot.Element -{ - bar: string; - foo: string; - - constructor(options) - { - super(); - - //this.bar = options.bar !== undefined ? options.bar : "default bar"; - this.bar = options.bar||"default bar"; - this.foo = options.foo||"default foo"; - } -} - -@template("
getter={myval}
") -class TestGetterSetter extends Riot.Element -{ - private a = 42; - - get myval() - { - return this.a; - } - - set myval(v) - { - this.a = v; - this.update(); - } -} - - -class TestObservable extends Riot.Observable -{ - doSomething() - { - this.trigger("something-done"); - } -} - -var MixinPlainObject = -{ - method1: function() { return "ok1"; } -} - -class MixinClass -{ - method2() - { - return "ok2"; - } -} - -@template("") -class TestMixins extends Riot.Element -{ - method1: () => void; - method2: () => void; - - constructor() - { - super(); - this.mixin(MixinPlainObject); - this.mixin(MixinClass.prototype); - } - - check1() - { - return this.method1(); - } - - check2() - { - return this.method2(); - } -} - diff --git a/Test/elements/template-cache.js b/Test/elements/template-cache.js deleted file mode 100644 index 67e5e0f..0000000 --- a/Test/elements/template-cache.js +++ /dev/null @@ -1,25 +0,0 @@ -Riot.templateCache = (function(){ - -var mytemplate = {}; - -mytemplate["elements/test-template.html"] = "\n" + - "
template from URL
\n" + - "
"; - -mytemplate["elements/timer.html"] = "\n" + - " \n" + - "
\n" + - " timer: {{ time }}
\n" + - " trasclusion is ''
\n" + - "
iterating over array item \"{{el}}\"
\n" + - "
this is from timer.html file!
\n" + - "
\n" + - "
\n" + - ""; - return mytemplate; -})(); diff --git a/Test/elements/test-template.html b/Test/elements/test-template.html deleted file mode 100644 index 002ff8c..0000000 --- a/Test/elements/test-template.html +++ /dev/null @@ -1,3 +0,0 @@ - -
template from URL
-
\ No newline at end of file diff --git a/Test/elements/timer.html b/Test/elements/timer.html deleted file mode 100644 index f86a968..0000000 --- a/Test/elements/timer.html +++ /dev/null @@ -1,14 +0,0 @@ - - -
- timer: {{time}} and {time}
- trasclusion is ''
-
iterating over array item "{{el}}"
-
this is from timer.html file!
-
-
diff --git a/Test/elements/timer.js b/Test/elements/timer.js deleted file mode 100644 index 0aa3af4..0000000 --- a/Test/elements/timer.js +++ /dev/null @@ -1,52 +0,0 @@ -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; -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 Timer = (function (_super) { - __extends(Timer, _super); - function Timer(opts) { - var _this = this; - _super.call(this); - this.mylist = ["one", "two", "three"]; - this.time = opts.time || 0; - this.timerHandle = setInterval(function () { return _this.ticks(); }, 1000); - this.on("unmount", function () { - clearInterval(_this.timerHandle); - }); - } - Object.defineProperty(Timer.prototype, "aprop", { - get: function () { - return this.time + 1; - }, - enumerable: true, - configurable: true - }); - Timer.prototype.ticks = function () { - this.time++; - this.update(); - }; - Timer.prototype.mounted = function () { - //console.log("timer has been mounted"); - }; - Timer.prototype.unmounted = function () { - //console.log("timer has been unmounted"); - }; - Timer.prototype.updating = function () { - //console.log("timer is going to be updated"); - }; - Timer.prototype.updated = function () { - //console.log("timer has been updated"); - }; - Timer = __decorate([ - template("elements/timer.html") - ], Timer); - return Timer; -})(Riot.Element); -//# sourceMappingURL=timer.js.map \ No newline at end of file diff --git a/Test/elements/timer.js.map b/Test/elements/timer.js.map deleted file mode 100644 index c66244d..0000000 --- a/Test/elements/timer.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"timer.js","sourceRoot":"","sources":["timer.ts"],"names":["Timer","Timer.constructor","Timer.aprop","Timer.ticks","Timer.mounted","Timer.unmounted","Timer.updating","Timer.updated"],"mappings":";;;;;;;;;;;AAAA;IAEoBA,yBAAYA;IAO7BA,eAAYA,IAAIA;QATnBC,iBAgDCA;QAtCKA,iBAAOA,CAACA;QALXA,WAAMA,GAAGA,CAACA,KAAKA,EAAEA,KAAKA,EAAEA,OAAOA,CAACA,CAACA;QAM9BA,IAAIA,CAACA,IAAIA,GAACA,IAAIA,CAACA,IAAIA,IAAEA,CAACA,CAACA;QACvBA,IAAIA,CAACA,WAAWA,GAACA,WAAWA,CAACA,cAAMA,OAAAA,KAAIA,CAACA,KAAKA,EAAEA,EAAZA,CAAYA,EAACA,IAAIA,CAACA,CAACA;QAEtDA,IAAIA,CAACA,EAAEA,CAACA,SAASA,EAACA;YACfA,aAAaA,CAACA,KAAIA,CAACA,WAAWA,CAACA,CAACA;QACnCA,CAACA,CAACA,CAACA;IACNA,CAACA;IAEDD,sBAAIA,wBAAKA;aAATA;YAEGE,MAAMA,CAACA,IAAIA,CAACA,IAAIA,GAACA,CAACA,CAACA;QACtBA,CAACA;;;OAAAF;IAEDA,qBAAKA,GAALA;QACGG,IAAIA,CAACA,IAAIA,EAAEA,CAACA;QACZA,IAAIA,CAACA,MAAMA,EAAEA,CAACA;IACjBA,CAACA;IAEDH,uBAAOA,GAAPA;QAEGI,4CAA4CA;IAC/CA,CAACA;IAEDJ,yBAASA,GAATA;QAEGK,6CAA6CA;IAChDA,CAACA;IAEDL,wBAAQA,GAARA;QAEGM,oDAAoDA;IACvDA,CAACA;IAEDN,uBAAOA,GAAPA;QAEGO,8CAA8CA;IACjDA,CAACA;IA/CJP;QAACA,QAAQA,CAACA,qBAAqBA,CAACA;cAgD/BA;IAADA,YAACA;AAADA,CAACA,AAhDD,EAEoB,IAAI,CAAC,OAAO,EA8C/B"} \ No newline at end of file diff --git a/Test/elements/timer.ts b/Test/elements/timer.ts deleted file mode 100644 index 078eff5..0000000 --- a/Test/elements/timer.ts +++ /dev/null @@ -1,52 +0,0 @@ -@template("elements/timer.html") - -class Timer extends Riot.Element -{ - time: number; - mylist = ["one", "two", "three"]; - - private timerHandle: number; - - constructor(opts) { - super(); - this.time=opts.time||0; - this.timerHandle=setInterval(() => this.ticks(),1000); - - this.on("unmount",() => { - clearInterval(this.timerHandle); - }); - } - - get aprop() - { - return this.time+1; - } - - ticks() { - this.time++; - this.update(); - } - - mounted() - { - //console.log("timer has been mounted"); - } - - unmounted() - { - //console.log("timer has been unmounted"); - } - - updating() - { - //console.log("timer is going to be updated"); - } - - updated() - { - //console.log("timer has been updated"); - } -} - - - diff --git a/Test/index.html b/Test/index.html deleted file mode 100644 index 8149bdb..0000000 --- a/Test/index.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - TypeScript HTML App - - - - - - - - - - - -

Riot with TypeScript example

- this is inside timer - - - - diff --git a/Test/index.js b/Test/index.js deleted file mode 100644 index 60ed217..0000000 --- a/Test/index.js +++ /dev/null @@ -1,5 +0,0 @@ -/// -function main() { - riot.mount('*'); -} -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/Test/index.js.map b/Test/index.js.map deleted file mode 100644 index 549d5c7..0000000 --- a/Test/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":["main"],"mappings":"AAAA,8DAA8D;AAE9D;IAEGA,IAAIA,CAACA,KAAKA,CAACA,GAAGA,CAACA,CAACA;AACnBA,CAACA"} \ No newline at end of file diff --git a/Test/index.ts b/Test/index.ts deleted file mode 100644 index af63317..0000000 --- a/Test/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -/// - -function main() -{ - riot.mount('*'); -} - - - diff --git a/Test/precompiled-tags.js b/Test/precompiled-tags.js deleted file mode 100644 index cffa6b3..0000000 --- a/Test/precompiled-tags.js +++ /dev/null @@ -1,2 +0,0 @@ -Riot.precompiledTags['elements/test-template.html'] = { tagName: 'test-template-from-url', html: '
template from URL
', css: '', attribs: '' }; -Riot.precompiledTags['elements/timer.html'] = { tagName: 'timer', html: '
timer: {{time}} and {time}
trasclusion is \'\'
iterating over array item "{{el}}"
this is from timer.html file!
', css: 'timer .bolded,[riot-tag="timer"] .bolded { font-weight: bolder; font-size: large; }', attribs: '' }; diff --git a/Test/specRunner.html b/Test/specRunner.html deleted file mode 100644 index 42426ec..0000000 --- a/Test/specRunner.html +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - TypeScript HTML App - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Test/specRunner.js b/Test/specRunner.js deleted file mode 100644 index 27bfcc7..0000000 --- a/Test/specRunner.js +++ /dev/null @@ -1,167 +0,0 @@ -/// -/// -// jasmine boot.js links to window.onload -var startJasmine = window.onload; -window.onload = function (e) { - riot.mount('*'); - RunSpecs(); - startJasmine(null); -}; -// simulates the old Jasmine 1.3 waitsFor() -function waitFor(F) { - beforeEach(function (done) { - setInterval(function () { - if (F()) - done(); - }, 250); - }); -} -function querySelector(s) { - return document.querySelector(s); -} -function getClass(el) { - return el._tag; -} -// quickly checks if instance implements the class -function implements(instance, classFunction) { - var instanceMembers = {}; - for (var i in instance) - instanceMembers[i] = true; - var classMembers = []; - for (var i in classFunction.prototype) - classMembers.push(i); - for (var t = 0; t < classMembers.length; t++) { - if (instanceMembers[classMembers[t]] === undefined) { - return false; - } - } - return true; -} -function RunSpecs() { - describe("Element creation", function () { - var instance, el; - beforeAll(function () { - var root = querySelector('#put_here'); - el = test1.createElement(); - root.appendChild(el); - instance = getClass(el); - }); - it('creates correct element bodies', function () { - expect(instance.inner_div.innerHTML).toBe("test1 element"); - }); - it('creates elements with correct template', function () { - expect(el.innerHTML).toBe('
test1 element
'); - }); - // expect(implements(el, TestElement)).toBe(true); - }); - describe("@template decorator", function () { - var instance, el; - var instance1, el1; - beforeAll(function () { - var root = querySelector('#put_here'); - el = test2.createElement(); - root.appendChild(el); - instance = getClass(el); - el1 = test_template_from_url.createElement(); - root.appendChild(el1); - instance1 = getClass(el1); - }); - it('creates correct element bodies', function () { - expect(instance.inner_div.innerHTML).toBe("test2 element"); - }); - it('creates elements with correct template', function () { - expect(el.innerHTML).toBe('
test2 element
'); - }); - it('can load templates from .html files', function () { - expect(el1.innerHTML).toBe("
template from URL
"); - }); - }); - describe("Object cloning", function () { - var el, instance; - beforeAll(function () { - var root = querySelector('#put_here'); - el = TestGetterSetter.createElement(); - root.appendChild(el); - instance = getClass(el); - }); - waitFor(function () { return instance.isMounted; }); - it('works with getter and setter', function () { - expect(instance.myval).toBe(42); - instance.myval = 64; - expect(instance.myval).toBe(64); - expect(el.innerHTML).toBe('
getter=64
'); - expect(instance["inner"].innerHTML).toBe("getter=64"); - }); - }); - // TODO: test object well-formed - // TODO: test el is observable - describe("lifecycle helper methods", function () { - var el, instance; - beforeAll(function () { - var root = querySelector('#put_here'); - el = test_lifecycle.createElement(); - root.appendChild(el); - instance = getClass(el); - instance.unmount(); - }); - waitFor(function () { return instance.sequence != ""; }); - it('are executed, all in the correct order', function () { - expect(instance.sequence).toBe("1234"); - }); - }); - describe("createElement()", function () { - var el1, el2, el3, i1, i2, i3; - beforeAll(function () { - var root = querySelector('#put_here'); - el1 = test_options.createElement(); - el2 = test_options.createElement({ bar: "BAR" }); - el3 = test_options.createElement({ bar: "BAR", foo: "FOO" }); - root.appendChild(el1); - root.appendChild(el2); - root.appendChild(el3); - i1 = getClass(el1); - i2 = getClass(el2); - i3 = getClass(el3); - }); - it('works with no parameter specified', function () { - expect(i1.bar).toBe("default bar"); - expect(i1.foo).toBe("default foo"); - }); - it('works with partial parameter specified', function () { - expect(i2.bar).toBe("BAR"); - expect(i2.foo).toBe("default foo"); - }); - it('works with full parameter specified', function () { - expect(i3.bar).toBe("BAR"); - expect(i3.foo).toBe("FOO"); - }); - }); - describe("Observable", function () { - var eventRaised = false; - beforeAll(function () { - var obs = new TestObservable(); - obs.on("something-done", function () { - eventRaised = true; - }); - obs.doSomething(); - }); - waitFor(function () { return eventRaised; }); - it("can be observed for its events", function () { - expect(eventRaised).toBe(true); - }); - }); - describe("Mixin", function () { - var root = querySelector('#put_here'); - var el = TestMixins.createElement(); - root.appendChild(el); - it("mixes methods from a plain JavaScript object", function () { - var tag = el._tag; - expect(tag.check1()).toBe("ok1"); - }); - it("mixes methods from a TypeScript class .prototype", function () { - var tag = el._tag; - expect(tag.check2()).toBe("ok2"); - }); - }); -} -//# sourceMappingURL=specRunner.js.map \ No newline at end of file diff --git a/Test/specRunner.js.map b/Test/specRunner.js.map deleted file mode 100644 index 8e7468a..0000000 --- a/Test/specRunner.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"specRunner.js","sourceRoot":"","sources":["specRunner.ts"],"names":["waitFor","querySelector","getClass","implements","RunSpecs"],"mappings":"AAAA,8DAA8D;AAC9D,qDAAqD;AAErD,0CAA0C;AAC1C,IAAI,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC;AACjC,MAAM,CAAC,MAAM,GAAG,UAAC,CAAC;IAEf,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAChB,QAAQ,EAAE,CAAC;IACX,YAAY,CAAC,IAAI,CAAC,CAAC;AACtB,CAAC,CAAC;AAEF,2CAA2C;AAC3C,iBAAiB,CAAC;IAEfA,UAAUA,CAACA,UAACA,IAAIA;QACbA,WAAWA,CAACA;YACTA,EAAEA,CAAAA,CAACA,CAACA,EAAEA,CAACA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AEA;YAC1CA,MAAMA,CAACA,EAAEA,CAACA,SAASA,CAACA,CAACA,IAAIA,CAACA,yCAAyCA,CAACA,CAACA;QACxEA,CAACA,CAACA,CAACA;QAEHA,EAAEA,CAACA,qCAAqCA,EAAEA;YACvCA,MAAMA,CAACA,GAAGA,CAACA,SAASA,CAACA,CAACA,IAAIA,CAACA,8BAA8BA,CAACA,CAACA;QAC9DA,CAACA,CAACA,CAACA;IACNA,CAACA,CAACA,CAACA;IAEHA,QAAQA,CAACA,gBAAgBA,EAAEA;QACxBA,IAAIA,EAAEA,EAAEA,QAA0BA,CAACA;QAEnCA,SAASA,CAACA;YAEPA,IAAIA,IAAIA,GAAGA,aAAaA,CAACA,WAAWA,CAACA,CAACA;YACtCA,EAAEA,GAAGA,gBAAgBA,CAACA,aAAaA,EAAEA,CAACA;YACtCA,IAAIA,CAACA,WAAWA,CAACA,EAAEA,CAACA,CAACA;YACrBA,QAAQA,GAAGA,QAAQA,CAACA,EAAEA,CAACA,CAACA;QAC3BA,CAACA,CAACA,CAACA;QAEHA,OAAOA,CAACA,cAAKA,OAAAA,QAAQA,CAACA,SAASA,EAAlBA,CAAkBA,CAAEA,CAACA;QAElCA,EAAEA,CAACA,8BAA8BA,EAAEA;YAChCA,MAAMA,CAACA,QAAQA,CAACA,KAAKA,CAACA,CAACA,IAAIA,CAACA,EAAEA,CAACA,CAACA;YAChCA,QAAQA,CAACA,KAAKA,GAAGA,EAAEA,CAACA;YACpBA,MAAMA,CAACA,QAAQA,CAACA,KAAKA,CAACA,CAACA,IAAIA,CAACA,EAAEA,CAACA,CAACA;YAChCA,MAAMA,CAACA,EAAEA,CAACA,SAASA,CAACA,CAACA,IAAIA,CAACA,iCAAiCA,CAACA,CAACA;YAC7DA,MAAMA,CAACA,QAAQA,CAACA,OAAOA,CAACA,CAACA,SAASA,CAACA,CAACA,IAAIA,CAACA,WAAWA,CAACA,CAACA;QACzDA,CAACA,CAACA,CAACA;IACNA,CAACA,CAACA,CAACA;IAEH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EAAEA;gBAEtBA,WAAWA,GAAGA,IAAIA,CAACA;YACtBA,CAACA,CAACA,CAACA;YAEHA,GAAGA,CAACA,WAAWA,EAAEA,CAACA;QACrBA,CAACA,CAACA,CAACA;QAEHA,OAAOA,CAACA,cAAIA,OAAAA,WAAWA,EAAXA,CAAWA,CAACA,CAACA;QAEzBA,EAAEA,CAACA,gCAAgCA,EAACA;YAEjCA,MAAMA,CAACA,WAAWA,CAACA,CAACA,IAAIA,CAACA,IAAIA,CAACA,CAACA;QAClCA,CAACA,CAACA,CAACA;IACNA,CAACA,CAACA,CAACA;IAEHA,QAAQA,CAACA,OAAOA,EAAEA;QAEfA,IAAIA,IAAIA,GAAGA,aAAaA,CAACA,WAAWA,CAACA,CAACA;QACtCA,IAAIA,EAAEA,GAAGA,UAAUA,CAACA,aAAaA,EAAEA,CAACA;QAEpCA,IAAIA,CAACA,WAAWA,CAACA,EAAEA,CAACA,CAACA;QAErBA,EAAEA,CAACA,8CAA8CA,EAACA;YAE/CA,IAAIA,GAAGA,GAAeA,EAAEA,CAACA,IAAWA,CAACA;YACrCA,MAAMA,CAACA,GAAGA,CAACA,MAAMA,EAAEA,CAACA,CAACA,IAAIA,CAACA,KAAKA,CAACA,CAACA;QACpCA,CAACA,CAACA,CAACA;QAEHA,EAAEA,CAACA,kDAAkDA,EAACA;YAEnDA,IAAIA,GAAGA,GAAeA,EAAEA,CAACA,IAAWA,CAACA;YACrCA,MAAMA,CAACA,GAAGA,CAACA,MAAMA,EAAEA,CAACA,CAACA,IAAIA,CAACA,KAAKA,CAACA,CAACA;QACpCA,CAACA,CAACA,CAACA;IACNA,CAACA,CAACA,CAACA;AACNA,CAACA"} \ No newline at end of file diff --git a/Test/specRunner.ts b/Test/specRunner.ts deleted file mode 100644 index 326d7de..0000000 --- a/Test/specRunner.ts +++ /dev/null @@ -1,231 +0,0 @@ -/// -/// - -// jasmine boot.js links to window.onload -var startJasmine = window.onload; -window.onload = (e) => -{ - riot.mount('*'); - RunSpecs(); - startJasmine(null); -}; - -// simulates the old Jasmine 1.3 waitsFor() -function waitFor(F) -{ - beforeEach((done) => { - setInterval(() => { - if(F()) done(); - }, 250); - }); -} - -function querySelector(s) -{ - return document.querySelector(s); -} - -function getClass(el) -{ - return (el as any)._tag; -} - -// quickly checks if instance implements the class -function implements(instance: Object, classFunction: Function) -{ - var instanceMembers = {}; - for(var i in instance) instanceMembers[i] = true; - - var classMembers = []; - for(var i in classFunction.prototype) classMembers.push(i); - - for(var t=0; t { - var instance,el; - - beforeAll(()=> - { - var root = querySelector('#put_here'); - el = test1.createElement(); - root.appendChild(el); - instance = getClass(el); - }); - - it('creates correct element bodies', () => { - expect(instance.inner_div.innerHTML).toBe("test1 element"); - }); - - it('creates elements with correct template', () => { - expect(el.innerHTML).toBe('
test1 element
'); - }); - - // expect(implements(el, TestElement)).toBe(true); - - }); - - describe("@template decorator", () => { - var instance,el; - var instance1,el1; - - beforeAll(()=> - { - var root = querySelector('#put_here'); - el = test2.createElement(); - root.appendChild(el); - instance = getClass(el); - - el1 = test_template_from_url.createElement(); - root.appendChild(el1); - instance1 = getClass(el1); - }); - - it('creates correct element bodies', () => { - expect(instance.inner_div.innerHTML).toBe("test2 element"); - }); - - it('creates elements with correct template', () => { - expect(el.innerHTML).toBe('
test2 element
'); - }); - - it('can load templates from .html files', () => { - expect(el1.innerHTML).toBe("
template from URL
"); - }); - }); - - describe("Object cloning", () => { - var el, instance: TestGetterSetter; - - beforeAll(()=> - { - var root = querySelector('#put_here'); - el = TestGetterSetter.createElement(); - root.appendChild(el); - instance = getClass(el); - }); - - waitFor(()=> instance.isMounted ); - - it('works with getter and setter', () => { - expect(instance.myval).toBe(42); - instance.myval = 64; - expect(instance.myval).toBe(64); - expect(el.innerHTML).toBe('
getter=64
'); - expect(instance["inner"].innerHTML).toBe("getter=64"); - }); - }); - - // TODO: test object well-formed - // TODO: test el is observable - - describe("lifecycle helper methods", () => { - var el, instance: test_lifecycle; - - beforeAll(()=> - { - var root = querySelector('#put_here'); - el = test_lifecycle.createElement(); - root.appendChild(el); - instance = getClass(el); - instance.unmount(); - }); - - waitFor(()=>instance.sequence!=""); - - it('are executed, all in the correct order', () => { - expect(instance.sequence).toBe("1234"); - }); - }); - - describe("createElement()", () => { - var el1, el2, el3, - i1: test_options, - i2: test_options, - i3: test_options; - - beforeAll(()=> - { - var root = querySelector('#put_here'); - - el1 = test_options.createElement(); - el2 = test_options.createElement({bar: "BAR"}); - el3 = test_options.createElement({bar: "BAR", foo: "FOO"}); - - root.appendChild(el1); - root.appendChild(el2); - root.appendChild(el3); - i1 = getClass(el1); - i2 = getClass(el2); - i3 = getClass(el3); - }); - - it('works with no parameter specified', () => { - expect(i1.bar).toBe("default bar"); - expect(i1.foo).toBe("default foo"); - }); - - it('works with partial parameter specified', () => { - expect(i2.bar).toBe("BAR"); - expect(i2.foo).toBe("default foo"); - }); - - it('works with full parameter specified', () => { - expect(i3.bar).toBe("BAR"); - expect(i3.foo).toBe("FOO"); - }); - }); - - describe("Observable", () => - { - var eventRaised = false; - - beforeAll(()=> - { - var obs = new TestObservable(); - - obs.on("something-done", ()=> - { - eventRaised = true; - }); - - obs.doSomething(); - }); - - waitFor(()=>eventRaised); - - it("can be observed for its events",()=> - { - expect(eventRaised).toBe(true); - }); - }); - - describe("Mixin", () => - { - var root = querySelector('#put_here'); - var el = TestMixins.createElement(); - - root.appendChild(el); - - it("mixes methods from a plain JavaScript object",()=> - { - var tag: TestMixins = el._tag as any; - expect(tag.check1()).toBe("ok1"); - }); - - it("mixes methods from a TypeScript class .prototype",()=> - { - var tag: TestMixins = el._tag as any; - expect(tag.check2()).toBe("ok2"); - }); - }); -} diff --git a/Test/tsconfig.json b/Test/tsconfig.json deleted file mode 100644 index 72eb40c..0000000 --- a/Test/tsconfig.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "compilerOptions": { - "removeComments": true, - "out": "specRunner.js", - "target": "ES5", - "experimentalDecorators": true, - "sourceMap": true - }, - "files": [ - "bower_components/riot-ts/riot-ts.d.ts", - "elements/specElements.ts", - "specRunner.ts" - ] -} \ No newline at end of file diff --git a/Test/tsd.json b/Test/tsd.json deleted file mode 100644 index 2a2c223..0000000 --- a/Test/tsd.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "version": "v4", - "repo": "borisyankov/DefinitelyTyped", - "ref": "master", - "path": "typings", - "bundle": "typings/tsd.d.ts", - "installed": { - "jasmine/jasmine.d.ts": { - "commit": "4df20c9706ce6ca27137617770b57f3a0d3f9689" - } - } -} diff --git a/Test/typings/jasmine/jasmine.d.ts b/Test/typings/jasmine/jasmine.d.ts deleted file mode 100644 index 905b682..0000000 --- a/Test/typings/jasmine/jasmine.d.ts +++ /dev/null @@ -1,496 +0,0 @@ -// Type definitions for Jasmine 2.2 -// Project: http://jasmine.github.io/ -// Definitions by: Boris Yankov , Theodore Brown , David Pärsson -// Definitions: https://github.com/borisyankov/DefinitelyTyped - - -// For ddescribe / iit use : https://github.com/borisyankov/DefinitelyTyped/blob/master/karma-jasmine/karma-jasmine.d.ts - -declare function describe(description: string, specDefinitions: () => void): void; -declare function fdescribe(description: string, specDefinitions: () => void): void; -declare function xdescribe(description: string, specDefinitions: () => void): void; - -declare function it(expectation: string, assertion?: () => void, timeout?: number): void; -declare function it(expectation: string, assertion?: (done: () => void) => void, timeout?: number): void; -declare function fit(expectation: string, assertion?: () => void, timeout?: number): void; -declare function fit(expectation: string, assertion?: (done: () => void) => void, timeout?: number): void; -declare function xit(expectation: string, assertion?: () => void, timeout?: number): void; -declare function xit(expectation: string, assertion?: (done: () => void) => void, timeout?: number): void; - -/** If you call the function pending anywhere in the spec body, no matter the expectations, the spec will be marked pending. */ -declare function pending(reason?: string): void; - -declare function beforeEach(action: () => void, timeout?: number): void; -declare function beforeEach(action: (done: () => void) => void, timeout?: number): void; -declare function afterEach(action: () => void, timeout?: number): void; -declare function afterEach(action: (done: () => void) => void, timeout?: number): void; - -declare function beforeAll(action: () => void, timeout?: number): void; -declare function beforeAll(action: (done: () => void) => void, timeout?: number): void; -declare function afterAll(action: () => void, timeout?: number): void; -declare function afterAll(action: (done: () => void) => void, timeout?: number): void; - -declare function expect(spy: Function): jasmine.Matchers; -declare function expect(actual: any): jasmine.Matchers; - -declare function fail(e?: any): void; - -declare function spyOn(object: any, method: string): jasmine.Spy; - -declare function runs(asyncMethod: Function): void; -declare function waitsFor(latchMethod: () => boolean, failureMessage?: string, timeout?: number): void; -declare function waits(timeout?: number): void; - -declare module jasmine { - - var clock: () => Clock; - - function any(aclass: any): Any; - function anything(): Any; - function arrayContaining(sample: any[]): ArrayContaining; - function objectContaining(sample: any): ObjectContaining; - function createSpy(name: string, originalFn?: Function): Spy; - function createSpyObj(baseName: string, methodNames: any[]): any; - function createSpyObj(baseName: string, methodNames: any[]): T; - function pp(value: any): string; - function getEnv(): Env; - function addCustomEqualityTester(equalityTester: CustomEqualityTester): void; - function addMatchers(matchers: CustomMatcherFactories): void; - function stringMatching(str: string): Any; - function stringMatching(str: RegExp): Any; - - interface Any { - - new (expectedClass: any): any; - - jasmineMatches(other: any): boolean; - jasmineToString(): string; - } - - // taken from TypeScript lib.core.es6.d.ts, applicable to CustomMatchers.contains() - interface ArrayLike { - length: number; - [n: number]: T; - } - - interface ArrayContaining { - new (sample: any[]): any; - - asymmetricMatch(other: any): boolean; - jasmineToString(): string; - } - - interface ObjectContaining { - new (sample: any): any; - - jasmineMatches(other: any, mismatchKeys: any[], mismatchValues: any[]): boolean; - jasmineToString(): string; - } - - interface Block { - - new (env: Env, func: SpecFunction, spec: Spec): any; - - execute(onComplete: () => void): void; - } - - interface WaitsBlock extends Block { - new (env: Env, timeout: number, spec: Spec): any; - } - - interface WaitsForBlock extends Block { - new (env: Env, timeout: number, latchFunction: SpecFunction, message: string, spec: Spec): any; - } - - interface Clock { - install(): void; - uninstall(): void; - /** Calls to any registered callback are triggered when the clock is ticked forward via the jasmine.clock().tick function, which takes a number of milliseconds. */ - tick(ms: number): void; - mockDate(date?: Date): void; - } - - interface CustomEqualityTester { - (first: any, second: any): boolean; - } - - interface CustomMatcher { - compare(actual: T, expected: T): CustomMatcherResult; - compare(actual: any, expected: any): CustomMatcherResult; - } - - interface CustomMatcherFactory { - (util: MatchersUtil, customEqualityTesters: Array): CustomMatcher; - } - - interface CustomMatcherFactories { - [index: string]: CustomMatcherFactory; - } - - interface CustomMatcherResult { - pass: boolean; - message: string; - } - - interface MatchersUtil { - equals(a: any, b: any, customTesters?: Array): boolean; - contains(haystack: ArrayLike | string, needle: any, customTesters?: Array): boolean; - buildFailureMessage(matcherName: string, isNot: boolean, actual: any, ...expected: Array): string; - } - - interface Env { - setTimeout: any; - clearTimeout: void; - setInterval: any; - clearInterval: void; - updateInterval: number; - - currentSpec: Spec; - - matchersClass: Matchers; - - version(): any; - versionString(): string; - nextSpecId(): number; - addReporter(reporter: Reporter): void; - execute(): void; - describe(description: string, specDefinitions: () => void): Suite; - // ddescribe(description: string, specDefinitions: () => void): Suite; Not a part of jasmine. Angular team adds these - beforeEach(beforeEachFunction: () => void): void; - beforeAll(beforeAllFunction: () => void): void; - currentRunner(): Runner; - afterEach(afterEachFunction: () => void): void; - afterAll(afterAllFunction: () => void): void; - xdescribe(desc: string, specDefinitions: () => void): XSuite; - it(description: string, func: () => void): Spec; - // iit(description: string, func: () => void): Spec; Not a part of jasmine. Angular team adds these - xit(desc: string, func: () => void): XSpec; - compareRegExps_(a: RegExp, b: RegExp, mismatchKeys: string[], mismatchValues: string[]): boolean; - compareObjects_(a: any, b: any, mismatchKeys: string[], mismatchValues: string[]): boolean; - equals_(a: any, b: any, mismatchKeys: string[], mismatchValues: string[]): boolean; - contains_(haystack: any, needle: any): boolean; - addCustomEqualityTester(equalityTester: CustomEqualityTester): void; - addMatchers(matchers: CustomMatcherFactories): void; - specFilter(spec: Spec): boolean; - } - - interface FakeTimer { - - new (): any; - - reset(): void; - tick(millis: number): void; - runFunctionsWithinRange(oldMillis: number, nowMillis: number): void; - scheduleFunction(timeoutKey: any, funcToCall: () => void, millis: number, recurring: boolean): void; - } - - interface HtmlReporter { - new (): any; - } - - interface HtmlSpecFilter { - new (): any; - } - - interface Result { - type: string; - } - - interface NestedResults extends Result { - description: string; - - totalCount: number; - passedCount: number; - failedCount: number; - - skipped: boolean; - - rollupCounts(result: NestedResults): void; - log(values: any): void; - getItems(): Result[]; - addResult(result: Result): void; - passed(): boolean; - } - - interface MessageResult extends Result { - values: any; - trace: Trace; - } - - interface ExpectationResult extends Result { - matcherName: string; - passed(): boolean; - expected: any; - actual: any; - message: string; - trace: Trace; - } - - interface Trace { - name: string; - message: string; - stack: any; - } - - interface PrettyPrinter { - - new (): any; - - format(value: any): void; - iterateObject(obj: any, fn: (property: string, isGetter: boolean) => void): void; - emitScalar(value: any): void; - emitString(value: string): void; - emitArray(array: any[]): void; - emitObject(obj: any): void; - append(value: any): void; - } - - interface StringPrettyPrinter extends PrettyPrinter { - } - - interface Queue { - - new (env: any): any; - - env: Env; - ensured: boolean[]; - blocks: Block[]; - running: boolean; - index: number; - offset: number; - abort: boolean; - - addBefore(block: Block, ensure?: boolean): void; - add(block: any, ensure?: boolean): void; - insertNext(block: any, ensure?: boolean): void; - start(onComplete?: () => void): void; - isRunning(): boolean; - next_(): void; - results(): NestedResults; - } - - interface Matchers { - - new (env: Env, actual: any, spec: Env, isNot?: boolean): any; - - env: Env; - actual: any; - spec: Env; - isNot?: boolean; - message(): any; - - toBe(expected: any): boolean; - toEqual(expected: any): boolean; - toMatch(expected: any): boolean; - toBeDefined(): boolean; - toBeUndefined(): boolean; - toBeNull(): boolean; - toBeNaN(): boolean; - toBeTruthy(): boolean; - toBeFalsy(): boolean; - toHaveBeenCalled(): boolean; - toHaveBeenCalledWith(...params: any[]): boolean; - toContain(expected: any): boolean; - toBeLessThan(expected: any): boolean; - toBeGreaterThan(expected: any): boolean; - toBeCloseTo(expected: any, precision: any): boolean; - toContainHtml(expected: string): boolean; - toContainText(expected: string): boolean; - toThrow(expected?: any): boolean; - toThrowError(expected?: any, message?: string): boolean; - not: Matchers; - - Any: Any; - } - - interface Reporter { - reportRunnerStarting(runner: Runner): void; - reportRunnerResults(runner: Runner): void; - reportSuiteResults(suite: Suite): void; - reportSpecStarting(spec: Spec): void; - reportSpecResults(spec: Spec): void; - log(str: string): void; - } - - interface MultiReporter extends Reporter { - addReporter(reporter: Reporter): void; - } - - interface Runner { - - new (env: Env): any; - - execute(): void; - beforeEach(beforeEachFunction: SpecFunction): void; - afterEach(afterEachFunction: SpecFunction): void; - beforeAll(beforeAllFunction: SpecFunction): void; - afterAll(afterAllFunction: SpecFunction): void; - finishCallback(): void; - addSuite(suite: Suite): void; - add(block: Block): void; - specs(): Spec[]; - suites(): Suite[]; - topLevelSuites(): Suite[]; - results(): NestedResults; - } - - interface SpecFunction { - (spec?: Spec): void; - } - - interface SuiteOrSpec { - id: number; - env: Env; - description: string; - queue: Queue; - } - - interface Spec extends SuiteOrSpec { - - new (env: Env, suite: Suite, description: string): any; - - suite: Suite; - - afterCallbacks: SpecFunction[]; - spies_: Spy[]; - - results_: NestedResults; - matchersClass: Matchers; - - getFullName(): string; - results(): NestedResults; - log(arguments: any): any; - runs(func: SpecFunction): Spec; - addToQueue(block: Block): void; - addMatcherResult(result: Result): void; - expect(actual: any): any; - waits(timeout: number): Spec; - waitsFor(latchFunction: SpecFunction, timeoutMessage?: string, timeout?: number): Spec; - fail(e?: any): void; - getMatchersClass_(): Matchers; - addMatchers(matchersPrototype: CustomMatcherFactories): void; - finishCallback(): void; - finish(onComplete?: () => void): void; - after(doAfter: SpecFunction): void; - execute(onComplete?: () => void): any; - addBeforesAndAftersToQueue(): void; - explodes(): void; - spyOn(obj: any, methodName: string, ignoreMethodDoesntExist: boolean): Spy; - removeAllSpies(): void; - } - - interface XSpec { - id: number; - runs(): void; - } - - interface Suite extends SuiteOrSpec { - - new (env: Env, description: string, specDefinitions: () => void, parentSuite: Suite): any; - - parentSuite: Suite; - - getFullName(): string; - finish(onComplete?: () => void): void; - beforeEach(beforeEachFunction: SpecFunction): void; - afterEach(afterEachFunction: SpecFunction): void; - beforeAll(beforeAllFunction: SpecFunction): void; - afterAll(afterAllFunction: SpecFunction): void; - results(): NestedResults; - add(suiteOrSpec: SuiteOrSpec): void; - specs(): Spec[]; - suites(): Suite[]; - children(): any[]; - execute(onComplete?: () => void): void; - } - - interface XSuite { - execute(): void; - } - - interface Spy { - (...params: any[]): any; - - identity: string; - and: SpyAnd; - calls: Calls; - mostRecentCall: { args: any[]; }; - argsForCall: any[]; - wasCalled: boolean; - } - - interface SpyAnd { - /** By chaining the spy with and.callThrough, the spy will still track all calls to it but in addition it will delegate to the actual implementation. */ - callThrough(): Spy; - /** By chaining the spy with and.returnValue, all calls to the function will return a specific value. */ - returnValue(val: any): void; - /** By chaining the spy with and.callFake, all calls to the spy will delegate to the supplied function. */ - callFake(fn: Function): Spy; - /** By chaining the spy with and.throwError, all calls to the spy will throw the specified value. */ - throwError(msg: string): void; - /** When a calling strategy is used for a spy, the original stubbing behavior can be returned at any time with and.stub. */ - stub(): Spy; - } - - interface Calls { - /** By chaining the spy with calls.any(), will return false if the spy has not been called at all, and then true once at least one call happens. **/ - any(): boolean; - /** By chaining the spy with calls.count(), will return the number of times the spy was called **/ - count(): number; - /** By chaining the spy with calls.argsFor(), will return the arguments passed to call number index **/ - argsFor(index: number): any[]; - /** By chaining the spy with calls.allArgs(), will return the arguments to all calls **/ - allArgs(): any[]; - /** By chaining the spy with calls.all(), will return the context (the this) and arguments passed all calls **/ - all(): CallInfo[]; - /** By chaining the spy with calls.mostRecent(), will return the context (the this) and arguments for the most recent call **/ - mostRecent(): CallInfo; - /** By chaining the spy with calls.first(), will return the context (the this) and arguments for the first call **/ - first(): CallInfo; - /** By chaining the spy with calls.reset(), will clears all tracking for a spy **/ - reset(): void; - } - - interface CallInfo { - /** The context (the this) for the call */ - object: any; - /** All arguments passed to the call */ - args: any[]; - } - - interface Util { - inherit(childClass: Function, parentClass: Function): any; - formatException(e: any): any; - htmlEscape(str: string): string; - argsToArray(args: any): any; - extend(destination: any, source: any): any; - } - - interface JsApiReporter extends Reporter { - - started: boolean; - finished: boolean; - result: any; - messages: any; - - new (): any; - - suites(): Suite[]; - summarize_(suiteOrSpec: SuiteOrSpec): any; - results(): any; - resultsForSpec(specId: any): any; - log(str: any): any; - resultsForSpecs(specIds: any): any; - summarizeResult_(result: any): any; - } - - interface Jasmine { - Spec: Spec; - clock: Clock; - util: Util; - } - - export var HtmlReporter: HtmlReporter; - export var HtmlSpecFilter: HtmlSpecFilter; - export var DEFAULT_TIMEOUT_INTERVAL: number; -} diff --git a/Test/typings/tsd.d.ts b/Test/typings/tsd.d.ts deleted file mode 100644 index 3917153..0000000 --- a/Test/typings/tsd.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/Test/web.Debug.config b/Test/web.Debug.config deleted file mode 100644 index 9fdb00f..0000000 --- a/Test/web.Debug.config +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/Test/web.Release.config b/Test/web.Release.config deleted file mode 100644 index d71b662..0000000 --- a/Test/web.Release.config +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/Test/web.config b/Test/web.config deleted file mode 100644 index 9f2197e..0000000 --- a/Test/web.config +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/bower.json b/bower.json deleted file mode 100644 index 73d0687..0000000 --- a/bower.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "riot-ts", - "version": "0.0.0", - "homepage": "https://github.com/nippur72/RiotTS", - "authors": [ - "Antonino Porcino " - ], - "description": "Riot for TypeScript", - "main": "riot-ts.js", - "license": "MIT", - "ignore": [ - "/*", - "!riot-ts.*", - "!LICENSE.txt", - "!README.md" - ], - "dependencies": { - "riot": "~2.3.11" - } -} diff --git a/package.json b/package.json new file mode 100644 index 0000000..1bcb4ea --- /dev/null +++ b/package.json @@ -0,0 +1,22 @@ +{ + "name": "riot-ts", + "version": "1.0.0", + "description": "Riot for TypeScript", + "main": "riot-ts.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/nippur72/RiotTS.git" + }, + "author": "Antonino Porcino ", + "license": "MIT", + "bugs": { + "url": "https://github.com/nippur72/RiotTS/issues" + }, + "homepage": "https://github.com/nippur72/RiotTS#readme", + "dependencies": { + "riot": "^2.4.1" + } +} diff --git a/riot-ts.d.ts b/riot-ts.d.ts index a0dcf72..02dbf31 100644 --- a/riot-ts.d.ts +++ b/riot-ts.d.ts @@ -1,83 +1,39 @@ -declare module Riot { - interface Settings { - brackets: string; - } - class Observable { - on(events: string, callback: Function): void; - one(events: string, callback: Function): void; - off(events: string): void; - trigger(eventName: string, ...args: any[]): void; - constructor(); - } - interface Router { - (callback: Function): void; - (filter: string, callback: Function): void; - (to: string, title?: string): any; - create(): Router; - start(autoExec?: boolean): any; - stop(): any; - exec(): any; - query(): any; - base(base: string): any; - parser(parser: (path: string) => string, secondParser?: Function): any; - } - interface CompilerResult { - tagName: string; - html: string; - css: string; - attribs: string; - js: string; - } - interface Base { - version: string; - settings: Riot.Settings; - mount(customTagSelector: string, opts?: any): Array; - mount(selector: string, tagName: string, opts?: any): Array; - mount(domNode: Node, tagName: string, opts?: any): Array; - render(tagName: string, opts?: any): string; - tag(tagName: string, html: string, css: string, attrs: string, constructor: Function): any; - tag2(tagName: string, html: string, css: string, attrs: string, constructor: Function, bpair: string): any; - class(element: Function): void; - observable(object: any): void; - mixin(mixinName: string, mixinObject: any): void; - compile(callback: Function): void; - compile(url: string, callback: Function): void; - compile(tag: string): string; - compile(tag: string, dontExecute: boolean): string; - compile(tag: string, options: any): string; - compile(tag: string, dontExecute: boolean, options: any): CompilerResult[]; - route: Riot.Router; - } - interface LifeCycle { - mounted?(F: Function): any; - unmounted?(F: Function): any; - updating?(F: Function): any; - updated?(F: Function): any; - } - interface HTMLRiotElement extends HTMLElement { - _tag: Element; - } - class Element implements Riot.Observable, LifeCycle { - opts: any; - parent: Element; - root: HTMLElement; - tags: any; - tagName: string; - template: string; - isMounted: boolean; - update(data?: any): void; - unmount(keepTheParent?: boolean): void; - on(eventName: string, fun: Function): void; - one(eventName: string, fun: Function): void; - off(events: string): void; - trigger(eventName: string, ...args: any[]): void; - mixin(mixinObject: Object | Function | string, instance?: any): void; - static createElement(options?: any): HTMLRiotElement; - } - var precompiledTags: { - [fileName: string]: CompilerResult; - }; - function registerClass(element: Function): void; +import { CompilerResult } from "./types"; +export declare class Observable { + on(events: string, callback: Function): void; + one(events: string, callback: Function): void; + off(events: string): void; + trigger(eventName: string, ...args: any[]): void; + constructor(); } -declare var riot: Riot.Base; -declare function template(template: string): (target: Function) => void; +export interface LifeCycle { + mounted?(F: Function): any; + unmounted?(F: Function): any; + updating?(F: Function): any; + updated?(F: Function): any; +} +export interface HTMLRiotElement extends HTMLElement { + _tag: Element; +} +export declare class Element implements Observable, LifeCycle { + opts: any; + parent: Element; + root: HTMLElement; + tags: any; + tagName: string; + template: string; + isMounted: boolean; + update(data?: any): void; + unmount(keepTheParent?: boolean): void; + on(eventName: string, fun: Function): void; + one(eventName: string, fun: Function): void; + off(events: string): void; + trigger(eventName: string, ...args: any[]): void; + mixin(mixinObject: Object | Function | string, instance?: any): void; + static createElement(options?: any): HTMLRiotElement; +} +export declare var precompiledTags: { + [fileName: string]: CompilerResult; +}; +export declare function registerClass(element: Function): void; +export declare function template(template: string): (target: Function) => void; diff --git a/riot-ts.js b/riot-ts.js index 763cb4d..8a195bd 100644 --- a/riot-ts.js +++ b/riot-ts.js @@ -1,119 +1,118 @@ -var Riot; -(function (Riot) { - var Observable = (function () { - function Observable() { - riot.observable(this); +"use strict"; +var riot = require("riot"); +var Observable = (function () { + function Observable() { + riot.observable(this); + } + Observable.prototype.on = function (events, callback) { }; + Observable.prototype.one = function (events, callback) { }; + Observable.prototype.off = function (events) { }; + Observable.prototype.trigger = function (eventName) { + var args = []; + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i]; } - Observable.prototype.on = function (events, callback) { }; - Observable.prototype.one = function (events, callback) { }; - Observable.prototype.off = function (events) { }; - Observable.prototype.trigger = function (eventName) { - var args = []; - for (var _i = 1; _i < arguments.length; _i++) { - args[_i - 1] = arguments[_i]; - } - }; - return Observable; - })(); - Riot.Observable = Observable; - var Element = (function () { - function Element() { + }; + return Observable; +}()); +exports.Observable = Observable; +var Element = (function () { + function Element() { + } + Element.prototype.update = function (data) { }; + Element.prototype.unmount = function (keepTheParent) { }; + Element.prototype.on = function (eventName, fun) { }; + Element.prototype.one = function (eventName, fun) { }; + Element.prototype.off = function (events) { }; + Element.prototype.trigger = function (eventName) { + var args = []; + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i]; } - Element.prototype.update = function (data) { }; - Element.prototype.unmount = function (keepTheParent) { }; - Element.prototype.on = function (eventName, fun) { }; - Element.prototype.one = function (eventName, fun) { }; - Element.prototype.off = function (events) { }; - Element.prototype.trigger = function (eventName) { - var args = []; - for (var _i = 1; _i < arguments.length; _i++) { - args[_i - 1] = arguments[_i]; - } - }; - Element.prototype.mixin = function (mixinObject, instance) { }; - Element.createElement = function (options) { - var tagName = this.prototype.tagName; - var el = document.createElement(tagName); - riot.mount(el, tagName, options); - return el; + }; + Element.prototype.mixin = function (mixinObject, instance) { }; + Element.createElement = function (options) { + var tagName = this.prototype.tagName; + var el = document.createElement(tagName); + riot.mount(el, tagName, options); + return el; + }; + return Element; +}()); +exports.Element = Element; +// new extend, works with getters and setters +function extend(d, element) { + var map = Object.keys(element.prototype).reduce(function (descriptors, key) { + descriptors[key] = Object.getOwnPropertyDescriptor(element.prototype, key); + return descriptors; + }, {}); + Object.defineProperties(d, map); +} +/* old extend, without getters and setters +function extend(d, element) { + Object.keys(element.prototype).forEach((key) => d[key] = element.prototype[key]); +} +*/ +exports.precompiledTags = {}; +function registerClass(element) { + function registerTag(compiledTag) { + var transformFunction = function (opts) { + extend(this, element); // copies prototype into "this" + element.apply(this, [opts]); // calls class constructor applying it on "this" + if (element.prototype.mounted !== undefined) + this.on("mount", this.mounted); + if (element.prototype.unmounted !== undefined) + this.on("unmount", this.unmounted); + if (element.prototype.updating !== undefined) + this.on("update", this.updating); + if (element.prototype.updated !== undefined) + this.on("updated", this.updated); + // TODO support for init(opts) ? }; - return Element; - })(); - Riot.Element = Element; - // new extend, works with getters and setters - function extend(d, element) { - var map = Object.keys(element.prototype).reduce(function (descriptors, key) { - descriptors[key] = Object.getOwnPropertyDescriptor(element.prototype, key); - return descriptors; - }, {}); - Object.defineProperties(d, map); + riot.tag2(compiledTag.tagName, compiledTag.html, compiledTag.css, compiledTag.attribs, transformFunction, riot.settings.brackets); + return compiledTag.tagName; } - /* old extend, without getters and setters - function extend(d, element) { - Object.keys(element.prototype).forEach((key) => d[key] = element.prototype[key]); + function loadTemplateFromHTTP(template) { + var req = new XMLHttpRequest(); + req.open("GET", template, false); + req.send(); + if (req.status == 200) + return req.responseText; + else + throw req.responseText; } - */ - Riot.precompiledTags = {}; - function registerClass(element) { - function registerTag(compiledTag) { - var transformFunction = function (opts) { - extend(this, element); // copies prototype into "this" - element.apply(this, [opts]); // calls class constructor applying it on "this" - if (element.prototype.mounted !== undefined) - this.on("mount", this.mounted); - if (element.prototype.unmounted !== undefined) - this.on("unmount", this.unmounted); - if (element.prototype.updating !== undefined) - this.on("update", this.updating); - if (element.prototype.updated !== undefined) - this.on("updated", this.updated); - // TODO support for init(opts) ? - }; - riot.tag2(compiledTag.tagName, compiledTag.html, compiledTag.css, compiledTag.attribs, transformFunction, riot.settings.brackets); - return compiledTag.tagName; - } - function loadTemplateFromHTTP(template) { - var req = new XMLHttpRequest(); - req.open("GET", template, false); - req.send(); - if (req.status == 200) - return req.responseText; - else - throw req.responseText; - } - ; - var compiled; - // gets string template: inlined, via http request or via precompiled cache - if (element.prototype.template !== undefined) { - var tagTemplate = element.prototype.template; - if (tagTemplate.indexOf("<") < 0) { - // tag is a file - if (Riot.precompiledTags[tagTemplate] !== undefined) { - // loads it from precompiled cache - compiled = Riot.precompiledTags[tagTemplate]; - } - else { - // loads from HTTP and compile on the fly - tagTemplate = loadTemplateFromHTTP(tagTemplate); - compiled = riot.compile(tagTemplate, true, { entities: true })[0]; - } + ; + var compiled; + // gets string template: inlined, via http request or via precompiled cache + if (element.prototype.template !== undefined) { + var tagTemplate = element.prototype.template; + if (tagTemplate.indexOf("<") < 0) { + // tag is a file + if (exports.precompiledTags[tagTemplate] !== undefined) { + // loads it from precompiled cache + compiled = exports.precompiledTags[tagTemplate]; } else { - // tag is inlined, compile on the fly + // loads from HTTP and compile on the fly + tagTemplate = loadTemplateFromHTTP(tagTemplate); compiled = riot.compile(tagTemplate, true, { entities: true })[0]; } - element.prototype.tagName = registerTag(compiled); } - else - throw "template property not specified"; + else { + // tag is inlined, compile on the fly + compiled = riot.compile(tagTemplate, true, { entities: true })[0]; + } + element.prototype.tagName = registerTag(compiled); } - Riot.registerClass = registerClass; -})(Riot || (Riot = {})); + else + throw "template property not specified"; +} +exports.registerClass = registerClass; // @template decorator function template(template) { return function (target) { target.prototype["template"] = template; - Riot.registerClass(target); + registerClass(target); }; } -//# sourceMappingURL=riot-ts.js.map \ No newline at end of file +exports.template = template; diff --git a/riot-ts.js.map b/riot-ts.js.map index ee06312..358338a 100644 --- a/riot-ts.js.map +++ b/riot-ts.js.map @@ -1 +1 @@ -{"version":3,"file":"riot-ts.js","sourceRoot":"","sources":["riot-ts.ts"],"names":["Riot","Riot.Observable","Riot.Observable.constructor","Riot.Observable.on","Riot.Observable.one","Riot.Observable.off","Riot.Observable.trigger","Riot.Element","Riot.Element.constructor","Riot.Element.update","Riot.Element.unmount","Riot.Element.on","Riot.Element.one","Riot.Element.off","Riot.Element.trigger","Riot.Element.mixin","Riot.Element.createElement","Riot.extend","Riot.registerClass","Riot.registerClass.registerTag","Riot.registerClass.loadTemplateFromHTTP","template"],"mappings":"AAAA,IAAO,IAAI,CAqLV;AArLD,WAAO,IAAI,EACX,C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CAACA,GAACA,CAACA,CAACA,CAACA,CAACA;gBAC7BA,gBAAgBA;gBAChBA,EAAEA,CAAAA,CAACA,oBAAeA,CAACA,WAAWA,CAACA,KAAGA,SAASA,CAACA,CAC5CA,CAACA;oBACEA,kDAAkDA;oBAClDA,QAAQA,GAAGA,oBAAeA,CAACA,WAAWA,CAACA,CAACA;gBAC3CA,CAACA;gBACDA,IAAIA,CACJA,CAACA;oBACEA,yCAAyCA;oBACzCA,WAAWA,GAAGA,oBAAoBA,CAACA,WAAWA,CAACA,CAACA;oBAChDA,QAAQA,GAAGA,IAAIA,CAACA,OAAOA,CAACA,WAAWA,EAAEA,IAAIA,EAAEA,EAACA,QAAQA,EAAEA,IAAIA,EAACA,CAACA,CAACA,CAACA,CAACA,CAACA;gBACnEA,CAACA;YACJA,CAACA;YACDA,IAAIA,CACJA,CAACA;gBACEA,qCAAqCA;gBACrCA,QAAQA,GAAGA,IAAIA,CAACA,OAAOA,CAACA,WAAWA,EAAEA,IAAIA,EAAEA,EAACA,QAAQA,EAAEA,IAAIA,EAACA,CAACA,CAACA,CAACA,CAACA,CAACA;YACnEA,CAACA;YAEDA,OAAOA,CAACA,SAASA,CAACA,OAAOA,GAAGA,WAAWA,CAACA,QAAQA,CAACA,CAACA;QACrDA,CAACA;QACDA,IAAIA;YAACA,MAAMA,iCAAiCA,CAACA;IAChDA,CAACA;IAzDelB,kBAAaA,gBAyD5BA,CAAAA;AACJA,CAACA,EArLM,IAAI,KAAJ,IAAI,QAqLV;AAID,sBAAsB;AACtB,kBAAkB,QAAgB;IACjCqB,MAAMA,CAACA,UAASA,MAAgBA;QAC3B,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,QAAQ,CAAC;QACxC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC,CAAAA;AACJA,CAACA"} \ No newline at end of file +{"version":3,"file":"riot-ts.js","sourceRoot":"","sources":["riot-ts.ts"],"names":[],"mappings":";AAAC,IAAY,I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,OAAO,CAAC,WAAW,EAAE,IAAI,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACnE,CAAC;QACJ,CAAC;QACD,IAAI,CACJ,CAAC;YACE,qCAAqC;YACrC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACnE,CAAC;QAED,OAAO,CAAC,SAAS,CAAC,OAAO,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;IACrD,CAAC;IACD,IAAI;QAAC,MAAM,iCAAiC,CAAC;AAChD,CAAC;AAzDe,qBAAa,gBAyD5B,CAAA;AAED,sBAAsB;AACtB,kBAAyB,QAAgB;IACxC,MAAM,CAAC,UAAS,MAAgB;QAC3B,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,QAAQ,CAAC;QACxC,aAAa,CAAC,MAAM,CAAC,CAAC;IACzB,CAAC,CAAA;AACJ,CAAC;AALe,gBAAQ,WAKvB,CAAA"} \ No newline at end of file diff --git a/riot-ts.ts b/riot-ts.ts index 5279639..0c1f297 100644 --- a/riot-ts.ts +++ b/riot-ts.ts @@ -1,193 +1,137 @@ -module Riot -{ - export interface Settings { - brackets: string; - } - - export class Observable { - on(events: string, callback: Function) {} - one(events: string, callback: Function) {} - off(events: string) {} - trigger(eventName: string, ...args) {} - - constructor() { - riot.observable(this); - } - } +import * as riot from "riot"; - export interface Router { - (callback: Function): void; - (filter: string, callback: Function): void; - (to: string, title?: string); +import { CompilerResult } from "./types"; - create(): Router; - start(autoExec?: boolean); - stop(); - exec(); - query(): any; +export class Observable { + on(events: string, callback: Function) {} + one(events: string, callback: Function) {} + off(events: string) {} + trigger(eventName: string, ...args) {} - base(base: string); - parser(parser: (path: string)=>string, secondParser?: Function ); + constructor() { + riot.observable(this); } +} - export interface CompilerResult - { - tagName: string; - html: string; - css: string; - attribs: string; - js: string; - } - - export interface Base - { - version: string; - settings: Riot.Settings; - mount(customTagSelector: string, opts?: any): Array; - mount(selector: string, tagName: string, opts?: any): Array; - mount(domNode: Node, tagName: string, opts?: any): Array; - render(tagName: string, opts?: any): string; - tag(tagName: string, html: string, css: string, attrs: string, constructor: Function); - tag2(tagName: string, html: string, css: string, attrs: string, constructor: Function, bpair: string); - class(element: Function): void; - observable(object: any): void; - - mixin(mixinName: string, mixinObject: any): void; - - compile(callback: Function): void; - compile(url: string, callback: Function): void; - compile(tag: string): string; - compile(tag: string, dontExecute: boolean): string; - compile(tag: string, options: any): string; - compile(tag: string, dontExecute: boolean, options: any): CompilerResult[]; - - // TODO server-only methods - - route: Riot.Router; - } - - export interface LifeCycle - { - mounted?(F: Function); - unmounted?(F: Function); - updating?(F: Function); - updated?(F: Function); - } +export interface LifeCycle +{ + mounted?(F: Function); + unmounted?(F: Function); + updating?(F: Function); + updated?(F: Function); +} - export interface HTMLRiotElement extends HTMLElement - { - _tag: Element; - } +export interface HTMLRiotElement extends HTMLElement +{ + _tag: Element; +} - export class Element implements Riot.Observable, LifeCycle { - opts: any; - parent: Element; - root: HTMLElement; - tags: any; - tagName: string; - template: string; - isMounted: boolean; - - update(data?: any) { } - unmount(keepTheParent?: boolean) { } - on(eventName: string,fun: Function) { } - one(eventName: string,fun: Function) { } - off(events: string) {} - trigger(eventName: string,...args) {} - mixin(mixinObject: Object|Function|string, instance?: any) {} - - static createElement(options?:any): HTMLRiotElement { - var tagName = (this.prototype as any).tagName; - var el = document.createElement(tagName); - riot.mount(el, tagName, options); - return el as any as HTMLRiotElement; - } - } +export class Element implements Observable, LifeCycle { + opts: any; + parent: Element; + root: HTMLElement; + tags: any; + tagName: string; + template: string; + isMounted: boolean; + + update(data?: any) { } + unmount(keepTheParent?: boolean) { } + on(eventName: string,fun: Function) { } + one(eventName: string,fun: Function) { } + off(events: string) {} + trigger(eventName: string,...args) {} + mixin(mixinObject: Object|Function|string, instance?: any) {} + + static createElement(options?:any): HTMLRiotElement { + var tagName = (this.prototype as any).tagName; + var el = document.createElement(tagName); + riot.mount(el, tagName, options); + return el as any as HTMLRiotElement; + } +} - // new extend, works with getters and setters - function extend(d, element) { - var map = Object.keys(element.prototype).reduce((descriptors, key) => { - descriptors[key] = Object.getOwnPropertyDescriptor(element.prototype, key); - return descriptors; - },{}) as PropertyDescriptorMap; - Object.defineProperties(d, map); - } +// new extend, works with getters and setters +function extend(d, element) { + var map = Object.keys(element.prototype).reduce((descriptors, key) => { + descriptors[key] = Object.getOwnPropertyDescriptor(element.prototype, key); + return descriptors; + },{}) as PropertyDescriptorMap; + Object.defineProperties(d, map); +} - /* old extend, without getters and setters - function extend(d, element) { - Object.keys(element.prototype).forEach((key) => d[key] = element.prototype[key]); - } - */ +/* old extend, without getters and setters +function extend(d, element) { + Object.keys(element.prototype).forEach((key) => d[key] = element.prototype[key]); +} +*/ - export var precompiledTags: { [fileName: string]: CompilerResult } = {}; +export var precompiledTags: { [fileName: string]: CompilerResult } = {}; - export function registerClass(element: Function) { +export function registerClass(element: Function) { - function registerTag(compiledTag: CompilerResult) { + function registerTag(compiledTag: CompilerResult) { - var transformFunction = function (opts) { - extend(this,element); // copies prototype into "this" - element.apply(this, [opts]); // calls class constructor applying it on "this" + var transformFunction = function (opts) { + extend(this,element); // copies prototype into "this" + element.apply(this, [opts]); // calls class constructor applying it on "this" - if(element.prototype.mounted !== undefined) this.on("mount" , this.mounted); - if(element.prototype.unmounted !== undefined) this.on("unmount" , this.unmounted); - if(element.prototype.updating !== undefined) this.on("update" , this.updating); - if(element.prototype.updated !== undefined) this.on("updated" , this.updated); + if(element.prototype.mounted !== undefined) this.on("mount" , this.mounted); + if(element.prototype.unmounted !== undefined) this.on("unmount" , this.unmounted); + if(element.prototype.updating !== undefined) this.on("update" , this.updating); + if(element.prototype.updated !== undefined) this.on("updated" , this.updated); - // TODO support for init(opts) ? - }; + // TODO support for init(opts) ? + }; - riot.tag2(compiledTag.tagName, compiledTag.html, compiledTag.css, compiledTag.attribs, transformFunction, riot.settings.brackets); + riot.tag2(compiledTag.tagName, compiledTag.html, compiledTag.css, compiledTag.attribs, transformFunction, riot.settings.brackets); - return compiledTag.tagName; - } - - function loadTemplateFromHTTP(template) { - var req = new XMLHttpRequest(); - req.open("GET", template, false); - req.send(); - if (req.status == 200) return req.responseText; - else throw req.responseText; - }; + return compiledTag.tagName; + } - let compiled: CompilerResult; - - // gets string template: inlined, via http request or via precompiled cache - if(element.prototype.template !== undefined) { - let tagTemplate = element.prototype.template; - if(tagTemplate.indexOf("<")<0) { - // tag is a file - if(precompiledTags[tagTemplate]!==undefined) - { - // loads it from precompiled cache - compiled = precompiledTags[tagTemplate]; - } - else - { - // loads from HTTP and compile on the fly - tagTemplate = loadTemplateFromHTTP(tagTemplate); - compiled = riot.compile(tagTemplate, true, {entities: true})[0]; - } + function loadTemplateFromHTTP(template) { + var req = new XMLHttpRequest(); + req.open("GET", template, false); + req.send(); + if (req.status == 200) return req.responseText; + else throw req.responseText; + }; + + let compiled: CompilerResult; + + // gets string template: inlined, via http request or via precompiled cache + if(element.prototype.template !== undefined) { + let tagTemplate = element.prototype.template; + if(tagTemplate.indexOf("<")<0) { + // tag is a file + if(precompiledTags[tagTemplate]!==undefined) + { + // loads it from precompiled cache + compiled = precompiledTags[tagTemplate]; } - else + else { - // tag is inlined, compile on the fly + // loads from HTTP and compile on the fly + tagTemplate = loadTemplateFromHTTP(tagTemplate); compiled = riot.compile(tagTemplate, true, {entities: true})[0]; } - - element.prototype.tagName = registerTag(compiled); } - else throw "template property not specified"; + else + { + // tag is inlined, compile on the fly + compiled = riot.compile(tagTemplate, true, {entities: true})[0]; + } + + element.prototype.tagName = registerTag(compiled); } + else throw "template property not specified"; } -declare var riot: Riot.Base; - // @template decorator -function template(template: string) { +export function template(template: string) { return function(target: Function) { target.prototype["template"] = template; - Riot.registerClass(target); + registerClass(target); } } \ No newline at end of file diff --git a/riot.d.ts b/riot.d.ts new file mode 100644 index 0000000..0911de4 --- /dev/null +++ b/riot.d.ts @@ -0,0 +1,47 @@ +declare module "riot" { + interface Router { + (callback: Function): void; + (filter: string, callback: Function): void; + (to: string, title?: string): any; + create(): Router; + start(autoExec?: boolean): any; + stop(): any; + exec(): any; + query(): any; + base(base: string): any; + parser(parser: (path: string) => string, secondParser?: Function): any; + } + interface CompilerResult { + tagName: string; + html: string; + css: string; + attribs: string; + js: string; + } + interface Settings { + brackets: string; + } + type RiotElement = any; + interface Base { + version: string; + settings: Settings; + mount(customTagSelector: string, opts?: any): Array; + mount(selector: string, tagName: string, opts?: any): Array; + mount(domNode: Node, tagName: string, opts?: any): Array; + render(tagName: string, opts?: any): string; + tag(tagName: string, html: string, css: string, attrs: string, constructor: Function): any; + tag2(tagName: string, html: string, css: string, attrs: string, constructor: Function, bpair: string): any; + class(element: Function): void; + observable(object: any): void; + mixin(mixinName: string, mixinObject: any): void; + compile(callback: Function): void; + compile(url: string, callback: Function): void; + compile(tag: string): string; + compile(tag: string, dontExecute: boolean): string; + compile(tag: string, options: any): string; + compile(tag: string, dontExecute: boolean, options: any): CompilerResult[]; + route: Router; + } + var riot: Base; + export = riot; +} diff --git a/riot.js b/riot.js new file mode 100644 index 0000000..e69de29 diff --git a/riot.js.map b/riot.js.map new file mode 100644 index 0000000..7d03cd0 --- /dev/null +++ b/riot.js.map @@ -0,0 +1 @@ +{"version":3,"file":"riot.js","sourceRoot":"","sources":["riot.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/riot.ts b/riot.ts new file mode 100644 index 0000000..9d964ba --- /dev/null +++ b/riot.ts @@ -0,0 +1,63 @@ +declare module "riot" +{ + interface Router { + (callback: Function): void; + (filter: string, callback: Function): void; + (to: string, title?: string); + + create(): Router; + start(autoExec?: boolean); + stop(); + exec(); + query(): any; + + base(base: string); + parser(parser: (path: string)=>string, secondParser?: Function ); + } + + interface CompilerResult + { + tagName: string; + html: string; + css: string; + attribs: string; + js: string; + } + + interface Settings { + brackets: string; + } + + type RiotElement = any; + + interface Base + { + version: string; + settings: Settings; + mount(customTagSelector: string, opts?: any): Array; + mount(selector: string, tagName: string, opts?: any): Array; + mount(domNode: Node, tagName: string, opts?: any): Array; + render(tagName: string, opts?: any): string; + tag(tagName: string, html: string, css: string, attrs: string, constructor: Function); + tag2(tagName: string, html: string, css: string, attrs: string, constructor: Function, bpair: string); + class(element: Function): void; + observable(object: any): void; + + mixin(mixinName: string, mixinObject: any): void; + + compile(callback: Function): void; + compile(url: string, callback: Function): void; + compile(tag: string): string; + compile(tag: string, dontExecute: boolean): string; + compile(tag: string, options: any): string; + compile(tag: string, dontExecute: boolean, options: any): CompilerResult[]; + + // TODO server-only methods + + route: Router; + } + + var riot: Base; + + export = riot; +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..8e1a283 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "noImplicitAny": false, + "sourceMap": false + }, + "exclude": [ + "node_modules" + ] +} \ No newline at end of file diff --git a/types.d.ts b/types.d.ts new file mode 100644 index 0000000..1e1cad4 --- /dev/null +++ b/types.d.ts @@ -0,0 +1,22 @@ +export interface Router { + (callback: Function): void; + (filter: string, callback: Function): void; + (to: string, title?: string): any; + create(): Router; + start(autoExec?: boolean): any; + stop(): any; + exec(): any; + query(): any; + base(base: string): any; + parser(parser: (path: string) => string, secondParser?: Function): any; +} +export interface CompilerResult { + tagName: string; + html: string; + css: string; + attribs: string; + js: string; +} +export interface Settings { + brackets: string; +} diff --git a/types.js b/types.js new file mode 100644 index 0000000..3918c74 --- /dev/null +++ b/types.js @@ -0,0 +1 @@ +"use strict"; diff --git a/types.js.map b/types.js.map new file mode 100644 index 0000000..8da0887 --- /dev/null +++ b/types.js.map @@ -0,0 +1 @@ +{"version":3,"file":"types.js","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/types.ts b/types.ts new file mode 100644 index 0000000..24201dd --- /dev/null +++ b/types.ts @@ -0,0 +1,27 @@ +export interface Router { + (callback: Function): void; + (filter: string, callback: Function): void; + (to: string, title?: string); + + create(): Router; + start(autoExec?: boolean); + stop(); + exec(); + query(): any; + + base(base: string); + parser(parser: (path: string)=>string, secondParser?: Function ); +} + +export interface CompilerResult { + tagName: string; + html: string; + css: string; + attribs: string; + js: string; +} + +export interface Settings { + brackets: string; +} + From c3c6f770ebc46554cfe2ca8438de9b0a31537e62 Mon Sep 17 00:00:00 2001 From: Antonino Porcino Date: Tue, 31 May 2016 13:25:13 +0200 Subject: [PATCH 02/14] Made index.ts entry point --- RiotTS.csproj | 2 +- index.js | 118 +++++++++++++++++++++++++++++++++++++++++ riot-ts.ts => index.ts | 0 package.json | 2 +- riot-ts.js.map | 2 +- 5 files changed, 121 insertions(+), 3 deletions(-) create mode 100644 index.js rename riot-ts.ts => index.ts (100%) diff --git a/RiotTS.csproj b/RiotTS.csproj index 3fa31be..54c7e64 100644 --- a/RiotTS.csproj +++ b/RiotTS.csproj @@ -24,7 +24,7 @@ - + diff --git a/index.js b/index.js new file mode 100644 index 0000000..8a195bd --- /dev/null +++ b/index.js @@ -0,0 +1,118 @@ +"use strict"; +var riot = require("riot"); +var Observable = (function () { + function Observable() { + riot.observable(this); + } + Observable.prototype.on = function (events, callback) { }; + Observable.prototype.one = function (events, callback) { }; + Observable.prototype.off = function (events) { }; + Observable.prototype.trigger = function (eventName) { + var args = []; + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i]; + } + }; + return Observable; +}()); +exports.Observable = Observable; +var Element = (function () { + function Element() { + } + Element.prototype.update = function (data) { }; + Element.prototype.unmount = function (keepTheParent) { }; + Element.prototype.on = function (eventName, fun) { }; + Element.prototype.one = function (eventName, fun) { }; + Element.prototype.off = function (events) { }; + Element.prototype.trigger = function (eventName) { + var args = []; + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i]; + } + }; + Element.prototype.mixin = function (mixinObject, instance) { }; + Element.createElement = function (options) { + var tagName = this.prototype.tagName; + var el = document.createElement(tagName); + riot.mount(el, tagName, options); + return el; + }; + return Element; +}()); +exports.Element = Element; +// new extend, works with getters and setters +function extend(d, element) { + var map = Object.keys(element.prototype).reduce(function (descriptors, key) { + descriptors[key] = Object.getOwnPropertyDescriptor(element.prototype, key); + return descriptors; + }, {}); + Object.defineProperties(d, map); +} +/* old extend, without getters and setters +function extend(d, element) { + Object.keys(element.prototype).forEach((key) => d[key] = element.prototype[key]); +} +*/ +exports.precompiledTags = {}; +function registerClass(element) { + function registerTag(compiledTag) { + var transformFunction = function (opts) { + extend(this, element); // copies prototype into "this" + element.apply(this, [opts]); // calls class constructor applying it on "this" + if (element.prototype.mounted !== undefined) + this.on("mount", this.mounted); + if (element.prototype.unmounted !== undefined) + this.on("unmount", this.unmounted); + if (element.prototype.updating !== undefined) + this.on("update", this.updating); + if (element.prototype.updated !== undefined) + this.on("updated", this.updated); + // TODO support for init(opts) ? + }; + riot.tag2(compiledTag.tagName, compiledTag.html, compiledTag.css, compiledTag.attribs, transformFunction, riot.settings.brackets); + return compiledTag.tagName; + } + function loadTemplateFromHTTP(template) { + var req = new XMLHttpRequest(); + req.open("GET", template, false); + req.send(); + if (req.status == 200) + return req.responseText; + else + throw req.responseText; + } + ; + var compiled; + // gets string template: inlined, via http request or via precompiled cache + if (element.prototype.template !== undefined) { + var tagTemplate = element.prototype.template; + if (tagTemplate.indexOf("<") < 0) { + // tag is a file + if (exports.precompiledTags[tagTemplate] !== undefined) { + // loads it from precompiled cache + compiled = exports.precompiledTags[tagTemplate]; + } + else { + // loads from HTTP and compile on the fly + tagTemplate = loadTemplateFromHTTP(tagTemplate); + compiled = riot.compile(tagTemplate, true, { entities: true })[0]; + } + } + else { + // tag is inlined, compile on the fly + compiled = riot.compile(tagTemplate, true, { entities: true })[0]; + } + element.prototype.tagName = registerTag(compiled); + } + else + throw "template property not specified"; +} +exports.registerClass = registerClass; +// @template decorator +function template(template) { + return function (target) { + target.prototype["template"] = template; + registerClass(target); + }; +} +exports.template = template; diff --git a/riot-ts.ts b/index.ts similarity index 100% rename from riot-ts.ts rename to index.ts diff --git a/package.json b/package.json index 1bcb4ea..17c17ae 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "riot-ts", "version": "1.0.0", "description": "Riot for TypeScript", - "main": "riot-ts.js", + "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, diff --git a/riot-ts.js.map b/riot-ts.js.map index 358338a..d87f65c 100644 --- a/riot-ts.js.map +++ b/riot-ts.js.map @@ -1 +1 @@ -{"version":3,"file":"riot-ts.js","sourceRoot":"","sources":["riot-ts.ts"],"names":[],"mappings":";AAAC,IAAY,IAAI,WAAM,MAAM,CAAC,CAAA;AAI9B;IAMG;QACG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAPD,uBAAE,GAAF,UAAG,MAAc,EAAE,QAAkB,IAAG,CAAC;IACzC,wBAAG,GAAH,UAAI,MAAc,EAAE,QAAkB,IAAG,CAAC;IAC1C,wBAAG,GAAH,UAAI,MAAc,IAAG,CAAC;IACtB,4BAAO,GAAP,UAAQ,SAAiB;QAAE,cAAO;aAAP,WAAO,CAAP,sBAAO,CAAP,IAAO;YAAP,6BAAO;;IAAG,CAAC;IAKzC,iBAAC;AAAD,CAAC,AATD,IASC;AATY,kBAAU,aAStB,CAAA;AAeD;IAAA;IAuBA,CAAC;IAdE,wBAAM,GAAN,UAAO,IAAU,IAAI,CAAC;IACtB,yBAAO,GAAP,UAAQ,aAAuB,IAAI,CAAC;IACpC,oBAAE,GAAF,UAAG,SAAiB,EAAC,GAAa,IAAI,CAAC;IACvC,qBAAG,GAAH,UAAI,SAAiB,EAAC,GAAa,IAAI,CAAC;IACxC,qBAAG,GAAH,UAAI,MAAc,IAAG,CAAC;IACtB,yBAAO,GAAP,UAAQ,SAAiB;QAAC,cAAO;aAAP,WAAO,CAAP,sBAAO,CAAP,IAAO;YAAP,6BAAO;;IAAG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BAAP,WAAO,CAAP,sBAAO,CAAP,IAAO;wBAAP,6BAAO;;gBAAG,CAAC;gBACrC,uBAAK,GAAL,UAAM,WAAmC,EAAE,QAAc,IAAG,CAAC;gBAEtD,qBAAa,GAApB,UAAqB,OAAY;oBAC9B,IAAI,OAAO,GAAI,IAAI,CAAC,SAAiB,CAAC,OAAO,CAAC;oBAC9C,IAAI,EAAE,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;oBACzC,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;oBACjC,MAAM,CAAC,EAA4B,CAAC;gBACvC,CAAC;gBACJ,cAAC;YAAD,CAAC,AAvBD,IAuBC;YAvBD,6BAuBC,CAAA;YAiBU,6BAAA,eAAe,GAA2C,EAAE,CAAA,CAAC"} \ No newline at end of file From c955dd01e65adcc86157061d9710dda1a69c75f7 Mon Sep 17 00:00:00 2001 From: Antonino Porcino Date: Tue, 31 May 2016 14:04:30 +0200 Subject: [PATCH 03/14] Referenced riot+compiler --- index.js | 3 ++- index.ts | 7 +++++-- riot.ts | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 8a195bd..6350592 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,5 @@ "use strict"; -var riot = require("riot"); +var riot = require("riot/riot+compiler"); var Observable = (function () { function Observable() { riot.observable(this); @@ -116,3 +116,4 @@ function template(template) { }; } exports.template = template; +exports.base = riot; diff --git a/index.ts b/index.ts index 0c1f297..d5dbd59 100644 --- a/index.ts +++ b/index.ts @@ -1,4 +1,4 @@ -import * as riot from "riot"; +import * as riot from "riot/riot+compiler"; import { CompilerResult } from "./types"; @@ -134,4 +134,7 @@ export function template(template: string) { registerClass(target); } } - \ No newline at end of file + +export var base = riot; + + \ No newline at end of file diff --git a/riot.ts b/riot.ts index 9d964ba..47ecf10 100644 --- a/riot.ts +++ b/riot.ts @@ -1,4 +1,4 @@ -declare module "riot" +declare module "riot/riot+compiler" { interface Router { (callback: Function): void; From b0e5fb0e541e4b2f217196074443265f1ebe809f Mon Sep 17 00:00:00 2001 From: Antonino Porcino Date: Tue, 31 May 2016 14:17:40 +0200 Subject: [PATCH 04/14] revert index to riot-ts --- RiotTS.csproj | 2 +- index.js | 119 ----------------------------------------- riot-ts.js | 3 +- index.ts => riot-ts.ts | 0 4 files changed, 3 insertions(+), 121 deletions(-) delete mode 100644 index.js rename index.ts => riot-ts.ts (100%) diff --git a/RiotTS.csproj b/RiotTS.csproj index 54c7e64..3fa31be 100644 --- a/RiotTS.csproj +++ b/RiotTS.csproj @@ -24,7 +24,7 @@ - + diff --git a/index.js b/index.js deleted file mode 100644 index 6350592..0000000 --- a/index.js +++ /dev/null @@ -1,119 +0,0 @@ -"use strict"; -var riot = require("riot/riot+compiler"); -var Observable = (function () { - function Observable() { - riot.observable(this); - } - Observable.prototype.on = function (events, callback) { }; - Observable.prototype.one = function (events, callback) { }; - Observable.prototype.off = function (events) { }; - Observable.prototype.trigger = function (eventName) { - var args = []; - for (var _i = 1; _i < arguments.length; _i++) { - args[_i - 1] = arguments[_i]; - } - }; - return Observable; -}()); -exports.Observable = Observable; -var Element = (function () { - function Element() { - } - Element.prototype.update = function (data) { }; - Element.prototype.unmount = function (keepTheParent) { }; - Element.prototype.on = function (eventName, fun) { }; - Element.prototype.one = function (eventName, fun) { }; - Element.prototype.off = function (events) { }; - Element.prototype.trigger = function (eventName) { - var args = []; - for (var _i = 1; _i < arguments.length; _i++) { - args[_i - 1] = arguments[_i]; - } - }; - Element.prototype.mixin = function (mixinObject, instance) { }; - Element.createElement = function (options) { - var tagName = this.prototype.tagName; - var el = document.createElement(tagName); - riot.mount(el, tagName, options); - return el; - }; - return Element; -}()); -exports.Element = Element; -// new extend, works with getters and setters -function extend(d, element) { - var map = Object.keys(element.prototype).reduce(function (descriptors, key) { - descriptors[key] = Object.getOwnPropertyDescriptor(element.prototype, key); - return descriptors; - }, {}); - Object.defineProperties(d, map); -} -/* old extend, without getters and setters -function extend(d, element) { - Object.keys(element.prototype).forEach((key) => d[key] = element.prototype[key]); -} -*/ -exports.precompiledTags = {}; -function registerClass(element) { - function registerTag(compiledTag) { - var transformFunction = function (opts) { - extend(this, element); // copies prototype into "this" - element.apply(this, [opts]); // calls class constructor applying it on "this" - if (element.prototype.mounted !== undefined) - this.on("mount", this.mounted); - if (element.prototype.unmounted !== undefined) - this.on("unmount", this.unmounted); - if (element.prototype.updating !== undefined) - this.on("update", this.updating); - if (element.prototype.updated !== undefined) - this.on("updated", this.updated); - // TODO support for init(opts) ? - }; - riot.tag2(compiledTag.tagName, compiledTag.html, compiledTag.css, compiledTag.attribs, transformFunction, riot.settings.brackets); - return compiledTag.tagName; - } - function loadTemplateFromHTTP(template) { - var req = new XMLHttpRequest(); - req.open("GET", template, false); - req.send(); - if (req.status == 200) - return req.responseText; - else - throw req.responseText; - } - ; - var compiled; - // gets string template: inlined, via http request or via precompiled cache - if (element.prototype.template !== undefined) { - var tagTemplate = element.prototype.template; - if (tagTemplate.indexOf("<") < 0) { - // tag is a file - if (exports.precompiledTags[tagTemplate] !== undefined) { - // loads it from precompiled cache - compiled = exports.precompiledTags[tagTemplate]; - } - else { - // loads from HTTP and compile on the fly - tagTemplate = loadTemplateFromHTTP(tagTemplate); - compiled = riot.compile(tagTemplate, true, { entities: true })[0]; - } - } - else { - // tag is inlined, compile on the fly - compiled = riot.compile(tagTemplate, true, { entities: true })[0]; - } - element.prototype.tagName = registerTag(compiled); - } - else - throw "template property not specified"; -} -exports.registerClass = registerClass; -// @template decorator -function template(template) { - return function (target) { - target.prototype["template"] = template; - registerClass(target); - }; -} -exports.template = template; -exports.base = riot; diff --git a/riot-ts.js b/riot-ts.js index 8a195bd..6350592 100644 --- a/riot-ts.js +++ b/riot-ts.js @@ -1,5 +1,5 @@ "use strict"; -var riot = require("riot"); +var riot = require("riot/riot+compiler"); var Observable = (function () { function Observable() { riot.observable(this); @@ -116,3 +116,4 @@ function template(template) { }; } exports.template = template; +exports.base = riot; diff --git a/index.ts b/riot-ts.ts similarity index 100% rename from index.ts rename to riot-ts.ts From be00bcd1c52e9a5f0ab094ba0b68cda0fe3ed793 Mon Sep 17 00:00:00 2001 From: Antonino Porcino Date: Tue, 31 May 2016 16:15:21 +0200 Subject: [PATCH 05/14] Separated riot-compile --- RiotTS.csproj | 1 + riot-compiler.js | 0 riot-compiler.ts | 25 +++++++++++++++++++++++++ riot-ts.js | 7 ++++--- riot-ts.js.map | 2 +- riot-ts.ts | 7 ++++--- riot.ts | 18 +----------------- 7 files changed, 36 insertions(+), 24 deletions(-) create mode 100644 riot-compiler.js create mode 100644 riot-compiler.ts diff --git a/RiotTS.csproj b/RiotTS.csproj index 3fa31be..9a27944 100644 --- a/RiotTS.csproj +++ b/RiotTS.csproj @@ -22,6 +22,7 @@ + diff --git a/riot-compiler.js b/riot-compiler.js new file mode 100644 index 0000000..e69de29 diff --git a/riot-compiler.ts b/riot-compiler.ts new file mode 100644 index 0000000..8e2110e --- /dev/null +++ b/riot-compiler.ts @@ -0,0 +1,25 @@ +declare module "riot-compiler" +{ + interface CompilerResult + { + tagName: string; + html: string; + css: string; + attribs: string; + js: string; + } + + interface Compile + { + (callback: Function): void; + (url: string, callback: Function): void; + (tag: string): string; + (tag: string, dontExecute: boolean): string; + (tag: string, options: any): string; + (tag: string, dontExecute: boolean, options: any): CompilerResult[]; + } + + var compile: Compile; + + export = compile; +} diff --git a/riot-ts.js b/riot-ts.js index 6350592..ea8da26 100644 --- a/riot-ts.js +++ b/riot-ts.js @@ -1,5 +1,6 @@ "use strict"; -var riot = require("riot/riot+compiler"); +var riot = require("riot"); +var compile = require("riot-compiler"); var Observable = (function () { function Observable() { riot.observable(this); @@ -95,12 +96,12 @@ function registerClass(element) { else { // loads from HTTP and compile on the fly tagTemplate = loadTemplateFromHTTP(tagTemplate); - compiled = riot.compile(tagTemplate, true, { entities: true })[0]; + compiled = compile(tagTemplate, true, { entities: true })[0]; } } else { // tag is inlined, compile on the fly - compiled = riot.compile(tagTemplate, true, { entities: true })[0]; + compiled = compile(tagTemplate, true, { entities: true })[0]; } element.prototype.tagName = registerTag(compiled); } diff --git a/riot-ts.js.map b/riot-ts.js.map index d87f65c..b68ccb7 100644 --- a/riot-ts.js.map +++ b/riot-ts.js.map @@ -1 +1 @@ -{"version":3,"file":"riot-ts.js","sourceRoot":"","sources":["riot-ts.ts"],"names":[],"mappings":";;;;6BAoEW,eAAe;IAd1B,gBAAgB,CAAC,EAAE,OAAO;QACvB,IAAI,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,UAAC,WAAW,EAAE,GAAG;YAC9D,WAAW,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,wBAAwB,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;YAC3E,MAAM,CAAC,WAAW,CAAC;QACtB,CAAC,EAAC,EAAE,CAA0B,CAAC;QAC/B,MAAM,CAAC,gBAAgB,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACnC,CAAC;IAUD,uBAA8B,OAAiB;QAE5C,qBAAqB,WAA2B;YAE7C,IAAI,iBAAiB,GAAG,UAAU,IAAI;gBACnC,MAAM,CAAC,IAAI,EAAC,OAAO,CAAC,CAAC;gBACrB,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;gBAE5B,EAAE,CAAA,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,KAAO,SAAS,CAAC;oBAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAK,IAAI,CAAC,OAAO,CAAC,CAAC;gBAChF,EAAE,CAAA,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,KAAK,SAAS,CAAC;oBAAC,IAAI,CAAC,EAAE,CAAC,SAAS,EAAG,IAAI,CAAC,SAAS,CAAC,CAAC;gBAClF,EAAE,CAAA,CAAC,OAAO,CAAC,SAAS,CAAC,QAAQ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AC,CAAC;oBACzC,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;oBACjC,MAAM,CAAC,EAA4B,CAAC;gBACvC,CAAC;gBACJ,cAAC;YAAD,CAAC,AAvBD,IAuBC;YAvBD,6BAuBC,CAAA;YAiBU,6BAAA,eAAe,GAA2C,EAAE,CAAA,CAAC;YAqE7D,kBAAA,IAAI,GAAG,IAAI,CAAA,CAAC"} \ No newline at end of file diff --git a/riot-ts.ts b/riot-ts.ts index d5dbd59..674323a 100644 --- a/riot-ts.ts +++ b/riot-ts.ts @@ -1,4 +1,5 @@ -import * as riot from "riot/riot+compiler"; +import * as riot from "riot"; +import * as compile from "riot-compiler"; import { CompilerResult } from "./types"; @@ -113,13 +114,13 @@ export function registerClass(element: Function) { { // loads from HTTP and compile on the fly tagTemplate = loadTemplateFromHTTP(tagTemplate); - compiled = riot.compile(tagTemplate, true, {entities: true})[0]; + compiled = compile(tagTemplate, true, {entities: true})[0]; } } else { // tag is inlined, compile on the fly - compiled = riot.compile(tagTemplate, true, {entities: true})[0]; + compiled = compile(tagTemplate, true, {entities: true})[0]; } element.prototype.tagName = registerTag(compiled); diff --git a/riot.ts b/riot.ts index 47ecf10..862c59c 100644 --- a/riot.ts +++ b/riot.ts @@ -1,4 +1,4 @@ -declare module "riot/riot+compiler" +declare module "riot" { interface Router { (callback: Function): void; @@ -13,15 +13,6 @@ base(base: string); parser(parser: (path: string)=>string, secondParser?: Function ); - } - - interface CompilerResult - { - tagName: string; - html: string; - css: string; - attribs: string; - js: string; } interface Settings { @@ -45,13 +36,6 @@ mixin(mixinName: string, mixinObject: any): void; - compile(callback: Function): void; - compile(url: string, callback: Function): void; - compile(tag: string): string; - compile(tag: string, dontExecute: boolean): string; - compile(tag: string, options: any): string; - compile(tag: string, dontExecute: boolean, options: any): CompilerResult[]; - // TODO server-only methods route: Router; From a2cc01e0a0ffe5a119e371218cbbc669f7b46646 Mon Sep 17 00:00:00 2001 From: Antonino Porcino Date: Tue, 31 May 2016 16:17:25 +0200 Subject: [PATCH 06/14] Updated package.json --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 17c17ae..97841da 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ }, "homepage": "https://github.com/nippur72/RiotTS#readme", "dependencies": { - "riot": "^2.4.1" + "riot": "^2.4.1", + "riot-compiler": "^2.4.1" } } From 6e6be6640c663d8a7b39afebdf4cd654fea673a8 Mon Sep 17 00:00:00 2001 From: Antonino Porcino Date: Tue, 31 May 2016 16:48:01 +0200 Subject: [PATCH 07/14] Files in tsconfig.json --- riot-compiler.js.map | 1 + riot-ts.js.map | 2 +- tsconfig.json | 7 +++++-- 3 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 riot-compiler.js.map diff --git a/riot-compiler.js.map b/riot-compiler.js.map new file mode 100644 index 0000000..f281ae5 --- /dev/null +++ b/riot-compiler.js.map @@ -0,0 +1 @@ +{"version":3,"file":"riot-compiler.js","sourceRoot":"","sources":["riot-compiler.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/riot-ts.js.map b/riot-ts.js.map index b68ccb7..aa6abe3 100644 --- a/riot-ts.js.map +++ b/riot-ts.js.map @@ -1 +1 @@ -{"version":3,"file":"riot-ts.js","sourceRoot":"","sources":["riot-ts.ts"],"names":[],"mappings":";;;;6BAoEW,eAAe,EAqEf,IAAI;IAnFf,gBAAgB,CAAC,EAAE,OAAO;QACvB,IAAI,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,UAAC,WAAW,EAAE,GAAG;YAC9D,WAAW,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,wBAAwB,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;YAC3E,MAAM,CAAC,WAAW,CAAC;QACtB,CAAC,EAAC,EAAE,CAA0B,CAAC;QAC/B,MAAM,CAAC,gBA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ATD,IASC;YATD,mCASC,CAAA;YAeD;gBAAA;gBAuBA,CAAC;gBAdE,wBAAM,GAAN,UAAO,IAAU,IAAI,CAAC;gBACtB,yBAAO,GAAP,UAAQ,aAAuB,IAAI,CAAC;gBACpC,oBAAE,GAAF,UAAG,SAAiB,EAAC,GAAa,IAAI,CAAC;gBACvC,qBAAG,GAAH,UAAI,SAAiB,EAAC,GAAa,IAAI,CAAC;gBACxC,qBAAG,GAAH,UAAI,MAAc,IAAG,CAAC;gBACtB,yBAAO,GAAP,UAAQ,SAAiB;oBAAC,cAAO;yBAAP,WAAO,CAAP,sBAAO,CAAP,IAAO;wBAAP,6BAAO;;gBAAG,CAAC;gBACrC,uBAAK,GAAL,UAAM,WAAmC,EAAE,QAAc,IAAG,CAAC;gBAEtD,qBAAa,GAApB,UAAqB,OAAY;oBAC9B,IAAI,OAAO,GAAI,IAAI,CAAC,SAAiB,CAAC,OAAO,CAAC;oBAC9C,IAAI,EAAE,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;oBACzC,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;oBACjC,MAAM,CAAC,EAA4B,CAAC;gBACvC,CAAC;gBACJ,cAAC;YAAD,CAAC,AAvBD,IAuBC;YAvBD,6BAuBC,CAAA;YAiBU,6BAAA,eAAe,GAA2C,EAAE,CAAA,CAAC;YAqE7D,kBAAA,IAAI,GAAG,IAAI,CAAA,CAAC"} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 8e1a283..799904d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,7 +5,10 @@ "noImplicitAny": false, "sourceMap": false }, - "exclude": [ - "node_modules" + "files": [ + "riot-compiler.ts", + "riot-ts.ts", + "riot.ts", + "types.ts" ] } \ No newline at end of file From e83f0b45f8ebe84c3af75c26f1e1616b9075a602 Mon Sep 17 00:00:00 2001 From: Antonino Porcino Date: Tue, 31 May 2016 16:57:10 +0200 Subject: [PATCH 08/14] Renamed main file --- RiotTS.csproj | 2 +- RiotTS.js | 120 ++++++++++++++++++++++ riot-ts.ts => RiotTS.ts | 0 riot-ts.js | 222 ++++++++++++++++++++-------------------- tsconfig.json | 2 +- 5 files changed, 234 insertions(+), 112 deletions(-) create mode 100644 RiotTS.js rename riot-ts.ts => RiotTS.ts (100%) diff --git a/RiotTS.csproj b/RiotTS.csproj index 9a27944..ed91c9d 100644 --- a/RiotTS.csproj +++ b/RiotTS.csproj @@ -25,7 +25,7 @@ - + diff --git a/RiotTS.js b/RiotTS.js new file mode 100644 index 0000000..ea8da26 --- /dev/null +++ b/RiotTS.js @@ -0,0 +1,120 @@ +"use strict"; +var riot = require("riot"); +var compile = require("riot-compiler"); +var Observable = (function () { + function Observable() { + riot.observable(this); + } + Observable.prototype.on = function (events, callback) { }; + Observable.prototype.one = function (events, callback) { }; + Observable.prototype.off = function (events) { }; + Observable.prototype.trigger = function (eventName) { + var args = []; + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i]; + } + }; + return Observable; +}()); +exports.Observable = Observable; +var Element = (function () { + function Element() { + } + Element.prototype.update = function (data) { }; + Element.prototype.unmount = function (keepTheParent) { }; + Element.prototype.on = function (eventName, fun) { }; + Element.prototype.one = function (eventName, fun) { }; + Element.prototype.off = function (events) { }; + Element.prototype.trigger = function (eventName) { + var args = []; + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i]; + } + }; + Element.prototype.mixin = function (mixinObject, instance) { }; + Element.createElement = function (options) { + var tagName = this.prototype.tagName; + var el = document.createElement(tagName); + riot.mount(el, tagName, options); + return el; + }; + return Element; +}()); +exports.Element = Element; +// new extend, works with getters and setters +function extend(d, element) { + var map = Object.keys(element.prototype).reduce(function (descriptors, key) { + descriptors[key] = Object.getOwnPropertyDescriptor(element.prototype, key); + return descriptors; + }, {}); + Object.defineProperties(d, map); +} +/* old extend, without getters and setters +function extend(d, element) { + Object.keys(element.prototype).forEach((key) => d[key] = element.prototype[key]); +} +*/ +exports.precompiledTags = {}; +function registerClass(element) { + function registerTag(compiledTag) { + var transformFunction = function (opts) { + extend(this, element); // copies prototype into "this" + element.apply(this, [opts]); // calls class constructor applying it on "this" + if (element.prototype.mounted !== undefined) + this.on("mount", this.mounted); + if (element.prototype.unmounted !== undefined) + this.on("unmount", this.unmounted); + if (element.prototype.updating !== undefined) + this.on("update", this.updating); + if (element.prototype.updated !== undefined) + this.on("updated", this.updated); + // TODO support for init(opts) ? + }; + riot.tag2(compiledTag.tagName, compiledTag.html, compiledTag.css, compiledTag.attribs, transformFunction, riot.settings.brackets); + return compiledTag.tagName; + } + function loadTemplateFromHTTP(template) { + var req = new XMLHttpRequest(); + req.open("GET", template, false); + req.send(); + if (req.status == 200) + return req.responseText; + else + throw req.responseText; + } + ; + var compiled; + // gets string template: inlined, via http request or via precompiled cache + if (element.prototype.template !== undefined) { + var tagTemplate = element.prototype.template; + if (tagTemplate.indexOf("<") < 0) { + // tag is a file + if (exports.precompiledTags[tagTemplate] !== undefined) { + // loads it from precompiled cache + compiled = exports.precompiledTags[tagTemplate]; + } + else { + // loads from HTTP and compile on the fly + tagTemplate = loadTemplateFromHTTP(tagTemplate); + compiled = compile(tagTemplate, true, { entities: true })[0]; + } + } + else { + // tag is inlined, compile on the fly + compiled = compile(tagTemplate, true, { entities: true })[0]; + } + element.prototype.tagName = registerTag(compiled); + } + else + throw "template property not specified"; +} +exports.registerClass = registerClass; +// @template decorator +function template(template) { + return function (target) { + target.prototype["template"] = template; + registerClass(target); + }; +} +exports.template = template; +exports.base = riot; diff --git a/riot-ts.ts b/RiotTS.ts similarity index 100% rename from riot-ts.ts rename to RiotTS.ts diff --git a/riot-ts.js b/riot-ts.js index ea8da26..f71ae71 100644 --- a/riot-ts.js +++ b/riot-ts.js @@ -1,120 +1,122 @@ -"use strict"; -var riot = require("riot"); -var compile = require("riot-compiler"); -var Observable = (function () { - function Observable() { - riot.observable(this); +System.register(["riot", "riot-compiler"], function(exports_1, context_1) { + "use strict"; + var __moduleName = context_1 && context_1.id; + var riot, compile; + var Observable, Element, precompiledTags, base; + function extend(d, element) { + var map = Object.keys(element.prototype).reduce(function (descriptors, key) { + descriptors[key] = Object.getOwnPropertyDescriptor(element.prototype, key); + return descriptors; + }, {}); + Object.defineProperties(d, map); } - Observable.prototype.on = function (events, callback) { }; - Observable.prototype.one = function (events, callback) { }; - Observable.prototype.off = function (events) { }; - Observable.prototype.trigger = function (eventName) { - var args = []; - for (var _i = 1; _i < arguments.length; _i++) { - args[_i - 1] = arguments[_i]; + function registerClass(element) { + function registerTag(compiledTag) { + var transformFunction = function (opts) { + extend(this, element); + element.apply(this, [opts]); + if (element.prototype.mounted !== undefined) + this.on("mount", this.mounted); + if (element.prototype.unmounted !== undefined) + this.on("unmount", this.unmounted); + if (element.prototype.updating !== undefined) + this.on("update", this.updating); + if (element.prototype.updated !== undefined) + this.on("updated", this.updated); + }; + riot.tag2(compiledTag.tagName, compiledTag.html, compiledTag.css, compiledTag.attribs, transformFunction, riot.settings.brackets); + return compiledTag.tagName; } - }; - return Observable; -}()); -exports.Observable = Observable; -var Element = (function () { - function Element() { - } - Element.prototype.update = function (data) { }; - Element.prototype.unmount = function (keepTheParent) { }; - Element.prototype.on = function (eventName, fun) { }; - Element.prototype.one = function (eventName, fun) { }; - Element.prototype.off = function (events) { }; - Element.prototype.trigger = function (eventName) { - var args = []; - for (var _i = 1; _i < arguments.length; _i++) { - args[_i - 1] = arguments[_i]; + function loadTemplateFromHTTP(template) { + var req = new XMLHttpRequest(); + req.open("GET", template, false); + req.send(); + if (req.status == 200) + return req.responseText; + else + throw req.responseText; } - }; - Element.prototype.mixin = function (mixinObject, instance) { }; - Element.createElement = function (options) { - var tagName = this.prototype.tagName; - var el = document.createElement(tagName); - riot.mount(el, tagName, options); - return el; - }; - return Element; -}()); -exports.Element = Element; -// new extend, works with getters and setters -function extend(d, element) { - var map = Object.keys(element.prototype).reduce(function (descriptors, key) { - descriptors[key] = Object.getOwnPropertyDescriptor(element.prototype, key); - return descriptors; - }, {}); - Object.defineProperties(d, map); -} -/* old extend, without getters and setters -function extend(d, element) { - Object.keys(element.prototype).forEach((key) => d[key] = element.prototype[key]); -} -*/ -exports.precompiledTags = {}; -function registerClass(element) { - function registerTag(compiledTag) { - var transformFunction = function (opts) { - extend(this, element); // copies prototype into "this" - element.apply(this, [opts]); // calls class constructor applying it on "this" - if (element.prototype.mounted !== undefined) - this.on("mount", this.mounted); - if (element.prototype.unmounted !== undefined) - this.on("unmount", this.unmounted); - if (element.prototype.updating !== undefined) - this.on("update", this.updating); - if (element.prototype.updated !== undefined) - this.on("updated", this.updated); - // TODO support for init(opts) ? - }; - riot.tag2(compiledTag.tagName, compiledTag.html, compiledTag.css, compiledTag.attribs, transformFunction, riot.settings.brackets); - return compiledTag.tagName; - } - function loadTemplateFromHTTP(template) { - var req = new XMLHttpRequest(); - req.open("GET", template, false); - req.send(); - if (req.status == 200) - return req.responseText; - else - throw req.responseText; - } - ; - var compiled; - // gets string template: inlined, via http request or via precompiled cache - if (element.prototype.template !== undefined) { - var tagTemplate = element.prototype.template; - if (tagTemplate.indexOf("<") < 0) { - // tag is a file - if (exports.precompiledTags[tagTemplate] !== undefined) { - // loads it from precompiled cache - compiled = exports.precompiledTags[tagTemplate]; + ; + var compiled; + if (element.prototype.template !== undefined) { + var tagTemplate = element.prototype.template; + if (tagTemplate.indexOf("<") < 0) { + if (precompiledTags[tagTemplate] !== undefined) { + compiled = precompiledTags[tagTemplate]; + } + else { + tagTemplate = loadTemplateFromHTTP(tagTemplate); + compiled = compile(tagTemplate, true, { entities: true })[0]; + } } else { - // loads from HTTP and compile on the fly - tagTemplate = loadTemplateFromHTTP(tagTemplate); compiled = compile(tagTemplate, true, { entities: true })[0]; } + element.prototype.tagName = registerTag(compiled); } - else { - // tag is inlined, compile on the fly - compiled = compile(tagTemplate, true, { entities: true })[0]; + else + throw "template property not specified"; + } + exports_1("registerClass", registerClass); + function template(template) { + return function (target) { + target.prototype["template"] = template; + registerClass(target); + }; + } + exports_1("template", template); + return { + setters:[ + function (riot_1) { + riot = riot_1; + }, + function (compile_1) { + compile = compile_1; + }], + execute: function() { + Observable = (function () { + function Observable() { + riot.observable(this); + } + Observable.prototype.on = function (events, callback) { }; + Observable.prototype.one = function (events, callback) { }; + Observable.prototype.off = function (events) { }; + Observable.prototype.trigger = function (eventName) { + var args = []; + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i]; + } + }; + return Observable; + }()); + exports_1("Observable", Observable); + Element = (function () { + function Element() { + } + Element.prototype.update = function (data) { }; + Element.prototype.unmount = function (keepTheParent) { }; + Element.prototype.on = function (eventName, fun) { }; + Element.prototype.one = function (eventName, fun) { }; + Element.prototype.off = function (events) { }; + Element.prototype.trigger = function (eventName) { + var args = []; + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i]; + } + }; + Element.prototype.mixin = function (mixinObject, instance) { }; + Element.createElement = function (options) { + var tagName = this.prototype.tagName; + var el = document.createElement(tagName); + riot.mount(el, tagName, options); + return el; + }; + return Element; + }()); + exports_1("Element", Element); + exports_1("precompiledTags", precompiledTags = {}); + exports_1("base", base = riot); } - element.prototype.tagName = registerTag(compiled); } - else - throw "template property not specified"; -} -exports.registerClass = registerClass; -// @template decorator -function template(template) { - return function (target) { - target.prototype["template"] = template; - registerClass(target); - }; -} -exports.template = template; -exports.base = riot; +}); +//# sourceMappingURL=riot-ts.js.map \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 799904d..98bdbb2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,7 +7,7 @@ }, "files": [ "riot-compiler.ts", - "riot-ts.ts", + "RiotTS.ts", "riot.ts", "types.ts" ] From cb32c0770b530f200ba862b0800120ba03996271 Mon Sep 17 00:00:00 2001 From: Antonino Porcino Date: Tue, 31 May 2016 17:05:38 +0200 Subject: [PATCH 09/14] Reorganized package --- RiotTS.csproj | 1 + RiotTS.d.ts | 39 +++++++++++++++++++++++++++++++++++++++ RiotTS.js | 2 +- RiotTS.js.map | 1 + RiotTS.ts | 4 +--- package.json | 2 +- riot-compiler.d.ts | 19 +++++++++++++++++++ riot-compiler.js | 1 + riot.d.ts | 13 ------------- riot.js | 1 + tsconfig.json | 3 ++- types.js | 1 + 12 files changed, 68 insertions(+), 19 deletions(-) create mode 100644 RiotTS.d.ts create mode 100644 RiotTS.js.map create mode 100644 riot-compiler.d.ts diff --git a/RiotTS.csproj b/RiotTS.csproj index ed91c9d..7f1814f 100644 --- a/RiotTS.csproj +++ b/RiotTS.csproj @@ -31,6 +31,7 @@ + web.config diff --git a/RiotTS.d.ts b/RiotTS.d.ts new file mode 100644 index 0000000..02dbf31 --- /dev/null +++ b/RiotTS.d.ts @@ -0,0 +1,39 @@ +import { CompilerResult } from "./types"; +export declare class Observable { + on(events: string, callback: Function): void; + one(events: string, callback: Function): void; + off(events: string): void; + trigger(eventName: string, ...args: any[]): void; + constructor(); +} +export interface LifeCycle { + mounted?(F: Function): any; + unmounted?(F: Function): any; + updating?(F: Function): any; + updated?(F: Function): any; +} +export interface HTMLRiotElement extends HTMLElement { + _tag: Element; +} +export declare class Element implements Observable, LifeCycle { + opts: any; + parent: Element; + root: HTMLElement; + tags: any; + tagName: string; + template: string; + isMounted: boolean; + update(data?: any): void; + unmount(keepTheParent?: boolean): void; + on(eventName: string, fun: Function): void; + one(eventName: string, fun: Function): void; + off(events: string): void; + trigger(eventName: string, ...args: any[]): void; + mixin(mixinObject: Object | Function | string, instance?: any): void; + static createElement(options?: any): HTMLRiotElement; +} +export declare var precompiledTags: { + [fileName: string]: CompilerResult; +}; +export declare function registerClass(element: Function): void; +export declare function template(template: string): (target: Function) => void; diff --git a/RiotTS.js b/RiotTS.js index ea8da26..733e1c8 100644 --- a/RiotTS.js +++ b/RiotTS.js @@ -117,4 +117,4 @@ function template(template) { }; } exports.template = template; -exports.base = riot; +//# sourceMappingURL=RiotTS.js.map \ No newline at end of file diff --git a/RiotTS.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C;gBACE,kDAAkD;gBAClD,QAAQ,GAAG,uBAAe,CAAC,WAAW,CAAC,CAAC;YAC3C,CAAC;YACD,IAAI,CACJ,CAAC;gBACE,yCAAyC;gBACzC,WAAW,GAAG,oBAAoB,CAAC,WAAW,CAAC,CAAC;gBAChD,QAAQ,GAAG,OAAO,CAAC,WAAW,EAAE,IAAI,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC9D,CAAC;QACJ,CAAC;QACD,IAAI,CACJ,CAAC;YACE,qCAAqC;YACrC,QAAQ,GAAG,OAAO,CAAC,WAAW,EAAE,IAAI,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9D,CAAC;QAED,OAAO,CAAC,SAAS,CAAC,OAAO,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;IACrD,CAAC;IACD,IAAI;QAAC,MAAM,iCAAiC,CAAC;AAChD,CAAC;AAzDe,qBAAa,gBAyD5B,CAAA;AAED,sBAAsB;AACtB,kBAAyB,QAAgB;IACxC,MAAM,CAAC,UAAS,MAAgB;QAC3B,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,QAAQ,CAAC;QACxC,aAAa,CAAC,MAAM,CAAC,CAAC;IACzB,CAAC,CAAA;AACJ,CAAC;AALe,gBAAQ,WAKvB,CAAA"} \ No newline at end of file diff --git a/RiotTS.ts b/RiotTS.ts index 674323a..d62584a 100644 --- a/RiotTS.ts +++ b/RiotTS.ts @@ -13,7 +13,7 @@ export class Observable { riot.observable(this); } } - + export interface LifeCycle { mounted?(F: Function); @@ -136,6 +136,4 @@ export function template(template: string) { } } -export var base = riot; - \ No newline at end of file diff --git a/package.json b/package.json index 97841da..c0b9e73 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "riot-ts", "version": "1.0.0", "description": "Riot for TypeScript", - "main": "index.js", + "main": "RiotTS.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, diff --git a/riot-compiler.d.ts b/riot-compiler.d.ts new file mode 100644 index 0000000..eba3d9a --- /dev/null +++ b/riot-compiler.d.ts @@ -0,0 +1,19 @@ +declare module "riot-compiler" { + interface CompilerResult { + tagName: string; + html: string; + css: string; + attribs: string; + js: string; + } + interface Compile { + (callback: Function): void; + (url: string, callback: Function): void; + (tag: string): string; + (tag: string, dontExecute: boolean): string; + (tag: string, options: any): string; + (tag: string, dontExecute: boolean, options: any): CompilerResult[]; + } + var compile: Compile; + export = compile; +} diff --git a/riot-compiler.js b/riot-compiler.js index e69de29..6706a4b 100644 --- a/riot-compiler.js +++ b/riot-compiler.js @@ -0,0 +1 @@ +//# sourceMappingURL=riot-compiler.js.map \ No newline at end of file diff --git a/riot.d.ts b/riot.d.ts index 0911de4..84d184d 100644 --- a/riot.d.ts +++ b/riot.d.ts @@ -11,13 +11,6 @@ declare module "riot" { base(base: string): any; parser(parser: (path: string) => string, secondParser?: Function): any; } - interface CompilerResult { - tagName: string; - html: string; - css: string; - attribs: string; - js: string; - } interface Settings { brackets: string; } @@ -34,12 +27,6 @@ declare module "riot" { class(element: Function): void; observable(object: any): void; mixin(mixinName: string, mixinObject: any): void; - compile(callback: Function): void; - compile(url: string, callback: Function): void; - compile(tag: string): string; - compile(tag: string, dontExecute: boolean): string; - compile(tag: string, options: any): string; - compile(tag: string, dontExecute: boolean, options: any): CompilerResult[]; route: Router; } var riot: Base; diff --git a/riot.js b/riot.js index e69de29..ea5c8f7 100644 --- a/riot.js +++ b/riot.js @@ -0,0 +1 @@ +//# sourceMappingURL=riot.js.map \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 98bdbb2..621ec4a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,7 +3,8 @@ "module": "commonjs", "target": "es5", "noImplicitAny": false, - "sourceMap": false + "sourceMap": true, + "declaration": true }, "files": [ "riot-compiler.ts", diff --git a/types.js b/types.js index 3918c74..2f0e414 100644 --- a/types.js +++ b/types.js @@ -1 +1,2 @@ "use strict"; +//# sourceMappingURL=types.js.map \ No newline at end of file From 9ec45f7f274b7960400feaeabf1047ba4ff390c4 Mon Sep 17 00:00:00 2001 From: Antonino Porcino Date: Tue, 31 May 2016 17:10:55 +0200 Subject: [PATCH 10/14] Added index.js to package.json --- RiotTS.csproj | 3 +- index.d.ts | 2 + index.js | 5 + index.js.map | 1 + index.ts | 2 + package.json | 5 +- riot-ts.js | 220 ++++++++++++++++++++-------------------- riot-ts.js.map | 2 +- RiotTS.ts => riot-ts.ts | 0 tsconfig.json | 3 +- 10 files changed, 128 insertions(+), 115 deletions(-) create mode 100644 index.d.ts create mode 100644 index.js create mode 100644 index.js.map create mode 100644 index.ts rename RiotTS.ts => riot-ts.ts (100%) diff --git a/RiotTS.csproj b/RiotTS.csproj index 7f1814f..961a1ec 100644 --- a/RiotTS.csproj +++ b/RiotTS.csproj @@ -22,10 +22,11 @@ + - + diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..4bc6d52 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,2 @@ +import * as Riot from "./riot-ts"; +export default Riot; diff --git a/index.js b/index.js new file mode 100644 index 0000000..80f9361 --- /dev/null +++ b/index.js @@ -0,0 +1,5 @@ +"use strict"; +var Riot = require("./riot-ts"); +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = Riot; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..cba4dcc --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAC,IAAY,IAAI,WAAM,WAAW,CAAC,CAAA;AACnC;kBAAe,IAAI,CAAC"} \ No newline at end of file diff --git a/index.ts b/index.ts new file mode 100644 index 0000000..c417a3d --- /dev/null +++ b/index.ts @@ -0,0 +1,2 @@ +import * as Riot from "./riot-ts"; +export default Riot; \ No newline at end of file diff --git a/package.json b/package.json index c0b9e73..7d74b40 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "riot-ts", "version": "1.0.0", "description": "Riot for TypeScript", - "main": "RiotTS.js", + "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -19,5 +19,8 @@ "dependencies": { "riot": "^2.4.1", "riot-compiler": "^2.4.1" + }, + "typescript": { + "definition": "riot-ts.d.ts" } } diff --git a/riot-ts.js b/riot-ts.js index f71ae71..c550831 100644 --- a/riot-ts.js +++ b/riot-ts.js @@ -1,122 +1,120 @@ -System.register(["riot", "riot-compiler"], function(exports_1, context_1) { - "use strict"; - var __moduleName = context_1 && context_1.id; - var riot, compile; - var Observable, Element, precompiledTags, base; - function extend(d, element) { - var map = Object.keys(element.prototype).reduce(function (descriptors, key) { - descriptors[key] = Object.getOwnPropertyDescriptor(element.prototype, key); - return descriptors; - }, {}); - Object.defineProperties(d, map); +"use strict"; +var riot = require("riot"); +var compile = require("riot-compiler"); +var Observable = (function () { + function Observable() { + riot.observable(this); } - function registerClass(element) { - function registerTag(compiledTag) { - var transformFunction = function (opts) { - extend(this, element); - element.apply(this, [opts]); - if (element.prototype.mounted !== undefined) - this.on("mount", this.mounted); - if (element.prototype.unmounted !== undefined) - this.on("unmount", this.unmounted); - if (element.prototype.updating !== undefined) - this.on("update", this.updating); - if (element.prototype.updated !== undefined) - this.on("updated", this.updated); - }; - riot.tag2(compiledTag.tagName, compiledTag.html, compiledTag.css, compiledTag.attribs, transformFunction, riot.settings.brackets); - return compiledTag.tagName; + Observable.prototype.on = function (events, callback) { }; + Observable.prototype.one = function (events, callback) { }; + Observable.prototype.off = function (events) { }; + Observable.prototype.trigger = function (eventName) { + var args = []; + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i]; } - function loadTemplateFromHTTP(template) { - var req = new XMLHttpRequest(); - req.open("GET", template, false); - req.send(); - if (req.status == 200) - return req.responseText; - else - throw req.responseText; + }; + return Observable; +}()); +exports.Observable = Observable; +var Element = (function () { + function Element() { + } + Element.prototype.update = function (data) { }; + Element.prototype.unmount = function (keepTheParent) { }; + Element.prototype.on = function (eventName, fun) { }; + Element.prototype.one = function (eventName, fun) { }; + Element.prototype.off = function (events) { }; + Element.prototype.trigger = function (eventName) { + var args = []; + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i]; } - ; - var compiled; - if (element.prototype.template !== undefined) { - var tagTemplate = element.prototype.template; - if (tagTemplate.indexOf("<") < 0) { - if (precompiledTags[tagTemplate] !== undefined) { - compiled = precompiledTags[tagTemplate]; - } - else { - tagTemplate = loadTemplateFromHTTP(tagTemplate); - compiled = compile(tagTemplate, true, { entities: true })[0]; - } + }; + Element.prototype.mixin = function (mixinObject, instance) { }; + Element.createElement = function (options) { + var tagName = this.prototype.tagName; + var el = document.createElement(tagName); + riot.mount(el, tagName, options); + return el; + }; + return Element; +}()); +exports.Element = Element; +// new extend, works with getters and setters +function extend(d, element) { + var map = Object.keys(element.prototype).reduce(function (descriptors, key) { + descriptors[key] = Object.getOwnPropertyDescriptor(element.prototype, key); + return descriptors; + }, {}); + Object.defineProperties(d, map); +} +/* old extend, without getters and setters +function extend(d, element) { + Object.keys(element.prototype).forEach((key) => d[key] = element.prototype[key]); +} +*/ +exports.precompiledTags = {}; +function registerClass(element) { + function registerTag(compiledTag) { + var transformFunction = function (opts) { + extend(this, element); // copies prototype into "this" + element.apply(this, [opts]); // calls class constructor applying it on "this" + if (element.prototype.mounted !== undefined) + this.on("mount", this.mounted); + if (element.prototype.unmounted !== undefined) + this.on("unmount", this.unmounted); + if (element.prototype.updating !== undefined) + this.on("update", this.updating); + if (element.prototype.updated !== undefined) + this.on("updated", this.updated); + // TODO support for init(opts) ? + }; + riot.tag2(compiledTag.tagName, compiledTag.html, compiledTag.css, compiledTag.attribs, transformFunction, riot.settings.brackets); + return compiledTag.tagName; + } + function loadTemplateFromHTTP(template) { + var req = new XMLHttpRequest(); + req.open("GET", template, false); + req.send(); + if (req.status == 200) + return req.responseText; + else + throw req.responseText; + } + ; + var compiled; + // gets string template: inlined, via http request or via precompiled cache + if (element.prototype.template !== undefined) { + var tagTemplate = element.prototype.template; + if (tagTemplate.indexOf("<") < 0) { + // tag is a file + if (exports.precompiledTags[tagTemplate] !== undefined) { + // loads it from precompiled cache + compiled = exports.precompiledTags[tagTemplate]; } else { + // loads from HTTP and compile on the fly + tagTemplate = loadTemplateFromHTTP(tagTemplate); compiled = compile(tagTemplate, true, { entities: true })[0]; } - element.prototype.tagName = registerTag(compiled); } - else - throw "template property not specified"; - } - exports_1("registerClass", registerClass); - function template(template) { - return function (target) { - target.prototype["template"] = template; - registerClass(target); - }; - } - exports_1("template", template); - return { - setters:[ - function (riot_1) { - riot = riot_1; - }, - function (compile_1) { - compile = compile_1; - }], - execute: function() { - Observable = (function () { - function Observable() { - riot.observable(this); - } - Observable.prototype.on = function (events, callback) { }; - Observable.prototype.one = function (events, callback) { }; - Observable.prototype.off = function (events) { }; - Observable.prototype.trigger = function (eventName) { - var args = []; - for (var _i = 1; _i < arguments.length; _i++) { - args[_i - 1] = arguments[_i]; - } - }; - return Observable; - }()); - exports_1("Observable", Observable); - Element = (function () { - function Element() { - } - Element.prototype.update = function (data) { }; - Element.prototype.unmount = function (keepTheParent) { }; - Element.prototype.on = function (eventName, fun) { }; - Element.prototype.one = function (eventName, fun) { }; - Element.prototype.off = function (events) { }; - Element.prototype.trigger = function (eventName) { - var args = []; - for (var _i = 1; _i < arguments.length; _i++) { - args[_i - 1] = arguments[_i]; - } - }; - Element.prototype.mixin = function (mixinObject, instance) { }; - Element.createElement = function (options) { - var tagName = this.prototype.tagName; - var el = document.createElement(tagName); - riot.mount(el, tagName, options); - return el; - }; - return Element; - }()); - exports_1("Element", Element); - exports_1("precompiledTags", precompiledTags = {}); - exports_1("base", base = riot); + else { + // tag is inlined, compile on the fly + compiled = compile(tagTemplate, true, { entities: true })[0]; } + element.prototype.tagName = registerTag(compiled); } -}); + else + throw "template property not specified"; +} +exports.registerClass = registerClass; +// @template decorator +function template(template) { + return function (target) { + target.prototype["template"] = template; + registerClass(target); + }; +} +exports.template = template; //# sourceMappingURL=riot-ts.js.map \ No newline at end of file diff --git a/riot-ts.js.map b/riot-ts.js.map index aa6abe3..9923b29 100644 --- a/riot-ts.js.map +++ b/riot-ts.js.map @@ -1 +1 @@ -{"version":3,"file":"riot-ts.js","sourceRoot":"","sources":["riot-ts.ts"],"names":[],"mappings":";;;;6BAqEW,eAAe,EAqEf,IAAI;IAnFf,gBAAgB,CAAC,EAAE,OAAO;QACvB,IAAI,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,UAAC,WAAW,EAAE,GAAG;YAC9D,WAAW,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,wBAAwB,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;YAC3E,MAAM,CAAC,WAAW,CAAC;QACtB,CAAC,EAAC,EAAE,CAA0B,CAAC;QAC/B,MAAM,CAAC,gBAAgB,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACnC,CAAC;IAUD,uBAA8B,OAAiB;QAE5C,qBAAqB,WAA2B;YAE7C,IAAI,iBAAiB,GAAG,UAAU,IAAI;gBACnC,MAAM,CAAC,IAAI,EAAC,OAAO,CAAC,CAAC;gBACrB,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;gBAE5B,EAAE,CAAA,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,KAAO,SAAS,CAAC;oBAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAK,IAAI,CAAC,OAAO,CAAC,CAAC;gBAChF,EAAE,CAAA,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,KAAK,SAAS,CAAC;oBAAC,IAAI,CAAC,EAAE,CAAC,SAAS,EAAG,IAAI,CAAC,SAAS,CAAC,CAAC;gBAClF,EAAE,CAAA,CAAC,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AAI,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9D,CAAC;QAED,OAAO,CAAC,SAAS,CAAC,OAAO,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;IACrD,CAAC;IACD,IAAI;QAAC,MAAM,iCAAiC,CAAC;AAChD,CAAC;AAzDe,qBAAa,gBAyD5B,CAAA;AAED,sBAAsB;AACtB,kBAAyB,QAAgB;IACxC,MAAM,CAAC,UAAS,MAAgB;QAC3B,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,QAAQ,CAAC;QACxC,aAAa,CAAC,MAAM,CAAC,CAAC;IACzB,CAAC,CAAA;AACJ,CAAC;AALe,gBAAQ,WAKvB,CAAA"} \ No newline at end of file diff --git a/RiotTS.ts b/riot-ts.ts similarity index 100% rename from RiotTS.ts rename to riot-ts.ts diff --git a/tsconfig.json b/tsconfig.json index 621ec4a..ffcf908 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,8 +7,9 @@ "declaration": true }, "files": [ + "index.ts", "riot-compiler.ts", - "RiotTS.ts", + "riot-ts.ts", "riot.ts", "types.ts" ] From 6760c2f60e022320a83451ecbbadd71e9366f9e4 Mon Sep 17 00:00:00 2001 From: Antonino Porcino Date: Mon, 3 Oct 2016 19:26:10 +0200 Subject: [PATCH 11/14] makes RiotTS a npm module --- .gitignore | 54 +---------- RiotTS.csproj | 97 ------------------- RiotTS.csproj.user | 30 ------ RiotTS.d.ts | 39 -------- RiotTS.js | 120 ----------------------- RiotTS.js.map | 1 - RiotTS.sln | 21 ----- RiotTS.v12.suo | Bin 28672 -> 0 bytes riot-ts.d.ts => dist/riot-ts.d.ts | 24 ++++- dist/riot-ts.js | 152 ++++++++++++++++++++++++++++++ dist/riot-ts.js.map | 1 + index.d.ts | 2 - index.js | 5 - index.js.map | 1 - index.ts | 2 - package.json | 13 +-- riot-compiler.d.ts | 19 ---- riot-compiler.js | 1 - riot-compiler.js.map | 1 - riot-compiler.ts | 25 ----- riot-ts.js | 120 ----------------------- riot-ts.js.map | 1 - riot.d.ts | 34 ------- riot.js | 1 - riot.js.map | 1 - riot.ts | 47 --------- riot-ts.ts => src/riot-ts.ts | 103 +++++++++++++------- tsconfig.json | 22 +++-- types.d.ts | 22 ----- types.js | 2 - types.js.map | 1 - types.ts | 27 ------ web.Debug.config | 31 ------ web.Release.config | 32 ------- web.config | 14 --- 35 files changed, 266 insertions(+), 800 deletions(-) delete mode 100644 RiotTS.csproj delete mode 100644 RiotTS.csproj.user delete mode 100644 RiotTS.d.ts delete mode 100644 RiotTS.js delete mode 100644 RiotTS.js.map delete mode 100644 RiotTS.sln delete mode 100644 RiotTS.v12.suo rename riot-ts.d.ts => dist/riot-ts.d.ts (69%) create mode 100644 dist/riot-ts.js create mode 100644 dist/riot-ts.js.map delete mode 100644 index.d.ts delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 index.ts delete mode 100644 riot-compiler.d.ts delete mode 100644 riot-compiler.js delete mode 100644 riot-compiler.js.map delete mode 100644 riot-compiler.ts delete mode 100644 riot-ts.js delete mode 100644 riot-ts.js.map delete mode 100644 riot.d.ts delete mode 100644 riot.js delete mode 100644 riot.js.map delete mode 100644 riot.ts rename riot-ts.ts => src/riot-ts.ts (66%) delete mode 100644 types.d.ts delete mode 100644 types.js delete mode 100644 types.js.map delete mode 100644 types.ts delete mode 100644 web.Debug.config delete mode 100644 web.Release.config delete mode 100644 web.config diff --git a/.gitignore b/.gitignore index 6ed069d..8d056c8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,54 +1,2 @@ -.vs/ -bin/ -obj/ +.vscode/ node_modules/ -bower_components/ - -Test/bin -Test/obj -Test/node_modules/ -Test/bower_components/ - -# Windows image file caches -Thumbs.db -ehthumbs.db - -# Folder config file -Desktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Windows Installer files -*.cab -*.msi -*.msm -*.msp - -# Windows shortcuts -*.lnk - -# ========================= -# Operating System Files -# ========================= - -# OSX -# ========================= - -.DS_Store -.AppleDouble -.LSOverride - -# Thumbnails -._* - -# Files that might appear on external disk -.Spotlight-V100 -.Trashes - -# Directories potentially created on remote AFP share -.AppleDB -.AppleDesktop -Network Trash Folder -Temporary Items -.apdisk diff --git a/RiotTS.csproj b/RiotTS.csproj deleted file mode 100644 index 961a1ec..0000000 --- a/RiotTS.csproj +++ /dev/null @@ -1,97 +0,0 @@ - - - - - Debug - {C24611C6-0BE4-47B9-B298-13962D2CBF9F} - {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} - Library - bin - v4.5.2 - full - true - 1.8 - true - - - - - - - - - - - - - - - - - - - - - - - web.config - - - web.config - - - - 12.0 - - - RiotExample - - - - - - - - True - True - 4228 - / - http://localhost:4228/ - False - False - - - False - - - - - - false - true - ES5 - True - False - CommonJS - - - True - True - - - None - - - true - false - - - - - - - - - - - \ No newline at end of file diff --git a/RiotTS.csproj.user b/RiotTS.csproj.user deleted file mode 100644 index ba4ef37..0000000 --- a/RiotTS.csproj.user +++ /dev/null @@ -1,30 +0,0 @@ - - - - 1.8 - - - - - - index.html - CurrentPage - True - False - False - False - - - - - - - - - True - True - - - - - \ No newline at end of file diff --git a/RiotTS.d.ts b/RiotTS.d.ts deleted file mode 100644 index 02dbf31..0000000 --- a/RiotTS.d.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { CompilerResult } from "./types"; -export declare class Observable { - on(events: string, callback: Function): void; - one(events: string, callback: Function): void; - off(events: string): void; - trigger(eventName: string, ...args: any[]): void; - constructor(); -} -export interface LifeCycle { - mounted?(F: Function): any; - unmounted?(F: Function): any; - updating?(F: Function): any; - updated?(F: Function): any; -} -export interface HTMLRiotElement extends HTMLElement { - _tag: Element; -} -export declare class Element implements Observable, LifeCycle { - opts: any; - parent: Element; - root: HTMLElement; - tags: any; - tagName: string; - template: string; - isMounted: boolean; - update(data?: any): void; - unmount(keepTheParent?: boolean): void; - on(eventName: string, fun: Function): void; - one(eventName: string, fun: Function): void; - off(events: string): void; - trigger(eventName: string, ...args: any[]): void; - mixin(mixinObject: Object | Function | string, instance?: any): void; - static createElement(options?: any): HTMLRiotElement; -} -export declare var precompiledTags: { - [fileName: string]: CompilerResult; -}; -export declare function registerClass(element: Function): void; -export declare function template(template: string): (target: Function) => void; diff --git a/RiotTS.js b/RiotTS.js deleted file mode 100644 index 733e1c8..0000000 --- a/RiotTS.js +++ /dev/null @@ -1,120 +0,0 @@ -"use strict"; -var riot = require("riot"); -var compile = require("riot-compiler"); -var Observable = (function () { - function Observable() { - riot.observable(this); - } - Observable.prototype.on = function (events, callback) { }; - Observable.prototype.one = function (events, callback) { }; - Observable.prototype.off = function (events) { }; - Observable.prototype.trigger = function (eventName) { - var args = []; - for (var _i = 1; _i < arguments.length; _i++) { - args[_i - 1] = arguments[_i]; - } - }; - return Observable; -}()); -exports.Observable = Observable; -var Element = (function () { - function Element() { - } - Element.prototype.update = function (data) { }; - Element.prototype.unmount = function (keepTheParent) { }; - Element.prototype.on = function (eventName, fun) { }; - Element.prototype.one = function (eventName, fun) { }; - Element.prototype.off = function (events) { }; - Element.prototype.trigger = function (eventName) { - var args = []; - for (var _i = 1; _i < arguments.length; _i++) { - args[_i - 1] = arguments[_i]; - } - }; - Element.prototype.mixin = function (mixinObject, instance) { }; - Element.createElement = function (options) { - var tagName = this.prototype.tagName; - var el = document.createElement(tagName); - riot.mount(el, tagName, options); - return el; - }; - return Element; -}()); -exports.Element = Element; -// new extend, works with getters and setters -function extend(d, element) { - var map = Object.keys(element.prototype).reduce(function (descriptors, key) { - descriptors[key] = Object.getOwnPropertyDescriptor(element.prototype, key); - return descriptors; - }, {}); - Object.defineProperties(d, map); -} -/* old extend, without getters and setters -function extend(d, element) { - Object.keys(element.prototype).forEach((key) => d[key] = element.prototype[key]); -} -*/ -exports.precompiledTags = {}; -function registerClass(element) { - function registerTag(compiledTag) { - var transformFunction = function (opts) { - extend(this, element); // copies prototype into "this" - element.apply(this, [opts]); // calls class constructor applying it on "this" - if (element.prototype.mounted !== undefined) - this.on("mount", this.mounted); - if (element.prototype.unmounted !== undefined) - this.on("unmount", this.unmounted); - if (element.prototype.updating !== undefined) - this.on("update", this.updating); - if (element.prototype.updated !== undefined) - this.on("updated", this.updated); - // TODO support for init(opts) ? - }; - riot.tag2(compiledTag.tagName, compiledTag.html, compiledTag.css, compiledTag.attribs, transformFunction, riot.settings.brackets); - return compiledTag.tagName; - } - function loadTemplateFromHTTP(template) { - var req = new XMLHttpRequest(); - req.open("GET", template, false); - req.send(); - if (req.status == 200) - return req.responseText; - else - throw req.responseText; - } - ; - var compiled; - // gets string template: inlined, via http request or via precompiled cache - if (element.prototype.template !== undefined) { - var tagTemplate = element.prototype.template; - if (tagTemplate.indexOf("<") < 0) { - // tag is a file - if (exports.precompiledTags[tagTemplate] !== undefined) { - // loads it from precompiled cache - compiled = exports.precompiledTags[tagTemplate]; - } - else { - // loads from HTTP and compile on the fly - tagTemplate = loadTemplateFromHTTP(tagTemplate); - compiled = compile(tagTemplate, true, { entities: true })[0]; - } - } - else { - // tag is inlined, compile on the fly - compiled = compile(tagTemplate, true, { entities: true })[0]; - } - element.prototype.tagName = registerTag(compiled); - } - else - throw "template property not specified"; -} -exports.registerClass = registerClass; -// @template decorator -function template(template) { - return function (target) { - target.prototype["template"] = template; - registerClass(target); - }; -} -exports.template = template; -//# sourceMappingURL=RiotTS.js.map \ No newline at end of file diff --git a/RiotTS.js.map b/RiotTS.js.map deleted file mode 100644 index a199d69..0000000 --- a/RiotTS.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"RiotTS.js","sourceRoot":"","sources":["RiotTS.ts"],"names":[],"mappings":";AAAC,IAAY,IAAI,WAAM,MAAM,CAAC,CAAA;AAC9B,IAAY,OAAO,WAAM,eAAe,CAAC,CAAA;AAIzC;IAMG;QACG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAPD,uBAAE,GAAF,UAAG,MAAc,EAAE,QAAkB,IAAG,CAAC;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Q,GAAG,OAAO,CAAC,WAAW,EAAE,IAAI,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9D,CAAC;QAED,OAAO,CAAC,SAAS,CAAC,OAAO,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;IACrD,CAAC;IACD,IAAI;QAAC,MAAM,iCAAiC,CAAC;AAChD,CAAC;AAzDe,qBAAa,gBAyD5B,CAAA;AAED,sBAAsB;AACtB,kBAAyB,QAAgB;IACxC,MAAM,CAAC,UAAS,MAAgB;QAC3B,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,QAAQ,CAAC;QACxC,aAAa,CAAC,MAAM,CAAC,CAAC;IACzB,CAAC,CAAA;AACJ,CAAC;AALe,gBAAQ,WAKvB,CAAA"} \ No newline at end of file diff --git a/RiotTS.sln b/RiotTS.sln deleted file mode 100644 index 3d023f4..0000000 --- a/RiotTS.sln +++ /dev/null @@ -1,21 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25029.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RiotTS", "RiotTS.csproj", "{C24611C6-0BE4-47B9-B298-13962D2CBF9F}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {C24611C6-0BE4-47B9-B298-13962D2CBF9F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C24611C6-0BE4-47B9-B298-13962D2CBF9F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C24611C6-0BE4-47B9-B298-13962D2CBF9F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C24611C6-0BE4-47B9-B298-13962D2CBF9F}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/RiotTS.v12.suo b/RiotTS.v12.suo deleted file mode 100644 index 8425c7756ffab6af73c565aa82c0e80958edc13d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 28672 zcmeHQU2t1R6~0PHnkI!NO-X-%L`g%N{z#Q%MY0n5WBoa4?KVWtPm5@=W!X_IORgn5 zY3x90fq_DxlVQ?4z;vMHrBj$``597%q0K|5Pc%G~hd%IA7#{h3fMF&L-?w|$x{|J> zdu7?N!(GkM?%lh0&)IX&?w&p8$iDE-hCh7o)tmpQ)uem1mD&fFuGUr?>RpDiwq6tW zSoguDOP6?yWfYyXj5x4gE88M@$3cH z4Y>Kn7TIDSFc!6=+FoEEK`EgfH+!^U-6n0t9DcIBVMD`>&!Y_S6{$y?z$dTew2U^0 z@#jE8K~Pgdc~m=sx{}`3EZd>2aNUF(YXDa9Pw4I0-vF?dv@xv@*h;{40N+{gMAbLL z&F8lR|2E_+09NrA(U$ZwT?M$v2Wt}NG}~McAg`_gux_26tLAHQt;$!UywPxdBg*8> z&47;qJ`VT^r=gx= zr^d(uz9;S-D*+z@@O^S0=f0rcDc5+e``iP#u6_h?Er9#N1^{J;>po?Lvcvb!Jzl+k z;!vR0e{TP7z*YeFfLj3E13n2*ZJFPW>pK8<0`3BM0A2v^`Sd)1oco4x{pb7d21Ee6 z0Brv$6U?AJ7Ac0%CwTAOT1MdI5U?djSss9t89O`T-9C9tP|Kd>XJHkOB+< z4gd}U4gn4WjAKdb*N-889Pl~7AYcfP0Sp7OfDynb;0QoHKV~SaI+ai2UP-?{g?w5s zA4g7Y?u33li~OWs=Ce!>Yg5oVsQ(lMjAA5Zp$TQdj~q0S=85`;>`8t%Z!Paq4=AsY zJ;|%Kk6bo^zN0OrSz{9xLyP$WxNq`hJ0<7F#frO0Cj1;OD+W+)S<7^Zq!1vd%OBJQElxN6Zr+ z&tO@MnYiPCY0N>N*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Vz?t6|DV#-jJf0gYwVkJ{C~}Sk&gfGa(OH3 z>^)YUmdn&cek_;T@+6q{WKY8g8IYm- zwmWG{u4Z(zmq1TKjdQH_;SOI@tDbK%qj)}b?a;$G;->)iV%_T_*crRbUm;J4ICHm% zTAM-?7yssj8(wQh{`+9tI|xi^5&h1n_Y(Zo8RVLF`m)n74N8nL^rVV`n~TdC#=zxa zQ5g|@QT$QYONSy!CwcUZ%giGN>Sn+*N*jOEU@bNJHIKEYWdJQ>6s2@5WCXrBMV(lG z%zL(0JKy;4zsLBOPdb&H^}k(CI_tk$W1aQie6Kd&k(~8k{@(*<{cmsO>FoM%p9bge XKk+XE+WGsL&3%9B7j}#F_n-a;*$wcs diff --git a/riot-ts.d.ts b/dist/riot-ts.d.ts similarity index 69% rename from riot-ts.d.ts rename to dist/riot-ts.d.ts index 02dbf31..5baf69e 100644 --- a/riot-ts.d.ts +++ b/dist/riot-ts.d.ts @@ -1,4 +1,3 @@ -import { CompilerResult } from "./types"; export declare class Observable { on(events: string, callback: Function): void; one(events: string, callback: Function): void; @@ -37,3 +36,26 @@ export declare var precompiledTags: { }; export declare function registerClass(element: Function): void; export declare function template(template: string): (target: Function) => void; +export interface Router { + (callback: Function): void; + (filter: string, callback: Function): void; + (to: string, title?: string): any; + create(): Router; + start(autoExec?: boolean): any; + stop(): any; + exec(): any; + query(): any; + base(base: string): any; + parser(parser: (path: string) => string, secondParser?: Function): any; +} +export interface CompilerResult { + tagName: string; + html: string; + css: string; + attribs: string; + js: string; +} +export interface Settings { + brackets: string; +} +export as namespace Riot; \ No newline at end of file diff --git a/dist/riot-ts.js b/dist/riot-ts.js new file mode 100644 index 0000000..8bdf45c --- /dev/null +++ b/dist/riot-ts.js @@ -0,0 +1,152 @@ +/* +export as namespace Riot; + +else +{ + var require = function(module) { + return window["riot"]; + } + exports = {}; + var v = factory(require, exports); + window["Riot"] = exports; + window["template"] = Riot.template; +} +*/ +(function (dependencies, factory) { + if (typeof module === 'object' && typeof module.exports === 'object') { + var v = factory(require, exports); if (v !== undefined) module.exports = v; + } + else if (typeof define === 'function' && define.amd) { + define(dependencies, factory); + } + else + { + var require = function(module) { + return window["riot"]; + } + exports = {}; + var v = factory(require, exports); + window["Riot"] = exports; + window["template"] = Riot.template; + } +})(["require", "exports", "riot/riot+compiler"], function (require, exports) { + "use strict"; + var riot = require("riot/riot+compiler"); + var Observable = (function () { + function Observable() { + riot.observable(this); + } + Observable.prototype.on = function (events, callback) { }; + Observable.prototype.one = function (events, callback) { }; + Observable.prototype.off = function (events) { }; + Observable.prototype.trigger = function (eventName) { + var args = []; + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i]; + } + }; + return Observable; + }()); + exports.Observable = Observable; + var Element = (function () { + function Element() { + } + Element.prototype.update = function (data) { }; + Element.prototype.unmount = function (keepTheParent) { }; + Element.prototype.on = function (eventName, fun) { }; + Element.prototype.one = function (eventName, fun) { }; + Element.prototype.off = function (events) { }; + Element.prototype.trigger = function (eventName) { + var args = []; + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i]; + } + }; + Element.prototype.mixin = function (mixinObject, instance) { }; + Element.createElement = function (options) { + var tagName = this.prototype.tagName; + var el = document.createElement(tagName); + riot.mount(el, tagName, options); + return el; + }; + return Element; + }()); + exports.Element = Element; + // new extend, works with getters and setters + function extend(d, element) { + var map = Object.keys(element.prototype).reduce(function (descriptors, key) { + descriptors[key] = Object.getOwnPropertyDescriptor(element.prototype, key); + return descriptors; + }, {}); + Object.defineProperties(d, map); + } + /* old extend, without getters and setters + function extend(d, element) { + Object.keys(element.prototype).forEach((key) => d[key] = element.prototype[key]); + } + */ + exports.precompiledTags = {}; + function registerClass(element) { + function registerTag(compiledTag) { + var transformFunction = function (opts) { + extend(this, element); // copies prototype into "this" + element.apply(this, [opts]); // calls class constructor applying it on "this" + if (element.prototype.mounted !== undefined) + this.on("mount", this.mounted); + if (element.prototype.unmounted !== undefined) + this.on("unmount", this.unmounted); + if (element.prototype.updating !== undefined) + this.on("update", this.updating); + if (element.prototype.updated !== undefined) + this.on("updated", this.updated); + // TODO support for init(opts) ? + }; + riot.tag2(compiledTag.tagName, compiledTag.html, compiledTag.css, compiledTag.attribs, transformFunction, riot.settings.brackets); + return compiledTag.tagName; + } + function loadTemplateFromHTTP(template) { + var req = new XMLHttpRequest(); + req.open("GET", template, false); + req.send(); + if (req.status == 200) + return req.responseText; + else + throw req.responseText; + } + ; + var compiled; + // gets string template: inlined, via http request or via precompiled cache + if (element.prototype.template !== undefined) { + var tagTemplate = element.prototype.template; + if (tagTemplate.indexOf("<") < 0) { + // tag is a file + if (exports.precompiledTags[tagTemplate] !== undefined) { + // loads it from precompiled cache + compiled = exports.precompiledTags[tagTemplate]; + } + else { + // loads from HTTP and compile on the fly + tagTemplate = loadTemplateFromHTTP(tagTemplate); + compiled = riot.compile(tagTemplate, true, { entities: true })[0]; + } + } + else { + // tag is inlined, compile on the fly + compiled = riot.compile(tagTemplate, true, { entities: true })[0]; + } + element.prototype.tagName = registerTag(compiled); + } + else + throw "template property not specified"; + } + exports.registerClass = registerClass; + // @template decorator + function template(template) { + return function (target) { + target.prototype["template"] = template; + registerClass(target); + }; + } + exports.template = template; +}); +//# sourceMappingURL=riot-ts.js.map \ No newline at end of file diff --git a/dist/riot-ts.js.map b/dist/riot-ts.js.map new file mode 100644 index 0000000..600af00 --- /dev/null +++ b/dist/riot-ts.js.map @@ -0,0 +1 @@ +{"version":3,"file":"riot-ts.js","sourceRoot":"","sources":["../src/riot-ts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;EAaE;;;;;;;;;;IAEF,yCAA4C;IAE5C;QAMG;YACG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACzB,CAAC;QAPD,uBAAE,GAAF,UAAG,MAAc,EAAE,QAAkB,IAAG,CAAC;QACzC,wBAAG,GAAH,UAAI,MAAc,EAAE,QAAkB,IAAG,CAAC;QAC1C,wBAAG,GAAH,UAAI,MAAc,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AE,IAAI,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACnE,CAAC;YAED,OAAO,CAAC,SAAS,CAAC,OAAO,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;QACrD,CAAC;QACD,IAAI;YAAC,MAAM,iCAAiC,CAAC;IAChD,CAAC;IAzDD,sCAyDC;IAED,sBAAsB;IACtB,kBAAyB,QAAgB;QACxC,MAAM,CAAC,UAAS,MAAgB;YAC3B,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,QAAQ,CAAC;YACxC,aAAa,CAAC,MAAM,CAAC,CAAC;QACzB,CAAC,CAAA;IACJ,CAAC;IALD,4BAKC"} \ No newline at end of file diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 4bc6d52..0000000 --- a/index.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import * as Riot from "./riot-ts"; -export default Riot; diff --git a/index.js b/index.js deleted file mode 100644 index 80f9361..0000000 --- a/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict"; -var Riot = require("./riot-ts"); -Object.defineProperty(exports, "__esModule", { value: true }); -exports.default = Riot; -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/index.js.map b/index.js.map deleted file mode 100644 index cba4dcc..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAC,IAAY,IAAI,WAAM,WAAW,CAAC,CAAA;AACnC;kBAAe,IAAI,CAAC"} \ No newline at end of file diff --git a/index.ts b/index.ts deleted file mode 100644 index c417a3d..0000000 --- a/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -import * as Riot from "./riot-ts"; -export default Riot; \ No newline at end of file diff --git a/package.json b/package.json index 7d74b40..bc8eab8 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,9 @@ { - "name": "riot-ts", - "version": "1.0.0", + "name": "riot-typescript", + "version": "1.0.1", "description": "Riot for TypeScript", - "main": "index.js", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -17,10 +18,6 @@ }, "homepage": "https://github.com/nippur72/RiotTS#readme", "dependencies": { - "riot": "^2.4.1", - "riot-compiler": "^2.4.1" - }, - "typescript": { - "definition": "riot-ts.d.ts" + "riot": "^2.6.2" } } diff --git a/riot-compiler.d.ts b/riot-compiler.d.ts deleted file mode 100644 index eba3d9a..0000000 --- a/riot-compiler.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -declare module "riot-compiler" { - interface CompilerResult { - tagName: string; - html: string; - css: string; - attribs: string; - js: string; - } - interface Compile { - (callback: Function): void; - (url: string, callback: Function): void; - (tag: string): string; - (tag: string, dontExecute: boolean): string; - (tag: string, options: any): string; - (tag: string, dontExecute: boolean, options: any): CompilerResult[]; - } - var compile: Compile; - export = compile; -} diff --git a/riot-compiler.js b/riot-compiler.js deleted file mode 100644 index 6706a4b..0000000 --- a/riot-compiler.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=riot-compiler.js.map \ No newline at end of file diff --git a/riot-compiler.js.map b/riot-compiler.js.map deleted file mode 100644 index f281ae5..0000000 --- a/riot-compiler.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"riot-compiler.js","sourceRoot":"","sources":["riot-compiler.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/riot-compiler.ts b/riot-compiler.ts deleted file mode 100644 index 8e2110e..0000000 --- a/riot-compiler.ts +++ /dev/null @@ -1,25 +0,0 @@ -declare module "riot-compiler" -{ - interface CompilerResult - { - tagName: string; - html: string; - css: string; - attribs: string; - js: string; - } - - interface Compile - { - (callback: Function): void; - (url: string, callback: Function): void; - (tag: string): string; - (tag: string, dontExecute: boolean): string; - (tag: string, options: any): string; - (tag: string, dontExecute: boolean, options: any): CompilerResult[]; - } - - var compile: Compile; - - export = compile; -} diff --git a/riot-ts.js b/riot-ts.js deleted file mode 100644 index c550831..0000000 --- a/riot-ts.js +++ /dev/null @@ -1,120 +0,0 @@ -"use strict"; -var riot = require("riot"); -var compile = require("riot-compiler"); -var Observable = (function () { - function Observable() { - riot.observable(this); - } - Observable.prototype.on = function (events, callback) { }; - Observable.prototype.one = function (events, callback) { }; - Observable.prototype.off = function (events) { }; - Observable.prototype.trigger = function (eventName) { - var args = []; - for (var _i = 1; _i < arguments.length; _i++) { - args[_i - 1] = arguments[_i]; - } - }; - return Observable; -}()); -exports.Observable = Observable; -var Element = (function () { - function Element() { - } - Element.prototype.update = function (data) { }; - Element.prototype.unmount = function (keepTheParent) { }; - Element.prototype.on = function (eventName, fun) { }; - Element.prototype.one = function (eventName, fun) { }; - Element.prototype.off = function (events) { }; - Element.prototype.trigger = function (eventName) { - var args = []; - for (var _i = 1; _i < arguments.length; _i++) { - args[_i - 1] = arguments[_i]; - } - }; - Element.prototype.mixin = function (mixinObject, instance) { }; - Element.createElement = function (options) { - var tagName = this.prototype.tagName; - var el = document.createElement(tagName); - riot.mount(el, tagName, options); - return el; - }; - return Element; -}()); -exports.Element = Element; -// new extend, works with getters and setters -function extend(d, element) { - var map = Object.keys(element.prototype).reduce(function (descriptors, key) { - descriptors[key] = Object.getOwnPropertyDescriptor(element.prototype, key); - return descriptors; - }, {}); - Object.defineProperties(d, map); -} -/* old extend, without getters and setters -function extend(d, element) { - Object.keys(element.prototype).forEach((key) => d[key] = element.prototype[key]); -} -*/ -exports.precompiledTags = {}; -function registerClass(element) { - function registerTag(compiledTag) { - var transformFunction = function (opts) { - extend(this, element); // copies prototype into "this" - element.apply(this, [opts]); // calls class constructor applying it on "this" - if (element.prototype.mounted !== undefined) - this.on("mount", this.mounted); - if (element.prototype.unmounted !== undefined) - this.on("unmount", this.unmounted); - if (element.prototype.updating !== undefined) - this.on("update", this.updating); - if (element.prototype.updated !== undefined) - this.on("updated", this.updated); - // TODO support for init(opts) ? - }; - riot.tag2(compiledTag.tagName, compiledTag.html, compiledTag.css, compiledTag.attribs, transformFunction, riot.settings.brackets); - return compiledTag.tagName; - } - function loadTemplateFromHTTP(template) { - var req = new XMLHttpRequest(); - req.open("GET", template, false); - req.send(); - if (req.status == 200) - return req.responseText; - else - throw req.responseText; - } - ; - var compiled; - // gets string template: inlined, via http request or via precompiled cache - if (element.prototype.template !== undefined) { - var tagTemplate = element.prototype.template; - if (tagTemplate.indexOf("<") < 0) { - // tag is a file - if (exports.precompiledTags[tagTemplate] !== undefined) { - // loads it from precompiled cache - compiled = exports.precompiledTags[tagTemplate]; - } - else { - // loads from HTTP and compile on the fly - tagTemplate = loadTemplateFromHTTP(tagTemplate); - compiled = compile(tagTemplate, true, { entities: true })[0]; - } - } - else { - // tag is inlined, compile on the fly - compiled = compile(tagTemplate, true, { entities: true })[0]; - } - element.prototype.tagName = registerTag(compiled); - } - else - throw "template property not specified"; -} -exports.registerClass = registerClass; -// @template decorator -function template(template) { - return function (target) { - target.prototype["template"] = template; - registerClass(target); - }; -} -exports.template = template; -//# sourceMappingURL=riot-ts.js.map \ No newline at end of file diff --git a/riot-ts.js.map b/riot-ts.js.map deleted file mode 100644 index 9923b29..0000000 --- a/riot-ts.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"riot-ts.js","sourceRoot":"","sources":["riot-ts.ts"],"names":[],"mappings":";AAAC,IAAY,IAAI,WAAM,MAAM,CAAC,CAAA;AAC9B,IAAY,OAAO,WAAM,eAAe,CAAC,CAAA;AAIzC;IAMG;QACG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAPD,uBAAE,GAAF,UAAG,MAAc,EAAE,QAAkB,IAAG,CAAC;IACzC,wBAAG,GAAH,UAAI,MAAc,EAAE,QAAkB,IAAG,CAAC;IAC1C,wBAAG,GAAH,UAAI,MAAc,IAAG,CAAC;IACtB,4BAAO,GAAP,UAAQ,SAAiB;QAAE,cAAO;aAAP,WAAO,CAAP,sBAAO,CAAP,IAAO;YAAP,6BAAO;;IAAG,CAAC;IAKzC,iBAAC;AAAD,CAAC,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AAC;AAChD,CAAC;AAzDe,qBAAa,gBAyD5B,CAAA;AAED,sBAAsB;AACtB,kBAAyB,QAAgB;IACxC,MAAM,CAAC,UAAS,MAAgB;QAC3B,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,QAAQ,CAAC;QACxC,aAAa,CAAC,MAAM,CAAC,CAAC;IACzB,CAAC,CAAA;AACJ,CAAC;AALe,gBAAQ,WAKvB,CAAA"} \ No newline at end of file diff --git a/riot.d.ts b/riot.d.ts deleted file mode 100644 index 84d184d..0000000 --- a/riot.d.ts +++ /dev/null @@ -1,34 +0,0 @@ -declare module "riot" { - interface Router { - (callback: Function): void; - (filter: string, callback: Function): void; - (to: string, title?: string): any; - create(): Router; - start(autoExec?: boolean): any; - stop(): any; - exec(): any; - query(): any; - base(base: string): any; - parser(parser: (path: string) => string, secondParser?: Function): any; - } - interface Settings { - brackets: string; - } - type RiotElement = any; - interface Base { - version: string; - settings: Settings; - mount(customTagSelector: string, opts?: any): Array; - mount(selector: string, tagName: string, opts?: any): Array; - mount(domNode: Node, tagName: string, opts?: any): Array; - render(tagName: string, opts?: any): string; - tag(tagName: string, html: string, css: string, attrs: string, constructor: Function): any; - tag2(tagName: string, html: string, css: string, attrs: string, constructor: Function, bpair: string): any; - class(element: Function): void; - observable(object: any): void; - mixin(mixinName: string, mixinObject: any): void; - route: Router; - } - var riot: Base; - export = riot; -} diff --git a/riot.js b/riot.js deleted file mode 100644 index ea5c8f7..0000000 --- a/riot.js +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=riot.js.map \ No newline at end of file diff --git a/riot.js.map b/riot.js.map deleted file mode 100644 index 7d03cd0..0000000 --- a/riot.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"riot.js","sourceRoot":"","sources":["riot.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/riot.ts b/riot.ts deleted file mode 100644 index 862c59c..0000000 --- a/riot.ts +++ /dev/null @@ -1,47 +0,0 @@ -declare module "riot" -{ - interface Router { - (callback: Function): void; - (filter: string, callback: Function): void; - (to: string, title?: string); - - create(): Router; - start(autoExec?: boolean); - stop(); - exec(); - query(): any; - - base(base: string); - parser(parser: (path: string)=>string, secondParser?: Function ); - } - - interface Settings { - brackets: string; - } - - type RiotElement = any; - - interface Base - { - version: string; - settings: Settings; - mount(customTagSelector: string, opts?: any): Array; - mount(selector: string, tagName: string, opts?: any): Array; - mount(domNode: Node, tagName: string, opts?: any): Array; - render(tagName: string, opts?: any): string; - tag(tagName: string, html: string, css: string, attrs: string, constructor: Function); - tag2(tagName: string, html: string, css: string, attrs: string, constructor: Function, bpair: string); - class(element: Function): void; - observable(object: any): void; - - mixin(mixinName: string, mixinObject: any): void; - - // TODO server-only methods - - route: Router; - } - - var riot: Base; - - export = riot; -} diff --git a/riot-ts.ts b/src/riot-ts.ts similarity index 66% rename from riot-ts.ts rename to src/riot-ts.ts index d62584a..dd3864f 100644 --- a/riot-ts.ts +++ b/src/riot-ts.ts @@ -1,7 +1,19 @@ -import * as riot from "riot"; -import * as compile from "riot-compiler"; +/* +export as namespace Riot; -import { CompilerResult } from "./types"; + else + { + var require = function(module) { + return window["riot"]; + } + exports = {}; + var v = factory(require, exports); + window["Riot"] = exports; + window["template"] = Riot.template; + } +*/ + +import riot = require("riot/riot+compiler"); export class Observable { on(events: string, callback: Function) {} @@ -12,8 +24,8 @@ export class Observable { constructor() { riot.observable(this); } -} - +} + export interface LifeCycle { mounted?(F: Function); @@ -41,40 +53,40 @@ export class Element implements Observable, LifeCycle { on(eventName: string,fun: Function) { } one(eventName: string,fun: Function) { } off(events: string) {} - trigger(eventName: string,...args) {} - mixin(mixinObject: Object|Function|string, instance?: any) {} + trigger(eventName: string,...args) {} + mixin(mixinObject: Object|Function|string, instance?: any) {} static createElement(options?:any): HTMLRiotElement { var tagName = (this.prototype as any).tagName; - var el = document.createElement(tagName); - riot.mount(el, tagName, options); + var el = document.createElement(tagName); + riot.mount(el, tagName, options); return el as any as HTMLRiotElement; - } + } } - + // new extend, works with getters and setters -function extend(d, element) { +function extend(d, element) { var map = Object.keys(element.prototype).reduce((descriptors, key) => { descriptors[key] = Object.getOwnPropertyDescriptor(element.prototype, key); return descriptors; },{}) as PropertyDescriptorMap; Object.defineProperties(d, map); } - + /* old extend, without getters and setters -function extend(d, element) { +function extend(d, element) { Object.keys(element.prototype).forEach((key) => d[key] = element.prototype[key]); } */ export var precompiledTags: { [fileName: string]: CompilerResult } = {}; -export function registerClass(element: Function) { - +export function registerClass(element: Function) { + function registerTag(compiledTag: CompilerResult) { - var transformFunction = function (opts) { - extend(this,element); // copies prototype into "this" + var transformFunction = function (opts) { + extend(this,element); // copies prototype into "this" element.apply(this, [opts]); // calls class constructor applying it on "this" if(element.prototype.mounted !== undefined) this.on("mount" , this.mounted); @@ -84,18 +96,18 @@ export function registerClass(element: Function) { // TODO support for init(opts) ? }; - - riot.tag2(compiledTag.tagName, compiledTag.html, compiledTag.css, compiledTag.attribs, transformFunction, riot.settings.brackets); + + riot.tag2(compiledTag.tagName, compiledTag.html, compiledTag.css, compiledTag.attribs, transformFunction, riot.settings.brackets); return compiledTag.tagName; - } + } function loadTemplateFromHTTP(template) { - var req = new XMLHttpRequest(); + var req = new XMLHttpRequest(); req.open("GET", template, false); req.send(); if (req.status == 200) return req.responseText; - else throw req.responseText; + else throw req.responseText; }; let compiled: CompilerResult; @@ -105,35 +117,60 @@ export function registerClass(element: Function) { let tagTemplate = element.prototype.template; if(tagTemplate.indexOf("<")<0) { // tag is a file - if(precompiledTags[tagTemplate]!==undefined) + if(precompiledTags[tagTemplate]!==undefined) { - // loads it from precompiled cache + // loads it from precompiled cache compiled = precompiledTags[tagTemplate]; } - else + else { // loads from HTTP and compile on the fly - tagTemplate = loadTemplateFromHTTP(tagTemplate); - compiled = compile(tagTemplate, true, {entities: true})[0]; + tagTemplate = loadTemplateFromHTTP(tagTemplate); + compiled = riot.compile(tagTemplate, true, {entities: true})[0]; } } else { // tag is inlined, compile on the fly - compiled = compile(tagTemplate, true, {entities: true})[0]; + compiled = riot.compile(tagTemplate, true, {entities: true})[0]; } element.prototype.tagName = registerTag(compiled); } - else throw "template property not specified"; + else throw "template property not specified"; } // @template decorator export function template(template: string) { return function(target: Function) { - target.prototype["template"] = template; + target.prototype["template"] = template; registerClass(target); - } + } +} + +export interface Router { + (callback: Function): void; + (filter: string, callback: Function): void; + (to: string, title?: string); + + create(): Router; + start(autoExec?: boolean); + stop(); + exec(); + query(): any; + + base(base: string); + parser(parser: (path: string)=>string, secondParser?: Function ); } - \ No newline at end of file +export interface CompilerResult { + tagName: string; + html: string; + css: string; + attribs: string; + js: string; +} + +export interface Settings { + brackets: string; +} diff --git a/tsconfig.json b/tsconfig.json index ffcf908..8174833 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,16 +1,22 @@ { "compilerOptions": { - "module": "commonjs", + "module": "umd", "target": "es5", "noImplicitAny": false, "sourceMap": true, - "declaration": true + "declaration": true, + "lib": ["es5", "dom"], + "noImplicitReturns": true, + "noImplicitThis": false, + "outDir": "dist/", + "strictNullChecks": true, + "removeComments": false }, - "files": [ - "index.ts", - "riot-compiler.ts", - "riot-ts.ts", - "riot.ts", - "types.ts" + "include": [ + "src/**/*" + ], + "exclude": [ + "node_modules", + "**/*.spec.ts" ] } \ No newline at end of file diff --git a/types.d.ts b/types.d.ts deleted file mode 100644 index 1e1cad4..0000000 --- a/types.d.ts +++ /dev/null @@ -1,22 +0,0 @@ -export interface Router { - (callback: Function): void; - (filter: string, callback: Function): void; - (to: string, title?: string): any; - create(): Router; - start(autoExec?: boolean): any; - stop(): any; - exec(): any; - query(): any; - base(base: string): any; - parser(parser: (path: string) => string, secondParser?: Function): any; -} -export interface CompilerResult { - tagName: string; - html: string; - css: string; - attribs: string; - js: string; -} -export interface Settings { - brackets: string; -} diff --git a/types.js b/types.js deleted file mode 100644 index 2f0e414..0000000 --- a/types.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/types.js.map b/types.js.map deleted file mode 100644 index 8da0887..0000000 --- a/types.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"types.js","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/types.ts b/types.ts deleted file mode 100644 index 24201dd..0000000 --- a/types.ts +++ /dev/null @@ -1,27 +0,0 @@ -export interface Router { - (callback: Function): void; - (filter: string, callback: Function): void; - (to: string, title?: string); - - create(): Router; - start(autoExec?: boolean); - stop(); - exec(); - query(): any; - - base(base: string); - parser(parser: (path: string)=>string, secondParser?: Function ); -} - -export interface CompilerResult { - tagName: string; - html: string; - css: string; - attribs: string; - js: string; -} - -export interface Settings { - brackets: string; -} - diff --git a/web.Debug.config b/web.Debug.config deleted file mode 100644 index 9fdb00f..0000000 --- a/web.Debug.config +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/web.Release.config b/web.Release.config deleted file mode 100644 index d71b662..0000000 --- a/web.Release.config +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/web.config b/web.config deleted file mode 100644 index 9c14277..0000000 --- a/web.config +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - From 9250f2ef27b5ada29452c9aec4b5a9d863b1ab25 Mon Sep 17 00:00:00 2001 From: Antonino Porcino Date: Mon, 3 Oct 2016 20:28:32 +0200 Subject: [PATCH 12/14] restore riot.d.ts --- dist/riot-ts.d.ts | 2 +- dist/riot-ts.js | 20 +++++++------- dist/riot.d.ts | 67 ++++++++++++++++++++++++++++++++++++++++++++++ package.json | 6 ++--- src/riot.d.ts | 68 +++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 149 insertions(+), 14 deletions(-) create mode 100644 dist/riot.d.ts create mode 100644 src/riot.d.ts diff --git a/dist/riot-ts.d.ts b/dist/riot-ts.d.ts index 5baf69e..66691ca 100644 --- a/dist/riot-ts.d.ts +++ b/dist/riot-ts.d.ts @@ -58,4 +58,4 @@ export interface CompilerResult { export interface Settings { brackets: string; } -export as namespace Riot; \ No newline at end of file +export as namespace Riot; diff --git a/dist/riot-ts.js b/dist/riot-ts.js index 8bdf45c..1c7b00d 100644 --- a/dist/riot-ts.js +++ b/dist/riot-ts.js @@ -1,16 +1,16 @@ /* export as namespace Riot; -else -{ - var require = function(module) { - return window["riot"]; - } - exports = {}; - var v = factory(require, exports); - window["Riot"] = exports; - window["template"] = Riot.template; -} + else + { + var require = function(module) { + return window["riot"]; + } + exports = {}; + var v = factory(require, exports); + window["Riot"] = exports; + window["template"] = Riot.template; + } */ (function (dependencies, factory) { if (typeof module === 'object' && typeof module.exports === 'object') { diff --git a/dist/riot.d.ts b/dist/riot.d.ts new file mode 100644 index 0000000..6cb4cf0 --- /dev/null +++ b/dist/riot.d.ts @@ -0,0 +1,67 @@ +declare module "riot/riot+compiler" +{ + interface CompilerResult + { + tagName: string; + html: string; + css: string; + attribs: string; + js: string; + } + + interface Compile + { + (callback: Function): void; + (url: string, callback: Function): void; + (tag: string): string; + (tag: string, dontExecute: boolean): string; + (tag: string, options: any): string; + (tag: string, dontExecute: boolean, options: any): CompilerResult[]; + } + + interface Router { + (callback: Function): void; + (filter: string, callback: Function): void; + (to: string, title?: string); + + create(): Router; + start(autoExec?: boolean); + stop(); + exec(); + query(): any; + + base(base: string); + parser(parser: (path: string)=>string, secondParser?: Function ); + } + + interface Settings { + brackets: string; + } + + type RiotElement = any; + + interface Base + { + version: string; + settings: Settings; + mount(customTagSelector: string, opts?: any): Array; + mount(selector: string, tagName: string, opts?: any): Array; + mount(domNode: Node, tagName: string, opts?: any): Array; + render(tagName: string, opts?: any): string; + tag(tagName: string, html: string, css: string, attrs: string, constructor: Function); + tag2(tagName: string, html: string, css: string, attrs: string, constructor: Function, bpair: string); + class(element: Function): void; + observable(object: any): void; + compile: Compile; + + mixin(mixinName: string, mixinObject: any): void; + + // TODO server-only methods + + route: Router; + } + + var riot: Base; + + export = riot; +} diff --git a/package.json b/package.json index bc8eab8..3df5088 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,9 @@ { "name": "riot-typescript", - "version": "1.0.1", + "version": "1.0.4", "description": "Riot for TypeScript", - "main": "./dist/index.js", - "types": "./dist/index.d.ts", + "main": "./dist/riot-ts.js", + "typings": "./dist/riot-ts.d.ts", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, diff --git a/src/riot.d.ts b/src/riot.d.ts new file mode 100644 index 0000000..cdb8034 --- /dev/null +++ b/src/riot.d.ts @@ -0,0 +1,68 @@ +declare module "riot/riot+compiler" +{ + interface CompilerResult + { + tagName: string; + html: string; + css: string; + attribs: string; + js: string; + } + + interface Compile + { + (callback: Function): void; + (url: string, callback: Function): void; + (tag: string): string; + (tag: string, dontExecute: boolean): string; + (tag: string, options: any): string; + (tag: string, dontExecute: boolean, options: any): CompilerResult[]; + } + + interface Router { + (callback: Function): void; + (filter: string, callback: Function): void; + (to: string, title?: string); + + create(): Router; + start(autoExec?: boolean); + stop(); + exec(); + query(): any; + + base(base: string); + parser(parser: (path: string)=>string, secondParser?: Function ); + } + + interface Settings { + brackets: string; + } + + type RiotElement = any; + + interface Base + { + version: string; + settings: Settings; + mount(customTagSelector: string, opts?: any): Array; + mount(selector: string, tagName: string, opts?: any): Array; + mount(domNode: Node, tagName: string, opts?: any): Array; + render(tagName: string, opts?: any): string; + tag(tagName: string, html: string, css: string, attrs: string, constructor: Function); + tag2(tagName: string, html: string, css: string, attrs: string, constructor: Function, bpair: string); + class(element: Function): void; + observable(object: any): void; + compile: Compile; + + mixin(mixinName: string, mixinObject: any): void; + + // TODO server-only methods + + route: Router; + } + + var riot: Base; + + export = riot; +} + From 2af75a6933571ef8e441226e2b6fb8a998ddca43 Mon Sep 17 00:00:00 2001 From: Antonino Porcino Date: Tue, 4 Oct 2016 14:48:45 +0200 Subject: [PATCH 13/14] ship as npm package (final version) --- dist/riot-ts.js | 152 ------------------------------ dist/riot-ts.js.map | 1 - dist/riot.d.ts | 67 ------------- package.json | 8 +- dist/riot-ts.d.ts => riot-ts.d.ts | 2 +- riot-ts.globals.js | 123 ++++++++++++++++++++++++ riot-ts.js | 119 +++++++++++++++++++++++ riot-ts.js.map | 1 + src/riot-ts.ts => riot-ts.ts | 17 +--- src/riot.d.ts => riot.d.ts | 0 riot.global.d.ts | 63 +++++++++++++ tsconfig.json | 7 +- 12 files changed, 314 insertions(+), 246 deletions(-) delete mode 100644 dist/riot-ts.js delete mode 100644 dist/riot-ts.js.map delete mode 100644 dist/riot.d.ts rename dist/riot-ts.d.ts => riot-ts.d.ts (98%) create mode 100644 riot-ts.globals.js create mode 100644 riot-ts.js create mode 100644 riot-ts.js.map rename src/riot-ts.ts => riot-ts.ts (93%) rename src/riot.d.ts => riot.d.ts (100%) create mode 100644 riot.global.d.ts diff --git a/dist/riot-ts.js b/dist/riot-ts.js deleted file mode 100644 index 1c7b00d..0000000 --- a/dist/riot-ts.js +++ /dev/null @@ -1,152 +0,0 @@ -/* -export as namespace Riot; - - else - { - var require = function(module) { - return window["riot"]; - } - exports = {}; - var v = factory(require, exports); - window["Riot"] = exports; - window["template"] = Riot.template; - } -*/ -(function (dependencies, factory) { - if (typeof module === 'object' && typeof module.exports === 'object') { - var v = factory(require, exports); if (v !== undefined) module.exports = v; - } - else if (typeof define === 'function' && define.amd) { - define(dependencies, factory); - } - else - { - var require = function(module) { - return window["riot"]; - } - exports = {}; - var v = factory(require, exports); - window["Riot"] = exports; - window["template"] = Riot.template; - } -})(["require", "exports", "riot/riot+compiler"], function (require, exports) { - "use strict"; - var riot = require("riot/riot+compiler"); - var Observable = (function () { - function Observable() { - riot.observable(this); - } - Observable.prototype.on = function (events, callback) { }; - Observable.prototype.one = function (events, callback) { }; - Observable.prototype.off = function (events) { }; - Observable.prototype.trigger = function (eventName) { - var args = []; - for (var _i = 1; _i < arguments.length; _i++) { - args[_i - 1] = arguments[_i]; - } - }; - return Observable; - }()); - exports.Observable = Observable; - var Element = (function () { - function Element() { - } - Element.prototype.update = function (data) { }; - Element.prototype.unmount = function (keepTheParent) { }; - Element.prototype.on = function (eventName, fun) { }; - Element.prototype.one = function (eventName, fun) { }; - Element.prototype.off = function (events) { }; - Element.prototype.trigger = function (eventName) { - var args = []; - for (var _i = 1; _i < arguments.length; _i++) { - args[_i - 1] = arguments[_i]; - } - }; - Element.prototype.mixin = function (mixinObject, instance) { }; - Element.createElement = function (options) { - var tagName = this.prototype.tagName; - var el = document.createElement(tagName); - riot.mount(el, tagName, options); - return el; - }; - return Element; - }()); - exports.Element = Element; - // new extend, works with getters and setters - function extend(d, element) { - var map = Object.keys(element.prototype).reduce(function (descriptors, key) { - descriptors[key] = Object.getOwnPropertyDescriptor(element.prototype, key); - return descriptors; - }, {}); - Object.defineProperties(d, map); - } - /* old extend, without getters and setters - function extend(d, element) { - Object.keys(element.prototype).forEach((key) => d[key] = element.prototype[key]); - } - */ - exports.precompiledTags = {}; - function registerClass(element) { - function registerTag(compiledTag) { - var transformFunction = function (opts) { - extend(this, element); // copies prototype into "this" - element.apply(this, [opts]); // calls class constructor applying it on "this" - if (element.prototype.mounted !== undefined) - this.on("mount", this.mounted); - if (element.prototype.unmounted !== undefined) - this.on("unmount", this.unmounted); - if (element.prototype.updating !== undefined) - this.on("update", this.updating); - if (element.prototype.updated !== undefined) - this.on("updated", this.updated); - // TODO support for init(opts) ? - }; - riot.tag2(compiledTag.tagName, compiledTag.html, compiledTag.css, compiledTag.attribs, transformFunction, riot.settings.brackets); - return compiledTag.tagName; - } - function loadTemplateFromHTTP(template) { - var req = new XMLHttpRequest(); - req.open("GET", template, false); - req.send(); - if (req.status == 200) - return req.responseText; - else - throw req.responseText; - } - ; - var compiled; - // gets string template: inlined, via http request or via precompiled cache - if (element.prototype.template !== undefined) { - var tagTemplate = element.prototype.template; - if (tagTemplate.indexOf("<") < 0) { - // tag is a file - if (exports.precompiledTags[tagTemplate] !== undefined) { - // loads it from precompiled cache - compiled = exports.precompiledTags[tagTemplate]; - } - else { - // loads from HTTP and compile on the fly - tagTemplate = loadTemplateFromHTTP(tagTemplate); - compiled = riot.compile(tagTemplate, true, { entities: true })[0]; - } - } - else { - // tag is inlined, compile on the fly - compiled = riot.compile(tagTemplate, true, { entities: true })[0]; - } - element.prototype.tagName = registerTag(compiled); - } - else - throw "template property not specified"; - } - exports.registerClass = registerClass; - // @template decorator - function template(template) { - return function (target) { - target.prototype["template"] = template; - registerClass(target); - }; - } - exports.template = template; -}); -//# sourceMappingURL=riot-ts.js.map \ No newline at end of file diff --git a/dist/riot-ts.js.map b/dist/riot-ts.js.map deleted file mode 100644 index 600af00..0000000 --- a/dist/riot-ts.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"riot-ts.js","sourceRoot":"","sources":["../src/riot-ts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;EAaE;;;;;;;;;;IAEF,yCAA4C;IAE5C;QAMG;YACG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACzB,CAAC;QAPD,uBAAE,GAAF,UAAG,MAAc,EAAE,QAAkB,IAAG,CAAC;QACzC,wBAAG,GAAH,UAAI,MAAc,EAAE,QAAkB,IAAG,CAAC;QAC1C,wBAAG,GAAH,UAAI,MAAc,IAAG,CAAC;QACtB,4BAAO,GAAP,UAAQ,SAAiB;YAAE,cAAO;iBAAP,UAAO,EAAP,qBAAO,EAAP,IAAO;gBAAP,6BAAO;;QAAG,CAAC;QAKzC,iBAAC;IAAD,CAAC,AATD,IASC;IATD,gCASC;IAeD;QAAA;QAuBA,CAAC;QAdE,wBAAM,GAAN,UAAO,IAAU,IAAI,CAAC;QACtB,yBAAO,GAAP,UAAQ,aAAuB,IAAI,CAAC;QACpC,oBAAE,GAAF,UAAG,SAAiB,EAAC,GAAa,IAAI,CAAC;QACvC,qBAAG,GAAH,UAAI,SAAiB,EAAC,GAAa,IAAI,CAAC;QACxC,qBAAG,GAAH,UAAI,MAAc,IAAG,CAAC;QACtB,yBAAO,GAAP,UAAQ,SA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 index 6cb4cf0..0000000 --- a/dist/riot.d.ts +++ /dev/null @@ -1,67 +0,0 @@ -declare module "riot/riot+compiler" -{ - interface CompilerResult - { - tagName: string; - html: string; - css: string; - attribs: string; - js: string; - } - - interface Compile - { - (callback: Function): void; - (url: string, callback: Function): void; - (tag: string): string; - (tag: string, dontExecute: boolean): string; - (tag: string, options: any): string; - (tag: string, dontExecute: boolean, options: any): CompilerResult[]; - } - - interface Router { - (callback: Function): void; - (filter: string, callback: Function): void; - (to: string, title?: string); - - create(): Router; - start(autoExec?: boolean); - stop(); - exec(); - query(): any; - - base(base: string); - parser(parser: (path: string)=>string, secondParser?: Function ); - } - - interface Settings { - brackets: string; - } - - type RiotElement = any; - - interface Base - { - version: string; - settings: Settings; - mount(customTagSelector: string, opts?: any): Array; - mount(selector: string, tagName: string, opts?: any): Array; - mount(domNode: Node, tagName: string, opts?: any): Array; - render(tagName: string, opts?: any): string; - tag(tagName: string, html: string, css: string, attrs: string, constructor: Function); - tag2(tagName: string, html: string, css: string, attrs: string, constructor: Function, bpair: string); - class(element: Function): void; - observable(object: any): void; - compile: Compile; - - mixin(mixinName: string, mixinObject: any): void; - - // TODO server-only methods - - route: Router; - } - - var riot: Base; - - export = riot; -} diff --git a/package.json b/package.json index 3df5088..2d9d460 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,11 @@ { "name": "riot-typescript", - "version": "1.0.4", + "version": "1.0.7", "description": "Riot for TypeScript", - "main": "./dist/riot-ts.js", - "typings": "./dist/riot-ts.d.ts", + "main": "./riot-ts.js", + "typings": "./riot-ts.d.ts", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "build": "tsc --module es6 && rollup riot-ts.js --format iife --name Riot -o riot-ts.globals.js && tsc && echo export as namespace Riot; >> riot-ts.d.ts" }, "repository": { "type": "git", diff --git a/dist/riot-ts.d.ts b/riot-ts.d.ts similarity index 98% rename from dist/riot-ts.d.ts rename to riot-ts.d.ts index 66691ca..383235c 100644 --- a/dist/riot-ts.d.ts +++ b/riot-ts.d.ts @@ -58,4 +58,4 @@ export interface CompilerResult { export interface Settings { brackets: string; } -export as namespace Riot; +export as namespace Riot; diff --git a/riot-ts.globals.js b/riot-ts.globals.js new file mode 100644 index 0000000..9732d04 --- /dev/null +++ b/riot-ts.globals.js @@ -0,0 +1,123 @@ +(function (exports,riot) { + 'use strict'; + + var Observable = (function () { + function Observable() { + riot.observable(this); + } + Observable.prototype.on = function (events, callback) { }; + Observable.prototype.one = function (events, callback) { }; + Observable.prototype.off = function (events) { }; + Observable.prototype.trigger = function (eventName) { + var args = []; + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i]; + } + }; + return Observable; + }()); + var Element = (function () { + function Element() { + } + Element.prototype.update = function (data) { }; + Element.prototype.unmount = function (keepTheParent) { }; + Element.prototype.on = function (eventName, fun) { }; + Element.prototype.one = function (eventName, fun) { }; + Element.prototype.off = function (events) { }; + Element.prototype.trigger = function (eventName) { + var args = []; + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i]; + } + }; + Element.prototype.mixin = function (mixinObject, instance) { }; + Element.createElement = function (options) { + var tagName = this.prototype.tagName; + var el = document.createElement(tagName); + riot.mount(el, tagName, options); + return el; + }; + return Element; + }()); + // new extend, works with getters and setters + function extend(d, element) { + var map = Object.keys(element.prototype).reduce(function (descriptors, key) { + descriptors[key] = Object.getOwnPropertyDescriptor(element.prototype, key); + return descriptors; + }, {}); + Object.defineProperties(d, map); + } + /* old extend, without getters and setters + function extend(d, element) { + Object.keys(element.prototype).forEach((key) => d[key] = element.prototype[key]); + } + */ + var precompiledTags = {}; + function registerClass(element) { + function registerTag(compiledTag) { + var transformFunction = function (opts) { + extend(this, element); // copies prototype into "this" + element.apply(this, [opts]); // calls class constructor applying it on "this" + if (element.prototype.mounted !== undefined) + this.on("mount", this.mounted); + if (element.prototype.unmounted !== undefined) + this.on("unmount", this.unmounted); + if (element.prototype.updating !== undefined) + this.on("update", this.updating); + if (element.prototype.updated !== undefined) + this.on("updated", this.updated); + // TODO support for init(opts) ? + }; + riot.tag2(compiledTag.tagName, compiledTag.html, compiledTag.css, compiledTag.attribs, transformFunction, riot.settings.brackets); + return compiledTag.tagName; + } + function loadTemplateFromHTTP(template) { + var req = new XMLHttpRequest(); + req.open("GET", template, false); + req.send(); + if (req.status == 200) + return req.responseText; + else + throw req.responseText; + } + ; + var compiled; + // gets string template: inlined, via http request or via precompiled cache + if (element.prototype.template !== undefined) { + var tagTemplate = element.prototype.template; + if (tagTemplate.indexOf("<") < 0) { + // tag is a file + if (precompiledTags[tagTemplate] !== undefined) { + // loads it from precompiled cache + compiled = precompiledTags[tagTemplate]; + } + else { + // loads from HTTP and compile on the fly + tagTemplate = loadTemplateFromHTTP(tagTemplate); + compiled = riot.compile(tagTemplate, true, { entities: true })[0]; + } + } + else { + // tag is inlined, compile on the fly + compiled = riot.compile(tagTemplate, true, { entities: true })[0]; + } + element.prototype.tagName = registerTag(compiled); + } + else + throw "template property not specified"; + } + // @template decorator + function template(template) { + return function (target) { + target.prototype["template"] = template; + registerClass(target); + }; + } + + exports.Observable = Observable; + exports.Element = Element; + exports.precompiledTags = precompiledTags; + exports.registerClass = registerClass; + exports.template = template; + +}((this.Riot = this.Riot || {}),riot)); \ No newline at end of file diff --git a/riot-ts.js b/riot-ts.js new file mode 100644 index 0000000..7b772fb --- /dev/null +++ b/riot-ts.js @@ -0,0 +1,119 @@ +"use strict"; +var riot = require("riot/riot+compiler"); +var Observable = (function () { + function Observable() { + riot.observable(this); + } + Observable.prototype.on = function (events, callback) { }; + Observable.prototype.one = function (events, callback) { }; + Observable.prototype.off = function (events) { }; + Observable.prototype.trigger = function (eventName) { + var args = []; + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i]; + } + }; + return Observable; +}()); +exports.Observable = Observable; +var Element = (function () { + function Element() { + } + Element.prototype.update = function (data) { }; + Element.prototype.unmount = function (keepTheParent) { }; + Element.prototype.on = function (eventName, fun) { }; + Element.prototype.one = function (eventName, fun) { }; + Element.prototype.off = function (events) { }; + Element.prototype.trigger = function (eventName) { + var args = []; + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i]; + } + }; + Element.prototype.mixin = function (mixinObject, instance) { }; + Element.createElement = function (options) { + var tagName = this.prototype.tagName; + var el = document.createElement(tagName); + riot.mount(el, tagName, options); + return el; + }; + return Element; +}()); +exports.Element = Element; +// new extend, works with getters and setters +function extend(d, element) { + var map = Object.keys(element.prototype).reduce(function (descriptors, key) { + descriptors[key] = Object.getOwnPropertyDescriptor(element.prototype, key); + return descriptors; + }, {}); + Object.defineProperties(d, map); +} +/* old extend, without getters and setters +function extend(d, element) { + Object.keys(element.prototype).forEach((key) => d[key] = element.prototype[key]); +} +*/ +exports.precompiledTags = {}; +function registerClass(element) { + function registerTag(compiledTag) { + var transformFunction = function (opts) { + extend(this, element); // copies prototype into "this" + element.apply(this, [opts]); // calls class constructor applying it on "this" + if (element.prototype.mounted !== undefined) + this.on("mount", this.mounted); + if (element.prototype.unmounted !== undefined) + this.on("unmount", this.unmounted); + if (element.prototype.updating !== undefined) + this.on("update", this.updating); + if (element.prototype.updated !== undefined) + this.on("updated", this.updated); + // TODO support for init(opts) ? + }; + riot.tag2(compiledTag.tagName, compiledTag.html, compiledTag.css, compiledTag.attribs, transformFunction, riot.settings.brackets); + return compiledTag.tagName; + } + function loadTemplateFromHTTP(template) { + var req = new XMLHttpRequest(); + req.open("GET", template, false); + req.send(); + if (req.status == 200) + return req.responseText; + else + throw req.responseText; + } + ; + var compiled; + // gets string template: inlined, via http request or via precompiled cache + if (element.prototype.template !== undefined) { + var tagTemplate = element.prototype.template; + if (tagTemplate.indexOf("<") < 0) { + // tag is a file + if (exports.precompiledTags[tagTemplate] !== undefined) { + // loads it from precompiled cache + compiled = exports.precompiledTags[tagTemplate]; + } + else { + // loads from HTTP and compile on the fly + tagTemplate = loadTemplateFromHTTP(tagTemplate); + compiled = riot.compile(tagTemplate, true, { entities: true })[0]; + } + } + else { + // tag is inlined, compile on the fly + compiled = riot.compile(tagTemplate, true, { entities: true })[0]; + } + element.prototype.tagName = registerTag(compiled); + } + else + throw "template property not specified"; +} +exports.registerClass = registerClass; +// @template decorator +function template(template) { + return function (target) { + target.prototype["template"] = template; + registerClass(target); + }; +} +exports.template = template; +//# sourceMappingURL=riot-ts.js.map \ No newline at end of file diff --git a/riot-ts.js.map b/riot-ts.js.map new file mode 100644 index 0000000..a74d031 --- /dev/null +++ b/riot-ts.js.map @@ -0,0 +1 @@ +{"version":3,"file":"riot-ts.js","sourceRoot":"","sources":["riot-ts.ts"],"names":[],"mappings":";AAAA,yCAA2C;AAE3C;IAMG;QACG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAPD,uBAAE,GAAF,UAAG,MAAc,EAAE,QAAkB,IAAG,CAAC;IACzC,wBAAG,GAAH,UAAI,MAAc,EAAE,QAAkB,IAAG,CAAC;IAC1C,wBAAG,GAAH,UAAI,MAAc,IAAG,CAAC;IACtB,4BAAO,GAAP,UAAQ,SAAiB;QAAE,cAAO;aAAP,UAAO,EAAP,qBAAO,EAAP,IAAO;YAAP,6BAAO;;IAAG,CAAC;IAKzC,iBAAC;AAAD,CAAC,AATD,IASC;AATD,gCASC;AAeD;IAAA;IAuBA,CAAC;IAdE,wBAAM,GAAN,UAAO,IAAU,IAAI,CAAC;IACtB,yBAAO,GAAP,UAAQ,aAAuB,IAAI,CAAC;IACpC,oBAAE,GAAF,UAAG,SAAiB,EAAC,GAAa,IAAI,CAAC;IACvC,qBAAG,GAAH,UAAI,SAAiB,EAAC,GAAa,IAAI,CAAC;IACxC,qBAAG,GAAH,UAAI,MAAc,IAAG,CAAC;IACtB,yBAAO,GAAP,UAAQ,SAAiB;QAAC,cAAO;aAAP,UAAO,EAAP,qBAAO,EAAP,IAAO;YAAP,6BAAO;;IAAG,CAAC;IACrC,uBAAK,GAAL,UAAM,WAAmC,EAAE,QAAc,IAAG,CAAC;IAE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,CAAC,OAAO,CAAC,GAAG,CAAC,GAAC,CAAC,CAAC,CAAC,CAAC;YAC7B,gBAAgB;YAChB,EAAE,CAAA,CAAC,uBAAe,CAAC,WAAW,CAAC,KAAG,SAAS,CAAC,CAC5C,CAAC;gBACE,kCAAkC;gBAClC,QAAQ,GAAG,uBAAe,CAAC,WAAW,CAAC,CAAC;YAC3C,CAAC;YACD,IAAI,CACJ,CAAC;gBACE,yCAAyC;gBACzC,WAAW,GAAG,oBAAoB,CAAC,WAAW,CAAC,CAAC;gBAChD,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACnE,CAAC;QACJ,CAAC;QACD,IAAI,CACJ,CAAC;YACE,qCAAqC;YACrC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACnE,CAAC;QAED,OAAO,CAAC,SAAS,CAAC,OAAO,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;IACrD,CAAC;IACD,IAAI;QAAC,MAAM,iCAAiC,CAAC;AAChD,CAAC;AAzDD,sCAyDC;AAED,sBAAsB;AACtB,kBAAyB,QAAgB;IACxC,MAAM,CAAC,UAAS,MAAgB;QAC3B,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,QAAQ,CAAC;QACxC,aAAa,CAAC,MAAM,CAAC,CAAC;IACzB,CAAC,CAAA;AACJ,CAAC;AALD,4BAKC"} \ No newline at end of file diff --git a/src/riot-ts.ts b/riot-ts.ts similarity index 93% rename from src/riot-ts.ts rename to riot-ts.ts index dd3864f..bb8066b 100644 --- a/src/riot-ts.ts +++ b/riot-ts.ts @@ -1,19 +1,4 @@ -/* -export as namespace Riot; - - else - { - var require = function(module) { - return window["riot"]; - } - exports = {}; - var v = factory(require, exports); - window["Riot"] = exports; - window["template"] = Riot.template; - } -*/ - -import riot = require("riot/riot+compiler"); +import * as riot from "riot/riot+compiler"; export class Observable { on(events: string, callback: Function) {} diff --git a/src/riot.d.ts b/riot.d.ts similarity index 100% rename from src/riot.d.ts rename to riot.d.ts diff --git a/riot.global.d.ts b/riot.global.d.ts new file mode 100644 index 0000000..4038b98 --- /dev/null +++ b/riot.global.d.ts @@ -0,0 +1,63 @@ +declare module riot +{ + interface CompilerResult + { + tagName: string; + html: string; + css: string; + attribs: string; + js: string; + } + + interface Compile + { + (callback: Function): void; + (url: string, callback: Function): void; + (tag: string): string; + (tag: string, dontExecute: boolean): string; + (tag: string, options: any): string; + (tag: string, dontExecute: boolean, options: any): CompilerResult[]; + } + + interface Router { + (callback: Function): void; + (filter: string, callback: Function): void; + (to: string, title?: string); + + create(): Router; + start(autoExec?: boolean); + stop(); + exec(); + query(): any; + + base(base: string); + parser(parser: (path: string)=>string, secondParser?: Function ); + } + + interface Settings { + brackets: string; + } + + type RiotElement = any; + + var version: string; + var settings: Settings; + function mount(customTagSelector: string, opts?: any): Array; + function mount(selector: string, tagName: string, opts?: any): Array; + function mount(domNode: Node, tagName: string, opts?: any): Array; + function render(tagName: string, opts?: any): string; + function tag(tagName: string, html: string, css: string, attrs: string, constructor: Function); + function tag2(tagName: string, html: string, css: string, attrs: string, constructor: Function, bpair: string); + function _class(element: Function): void; + function observable(object: any): void; + function compile(callback: Function): void; + function compile(url: string, callback: Function): void; + function compile(tag: string): string; + function compile(tag: string, dontExecute: boolean): string; + function compile(tag: string, options: any): string; + function compile(tag: string, dontExecute: boolean, options: any): CompilerResult[]; + function mixin(mixinName: string, mixinObject: any): void; + + var route: Router; +} + diff --git a/tsconfig.json b/tsconfig.json index 8174833..32eaf3a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "module": "umd", + "module": "commonjs", "target": "es5", "noImplicitAny": false, "sourceMap": true, @@ -8,13 +8,10 @@ "lib": ["es5", "dom"], "noImplicitReturns": true, "noImplicitThis": false, - "outDir": "dist/", + "outDir": "./", "strictNullChecks": true, "removeComments": false }, - "include": [ - "src/**/*" - ], "exclude": [ "node_modules", "**/*.spec.ts" From 471d0889c937176943f92d14644af57e3328cdc7 Mon Sep 17 00:00:00 2001 From: Antonino Porcino Date: Tue, 4 Oct 2016 15:08:57 +0200 Subject: [PATCH 14/14] update documentation --- README.md | 104 ++++++++++++++++++++++++++---------------------------- 1 file changed, 50 insertions(+), 54 deletions(-) diff --git a/README.md b/README.md index c52a853..ae2b901 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Use Muut's [Riot.js](https://muut.com/riotjs/) minimalistic framework from TypeS - [Installation](#install) - [How to write elements](#howtowrite) -- [How to correctly reference in markup](#howtoreference) +- [Writing a basic element](#basic) - [The @template decorator](#template) - [Lifecycle events shortcuts](#lifecycle) - [How to create elements programmatically](#creating) @@ -15,25 +15,52 @@ Use Muut's [Riot.js](https://muut.com/riotjs/) minimalistic framework from TypeS - [Examples](#examples) - [A timer-based counter element](#timer_example) - [Precompiled tags](#precompiled) -- [Running the tests](#repoexample) -- [Known issues](#knownissues) - [Contributing](#contributing) - [Changelog](#changelog) # Installation -Install via bower: +Install via `npm`: ``` -bower install --save riot-ts +npm install --save riot-typescript ``` -This will also install `riot.js`. +## Use as a ` + + +``` +Somewhere in your TypeScript files add the references: +```ts +/// +/// +``` +- RiotTS can be referenced with the global name `Riot` +- riot can be referenced with the global name `riot` + +## Use as a module + +In your TypeScript files: +```ts +import * as Riot from "riot-typescript"; +``` +When mounting you will also need to reference to `riot` (for `riot.mount`): + +Put a declaration somewhere: +```ts +declare module "riot/riot+compiler"; +``` +and then import riot: +``` +import * as riot from "riot/riot+compiler"; +... +riot.mount("*"); +``` # How to write elements @@ -46,7 +73,7 @@ In brief: - Write elements as TypeScript classes - Extend the `Riot.Element` class -- Use `@template` to define the template string or load it from URL +- Use `@Riot.template` to define the template string or load it from URL - create instances of the element programmatically with `className.createElement()`. A class-element: @@ -56,29 +83,12 @@ A class-element: - can use TypeScript Mixins - `options` are passed to the class constructor -# How to correctly reference in markup - -In the `head` section of your main .html file: - -```HTML - - - - - - - - - - - - -``` +# Writing a basic element In your element TypeScript code (e.g. `elements/my-element.ts`): ```TypeScript -@template("my-element.html") +@Riot.template("my-element.html") class MyElement extends Riot.Element { // ... @@ -98,17 +108,13 @@ In `elements/my-element.html`: In your main application file: ```TypeScript -/// - -//... - riot.mount('*'); ``` # The @template decorator ``` -@template(param) +@Riot.template(param) ``` Sets the template for the element. The template parameter can be either: @@ -120,7 +126,7 @@ Sets the template for the element. The template parameter can be either: Example of an element ``: ```TypeScript -@template("
hello
") +@Riot.template("
hello
") class MyHello extends Riot.Element { } @@ -129,7 +135,7 @@ class MyHello extends Riot.Element or ```TypeScript -@template("elements/my-hello.html") +@Riot.template("elements/my-hello.html") class MyHello extends Riot.Element { } @@ -146,7 +152,7 @@ See how to setup [a grunt task that does this](#precompiled). Precompiled files can also be set to index tags by their tag names rather than their path, making it possible to use a shorter syntax: ```TypeScript -@template("my-hello") +@Riot.template("my-hello") // instead of @template("elements/my-hello.html") ``` @@ -164,7 +170,7 @@ Note: names ending in "-ed" have been choosen to not clash with already methods Example: ```TypeScript -@template("") +@Riot.template("") class MyEl extends Riot.Element { constructor(opts) { super(); @@ -244,7 +250,7 @@ riot.route.stop(); ### A timer-based counter element ```TypeScript -@template(` +@Riot.template(`
timer: { time }
@@ -361,19 +367,6 @@ instead of: ``` Note: Tags defined by tag name rather than path cannot work if precompiled tags are turned off. -# Running the tests - -To run the "Test" project containing the Jasmine specs: - -- clone this repo `nippur72/RiotTS` -- go to the `Test` directory -- run `bower update` -- Open the solution in Visual Studio and run the "Test" project. - -# Known issues - -- none (at the moment) - # Contributing Contributions are welcome. @@ -381,6 +374,9 @@ Contributions are welcome. If you find bugs or want to improve it, just send a pull request. # Change log +- v1.0.7 + - BREAKING CHANGE: ship as `npm` package (`bower` is no longer supported). The way files are loaded is + changed please check again the docs. `@template` is now available as `@Riot.template`. - v0.0.22 - removed the need for registration, `.register` and `.registerAll` are now removed from the API - v0.0.21