Permalink
Browse files

Run on the new SOA backend infrastructure

  • Loading branch information...
1 parent c1b4ca6 commit 8379bb3b9cf4bdde93fdceaa8cd3dcefce2e3b30 @andreyvit andreyvit committed Jul 8, 2013
Showing with 610 additions and 1,591 deletions.
  1. +7 −124 Shared/gen_src/nodeapp_rpc_router.c
  2. +18 −0 docs/EditorPlugin.md
  3. +11 −0 mac/Classes/Application/LiveReloadAppDelegate.m
  4. +15 −0 mac/Classes/Model/JsonStore.h
  5. +20 −0 mac/Classes/Model/JsonStore.m
  6. +7 −2 mac/Classes/Model/Project.m
  7. +0 −1 node_modules/livereload-new/.gitignore
  8. +0 −11 node_modules/livereload-new/features/startup.feature
  9. +0 −16 node_modules/livereload-new/features/support/running.coffee
  10. +0 −23 node_modules/livereload-new/features/support/world.coffee
  11. +0 −56 node_modules/livereload-new/lib/main.litcoffee
  12. +0 −342 node_modules/livereload-new/lib/rpc.litcoffee
  13. +0 −157 node_modules/livereload-new/lib/services/browser.litcoffee
  14. +0 −14 node_modules/livereload-new/lib/services/dummy.litcoffee
  15. +0 −87 node_modules/livereload-new/lib/services/reloader.litcoffee
  16. +0 −23 node_modules/livereload-new/lib/services/stub.litcoffee
  17. +0 −140 node_modules/livereload-new/lib/services/urloverride.litcoffee
  18. +7 −16 node_modules/livereload-new/package.json
  19. +14 −0 node_modules/livereload-new/src/endpoint.coffee
  20. +23 −0 node_modules/livereload-new/src/main.coffee
  21. +12 −0 node_modules/livereload-new/test/integration_test.coffee
  22. +0 −32 node_modules/livereload-new/test/reloader_test.coffee
  23. +0 −77 node_modules/livereload-new/test/rpc_test.coffee
  24. +0 −72 node_modules/livereload-new/test/support/stubs.coffee
  25. +0 −31 node_modules/livereload-service-browser/Gruntfile.js
  26. +9 −14 node_modules/livereload-service-dummy/Gruntfile.js
  27. +4 −3 node_modules/livereload-service-dummy/package.json
  28. +9 −0 node_modules/livereload-service-dummy/src/dummy.coffee
  29. +0 −12 node_modules/livereload-service-dummy/src/dummy.ts
  30. 0 node_modules/{livereload-service-browser → livereload-service-reloader}/.gitignore
  31. 0 node_modules/{livereload-service-browser → livereload-service-reloader}/.npmignore
  32. 0 node_modules/{livereload-service-browser → livereload-service-reloader}/README.md
  33. +1 −0 node_modules/{livereload-service-browser → livereload-service-reloader}/package.json
  34. +88 −0 node_modules/livereload-service-reloader/src/reloader.coffee
  35. +43 −0 node_modules/livereload-service-reloader/test/reloader_test.coffee
  36. +4 −0 node_modules/livereload-service-server/.gitignore
  37. +2 −0 node_modules/livereload-service-server/.npmignore
  38. +55 −0 node_modules/livereload-service-server/README.md
  39. +22 −0 node_modules/livereload-service-server/package.json
  40. 0 node_modules/{livereload-new → livereload-service-server}/res/livereload.js
  41. +3 −3 ...les/{livereload-service-browser/src/browser.coffee → livereload-service-server/src/server.coffee}
  42. 0 node_modules/{livereload-service-browser → livereload-service-server}/src/urloverride.coffee
  43. +2 −2 ...oad-service-browser/test/browser_test.coffee → livereload-service-server/test/server_test.coffee}
  44. +8 −35 node_modules/livereload-soa/Gruntfile.js
  45. +36 −0 node_modules/livereload-soa/README.md
  46. +14 −0 node_modules/livereload-soa/example/pingpong.coffee
  47. +32 −21 node_modules/livereload-soa/example/pingpong.js
  48. +0 −21 node_modules/livereload-soa/example/pingpong.ts
  49. +0 −15 node_modules/livereload-soa/index.d.ts
  50. +2 −2 node_modules/livereload-soa/index.js
  51. +0 −2 node_modules/livereload-soa/package.json
  52. +0 −35 node_modules/livereload-soa/src/api.ts
  53. +40 −0 node_modules/livereload-soa/src/carrier-node-stream.coffee
  54. +0 −48 node_modules/livereload-soa/src/carrier-node-stream.ts
  55. +61 −0 node_modules/livereload-soa/src/muxer.coffee
  56. +0 −76 node_modules/livereload-soa/src/muxer.ts
  57. +3 −1 node_modules/livereload-soa/src/{services.xcoffee → services.coffee}
  58. +0 −64 node_modules/livereload-soa/src/services.ts
  59. +3 −3 node_modules/livereload-soa/test/muxer_test.js
  60. +1 −1 node_modules/livereload-soa/test/pingpong_test.js
  61. +1 −0 nodeapp/core/src/nodeapp.h
  62. +27 −9 nodeapp/core/src/nodeapp_rpc_common.c
  63. +6 −0 nodeapp/core/src/nodeapp_rpc_protocol.c
