From 87ed2032fef534c1f3c523f669d61b30f4a9d137 Mon Sep 17 00:00:00 2001 From: ido Date: Thu, 29 Jun 2017 10:47:09 +0300 Subject: [PATCH] move back to master --- .babelrc | 4 + .editorconfig | 20 + .eslintignore | 27 + .eslintrc | 30 + .gitignore | 9 + .npmignore | 25 + .travis.yml | 26 + CONTRIBUTING.md | 33 + Gruntfile.js | 120 + LICENSE | 22 + README.md | 674 +- bin/rt.js | 7 + docs/cli.md | 127 + docs/integrations.md | 23 + docs/intellij-es6.png | Bin 0 -> 92449 bytes docs/native.md | 123 + fiddle.html | 49 + home.config.js | 30 + img/github-fork-me.png | Bin 0 -> 6893 bytes img/icons-footer-sab5af31545.png | Bin 0 -> 3378 bytes img/logo-rt.svg | 20 + img/samples/delete.png | Bin 0 -> 131 bytes index.html | 97 + package.json | 82 + playground.config.js | 30 + playground/.eslintrc | 16 + playground/CMLint.js | 118 + playground/CodeMirrorEditor.js | 175 + playground/CodeMirrorViewer.js | 46 + playground/aceEditor.js | 65 + playground/css/fiddle.css | 231 + playground/css/home.css | 1218 + playground/css/playground.css | 10 + playground/dist/fiddle.min.js | 15 + playground/dist/home.min.js | 10 + playground/dist/rt-main.browser.js | 60517 ++++++++++++++++ playground/dist/rt-main.browser.min.js | 20 + playground/examples.js | 38 + playground/examples.rt | 75 + playground/examples.rt.js | 41 + playground/fiddle-main.js | 29 + playground/fiddle.js | 76 + playground/fiddle.rt | 43 + playground/fiddle.rt.js | 99 + playground/home-main.js | 30 + .../src-min-noconflict/ace.js | 11 + .../src-min-noconflict/mode-html.js | 1 + .../src-min-noconflict/mode-javascript.js | 1 + .../src-min-noconflict/mode-json.js | 1 + .../theme-solarized_light.js | 1 + .../libs/ace-builds-1.1.8/src-min/ace.js | 11 + .../ace-builds-1.1.8/src-min/mode-html.js | 1 + .../src-min/mode-javascript.js | 1 + .../ace-builds-1.1.8/src-min/mode-json.js | 1 + playground/libs/bootstrap/bootstrap.js | 181 + playground/libs/bootstrap/bootstrap.min.js | 11 + .../codemirror-4.8/addon/display/panel.js | 94 + .../codemirror-4.8/addon/hint/css-hint.js | 56 + .../codemirror-4.8/addon/hint/html-hint.js | 348 + .../addon/hint/javascript-hint.js | 141 + .../codemirror-4.8/addon/hint/show-hint.css | 38 + .../codemirror-4.8/addon/hint/show-hint.js | 389 + .../codemirror-4.8/addon/hint/xml-hint.js | 111 + .../libs/codemirror-4.8/addon/lint/lint.css | 73 + .../codemirror-4.8/addon/runmode/runmode.js | 72 + .../libs/codemirror-4.8/lib/codemirror.css | 318 + .../libs/codemirror-4.8/lib/codemirror.js | 7922 ++ .../libs/codemirror-4.8/mode/css/css.js | 717 + .../mode/htmlmixed/htmlmixed.js | 121 + .../mode/javascript/javascript.js | 684 + .../libs/codemirror-4.8/mode/xml/xml.js | 384 + .../libs/codemirror-4.8/theme/solarized.css | 165 + playground/libs/requirejs-plugins/json.js | 61 + playground/libs/requirejs-plugins/json.min.js | 1 + playground/libs/requirejs-plugins/text.js | 332 + playground/libs/requirejs-plugins/text.min.js | 1 + playground/playground-fiddle.rt | 36 + playground/playground-fiddle.rt.js | 61 + playground/playground.js | 272 + playground/playground.rt | 45 + playground/playground.rt.js | 81 + playground/rt-main.js | 10 + playground/samples/hello.code | 3 + playground/samples/hello.rt | 1 + playground/samples/rt-if.code | 9 + playground/samples/rt-if.rt | 7 + playground/samples/rt-import.rt | 5 + playground/samples/rt-props.code | 16 + playground/samples/rt-props.rt | 16 + playground/samples/rt-repeat.code | 8 + playground/samples/rt-repeat.rt | 5 + playground/samples/rt-require.rt | 5 + playground/samples/todo.code | 31 + playground/samples/todo.rt | 21 + playground/samples/todo2.code | 24 + playground/samples/todo2.rt | 13 + playground/samples/weather.code | 34 + playground/samples/weather.rt | 19 + sample/.eslintrc | 16 + sample/ImageSearch.js | 94 + sample/ImageSearch.rt | 18 + sample/ImageSearch.rt.js | 58 + sample/InfiniteScroll.js | 37 + sample/index.html | 23 + sample/main.js | 18 + sample/sample.css | 83 + src/RTCodeError.js | 112 + src/api.js | 54 + src/cli.js | 112 + src/context.js | 80 + src/formatters/json.js | 4 + src/formatters/stylish.js | 89 + src/fsUtil.js | 27 + src/options.js | 130 + src/reactDOMSupport.js | 25 + src/reactNativeSupport.js | 19 + src/reactPropTemplates.js | 29 + src/reactSupport.js | 89 + src/reactTemplates.js | 729 + src/rt-style-support-data.js | 47 + src/rtStyle.js | 47 + src/shell.js | 16 + src/utils.js | 201 + test/data/autobind.rt | 2 + test/data/autobind.rt.js | 10 + test/data/className.rt | 1 + test/data/className.rt.html | 1 + test/data/comment.rt | 6 + test/data/comment.rt.amd.js | 9 + test/data/comment.rt.es6.js | 5 + test/data/concat.rt | 1 + test/data/concat.rt.html | 1 + test/data/custom-element.rt | 4 + test/data/custom-element.rt.html | 1 + test/data/div.rt | 2 + test/data/div.rt.amd.js | 9 + test/data/div.rt.commonjs.js | 6 + test/data/div.rt.es6.js | 5 + test/data/div.rt.globals.js | 3 + test/data/div.rt.js | 9 + test/data/div.rt.typescript.ts | 4 + test/data/eval.rt | 3 + test/data/eval.rt.html | 1 + test/data/if-with-scope/valid-if-scope.rt | 5 + test/data/if-with-scope/valid-if-scope.rt.js | 13 + test/data/import.rt | 6 + test/data/import.rt.amd.js | 16 + test/data/import.rt.commonjs.js | 10 + test/data/import.rt.es6.js | 9 + test/data/import.rt.globals.js | 3 + test/data/import.rt.js | 11 + test/data/import.rt.typescript.ts | 8 + test/data/include.rt | 4 + test/data/include.rt.html | 1 + test/data/inputs.rt | 5 + test/data/inputs.rt.js | 15 + .../if-with-scope/invalid-if-scope-1.rt | 5 + .../if-with-scope/invalid-if-scope-2.rt | 5 + .../if-with-scope/invalid-if-scope-3.rt | 5 + .../if-with-scope/invalid-if-scope-4.rt | 5 + .../if-with-scope/invalid-if-scope-5.rt | 5 + test/data/invalid/invalid-autobind.rt | 4 + test/data/invalid/invalid-brace.rt | 6 + test/data/invalid/invalid-exp.rt | 3 + test/data/invalid/invalid-html.rt | 1 + test/data/invalid/invalid-js.rt | 2 + test/data/invalid/invalid-lambda.rt | 2 + test/data/invalid/invalid-repeat-1.rt | 3 + test/data/invalid/invalid-repeat-2.rt | 1 + test/data/invalid/invalid-rt-import-1.rt | 3 + test/data/invalid/invalid-rt-import-2.rt | 3 + test/data/invalid/invalid-rt-import-3.rt | 3 + test/data/invalid/invalid-rt-import-4.rt | 3 + test/data/invalid/invalid-rt-require-1.rt | 3 + test/data/invalid/invalid-rt-require-2.rt | 5 + test/data/invalid/invalid-rt-template-1.rt | 5 + test/data/invalid/invalid-rt-template-2.rt | 6 + test/data/invalid/invalid-scope.rt | 2 + test/data/invalid/invalid-single-root.rt | 2 + test/data/invalid/invalid-style-1.rt | 3 + test/data/invalid/invalid-style-2.rt | 3 + test/data/invalid/invalid-style-2.rt.js | 13 + test/data/invalid/invalid-virtual-1.rt | 3 + test/data/invalid/invalid-virtual-2.rt | 5 + test/data/js-in-attr.rt | 1 + test/data/js-in-attr.rt.html | 1 + test/data/lambda.rt | 5 + test/data/lambda.rt.html | 3 + test/data/native/listViewAndCustomTemplate.rt | 12 + .../native/listViewAndCustomTemplate.rt.js | 22 + .../listViewAndCustomTemplate.rt.v029.js | 23 + test/data/native/listViewTemplate.rt | 7 + test/data/native/listViewTemplate.rt.js | 12 + test/data/native/listViewTemplate.rt.v029.js | 13 + test/data/native/nativeView.rt | 1 + test/data/native/nativeView.rt.js | 6 + test/data/native/nativeView.rt.v029.js | 7 + test/data/non-breaking-space.rt | 1 + test/data/non-breaking-space.rt.js | 9 + test/data/propTemplates/implicitTemplate.rt | 7 + .../data/propTemplates/implicitTemplate.rt.js | 19 + test/data/propTemplates/siblingTemplates.rt | 12 + .../data/propTemplates/siblingTemplates.rt.js | 22 + test/data/propTemplates/simpleTemplate.rt | 5 + test/data/propTemplates/simpleTemplate.rt.js | 12 + test/data/propTemplates/templateInScope.rt | 5 + test/data/propTemplates/templateInScope.rt.js | 16 + test/data/propTemplates/twoTemplates.rt | 10 + test/data/propTemplates/twoTemplates.rt.js | 15 + test/data/props-class.rt | 1 + test/data/props-class.rt.html | 1 + test/data/props.rt | 1 + test/data/props.rt.html | 1 + test/data/repeat-literal-collection.rt | 5 + test/data/repeat-literal-collection.rt.html | 1 + test/data/repeat-with-index.rt | 3 + test/data/repeat-with-index.rt.js | 16 + test/data/repeat.rt | 7 + test/data/repeat.rt.js | 31 + test/data/require.rt | 5 + test/data/require.rt.amd.js | 11 + test/data/require.rt.commonjs.js | 8 + test/data/require.rt.es6.js | 7 + test/data/require.rt.globals.js | 3 + test/data/require.rt.js | 11 + test/data/require.rt.typescript.ts | 6 + test/data/rt-class.rt | 6 + test/data/rt-class.rt.html | 1 + test/data/scope-evaluated-after-if.rt | 8 + test/data/scope-evaluated-after-if.rt.html | 1 + test/data/scope-evaluated-after-repeat.rt | 5 + .../data/scope-evaluated-after-repeat.rt.html | 1 + test/data/scope-evaluated-after-repeat2.rt | 9 + .../scope-evaluated-after-repeat2.rt.html | 1 + test/data/scope-obj.rt | 3 + test/data/scope-obj.rt.html | 3 + test/data/scope-reserved-tokens.rt | 4 + test/data/scope-reserved-tokens.rt.html | 2 + test/data/scope-trailing-semicolon.rt | 6 + test/data/scope-trailing-semicolon.rt.html | 2 + test/data/scope-variable-references.rt | 11 + test/data/scope-variable-references.rt.html | 1 + test/data/scope.rt | 7 + test/data/scope.rt.html | 9 + test/data/simple.js | 11 + test/data/simple.jsrt | 10 + test/data/stateless.rt | 1 + test/data/stateless.rt.js | 9 + test/data/style-vendor-prefix.rt | 4 + test/data/style-vendor-prefix.rt.js | 25 + test/data/style.rt | 5 + test/data/style.rt.html | 1 + test/data/svg.rt | 1 + test/data/svg.rt.html | 1 + test/data/test.rt | 14 + test/data/test.rt.js | 30 + test/data/virtual.rt | 14 + test/data/virtual.rt.html | 1 + test/data/virtual.rt.js | 26 + test/data/whitespace.rt | 24 + test/data/whitespace.rt.js | 9 + test/src/fsUtil.spec.js | 31 + test/src/rt-html-valid.spec.js | 62 + test/src/rt.invalid.spec.js | 111 + test/src/rt.valid.spec.js | 158 + test/src/rtStyle.spec.js | 14 + test/src/shell.spec.js | 53 + test/src/test.js | 11 + test/src/testUtils.js | 102 + test/src/utils.spec.js | 20 + 270 files changed, 81065 insertions(+), 3 deletions(-) create mode 100644 .babelrc create mode 100644 .editorconfig create mode 100644 .eslintignore create mode 100644 .eslintrc create mode 100644 .npmignore create mode 100644 .travis.yml create mode 100644 CONTRIBUTING.md create mode 100644 Gruntfile.js create mode 100644 LICENSE create mode 100755 bin/rt.js create mode 100644 docs/cli.md create mode 100644 docs/integrations.md create mode 100644 docs/intellij-es6.png create mode 100644 docs/native.md create mode 100644 fiddle.html create mode 100644 home.config.js create mode 100644 img/github-fork-me.png create mode 100644 img/icons-footer-sab5af31545.png create mode 100644 img/logo-rt.svg create mode 100644 img/samples/delete.png create mode 100644 index.html create mode 100644 package.json create mode 100644 playground.config.js create mode 100644 playground/.eslintrc create mode 100644 playground/CMLint.js create mode 100644 playground/CodeMirrorEditor.js create mode 100644 playground/CodeMirrorViewer.js create mode 100644 playground/aceEditor.js create mode 100644 playground/css/fiddle.css create mode 100644 playground/css/home.css create mode 100644 playground/css/playground.css create mode 100644 playground/dist/fiddle.min.js create mode 100644 playground/dist/home.min.js create mode 100644 playground/dist/rt-main.browser.js create mode 100644 playground/dist/rt-main.browser.min.js create mode 100644 playground/examples.js create mode 100644 playground/examples.rt create mode 100644 playground/examples.rt.js create mode 100644 playground/fiddle-main.js create mode 100644 playground/fiddle.js create mode 100644 playground/fiddle.rt create mode 100644 playground/fiddle.rt.js create mode 100644 playground/home-main.js create mode 100755 playground/libs/ace-builds-1.1.8/src-min-noconflict/ace.js create mode 100755 playground/libs/ace-builds-1.1.8/src-min-noconflict/mode-html.js create mode 100755 playground/libs/ace-builds-1.1.8/src-min-noconflict/mode-javascript.js create mode 100755 playground/libs/ace-builds-1.1.8/src-min-noconflict/mode-json.js create mode 100755 playground/libs/ace-builds-1.1.8/src-min-noconflict/theme-solarized_light.js create mode 100755 playground/libs/ace-builds-1.1.8/src-min/ace.js create mode 100755 playground/libs/ace-builds-1.1.8/src-min/mode-html.js create mode 100755 playground/libs/ace-builds-1.1.8/src-min/mode-javascript.js create mode 100755 playground/libs/ace-builds-1.1.8/src-min/mode-json.js create mode 100755 playground/libs/bootstrap/bootstrap.js create mode 100755 playground/libs/bootstrap/bootstrap.min.js create mode 100644 playground/libs/codemirror-4.8/addon/display/panel.js create mode 100644 playground/libs/codemirror-4.8/addon/hint/css-hint.js create mode 100755 playground/libs/codemirror-4.8/addon/hint/html-hint.js create mode 100644 playground/libs/codemirror-4.8/addon/hint/javascript-hint.js create mode 100644 playground/libs/codemirror-4.8/addon/hint/show-hint.css create mode 100644 playground/libs/codemirror-4.8/addon/hint/show-hint.js create mode 100644 playground/libs/codemirror-4.8/addon/hint/xml-hint.js create mode 100644 playground/libs/codemirror-4.8/addon/lint/lint.css create mode 100644 playground/libs/codemirror-4.8/addon/runmode/runmode.js create mode 100644 playground/libs/codemirror-4.8/lib/codemirror.css create mode 100644 playground/libs/codemirror-4.8/lib/codemirror.js create mode 100644 playground/libs/codemirror-4.8/mode/css/css.js create mode 100644 playground/libs/codemirror-4.8/mode/htmlmixed/htmlmixed.js create mode 100644 playground/libs/codemirror-4.8/mode/javascript/javascript.js create mode 100644 playground/libs/codemirror-4.8/mode/xml/xml.js create mode 100644 playground/libs/codemirror-4.8/theme/solarized.css create mode 100644 playground/libs/requirejs-plugins/json.js create mode 100644 playground/libs/requirejs-plugins/json.min.js create mode 100644 playground/libs/requirejs-plugins/text.js create mode 100644 playground/libs/requirejs-plugins/text.min.js create mode 100644 playground/playground-fiddle.rt create mode 100644 playground/playground-fiddle.rt.js create mode 100644 playground/playground.js create mode 100644 playground/playground.rt create mode 100644 playground/playground.rt.js create mode 100644 playground/rt-main.js create mode 100644 playground/samples/hello.code create mode 100644 playground/samples/hello.rt create mode 100644 playground/samples/rt-if.code create mode 100644 playground/samples/rt-if.rt create mode 100644 playground/samples/rt-import.rt create mode 100644 playground/samples/rt-props.code create mode 100644 playground/samples/rt-props.rt create mode 100644 playground/samples/rt-repeat.code create mode 100644 playground/samples/rt-repeat.rt create mode 100644 playground/samples/rt-require.rt create mode 100644 playground/samples/todo.code create mode 100644 playground/samples/todo.rt create mode 100644 playground/samples/todo2.code create mode 100644 playground/samples/todo2.rt create mode 100644 playground/samples/weather.code create mode 100644 playground/samples/weather.rt create mode 100644 sample/.eslintrc create mode 100644 sample/ImageSearch.js create mode 100644 sample/ImageSearch.rt create mode 100644 sample/ImageSearch.rt.js create mode 100644 sample/InfiniteScroll.js create mode 100644 sample/index.html create mode 100644 sample/main.js create mode 100644 sample/sample.css create mode 100644 src/RTCodeError.js create mode 100644 src/api.js create mode 100755 src/cli.js create mode 100644 src/context.js create mode 100644 src/formatters/json.js create mode 100644 src/formatters/stylish.js create mode 100644 src/fsUtil.js create mode 100644 src/options.js create mode 100644 src/reactDOMSupport.js create mode 100644 src/reactNativeSupport.js create mode 100644 src/reactPropTemplates.js create mode 100644 src/reactSupport.js create mode 100644 src/reactTemplates.js create mode 100644 src/rt-style-support-data.js create mode 100644 src/rtStyle.js create mode 100644 src/shell.js create mode 100644 src/utils.js create mode 100644 test/data/autobind.rt create mode 100644 test/data/autobind.rt.js create mode 100644 test/data/className.rt create mode 100644 test/data/className.rt.html create mode 100644 test/data/comment.rt create mode 100644 test/data/comment.rt.amd.js create mode 100644 test/data/comment.rt.es6.js create mode 100644 test/data/concat.rt create mode 100644 test/data/concat.rt.html create mode 100644 test/data/custom-element.rt create mode 100644 test/data/custom-element.rt.html create mode 100644 test/data/div.rt create mode 100644 test/data/div.rt.amd.js create mode 100644 test/data/div.rt.commonjs.js create mode 100644 test/data/div.rt.es6.js create mode 100644 test/data/div.rt.globals.js create mode 100644 test/data/div.rt.js create mode 100644 test/data/div.rt.typescript.ts create mode 100644 test/data/eval.rt create mode 100644 test/data/eval.rt.html create mode 100644 test/data/if-with-scope/valid-if-scope.rt create mode 100644 test/data/if-with-scope/valid-if-scope.rt.js create mode 100644 test/data/import.rt create mode 100644 test/data/import.rt.amd.js create mode 100644 test/data/import.rt.commonjs.js create mode 100644 test/data/import.rt.es6.js create mode 100644 test/data/import.rt.globals.js create mode 100644 test/data/import.rt.js create mode 100644 test/data/import.rt.typescript.ts create mode 100644 test/data/include.rt create mode 100644 test/data/include.rt.html create mode 100644 test/data/inputs.rt create mode 100644 test/data/inputs.rt.js create mode 100644 test/data/invalid/if-with-scope/invalid-if-scope-1.rt create mode 100644 test/data/invalid/if-with-scope/invalid-if-scope-2.rt create mode 100644 test/data/invalid/if-with-scope/invalid-if-scope-3.rt create mode 100644 test/data/invalid/if-with-scope/invalid-if-scope-4.rt create mode 100644 test/data/invalid/if-with-scope/invalid-if-scope-5.rt create mode 100644 test/data/invalid/invalid-autobind.rt create mode 100644 test/data/invalid/invalid-brace.rt create mode 100644 test/data/invalid/invalid-exp.rt create mode 100644 test/data/invalid/invalid-html.rt create mode 100644 test/data/invalid/invalid-js.rt create mode 100644 test/data/invalid/invalid-lambda.rt create mode 100644 test/data/invalid/invalid-repeat-1.rt create mode 100644 test/data/invalid/invalid-repeat-2.rt create mode 100644 test/data/invalid/invalid-rt-import-1.rt create mode 100644 test/data/invalid/invalid-rt-import-2.rt create mode 100644 test/data/invalid/invalid-rt-import-3.rt create mode 100644 test/data/invalid/invalid-rt-import-4.rt create mode 100644 test/data/invalid/invalid-rt-require-1.rt create mode 100644 test/data/invalid/invalid-rt-require-2.rt create mode 100644 test/data/invalid/invalid-rt-template-1.rt create mode 100644 test/data/invalid/invalid-rt-template-2.rt create mode 100644 test/data/invalid/invalid-scope.rt create mode 100644 test/data/invalid/invalid-single-root.rt create mode 100644 test/data/invalid/invalid-style-1.rt create mode 100644 test/data/invalid/invalid-style-2.rt create mode 100644 test/data/invalid/invalid-style-2.rt.js create mode 100644 test/data/invalid/invalid-virtual-1.rt create mode 100644 test/data/invalid/invalid-virtual-2.rt create mode 100644 test/data/js-in-attr.rt create mode 100644 test/data/js-in-attr.rt.html create mode 100644 test/data/lambda.rt create mode 100644 test/data/lambda.rt.html create mode 100644 test/data/native/listViewAndCustomTemplate.rt create mode 100644 test/data/native/listViewAndCustomTemplate.rt.js create mode 100644 test/data/native/listViewAndCustomTemplate.rt.v029.js create mode 100644 test/data/native/listViewTemplate.rt create mode 100644 test/data/native/listViewTemplate.rt.js create mode 100644 test/data/native/listViewTemplate.rt.v029.js create mode 100644 test/data/native/nativeView.rt create mode 100644 test/data/native/nativeView.rt.js create mode 100644 test/data/native/nativeView.rt.v029.js create mode 100644 test/data/non-breaking-space.rt create mode 100644 test/data/non-breaking-space.rt.js create mode 100644 test/data/propTemplates/implicitTemplate.rt create mode 100644 test/data/propTemplates/implicitTemplate.rt.js create mode 100644 test/data/propTemplates/siblingTemplates.rt create mode 100644 test/data/propTemplates/siblingTemplates.rt.js create mode 100644 test/data/propTemplates/simpleTemplate.rt create mode 100644 test/data/propTemplates/simpleTemplate.rt.js create mode 100644 test/data/propTemplates/templateInScope.rt create mode 100644 test/data/propTemplates/templateInScope.rt.js create mode 100644 test/data/propTemplates/twoTemplates.rt create mode 100644 test/data/propTemplates/twoTemplates.rt.js create mode 100644 test/data/props-class.rt create mode 100644 test/data/props-class.rt.html create mode 100644 test/data/props.rt create mode 100644 test/data/props.rt.html create mode 100644 test/data/repeat-literal-collection.rt create mode 100644 test/data/repeat-literal-collection.rt.html create mode 100644 test/data/repeat-with-index.rt create mode 100644 test/data/repeat-with-index.rt.js create mode 100644 test/data/repeat.rt create mode 100644 test/data/repeat.rt.js create mode 100644 test/data/require.rt create mode 100644 test/data/require.rt.amd.js create mode 100644 test/data/require.rt.commonjs.js create mode 100644 test/data/require.rt.es6.js create mode 100644 test/data/require.rt.globals.js create mode 100644 test/data/require.rt.js create mode 100644 test/data/require.rt.typescript.ts create mode 100644 test/data/rt-class.rt create mode 100644 test/data/rt-class.rt.html create mode 100644 test/data/scope-evaluated-after-if.rt create mode 100644 test/data/scope-evaluated-after-if.rt.html create mode 100644 test/data/scope-evaluated-after-repeat.rt create mode 100644 test/data/scope-evaluated-after-repeat.rt.html create mode 100644 test/data/scope-evaluated-after-repeat2.rt create mode 100644 test/data/scope-evaluated-after-repeat2.rt.html create mode 100644 test/data/scope-obj.rt create mode 100644 test/data/scope-obj.rt.html create mode 100644 test/data/scope-reserved-tokens.rt create mode 100644 test/data/scope-reserved-tokens.rt.html create mode 100644 test/data/scope-trailing-semicolon.rt create mode 100644 test/data/scope-trailing-semicolon.rt.html create mode 100644 test/data/scope-variable-references.rt create mode 100644 test/data/scope-variable-references.rt.html create mode 100644 test/data/scope.rt create mode 100644 test/data/scope.rt.html create mode 100644 test/data/simple.js create mode 100644 test/data/simple.jsrt create mode 100644 test/data/stateless.rt create mode 100644 test/data/stateless.rt.js create mode 100644 test/data/style-vendor-prefix.rt create mode 100644 test/data/style-vendor-prefix.rt.js create mode 100644 test/data/style.rt create mode 100644 test/data/style.rt.html create mode 100644 test/data/svg.rt create mode 100644 test/data/svg.rt.html create mode 100644 test/data/test.rt create mode 100644 test/data/test.rt.js create mode 100644 test/data/virtual.rt create mode 100644 test/data/virtual.rt.html create mode 100644 test/data/virtual.rt.js create mode 100644 test/data/whitespace.rt create mode 100644 test/data/whitespace.rt.js create mode 100644 test/src/fsUtil.spec.js create mode 100644 test/src/rt-html-valid.spec.js create mode 100644 test/src/rt.invalid.spec.js create mode 100644 test/src/rt.valid.spec.js create mode 100644 test/src/rtStyle.spec.js create mode 100644 test/src/shell.spec.js create mode 100644 test/src/test.js create mode 100644 test/src/testUtils.js create mode 100644 test/src/utils.spec.js diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..37db7f6 --- /dev/null +++ b/.babelrc @@ -0,0 +1,4 @@ +{ + "presets": ["es2015"], + "ignore": "test/data" +} diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..31285b3 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,20 @@ +# http://EditorConfig.org + +# top-most EditorConfig file +root = true + +# [*.{js,json}] +[*] +indent_style = space +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true # doesn't work yet +insert_final_newline = true # doesn't work yet + +[{package.json,*.yml}] +indent_style = space +indent_size = 2 + +[*.md] +trim_trailing_whitespace = false diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..9e898bb --- /dev/null +++ b/.eslintignore @@ -0,0 +1,27 @@ +node_modules/** +bower_components/** +**/*.rt.js +**/*.json.js + +playground/**/*.rt.js +playground/dist/** +playground/libs/** + +playground2/** +playground3/** +playground3/dist/** +playground3/libs/** +playground3/**/*.rt.js +playground4 + +web/** + +playground/sample/** +test/data/** +dist-test +dist + +internalTasks/release.js +playground.config.js +sample/InfiniteScroll.js +/coverage diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..b554368 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,30 @@ +{ + "extends": ["wix-editor", "wix-editor/node", "plugin:lodash/recommended"], + "plugins": ["lodash", "wix-editor"], + "rules": { + "semi": [2, "never"], + "func-style": [2, "declaration", {"allowArrowFunctions": true}], + "prefer-spread": 0, + "prefer-template": 0, + "consistent-return": 0, + + "no-restricted-syntax": [2, "WithStatement", "ContinueStatement", "ForStatement"], + "no-negated-condition": 1, + + + "lodash/prefer-filter": 0, + "lodash/chaining": [2, "always"], + "lodash/prefer-map": 0, + "lodash/path-style": 0, + "lodash/no-extra-args": 2, + "lodash/prefer-lodash-method": 0, + + "wix-editor/augmented-assignment": 1, + "wix-editor/no-not-not": 1, + "wix-editor/no-unneeded-match": 1, + "wix-editor/prefer-filter": 1, + "wix-editor/prefer-ternary": 1, + "wix-editor/return-boolean": 1, + "wix-editor/simplify-boolean-expression": 1 + } +} diff --git a/.gitignore b/.gitignore index caf1810..46833c1 100644 --- a/.gitignore +++ b/.gitignore @@ -16,7 +16,16 @@ npm-debug.log ### bower ### /bower_components/* +### babel ### +/dist +/dist-test + /web /target /coverage +### Test Output ### +test/data/**/*.rt.actual.js +test/data/**/*.code.js +test/data/**/*.actual.html + diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..2e1c1bc --- /dev/null +++ b/.npmignore @@ -0,0 +1,25 @@ + +### Operating systems ### +.DS_Store +.AppleDouble +.LSOverride +._* +.Spotlight-V100 +.Trashes + +### Regular dev ### +node_modules +npm-debug.log +.idea +*.iml + +### bower ### +/bower_components/* + +### tests ### +/test + +### gh-pages content ### +/index.html +/playground +/web diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..58e55ad --- /dev/null +++ b/.travis.yml @@ -0,0 +1,26 @@ +language: node_js +node_js: + - 4 + - 5 + - 6 + +sudo: false + +#before_script: +# - npm install -g grunt-cli + +install: + - npm install + +script: + - npm run lint + - npm run test-cov + +branches: + only: + - gh-pages +#after_success: +# - npm run coveralls + +#after_success: +# - cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..9a8b9aa --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,33 @@ +# Contributing to React-Templates + +Thanks for coming! Contributions of any kind are welcome. + +## Setup + +* Fork [React-Templates](https://github.com/wix/react-templates) +* Clone your fork +* In your `react-templates` directory, run `npm i && grunt all` + +## Submitting an issue + +You can submit an issue [here](https://github.com/wix/react-templates/issues). +Please make sure that there isn't already an issue regarding the same matter, +and include as many details as possible about the issue and on how to reproduce it, +if relevant. + +## Creating a pull request + +* Please adhere to the style and formatting of the code +* Write tests for new functionality +* Create purposeful and complete commits + +### Before committing + +* Make sure that `grunt all` passes. +* Pick a concise commit message + +When working on [wix.github.io/react-templates](http://wix.github.io/react-templates), +run `grunt pgall` to create the minified files, +but do not include their updated version in your commit. +Describe in your PR what you did to the site and we'll update them after the merge. +(This is important for preventing merge conflicts in the minified files). diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..ddf4deb --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,120 @@ +'use strict' +module.exports = function (grunt) { + grunt.initConfig({ + clean: { + main: { + src: ['coverage', 'playground/**/*.rt.js'] + } + }, + eslint: { + all: { + src: [ + 'src/**/*.js', 'playground/**/*.js', + 'test/src/**/*.js', + '!playground/libs/**/*.js', + '!playground/dist/**/*.js', + '!playground/**/*.rt.js' + ] + } + }, + jasmine_node: { + options: { + forceExit: true, + match: '.', + matchall: false, + specNameMatcher: 'spec', + extensions: 'js' + }, + all: ['server/test'], + grunt: ['conf/tasks/test'] + }, + browserify: { + rt: { + files: { + 'playground/dist/rt-main.browser.js': ['playground/rt-main.js'] + }, + options: { + transform: ['brfs'], + alias: ['react:react/addons'] + } + } + }, + tape: { + options: { + pretty: true, + output: 'console' + }, + files: ['test/src/*.js'] + }, + watch: { + rt: { + files: [ + 'playground/*.rt' + ], + tasks: ['rt'], + options: { + spawn: false + } + }, + test: { + files: [ + 'src/**/*.*', 'test/**/*.*' + ], + tasks: ['test'], + options: { + spawn: false + } + } + }, + uglify: { + my_target: { + //options: { + // sourceMap: true, + // sourceMapIncludeSources: true, + // sourceMapIn: 'example/coffeescript-sourcemap.js', // input sourcemap from a previous compilation + //}, + files: { + 'playground/dist/rt-main.browser.min.js': ['playground/dist/rt-main.browser.js'], + 'playground/libs/requirejs-plugins/text.min.js': ['playground/libs/requirejs-plugins/text.js'], + 'playground/libs/requirejs-plugins/json.min.js': ['playground/libs/requirejs-plugins/json.js'] + } + } + }, + requirejs: { + compile: { + options: readConfig('./home.config.js') + }, + playground: { + options: readConfig('./playground.config.js') + } + } + }) + + function readConfig(file) { + return eval(require('fs').readFileSync(file).toString()) // eslint-disable-line no-eval + } + + grunt.loadNpmTasks('grunt-tape') + grunt.loadNpmTasks('grunt-browserify') + grunt.loadNpmTasks('grunt-contrib-watch') + grunt.loadNpmTasks('grunt-contrib-requirejs') + grunt.loadNpmTasks('grunt-eslint') + grunt.loadNpmTasks('grunt-contrib-uglify') + + grunt.registerTask('default', ['eslint:all']) + grunt.registerTask('lint', ['eslint:all']) + grunt.registerTask('test', ['tape']) + + grunt.registerTask('rt', () => { + const reactTemplates = require('./src/cli') + const files = grunt.file.expand('playground/*.rt') + const ret = reactTemplates.execute({modules: 'amd', force: true, _: files}) + return ret === 0 + }) + + grunt.registerTask('build', ['rt', 'browserify:pg']) + grunt.registerTask('home', ['rt', 'browserify:home']) + grunt.registerTask('pgall', ['rt', 'browserify', 'uglify', 'requirejs']) + + grunt.registerTask('all', ['default', 'test']) +} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..a59f3aa --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2014 Wix.com + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/README.md b/README.md index 67e2a04..5325b42 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,673 @@ -# react-templates +[![NPM version][npm-image]][npm-url] +[![build status][travis-image]][travis-url] +[![Coverage Status][coveralls-image]][coveralls-url] -Branch `master` is not in use - do not use it! +# React Templates -Moved to the default [gh-pages branch](https://github.com/wix/react-templates). +Lightweight templates for [React](http://facebook.github.io/react/index.html). + +* No runtime libraries. No magic. Simply precompile your way to clear React code. +* Easy syntax that's similar to HTML, supported by most IDEs. +* Clear separation of presentation and logic - almost zero HTML in component files. +* Declarative coding ensures that the HTML that you write and the HTML you inspect look nearly identical. +* Supports AMD, CommonJS, ES6, Typescript and globals. + +## How does it work +React Templates compiles an *.rt file (react template file - an extended HTML format) into a JavaScript file. +This file, which uses AMD syntax, returns a function. When invoked, this function returns a virtual React DOM based on React.DOM elements and custom user components. +

