diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..0604d02
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,44 @@
+# Logs
+logs
+*.log
+.idea
+.vscode
+.DS_Store
+**/.DS_Store
+
+# Runtime data
+pids
+*.pid
+*.seed
+
+# Directory for instrumented libs generated by jscoverage/JSCover
+/lib-cov
+
+# Coverage directory used by tools like istanbul
+/coverage
+
+# Dependency directory
+# Commenting this out is preferred by some people, see
+# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
+node_modules
+
+# used for karma unit test coverage
+test/coverage
+
+# Users Environment Variables
+.lock-wscript
+
+# Server
+/dist/
+
+# Static files
+
+/bower_components/
+/web_modules/
+
+# Typings
+/typings/browser
+/typings/main
+/typings/browser.d.ts
+/typings/main.d.ts
+/tsd_typings
diff --git a/browser.ts b/browser.ts
deleted file mode 100644
index b626423..0000000
--- a/browser.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './src/browser/preboot_browser';
diff --git a/buildtasks/clean_task.js b/buildtasks/clean_task.js
new file mode 100644
index 0000000..83c3074
--- /dev/null
+++ b/buildtasks/clean_task.js
@@ -0,0 +1,12 @@
+var gulp = require('gulp');
+var del = require('del');
+
+module.exports = function (opts) {
+ gulp.task('clean', function() {
+ return del('dist', function (err, paths) {
+ return paths.length <= 0 ?
+ console.log('Nothing to clean.') :
+ console.log('Deleted folders:\n', paths.join('\n'));
+ });
+ });
+};
diff --git a/buildtasks/example_task.js b/buildtasks/example_task.js
new file mode 100644
index 0000000..289dcf5
--- /dev/null
+++ b/buildtasks/example_task.js
@@ -0,0 +1,69 @@
+var gulp = require('gulp');
+var size = require('gulp-size');
+
+module.exports = function (opts) {
+
+ // build version of preboot to be used in a simple example
+ gulp.task('example.build', [ 'tsc' ], function() {
+ var exec = require('child_process').exec;
+ var distExampleDir = 'dist/example';
+
+ // need to clear out preboot in require cache for when we are watching
+ for (var key in require.cache) {
+ if (key.indexOf(opts.distDir) >= 0) {
+ delete require.cache[key];
+ }
+ }
+
+ // now pull in the latest preboot code
+ var preboot = require(opts.prebootNode);
+
+ // copy static files to dist
+ exec('mkdir -p ./dist');
+ exec('mkdir -p ./' + distExampleDir);
+ exec('cp -fR example/. ' + distExampleDir);
+
+ return preboot.getBrowserCodeStream({
+ appRoot: 'app', // selector for root element
+ freeze: 'spinner', // show spinner w button click & freeze page
+ replay: 'rerender', // rerender replay strategy
+ buffer: true, // client app will write to hidden div until bootstrap complete
+ debug: true,
+ uglify: false,
+ presets: [ 'keyPress', 'buttonPress', 'focus' ]
+ }).
+ pipe(size()).
+ pipe(gulp.dest(distExampleDir));
+ });
+
+ gulp.task('example', [ 'example.build' ], function() {
+ var express = require('express');
+ var livereload = require('connect-livereload');
+ var reloader = require('gulp-livereload');
+ var serveStatic = require('serve-static');
+ var exec = require('child_process').exec;
+ var open = require('open');
+ var server = express();
+ var LIVERELOAD_PORT = 35729;
+ var PORT = 3000;
+
+ server.use(livereload({
+ port: LIVERELOAD_PORT
+ }));
+
+ server.use(serveStatic('dist/example'));
+
+ server.listen(PORT);
+ reloader.listen({
+ port: LIVERELOAD_PORT,
+ reloadPage: '/preboot_example.html'
+ });
+ open('http://localhost:3000/preboot_example.html');
+
+ exec('tsc -w');
+ gulp.watch(opts.tsFiles, [ 'example.build' ]);
+ gulp.watch('dist/example/preboot.js', function () {
+ reloader.reload();
+ });
+ });
+};
diff --git a/buildtasks/lint_task.js b/buildtasks/lint_task.js
new file mode 100644
index 0000000..d20ee3e
--- /dev/null
+++ b/buildtasks/lint_task.js
@@ -0,0 +1,15 @@
+var gulp = require('gulp');
+var tslint = require('gulp-tslint');
+var path = require('path');
+
+module.exports = function (opts) {
+ gulp.task('lint', function () {
+ var tslintConfig = require(path.join(opts.rootDir, 'tslint.json'));
+
+ return gulp.src(opts.tsFiles).
+ pipe(tslint({
+ configuration: tslintConfig
+ })).
+ pipe(tslint.report('verbose'));
+ });
+};
diff --git a/buildtasks/test_task.js b/buildtasks/test_task.js
new file mode 100644
index 0000000..97d0217
--- /dev/null
+++ b/buildtasks/test_task.js
@@ -0,0 +1,68 @@
+var gulp = require('gulp');
+var jasmine = require('gulp-jasmine');
+var browserify = require('browserify');
+var path = require('path');
+var vinylSourceStream = require('vinyl-source-stream');
+var karma = require('karma');
+
+module.exports = function (opts) {
+
+ gulp.task('test', [
+ 'jasmine',
+ 'karma'
+ ]);
+
+ gulp.task('jasmine', [ 'tsc' ], function () {
+ return gulp.src(opts.testFiles).
+ pipe(jasmine({
+ verbose: true,
+ includeStackTrace: true
+ }));
+ });
+
+ // build version of preboot to be used for karma testing
+ gulp.task('karma.build', [ 'tsc' ], function () {
+ var karmaEntryPoint = path.join(opts.distDir, 'test/preboot_karma');
+ var browserRoot = path.join(opts.distDir, 'src/browser');
+ var karmaDest = path.join(opts.distDir, 'karma');
+
+ var b = browserify({
+ entries: [karmaEntryPoint],
+ basedir: browserRoot,
+ browserField: false
+ });
+
+ return b.bundle().
+ pipe(vinylSourceStream('preboot_karma.js')).
+ pipe(gulp.dest(karmaDest));
+ });
+
+ gulp.task('karma', ['karma.build'], function (done) {
+ var karmaCode = path.join(opts.distDir, 'karma/preboot_karma.js');
+ var karmaConfig = {
+ port: 9201,
+ runnerPort: 9301,
+ captureTimeout: 20000,
+ growl: true,
+ colors: true,
+ browsers: [
+ 'PhantomJS'
+ ],
+ reporters: [
+ 'progress'
+ ],
+ plugins: [
+ 'karma-jasmine',
+ 'karma-phantomjs-launcher',
+ 'karma-chrome-launcher'
+ ],
+ frameworks: ['jasmine'],
+ singleRun: true,
+ autoWatch: false,
+ files: [karmaCode]
+ };
+
+ var server = new karma.Server(karmaConfig, done);
+ return server.start();
+ });
+};
diff --git a/buildtasks/tsc_task.js b/buildtasks/tsc_task.js
new file mode 100644
index 0000000..fe8d2e7
--- /dev/null
+++ b/buildtasks/tsc_task.js
@@ -0,0 +1,16 @@
+var gulp = require('gulp');
+var size = require('gulp-size');
+var typescript = require('gulp-typescript');
+var path = require('path');
+
+module.exports = function (opts) {
+ gulp.task('tsc', [ 'clean' ], function () {
+ var tsConfig = path.join(opts.rootDir, 'tsconfig.json');
+ var tsProject = typescript.createProject(tsConfig);
+
+ return tsProject.src().
+ pipe(typescript(tsProject)).
+ pipe(size()).
+ pipe(gulp.dest(tsProject.config.compilerOptions.outDir));
+ });
+};
diff --git a/buildtasks/watch_task.js b/buildtasks/watch_task.js
new file mode 100644
index 0000000..d13fe6e
--- /dev/null
+++ b/buildtasks/watch_task.js
@@ -0,0 +1,8 @@
+var gulp = require('gulp');
+
+module.exports = function (opts) {
+ gulp.task('watch', function(){
+ gulp.watch(opts.tsFiles, ['tsc']);
+ gulp.watch(opts.testFiles, ['jasmine']);
+ });
+};
diff --git a/example/preboot.css b/example/preboot.css
new file mode 100644
index 0000000..3c1be2c
--- /dev/null
+++ b/example/preboot.css
@@ -0,0 +1,69 @@
+/**
+ *
+ * This is a same CSS file for overlay and spinner. This can/should
+ * be overriden/customized to suit your needs
+ */
+
+.preboot-overlay {
+ background: grey;
+ opacity: .27;
+}
+
+@keyframes spin {
+ to { transform: rotate(1turn); }
+}
+
+.preboot-spinner {
+ position: relative;
+ display: inline-block;
+ width: 5em;
+ height: 5em;
+ margin: 0 .5em;
+ font-size: 12px;
+ text-indent: 999em;
+ overflow: hidden;
+ animation: spin 1s infinite steps(8);
+}
+
+.preboot-spinner.small {
+ font-size: 6px;
+}
+
+.preboot-spinner.large {
+ font-size: 24px;
+}
+
+.preboot-spinner:before,
+.preboot-spinner:after,
+.preboot-spinner > div:before,
+.preboot-spinner > div:after {
+ content: '';
+ position: absolute;
+ top: 0;
+ left: 2.25em; /* (container width - part width)/2 */
+ width: .5em;
+ height: 1.5em;
+ border-radius: .2em;
+ background: #eee;
+ box-shadow: 0 3.5em #eee; /* container height - part height */
+ transform-origin: 50% 2.5em; /* container height / 2 */
+}
+
+.preboot-spinner:before {
+ background: #555;
+}
+
+.preboot-spinner:after {
+ transform: rotate(-45deg);
+ background: #777;
+}
+
+.preboot-spinner > div:before {
+ transform: rotate(-90deg);
+ background: #999;
+}
+
+.preboot-spinner > div:after {
+ transform: rotate(-135deg);
+ background: #bbb;
+}
diff --git a/example/preboot_example.html b/example/preboot_example.html
new file mode 100644
index 0000000..126b252
--- /dev/null
+++ b/example/preboot_example.html
@@ -0,0 +1,72 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/gulpfile.js b/gulpfile.js
new file mode 100644
index 0000000..0b9490e
--- /dev/null
+++ b/gulpfile.js
@@ -0,0 +1,23 @@
+var gulp = require('gulp');
+var path = require('path');
+var fs = require('fs');
+var rootDir = __dirname;
+
+// config values passed into every gulp task file
+var buildConfig = {
+ rootDir: rootDir,
+ tsFiles: ['src/**/*.ts', 'test/**/*.ts'],
+ testFiles: 'dist/test/**/*_spec.js',
+ distDir: path.join(rootDir, 'dist'),
+ prebootBrowser: path.join(rootDir, 'dist/src/browser/preboot_browser'),
+ prebootNode: path.join(rootDir, 'dist/src/node/preboot_node')
+};
+
+// dynamically load in all the build task files
+var buildtasksDir = path.join(buildConfig.rootDir, 'buildtasks');
+var buildtaskFiles = fs.readdirSync(buildtasksDir) || [];
+buildtaskFiles.forEach(function (buildtaskFile) {
+ var buildtaskPath = path.join(buildtasksDir, buildtaskFile);
+ var buildtask = require(buildtaskPath);
+ buildtask(buildConfig);
+});
diff --git a/package.json b/package.json
index 074018c..82b30fc 100644
--- a/package.json
+++ b/package.json
@@ -1,13 +1,12 @@
{
"name": "preboot",
- "version": "1.1.3",
+ "version": "2.0.0",
"description": "Record and play back browser events",
- "main": "dist/server.js",
- "browser": "dist/browser.js",
- "typings": "preboot.d.ts",
+ "main": "dist/src/preboot_node.js",
+ "browser": "dist/src/preboot_browser.js",
+ "typings": "src/node/preboot_node.d.ts",
"scripts": {
- "build": "tsc || true",
- "prepublish": "npm run build"
+ "build": "gulp tsc"
},
"repository": {
"type": "git",
@@ -25,23 +24,38 @@
},
"homepage": "https://github.com/angular/universal/tree/master/modules/preboot",
"devDependencies": {
- "gulp-jasmine": "^2.1.0",
- "jasmine": "^2.3.2",
- "jasmine-reporters": "^2.0.7",
- "jasmine-spec-reporter": "^2.4.0",
- "karma": "^0.13.11",
- "karma-jasmine": "^0.3.6"
- },
- "dependencies": {
- "browserify": "^11.2.0",
- "event-stream": "^3.3.2",
- "gulp": "^3.9.0",
+ "connect-livereload": "^0.5.4",
+ "del": "^2.2.0",
+ "express": "^4.13.4",
"gulp-insert": "^0.5.0",
+ "gulp-jasmine": "^2.3.0",
+ "gulp-livereload": "^3.8.1",
"gulp-rename": "^1.2.2",
- "gulp-uglify": "^1.4.2",
- "lodash": "^3.10.1",
- "q": "^1.4.1",
+ "gulp-size": "^2.0.0",
+ "gulp-tslint": "^4.3.2",
+ "gulp-typescript": "^2.12.0",
+ "gulp-uglify": "^1.5.3",
+ "jasmine": "^2.4.1",
+ "jasmine-reporters": "^2.1.1",
+ "karma": "^0.13.21",
+ "karma-browserify": "^5.0.2",
+ "karma-chrome-launcher": "^0.2.2",
+ "karma-jasmine": "^0.3.7",
+ "karma-phantomjs-launcher": "^1.0.0",
+ "open": "0.0.5",
+ "phantomjs-prebuilt": "^2.1.4",
+ "serve-static": "^1.10.2",
+ "tslint": "^3.5.0",
+ "typescript": "^1.8.2",
"vinyl-buffer": "^1.0.0",
- "vinyl-source-stream": "^1.1.0"
+ "vinyl-source-stream": "^1.1.0",
+ "watchify": "^3.7.0"
+ },
+ "dependencies": {
+ "browserify": "^13.0.0",
+ "event-stream": "^3.3.2",
+ "gulp": "^3.9.1",
+ "lodash": "^4.5.1",
+ "q": "^1.4.1"
}
}
diff --git a/server.ts b/server.ts
deleted file mode 100644
index aef61dd..0000000
--- a/server.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './src/server/preboot_server';
diff --git a/src/browser/dom.ts b/src/browser/dom.ts
index 7b139fc..9796578 100644
--- a/src/browser/dom.ts
+++ b/src/browser/dom.ts
@@ -143,7 +143,7 @@ export function getSelection(node: Element): CursorSelection {
};
// if browser support selectionStart on node (Chrome, FireFox, IE9+)
- if (node && (node.selectionStart || node.selectionStart === 0)) {
+ if (node && node.hasOwnProperty('selectionStart') && (node.selectionStart || node.selectionStart === 0)) {
selection.start = node.selectionStart;
selection.end = node.selectionEnd;
selection.direction = node.selectionDirection;
@@ -167,7 +167,7 @@ export function setSelection(node: Element, selection: CursorSelection) {
}
// set selection if a modern browser (i.e. IE9+, etc.)
- if (node && node.setSelectionRange && selection) {
+ if (node && node.hasOwnProperty('setSelectionRange') && node.setSelectionRange && selection) {
node.setSelectionRange(selection.start, selection.end, selection.direction);
}
}
diff --git a/src/browser/event_manager.ts b/src/browser/event_manager.ts
index e2ab317..fd4e779 100644
--- a/src/browser/event_manager.ts
+++ b/src/browser/event_manager.ts
@@ -73,8 +73,8 @@ export function getEventHandler(preboot: PrebootRef, strategy: ListenStrategy, n
} else {
preboot.activeNode = {
node: event.target,
- nodeKey: preboot.dom.getNodeKey(event.target, preboot.dom.state.serverRoot)
- }
+ nodeKey: preboot.dom.getNodeKey(event.target, preboot.dom.state.serverRoot)
+ };
}
}
@@ -89,7 +89,7 @@ export function getEventHandler(preboot: PrebootRef, strategy: ListenStrategy, n
if (eventName === 'keyup' && event.which === 13 && node.attributes['(keyup.enter)']) {
preboot.dom.dispatchGlobalEvent('PrebootFreeze');
}
-
+
// we will record events for later replay unless explicitly marked as doNotReplay
if (!strategy.doNotReplay) {
let eventObj: PrebootEvent = {
@@ -98,7 +98,7 @@ export function getEventHandler(preboot: PrebootRef, strategy: ListenStrategy, n
name: eventName,
time: preboot.time || (new Date()).getTime()
};
- // TODO(gdi2290): better way to grab serverRoot without buffer
+
if (preboot &&
preboot.dom &&
preboot.dom.getNodeKey &&
@@ -106,7 +106,6 @@ export function getEventHandler(preboot: PrebootRef, strategy: ListenStrategy, n
preboot.dom.state.serverRoot) {
eventObj.nodeKey = preboot.dom.getNodeKey(node, preboot.dom.state.serverRoot);
-
}
state.events.push(eventObj);
diff --git a/src/browser/listen/listen_by_event_bindings.ts b/src/browser/listen/listen_by_event_bindings.ts
index 0bba67a..38753ce 100644
--- a/src/browser/listen/listen_by_event_bindings.ts
+++ b/src/browser/listen/listen_by_event_bindings.ts
@@ -44,7 +44,7 @@ export function addNodeEvents(node: any) {
let matchedEventName = name.match(ngEventPattern);
// if attribute name is an Angular 2 event binding
- if (matchedEventName.length > 0) {
+ if (matchedEventName && matchedEventName.length > 0) {
state.nodeEvents.push({
node: node,
eventName: matchedEventName.pop()
diff --git a/src/browser/replay/replay_after_rerender.ts b/src/browser/replay/replay_after_rerender.ts
index e459adc..52c33b6 100644
--- a/src/browser/replay/replay_after_rerender.ts
+++ b/src/browser/replay/replay_after_rerender.ts
@@ -17,11 +17,8 @@ export function replayEvents(preboot: PrebootRef, strategy: ReplayStrategy, even
for (let eventData of events) {
let event = eventData.event;
let serverNode = eventData.node;
- let clientNode = preboot.dom.findClientNode(serverNode);
- // TODO(gdi2290): better way query root without buffer
- if (!clientNode) {
- clientNode = preboot.dom.findClientNode(serverNode, eventData.nodeKey);
- }
+ let nodeKey = eventData.nodeKey;
+ let clientNode = preboot.dom.findClientNode(serverNode, nodeKey);
// if client node found, need to explicitly set value and then dispatch event
if (clientNode) {
diff --git a/src/server/browser_code_generator.ts b/src/node/browser_code_generator.ts
similarity index 97%
rename from src/server/browser_code_generator.ts
rename to src/node/browser_code_generator.ts
index 4bcda3d..e3b4cd7 100644
--- a/src/server/browser_code_generator.ts
+++ b/src/node/browser_code_generator.ts
@@ -38,7 +38,7 @@ export function ignoreUnusedStrategies(
/**
* Generate browser code as a readable stream for preboot based on the input options
*/
-export function getBrowserCodeStream(opts?: PrebootOptions): NodeJS.ReadableStream {
+export function getBrowserCodeStream(opts?: PrebootOptions): any {
opts = normalize(opts);
let bOpts = {
@@ -88,7 +88,7 @@ export function getBrowserCode(opts?: PrebootOptions, done?: Function): any {
if (browserCodeCache[cacheKey]) {
return Q.when(browserCodeCache[cacheKey]);
}
-
+
// get the browser code
getBrowserCodeStream(opts)
.pipe(eventStream.map(function(file, cb) {
diff --git a/src/server/normalize.ts b/src/node/normalize.ts
similarity index 100%
rename from src/server/normalize.ts
rename to src/node/normalize.ts
diff --git a/preboot.d.ts b/src/node/preboot_node.d.ts
similarity index 50%
rename from preboot.d.ts
rename to src/node/preboot_node.d.ts
index fb2239e..5515d50 100644
--- a/preboot.d.ts
+++ b/src/node/preboot_node.d.ts
@@ -1,4 +1,2 @@
export function getBrowserCode(opts: any): any;
export function getBrowserCodeStream(opts: any): any;
-export function getClientCode(opts: any): any;
-export function getClientCodeStream(opts: any): any;
diff --git a/src/server/preboot_server.ts b/src/node/preboot_node.ts
similarity index 100%
rename from src/server/preboot_server.ts
rename to src/node/preboot_node.ts
diff --git a/src/server/presets.ts b/src/node/presets.ts
similarity index 96%
rename from src/server/presets.ts
rename to src/node/presets.ts
index d643d14..ad33537 100644
--- a/src/server/presets.ts
+++ b/src/node/presets.ts
@@ -17,7 +17,7 @@ export default {
opts.listen.push({
name: 'selectors',
eventsBySelector: {
- 'input[type="checkbox"],input[type="radio"],select,option': ['change']
+ 'select,option': ['change']
}
});
},
diff --git a/src/server/utils.ts b/src/node/utils.ts
similarity index 100%
rename from src/server/utils.ts
rename to src/node/utils.ts
diff --git a/test/browser/buffer_manager_spec.ts b/test/browser/buffer_manager_spec.ts
index 32a077c..a805e5d 100644
--- a/test/browser/buffer_manager_spec.ts
+++ b/test/browser/buffer_manager_spec.ts
@@ -1,5 +1,3 @@
-///
-
import {state, prep, switchBuffer} from '../../src/browser/buffer_manager';
describe('buffer_manager', function () {
diff --git a/test/browser/dom_spec.ts b/test/browser/dom_spec.ts
index 4d291ad..bb366fe 100644
--- a/test/browser/dom_spec.ts
+++ b/test/browser/dom_spec.ts
@@ -1,5 +1,3 @@
-///
-
import * as dom from '../../src/browser/dom';
describe('dom', function () {
diff --git a/test/browser/event_manager_spec.ts b/test/browser/event_manager_spec.ts
index faea740..8ceaf79 100644
--- a/test/browser/event_manager_spec.ts
+++ b/test/browser/event_manager_spec.ts
@@ -1,5 +1,3 @@
-///
-
import * as eventManager from '../../src/browser/event_manager';
describe('event_manager', function () {
diff --git a/test/browser/freeze/freeze_with_spinner_spec.ts b/test/browser/freeze/freeze_with_spinner_spec.ts
index eab5c89..fbde9d3 100644
--- a/test/browser/freeze/freeze_with_spinner_spec.ts
+++ b/test/browser/freeze/freeze_with_spinner_spec.ts
@@ -1,5 +1,3 @@
-///
-
import {state, prep, cleanup} from '../../../src/browser/freeze/freeze_with_spinner';
describe('freeze_with_spinner', function () {
diff --git a/test/browser/listen/listen_by_attributes_spec.ts b/test/browser/listen/listen_by_attributes_spec.ts
index df40673..87a4e6f 100644
--- a/test/browser/listen/listen_by_attributes_spec.ts
+++ b/test/browser/listen/listen_by_attributes_spec.ts
@@ -1,5 +1,3 @@
-///
-
import {getNodeEvents} from '../../../src/browser/listen/listen_by_attributes';
describe('listen_by_attributes', function () {
diff --git a/test/browser/listen/listen_by_event_bindings_spec.ts b/test/browser/listen/listen_by_event_bindings_spec.ts
index 15fe745..461d916 100644
--- a/test/browser/listen/listen_by_event_bindings_spec.ts
+++ b/test/browser/listen/listen_by_event_bindings_spec.ts
@@ -1,5 +1,3 @@
-///
-
import {state, walkDOM, addNodeEvents, getNodeEvents} from '../../../src/browser/listen/listen_by_event_bindings';
describe('listen_by_event_bindings', function () {
diff --git a/test/browser/listen/listen_by_selectors_spec.ts b/test/browser/listen/listen_by_selectors_spec.ts
index 889d542..17d9fb1 100644
--- a/test/browser/listen/listen_by_selectors_spec.ts
+++ b/test/browser/listen/listen_by_selectors_spec.ts
@@ -1,5 +1,3 @@
-///
-
import {getNodeEvents} from '../../../src/browser/listen/listen_by_selectors';
describe('listen_by_selectors', function () {
diff --git a/test/browser/log_spec.ts b/test/browser/log_spec.ts
index 9183a76..bfcd460 100644
--- a/test/browser/log_spec.ts
+++ b/test/browser/log_spec.ts
@@ -1,5 +1,3 @@
-///
-
import {log} from '../../src/browser/log';
describe('log', function () {
diff --git a/test/browser/replay/replay_after_hydrate_spec.ts b/test/browser/replay/replay_after_hydrate_spec.ts
index cdefd63..0f62d22 100644
--- a/test/browser/replay/replay_after_hydrate_spec.ts
+++ b/test/browser/replay/replay_after_hydrate_spec.ts
@@ -1,5 +1,3 @@
-///
-
import {replayEvents} from '../../../src/browser/replay/replay_after_hydrate';
describe('replay_after_hydrate', function () {
diff --git a/test/browser/replay/replay_after_rerender_spec.ts b/test/browser/replay/replay_after_rerender_spec.ts
index 890eace..8c01fdf 100644
--- a/test/browser/replay/replay_after_rerender_spec.ts
+++ b/test/browser/replay/replay_after_rerender_spec.ts
@@ -1,5 +1,3 @@
-///
-
import {replayEvents} from '../../../src/browser/replay/replay_after_rerender';
describe('replay_after_rerender', function () {
diff --git a/test/server/browser_code_generator_spec.ts b/test/node/browser_code_generator_spec.ts
similarity index 93%
rename from test/server/browser_code_generator_spec.ts
rename to test/node/browser_code_generator_spec.ts
index 8e4a57e..5aa0c5b 100644
--- a/test/server/browser_code_generator_spec.ts
+++ b/test/node/browser_code_generator_spec.ts
@@ -1,7 +1,5 @@
-///
-
import * as browserify from 'browserify';
-import {ignoreUnusedStrategies, getBrowserCode} from '../../src/server/browser_code_generator';
+import {ignoreUnusedStrategies, getBrowserCode} from '../../src/node/browser_code_generator';
describe('clientCodeGenerator', function () {
diff --git a/test/server/normalize_spec.ts b/test/node/normalize_spec.ts
similarity index 98%
rename from test/server/normalize_spec.ts
rename to test/node/normalize_spec.ts
index 38f95f2..996cbc4 100644
--- a/test/server/normalize_spec.ts
+++ b/test/node/normalize_spec.ts
@@ -1,6 +1,4 @@
-///
-
-import {normalize, normalizers, defaultFreezeStyles} from '../../src/server/normalize';
+import {normalize, normalizers, defaultFreezeStyles} from '../../src/node/normalize';
describe('normalize', function () {
diff --git a/test/server/presets_spec.ts b/test/node/presets_spec.ts
similarity index 94%
rename from test/server/presets_spec.ts
rename to test/node/presets_spec.ts
index b00c788..d5341c7 100644
--- a/test/server/presets_spec.ts
+++ b/test/node/presets_spec.ts
@@ -1,6 +1,4 @@
-///
-
-import presetFns from '../../src/server/presets';
+import presetFns from '../../src/node/presets';
/**
* These tests are pretty basic, but just have something in
@@ -27,11 +25,8 @@ describe('presets', function () {
}
]
};
- presetFns.keyPress(opts);
-
- console.log(JSON.stringify(opts));
- console.log(JSON.stringify(expected));
+ presetFns.keyPress(opts);
expect(opts).toEqual(expected);
});
});
diff --git a/test/server/utils_spec.ts b/test/node/utils_spec.ts
similarity index 86%
rename from test/server/utils_spec.ts
rename to test/node/utils_spec.ts
index c0ca66b..168c07e 100644
--- a/test/server/utils_spec.ts
+++ b/test/node/utils_spec.ts
@@ -1,6 +1,4 @@
-///
-
-import {stringifyWithFunctions} from '../../src/server/utils';
+import {stringifyWithFunctions} from '../../src/node/utils';
/* tslint:disable:eofline no-trailing-whitespace */
/**
diff --git a/tsconfig.json b/tsconfig.json
index 956ed7a..58a089d 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,18 +1,36 @@
{
"compilerOptions": {
- "target": "es5",
- "module": "commonjs",
- "declaration": false,
+ "target": "es5",
+ "module": "commonjs",
+ "declaration": false,
"noImplicitAny": false,
"removeComments": false,
"noLib": false,
+ "moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
- "sourceMap": true,
+ "sourceMap": true,
"listFiles": false,
- "outDir": "dist"
+ "outDir": "dist"
},
"exclude": [
- "test"
- ]
+ "typings/browser",
+ "typings/browser.d.ts",
+ "node_modules",
+ "dist"
+ ],
+ "formatCodeOptions": {
+ "indentSize": 2,
+ "tabSize": 2,
+ "newLineCharacter": "\r\n",
+ "convertTabsToSpaces": true,
+ "insertSpaceAfterCommaDelimiter": true,
+ "insertSpaceAfterSemicolonInForStatements": true,
+ "insertSpaceBeforeAndAfterBinaryOperators": true,
+ "insertSpaceAfterKeywordsInControlFlowStatements": true,
+ "insertSpaceAfterFunctionKeywordForAnonymousFunctions": true,
+ "insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false,
+ "placeOpenBraceOnNewLineForFunctions": false,
+ "placeOpenBraceOnNewLineForControlBlocks": false
+ }
}
diff --git a/tslint.json b/tslint.json
new file mode 100644
index 0000000..4a0a9c5
--- /dev/null
+++ b/tslint.json
@@ -0,0 +1,52 @@
+{
+ "rules": {
+ "comment-format": [true, "check-space"],
+ "class-name": false,
+ "curly": true,
+ "eofline": true,
+ "forin": true,
+ "indent": [true, "spaces"],
+ "label-position": true,
+ "label-undefined": true,
+ "max-line-length": [true, 140],
+ "no-arg": true,
+ "no-bitwise": false,
+ "no-console": [true,
+ "debug",
+ "info",
+ "trace"
+ ],
+ "no-construct": true,
+ "no-debugger": true,
+ "no-duplicate-key": true,
+ "no-duplicate-variable": true,
+ "no-empty": false,
+ "no-eval": true,
+ "no-string-literal": true,
+ "no-switch-case-fall-through": true,
+ "no-trailing-whitespace": false,
+ "no-unused-expression": true,
+ "no-unused-variable": false,
+ "no-unreachable": true,
+ "no-use-before-declare": true,
+ "no-var-keyword": false,
+ "one-line": [true,
+ "check-open-brace",
+ "check-catch",
+ "check-else",
+ "check-whitespace"
+ ],
+ "quotemark": false,
+ "radix": true,
+ "semicolon": true,
+ "triple-equals": [true, "allow-null-check"],
+ "variable-name": false,
+ "whitespace": [true,
+ "check-branch",
+ "check-decl",
+ "check-operator",
+ "check-separator",
+ "check-type"
+ ]
+ }
+}
diff --git a/typings.json b/typings.json
new file mode 100644
index 0000000..2c491d0
--- /dev/null
+++ b/typings.json
@@ -0,0 +1,16 @@
+{
+ "ambientDependencies": {
+ "browserify": "github:DefinitelyTyped/DefinitelyTyped/browserify/browserify.d.ts#abc2bcfb8524b1e027e6298d3348012b5b06eda5",
+ "event-stream": "github:DefinitelyTyped/DefinitelyTyped/event-stream/event-stream.d.ts#14ba891ee5f5bf86d76c0dee99cbafc892febaf8",
+ "gulp-rename": "github:DefinitelyTyped/DefinitelyTyped/gulp-rename/gulp-rename.d.ts#03f12b0f667d29fe8e15c2e5c56f3ed7e10c8eb9",
+ "gulp-uglify": "github:DefinitelyTyped/DefinitelyTyped/gulp-uglify/gulp-uglify.d.ts#ba956a3e6e8ebb82d33548209f793234efac44a2",
+ "jasmine": "github:DefinitelyTyped/DefinitelyTyped/jasmine/jasmine.d.ts#dd638012d63e069f2c99d06ef4dcc9616a943ee4",
+ "lodash": "github:DefinitelyTyped/DefinitelyTyped/lodash/lodash-3.10.d.ts#86dbea8fc37d9473fee465da4f0a21bea4f8cbd9",
+ "node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#48c1e3c1d6baefa4f1a126f188c27c4fefd36bff",
+ "q": "github:DefinitelyTyped/DefinitelyTyped/q/Q.d.ts#4de74cb527395c13ba20b438c3a7a419ad931f1c",
+ "source-map": "github:DefinitelyTyped/DefinitelyTyped/source-map/source-map.d.ts#1c572762b93d4b059d89339867edf54946176361",
+ "uglify-js": "github:DefinitelyTyped/DefinitelyTyped/uglify-js/uglify-js.d.ts#51b587292f2ba85d68939d9c59cf7fa745a6173e",
+ "vinyl-buffer": "github:DefinitelyTyped/DefinitelyTyped/vinyl-buffer/vinyl-buffer.d.ts#1a4b2f0ff98d7b1071474c4ab16f2626d9a62d31",
+ "vinyl-source-stream": "github:DefinitelyTyped/DefinitelyTyped/vinyl-source-stream/vinyl-source-stream.d.ts#6be3aa6317135b9255b000924af9d7cebe3737bf"
+ }
+}