@@ -8,135 +8,18 @@ typedef struct {
msg_func_t func;
} msg_entry_t;
-void C_broker__unretain(json_t *data);
-void C_ui__update(json_t *data);
-json_t *C_app__display_popup_message(json_t *data);
-void C_app__reveal_file(json_t *data);
-void C_app__open_url(json_t *data);
-void C_app__terminate(json_t *data);
-json_t *C_preferences__read(json_t *data);
-json_t *C_licensing__verify_receipt(json_t *data);
-void C_mainwnd__set_project_list(json_t *data);
-void C_mainwnd__rpane__set_data(json_t *data);
-void C_app__good_time_to_deliver_news(json_t *data);
-void C_update(json_t *data);
-void C_app__failed_to_start(json_t *data);
-void C_mainwnd__set_connection_status(json_t *data);
-void C_mainwnd__set_change_count(json_t *data);
-void C_projects__notify_changed(json_t *data);
-void C_projects__notify_compilation_started(json_t *data);
-void C_projects__notify_compilation_finished(json_t *data);
-void C_workspace__set_monitoring_enabled(json_t *data);
-void C_app__request_model(json_t *data);
-json_t *C_project__path_of_best_file_matching_path_suffix(json_t *data);
+json_t *C_kernel__on_port_occupied_error(json_t *message);
-json_t *_C_broker__unretain_wrapper(json_t *data) {
- C_broker__unretain(data);
- return NULL;
-}
-
-json_t *_C_ui__update_wrapper(json_t *data) {
- C_ui__update(data);
- return NULL;
-}
-
-json_t *_C_app__reveal_file_wrapper(json_t *data) {
- C_app__reveal_file(data);
- return NULL;
-}
-
-json_t *_C_app__open_url_wrapper(json_t *data) {
- C_app__open_url(data);
- return NULL;
-}
-
-json_t *_C_app__terminate_wrapper(json_t *data) {
- C_app__terminate(data);
- return NULL;
-}
-
-json_t *_C_mainwnd__set_project_list_wrapper(json_t *data) {
- C_mainwnd__set_project_list(data);
- return NULL;
-}
-
-json_t *_C_mainwnd__rpane__set_data_wrapper(json_t *data) {
- C_mainwnd__rpane__set_data(data);
- return NULL;
-}
-
-json_t *_C_app__good_time_to_deliver_news_wrapper(json_t *data) {
- C_app__good_time_to_deliver_news(data);
- return NULL;
-}
-
-json_t *_C_update_wrapper(json_t *data) {
- C_update(data);
- return NULL;
-}
-
-json_t *_C_app__failed_to_start_wrapper(json_t *data) {
- C_app__failed_to_start(data);
- return NULL;
-}
-
-json_t *_C_mainwnd__set_connection_status_wrapper(json_t *data) {
- C_mainwnd__set_connection_status(data);
- return NULL;
-}
-
-json_t *_C_mainwnd__set_change_count_wrapper(json_t *data) {
- C_mainwnd__set_change_count(data);
- return NULL;
-}
-
-json_t *_C_projects__notify_changed_wrapper(json_t *data) {
- C_projects__notify_changed(data);
- return NULL;
-}
-
-json_t *_C_projects__notify_compilation_started_wrapper(json_t *data) {
- C_projects__notify_compilation_started(data);
- return NULL;
-}
-
-json_t *_C_projects__notify_compilation_finished_wrapper(json_t *data) {
- C_projects__notify_compilation_finished(data);
- return NULL;
-}
-
-json_t *_C_workspace__set_monitoring_enabled_wrapper(json_t *data) {
- C_workspace__set_monitoring_enabled(data);
- return NULL;
-}
-
-json_t *_C_app__request_model_wrapper(json_t *data) {
- C_app__request_model(data);
+json_t *C_kernel__log(json_t *message) {
+ const char *text = json_string_value(json_object_get(message, "text"));
+ const char *level = json_string_value(json_object_get(message, "level"));
+ fprintf(stderr, "[Node %s] %s\n", level, text);
return NULL;
}
msg_entry_t entries[] = {
- { "broker.unretain", &_C_broker__unretain_wrapper },
- { "ui.update", &_C_ui__update_wrapper },
- { "app.display_popup_message", &C_app__display_popup_message },
- { "app.reveal_file", &_C_app__reveal_file_wrapper },
- { "app.open_url", &_C_app__open_url_wrapper },
- { "app.terminate", &_C_app__terminate_wrapper },
- { "preferences.read", &C_preferences__read },
- { "licensing.verify_receipt", &C_licensing__verify_receipt },
- { "mainwnd.set_project_list", &_C_mainwnd__set_project_list_wrapper },
- { "mainwnd.rpane.set_data", &_C_mainwnd__rpane__set_data_wrapper },
- { "app.good_time_to_deliver_news", &_C_app__good_time_to_deliver_news_wrapper },
- { "update", &_C_update_wrapper },
- { "app.failed_to_start", &_C_app__failed_to_start_wrapper },
- { "mainwnd.set_connection_status", &_C_mainwnd__set_connection_status_wrapper },
- { "mainwnd.set_change_count", &_C_mainwnd__set_change_count_wrapper },
- { "projects.notify_changed", &_C_projects__notify_changed_wrapper },
- { "projects.notify_compilation_started", &_C_projects__notify_compilation_started_wrapper },
- { "projects.notify_compilation_finished", &_C_projects__notify_compilation_finished_wrapper },
- { "workspace.set_monitoring_enabled", &_C_workspace__set_monitoring_enabled_wrapper },
- { "app.request_model", &_C_app__request_model_wrapper },
- { "project.path_of_best_file_matching_path_suffix", &C_project__path_of_best_file_matching_path_suffix },
+ { "kernel.log", C_kernel__log },
+ { "kernel.on-port-occupied-error", C_kernel__on_port_occupied_error },
{ NULL, NULL }
};
View
@@ -0,0 +1,18 @@
+# Writing LiveReload editor plugins
+
+
+## Outputs
+
+ check not-found
+ check broken
+ check found
+ open failed
+ open ok
+
+
+## Exit code
+
+* 9: command-line parsing error
+* 2: command failed
+* 1: negative success (e.g. `--check` haven't found a usable editor)
+* 0: positive success
@@ -44,6 +44,17 @@ void C_update(json_t *arg) {
// ignored for compatibility with the Windows version
}
+json_t *C_kernel__on_port_occupied_error(json_t *message) {
+ int port = json_integer_value(json_object_get(message, "port"));
+
+ NSInteger response = [[NSAlert alertWithMessageText:@"Failed to start: port occupied" defaultButton:@"Quit" alternateButton:@"More Info" otherButton:nil informativeTextWithFormat:@"LiveReload tried to listen on port %d, but it was occupied by another app.\n\nThe following tools are incompatible with LiveReload: guard-livereload; rack-livereload; Sublime Text LiveReload plugin; any other tools that use LiveReload browser extensions.\n\nPlease make sure you're not running any of those tools, and restart LiveReload. If in doubt, contact support@livereload.com.", port] runModal];
+ if (response == NSAlertAlternateReturn) {
+ [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://go.livereload.com/err/port-occupied"]];
+ }
+ [NSApp terminate:nil];
+ return NULL;
+}
+
@interface LiveReloadAppDelegate ()
@@ -0,0 +1,15 @@
+
+#import <Foundation/Foundation.h>
+
+@interface JsonStore : NSObject
+
+@end
+
+
+@protocol JsonConvertible <NSObject>
+
+- (NSDictionary *)memento;
+
+- (void)setMemento:(NSDictionary *)data;
+
+@end
@@ -0,0 +1,20 @@
+
+#import "JsonStore.h"
+
+@interface JsonStore ()
+
+@property(nonatomic, strong) id<JsonConvertible> owner;
+
+@end
+
+@implementation JsonStore
+
+- (id)initWithPath:(NSString *)path owner:(id<JsonConvertible>)owner {
+ self = [super init];
+ if (self) {
+ _owner = [owner retain];
+ }
+ return self;
+}
+
+@end
@@ -519,8 +519,13 @@ - (void)processBatchOfPendingChanges:(NSSet *)pathes {
}
}
- json_t *arg = json_object_3("changes", reloadRequests, "forceFullReload", json_bool(self.disableLiveRefresh), "fullReloadDelay", json_real(_fullPageReloadDelay));
- S_reloader_reload(arg);
+ json_t *message = json_object();
+ json_object_set_new(message, "service", json_string("reloader"));
+ json_object_set_new(message, "command", json_string("reload"));
+ json_object_set_new(message, "changes", reloadRequests);
+ json_object_set_new(message, "forceFullReload", json_bool(self.disableLiveRefresh));
+ json_object_set_new(message, "fullReloadDelay", json_real(_fullPageReloadDelay));
+ nodeapp_rpc_send_json(message);
[[NSNotificationCenter defaultCenter] postNotificationName:ProjectDidDetectChangeNotification object:self];
eventbus_post(project_fs_change_event, NULL);
@@ -1,6 +1,5 @@
*.js
!bin/*.js
-!res/livereload.js
node_modules
npm-debug.log
@@ -1,11 +0,0 @@
-Feature: Startup
- In order to get any value from LiveReload and want purchase it
- As a user of LiveReload
- I want to start the app
-
- Scenario: Startup
- When I start the app
- Then I should see it run
-
- Scenario: Browser refresh
- When I send a reload request
@@ -1,16 +0,0 @@
-{ok, deepEqual} = require 'assert'
-
-module.exports = ->
-
- # TODO: make these steps do something sensible
-
- @When /^I start the app$/, (callback) ->
- @i 'dummy.ping', 42, '$1'
- @o '$1', 42, => callback()
-
- @When /^I should see it run$/, (callback) ->
- callback()
-
- @When /^I send a reload request$/, (callback) ->
- @i 'reloader.reload', { changes: [{ path: 'foo.css' }] }
- setTimeout callback, 50
@@ -1,23 +0,0 @@
-main = require "../../#{process.env.JSLIB or 'lib'}/main"
-rpc = require "../../#{process.env.JSLIB or 'lib'}/rpc"
-
-class World
- constructor: (callback) ->
- @rpc = rpc.createConnection(rpc.createMockTransport())
- main.exposeServices(@rpc)
-
- { @i, @o, @reply } = @rpc.transport
-
- callback()
-
- shutdown: (callback) ->
- @i 'browser.shutdown', {}, '$shutdown-complete'
- @o '$shutdown-complete', null, =>
- @rpc.transport.emit 'end'
- callback()
-
-module.exports = ->
- @World = World
-
- @After (callback) ->
- @shutdown(callback)
@@ -1,56 +0,0 @@
-# LiveReload backend entry point
-
-Invoked by `bin/livereload.js` to process command-line options and launch the backend.
-
-
-## Preamble
-
- debug = require('debug')('livereload:main')
- Path = require 'path'
- rpc = require './rpc'
-
-
-## Run
-
-There are no command-line options at the moment.
-
- exports.run = (argv) ->
- connection = rpc.createJsonStreamConnection(process.stdin, process.stdout)
-
- connection.on "end", -> shutdown()
-
- exposeServices(connection)
-
-
-## Expose
-
-Exposes all the bundled services on a given connection. This function can be called from integration tests to set up a full production environment with a more suitable transport.
-
- exports.exposeServices = exposeServices = (connection) ->
- Paths = {}
- Paths.rootDir = Path.dirname(__dirname)
- Paths.resourceDir = Path.join(Paths.rootDir, 'res')
-
- connection.publish require('./services/dummy').create()
- connection.publish require('./services/reloader').create()
- connection.publish require('./services/browser').create({ resourceDir: Paths.resourceDir, appVersion: '3.0.0' })
- connection.publish require('./services/stub').create('app', ['init', 'reloadLegacyProjects', 'handleChange'])
-
-
-## Shutting down
-
-This isn't really required because the service will be killed when the main app quits. (Is that true on a Mac? Certainly true on Windows, we're using a Job object to handle that.)
-
- shutdown = ->
-
-Output a string to mark this point in the logs. We sometimes receive logs that just end abruptly at an arbitrary line, so it's important to signal whether backend shutdown has actually happened.
-
- debug "Backend shutdown."
-
-Nobody's interested in this exit code anyway, so code zero is as good as any.
-
- process.exit 0
-
-The use of `process.exit` here is quite questionable; for example, we might be in the middle of writing a file at the moment. On the other hand, the background processing time is unbounded; we may even be stuck in an endless async loop, and maybe that's why the user is shutting us down in the first place.
-
-The best approach here would be to simulate ‘sudden termination’ semantics of OS X, setting a flag during dangerous operations like async file writes, but allowing an immediate shutdown at any other time.
Oops, something went wrong.

0 comments on commit 8379bb3

Please sign in to comment.