A common use case would be that a regular React component would require a JavaScript file generated from a template, +and then perform `func.apply(this)`, causing the template to have that component as its context. + +## Playground +http://wix.github.io/react-templates/ + +## Yeoman generator +https://github.com/wix/generator-react-templates + +## Hello react-templates +Here's a sample Hello project:
+https://github.com/wix/hello-react-templates + +Here's a sample Hello project with webpack, es6 and hot reload:
+https://github.com/wix/react-templates-transform-boilerplate + +## IntelliJ / WebStorm plugin +http://plugins.jetbrains.com/plugin/7648 + + +## Basic concepts for React templates +* Any valid HTML (including comments) is a template +* {} to identify JS expression +* Built-in directives: + * [rt-if](#rt-if) + * [rt-repeat](#rt-repeat) + * [rt-scope](#rt-scope) + * [rt-props](#rt-props) + * [rt-class](#rt-class) + * [rt-import](#rt-import) + * ~~rt-require~~ (deprecated, use rt-import) + * [rt-template](#rt-template) + * [rt-include](#rt-include) + * [rt-pre](#rt-pre) + * [rt-virtual](#rt-virtual) +* [styles](#styles) +* [event handlers](#event-handlers) + +## Why not use JSX? +Some love JSX, some don't. We don't. More specifically, it seems to us that JSX is only a good fit for components with very little HTML inside. +And this can be accomplished by creating DOM elements in code. Also, we like to separate code and HTML because it just feels right. + +## Installation +You can install react-templates using npm: +```shell +npm install react-templates -g +``` + +## Usage +```shell +rt [file.rt|dir]* [options] +``` + +See more on CLI usage [here](https://github.com/wix/react-templates/blob/gh-pages/docs/cli.md). + +In most cases, this package will be wrapped in a build task, so CLI will not be used explicitly: +* Grunt: [grunt-react-templates](https://github.com/wix/grunt-react-templates) +* Gulp: [gulp-react-templates](https://github.com/wix/gulp-react-templates) +* Broccoli: [broccoli-react-templates](https://github.com/kraftwer1/broccoli-react-templates) +* Browserify plugin: [react-templatify](https://www.npmjs.com/package/react-templatify) +* Webpack loader : [react-templates-loader](https://github.com/AlexanderPavlenko/react-templates-loader) + +### Use React Templates for Native Apps? +You can get all the react templates functionality and more. [Click here for more info](https://github.com/wix/react-templates/blob/gh-pages/docs/native.md) + +# Template directives and syntax + +## Any valid HTML is a template +Any HTML that you write is a valid template, except for inline event handlers ("on" attributes). See the "event handlers" section below for more information. + +## {} to identify JavaScript expressions +To embed JavaScript expressions in both attribute values and tag content, encapsulate them in {}. +If this is done inside an attribute value, the value still needs to be wrapped in quotes. For directives (see below), {} are not used. + +###### Sample: +```html +{this.state.linkText} +``` +###### Compiled: +```javascript +define([ + 'react', + 'lodash' +], function (React, _) { + 'use strict'; + return function () { + return React.DOM.a({ 'href': this.state.linkRef }, this.state.linkText); + }; +}); +``` + +## rt-if +This lets you add conditions to a subtree of HTML. If the condition evaluates to true, the subtree will be returned; otherwise, it will not be calculated. It is implemented as a ternary expression. + + +###### Sample: +```html +

