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/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 diff --git a/RiotTS.csproj b/RiotTS.csproj deleted file mode 100644 index cfd6ff1..0000000 --- a/RiotTS.csproj +++ /dev/null @@ -1,93 +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.7 - true - - - - - - - - - - - - - - - - - web.config - - - web.config - - - - 12.0 - - - RiotExample - - - - - - - - True - True - 4228 - / - http://localhost:4228/ - False - False - - - False - - - - - - false - true - ES5 - True - False - None - - - True - True - - - - - true - false - - - - - - - - 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 deleted file mode 100644 index c66da1a..0000000 --- a/RiotTS.csproj.user +++ /dev/null @@ -1,30 +0,0 @@ - - - - 1.7 - - - - - - index.html - CurrentPage - True - False - False - False - - - - - - - - - True - True - - - - - \ No newline at end of file diff --git a/RiotTS.sln b/RiotTS.sln deleted file mode 100644 index 8f1898c..0000000 --- a/RiotTS.sln +++ /dev/null @@ -1,30 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.23107.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 - 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 - {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 - EndGlobalSection -EndGlobal diff --git a/RiotTS.v12.suo b/RiotTS.v12.suo deleted file mode 100644 index 8425c77..0000000 Binary files a/RiotTS.v12.suo and /dev/null differ 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,E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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;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AAcA,EAAEA,CAACA;YAE/BA,GAAGA,CAACA,EAAEA,CAACA,gBAAgBA,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..2d9d460 --- /dev/null +++ b/package.json @@ -0,0 +1,23 @@ +{ + "name": "riot-typescript", + "version": "1.0.7", + "description": "Riot for TypeScript", + "main": "./riot-ts.js", + "typings": "./riot-ts.d.ts", + "scripts": { + "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", + "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.6.2" + } +} diff --git a/riot-ts.d.ts b/riot-ts.d.ts index a0dcf72..383235c 100644 --- a/riot-ts.d.ts +++ b/riot-ts.d.ts @@ -1,83 +1,61 @@ -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; +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; +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; 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 index 763cb4d..7b772fb 100644 --- a/riot-ts.js +++ b/riot-ts.js @@ -1,119 +1,119 @@ -var Riot; -(function (Riot) { - var Observable = (function () { - function Observable() { - riot.observable(this); +"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]; } - 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); }; } +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 ee06312..a74d031 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,CAAC;IAKEA;QAMGC;YACGC,IAAIA,CAACA,UAAUA,CAACA,IAAIA,CAACA,CAACA;QACzBA,CAACA;QAPDD,uBAAEA,GAAFA,UAAGA,MAAcA,EAAEA,QAAkBA,IAAGE,CAACA;QACzCF,wBAAGA,GAAH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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":";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,QAA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I,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/riot-ts.ts b/riot-ts.ts index 5279639..bb8066b 100644 --- a/riot-ts.ts +++ b/riot-ts.ts @@ -1,193 +1,161 @@ -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/riot+compiler"; - export interface Router { - (callback: Function): void; - (filter: string, callback: Function): void; - (to: string, title?: string); +export class Observable { + on(events: string, callback: Function) {} + one(events: string, callback: Function) {} + off(events: string) {} + trigger(eventName: string, ...args) {} - create(): Router; - start(autoExec?: boolean); - stop(); - exec(); - query(): any; - - 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 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 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; - } - } - - // 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]); - } - */ +// 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); +} - export var precompiledTags: { [fileName: string]: CompilerResult } = {}; +/* old extend, without getters and setters +function extend(d, element) { + Object.keys(element.prototype).forEach((key) => d[key] = element.prototype[key]); +} +*/ - export function registerClass(element: Function) { - - function registerTag(compiledTag: CompilerResult) { +export var precompiledTags: { [fileName: string]: CompilerResult } = {}; - var transformFunction = function (opts) { - extend(this,element); // copies prototype into "this" - element.apply(this, [opts]); // calls class constructor applying it on "this" +export function registerClass(element: Function) { - 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); + function registerTag(compiledTag: CompilerResult) { - // TODO support for init(opts) ? - }; - - riot.tag2(compiledTag.tagName, compiledTag.html, compiledTag.css, compiledTag.attribs, transformFunction, riot.settings.brackets); + var transformFunction = function (opts) { + extend(this,element); // copies prototype into "this" + element.apply(this, [opts]); // calls class constructor applying it on "this" - return compiledTag.tagName; - } + 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); - 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; + // TODO support for init(opts) ? }; - 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]; - } + 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; + }; + + 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 { - // 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); - } + 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 ); +} + +export interface CompilerResult { + tagName: string; + html: string; + css: string; + attribs: string; + js: string; +} + +export interface Settings { + brackets: string; } - \ No newline at end of file diff --git a/riot.d.ts b/riot.d.ts new file mode 100644 index 0000000..cdb8034 --- /dev/null +++ b/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; +} + 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 new file mode 100644 index 0000000..32eaf3a --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "noImplicitAny": false, + "sourceMap": true, + "declaration": true, + "lib": ["es5", "dom"], + "noImplicitReturns": true, + "noImplicitThis": false, + "outDir": "./", + "strictNullChecks": true, + "removeComments": false + }, + "exclude": [ + "node_modules", + "**/*.spec.ts" + ] +} \ No newline at end of file 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 @@ - - - - - - - - - - - - - -