Success!
+``` +###### Compiled: +```javascript +define([ + 'react', + 'lodash' +], function (React, _) { + 'use strict'; + return function () { + return this.state.resultCode === 200 ? React.DOM.div({}, 'Success!') : null; + }; +}); +``` + +## rt-repeat +Repeats a DOM node with its subtree for each item in an array. The syntax is `rt-repeat="itemVar, indexVar in arrayExpr"`, where the element, `itemVar`, will be available in JavaScript context, +and an `itemVarIndex` will be created to represent the index of the item. By using this naming scheme, repeated expressions have access to all levels of nesting. +It is also possible to declare a custom index variable using the syntax `rt-repeat="itemVar, indexVar in arrayExpr"`, in which case the index variable will be `indexVar`. + +###### Sample: +```html +
{myNumIndex}. {myNum}
+``` +###### Compiled: +```javascript +define([ + 'react', + 'lodash' +], function (React, _) { + 'use strict'; + function repeatMyNum1(myNum, myNumIndex) { + return React.DOM.div({}, myNumIndex + '. ' + myNum); + } + return function () { + return _.map(this.getMyNumbers(), repeatMyNum1.bind(this)); + }; +}); +``` + +## rt-virtual +This directive creates as a virtual node, which will not be rendered to the DOM, but can still be used as a root for directives, e.g. `rt-if` and `rt-repeat`. + +###### Sample: +For instance, to repeat several nodes at once without a shared root for each instance: +```html + +``` + +##### Compiled: +```javascript +define([ + 'react/addons', + 'lodash' +], function (React, _) { + 'use strict'; + function repeatN1(n, nIndex) { + return [ + React.createElement('li', {}, n), + React.createElement('li', {}, n * 2) + ]; + } + return function () { + return React.createElement.apply(this, [ + 'ul', + {}, + _.map([ + 1, + 2, + 3 + ], repeatN1.bind(this)) + ]); + }; +}); +``` +## rt-scope +This directive creates a new JavaScript scope by creating a new method and invoking it with its current context. The syntax is `rt-scope="expr1 as var1; expr2 as var2`. +This allows for a convenient shorthand to make the code more readable. It also helps to execute an expression only once per scope. + +###### Sample: +```html +
+
{rptIndex}{separator} {val}
+
'rpt' exists here, but not 'separator' and 'val'
+
+``` +###### Compiled: +```javascript +define([ + 'react', + 'lodash' +], function (React, _) { + 'use strict'; + function scopeSeparatorVal1(rpt, rptIndex, separator, val) { + return React.DOM.div({}, rptIndex + separator + ' ' + val); + } + function repeatRpt2(rpt, rptIndex) { + return React.DOM.div({}, scopeSeparatorVal1.apply(this, [ + rpt, + rptIndex, + ')', + rpt.val + ]), React.DOM.div({}, '\'rpt\' exists here, but not \'separator\' and \'val\'')); + } + return function () { + return _.map(array, repeatRpt2.bind(this)); + }; +}); +``` + +Subsequent expressions may reference preceding variables, since generated code declares each alias as a `var` (as opposed to a function parameter, which get bound to formal parameter names only after evaluation), +so you can do stuff like + +```html +
+``` + +When used with `rt-if`, the `rt-if` condition is evaluated first, and only if it is truthy, the `rt-scope` mappings are processed. This means you can write things like +```html +
+``` + +without risking accessing a field on an `undefined`, or doing something ugly like `user.profile && user.profile.image as image`. + +When used with `rt-repeat`, the `rt-scope` is evaluated for every iteration, so that iteration's `item` and `itemIndex` are in scope. + +## rt-props +rt-props is used to inject properties into an element programmatically. It will merge the properties with the properties received in the template. +This option allows you to build properties based on external logic and pass them to the template. It is also useful when passing properties set on the component to an element within the template. +The expected value of this attribute is an expression returning an object. The keys will be the property name, and the values will be the property values. + +###### Sample: +```html + +``` +###### Compiled: +```javascript +define([ + 'react', + 'lodash' +], function (React, _) { + 'use strict'; + return function () { + return React.DOM.input(_.merge({}, { + 'style': { + height: '10px', + width: '3px' + } + }, { + style: { width: '5px' }, + type: 'text' + })); + }; +}); +``` + +## rt-class +To reduce the boilerplate code when setting class names programatically, you can use the rt-class directive. It expects a JSON object with keys as class names, and a Boolean as the value. +If the value is true, the class name will be included. + +

Note the following:
+1. In React templates, you can use the "class" attribute as you would in HTML.
+2. If you use both class and rt-class on the same HTML element, they get merged. + +###### Sample: +```html +

+ These are logically equivalent +
Reference
+
Inline
+
Using the class attribute
+
+``` +###### Compiled: +```javascript +define([ + 'react', + 'lodash' +], function (React, _) { + 'use strict'; + function scopeClasses1(classes) { + return React.DOM.div({}, 'These are logically equivalent', React.DOM.div({ 'className': React.addons.classSet(classes) }, 'Reference'), React.DOM.div({ + 'className': React.addons.classSet({ + blue: true, + selected: this.isSelected() + }) + }, 'Inline'), React.DOM.div({ 'className': 'blue' + this.isSelected() ? ' selected' : '' }, 'Using the class attribute')); + } + return function () { + return scopeClasses1.apply(this, [{ + blue: true, + selected: this.isSelected() + }]); + }; +}); +``` + +## rt-include +Optionally choose to extract static contents out of rt files.
+rt-include is a "macro" that takes a text file (e.g svg/html/xml) and injects it into the file as if it was part of the original markup. + +###### Sample: +given `main.rt`: +```html +
+ +
+``` + +and `my-icon.svg`: +```html + + + +``` + +is equivalent to: +```html +
+ + + +
+``` + +## rt-pre + +When using the option `--normalize-html-whitespace` it allows to override the whitespace removal behaviour on a specific tag. + +###### Sample: +given `main.rt`: +```html + + here repeating whitespaces are preserved + even if --normalize-html-whitespace is on + + + here repeating whitespaces are removed + if --normalize-html-whitespace is on + +``` + +`rt-pre` is applied automatically on `
` and `