Socket
Socket
Sign inDemoInstall

nogap

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nogap - npm Package Compare versions

Comparing version 0.1.10 to 0.2.0

3

lib/CommandProxy.js

@@ -0,1 +1,2 @@

/**

@@ -53,3 +54,3 @@ * This file contains code for sending, executing and otherwise handling commands.

console.warn(new Error(
'Host called `reply` when there was no pending request expecting a reply for component `' +
'Host called `reply` when there was no pending request expecting a reply from component `' +
this._componentInstance.Shared._def.FullName + '`.').stack);

@@ -56,0 +57,0 @@ return;

@@ -590,3 +590,3 @@ /**

Shared.Libs.ComponentBootstrap.installComponentInstanceAndGetClientBootstrapCode(
session, sessionId, remoteAddr, clientRoot, function(code, instanceContext) {
session, sessionId, remoteAddr, clientRoot, function(codeString, instanceContext) {
// send out bootstrapping page to everyone who comes

@@ -598,3 +598,7 @@ res.writeHead(200, {'Content-Type': 'text/html'});

res.write('<script type="text/javascript">');
res.write(code);
// fix contained </script> tags
codeString = codeString.replace(/<\/script>/g, '\\x3c/script>');
res.write('eval(eval(' + JSON.stringify(codeString) + '))');
res.write('</script>');

@@ -601,0 +605,0 @@ res.write('</body></html>');

@@ -680,6 +680,26 @@ /**

var commStr;
try {
commStr = squishy.objToString(commands, true);
}
catch (err) {
// delete args (which caused the exception)
for (var i = 0; i < commands.length; ++i) {
delete commands[i].args;
}
// then report error
throw new Error(
'[NoGap] Invalid remote method call: Tried to send too complicated object. ' +
'Arguments to remote methods must be simple objects or functions (or a mixture thereof). ' +
'Commands: ' + squishy.objToString(commands, true) + '. ' +
'If the commands contain `ComponentCommunications.returnReply`, ' +
'this error was caused by `client.reply` somewhere.');
}
// flush response & close connection
res.contentType('application/json');
res.setHeader("Access-Control-Allow-Origin", "*");
res.write(squishy.objToString(commands, true));
res.write(commStr);
res.end();

@@ -686,0 +706,0 @@ res = null;

{
"name": "nogap",
"version": "0.1.10",
"version": "0.2.0",
"author": {

@@ -5,0 +5,0 @@ "name": "Dominik Seifert",

@@ -11,6 +11,10 @@ NoGap

Have a look at the [Samples](samples) for reference.
Have a look at the [Samples](#samples) for reference.
If you want to get serious, take a look at the [Getting Started](#getting_started) section to figure out how to build a complete Node-based web application with NoGap.
Note that currently, the only dependency of NoGap is `Node` and some of its modules but even that is planned to be removed in the future.
Installation

@@ -30,2 +34,15 @@ =============

The Samples highlight some (soon, all!) features of the NoGap framework and how they are used. To run the samples:
1. Create a new folder (e.g. NoGapTest)
2. Follow installation instructions given above
* You now have a `node_modules/nogap` subfolder.
* You can now work through the samples below and try it out in real-time
4. `cd node_modules/nogap/samples/HelloWorld` (or any other sample)
3. `npm install` (will automatically download and install the sample's dependencies)
4. `npm start` (this will run the app defined in the sample's `package.json`)
5. Open your browser and go to `localhost:1234` (or whatever port you are using)
6. Start playing!
## [HelloWorld](samples/HelloWorld)

@@ -214,8 +231,131 @@

## Multiple Components
This Sample is not done yet, but the [Simple Sample App](https://github.com/Domiii/NoGap/tree/master/samples/sample_app) already does this.
### Random Examples
* `Shared.ComponentA.say('hello');`
* `this.Instance.ComponentB.client.somePublicMethod(some, data);`
## [Dynamic Loading of Components](samples/DynamicallyLoadedComponents)
TODO: Not done yet...
TODO: Sample not done yet...
### New Concepts
* `this.Tools.requestClientComponents(names, callback);`
## [Simple Sample App](https://github.com/Domiii/NoGap/tree/master/samples/sample_app)
This App shows how to start building a real application with NoGap. It uses `Angular`, `Boostrap` and `Font-Awesome` to do some real client-side rendering. Important to note: None of these are required. You can build your frontend and backend any way you want.
<a name="component_skeleton"></a>Component Skeleton
=============
* In addition to structure, a component can have a lot of `optional methods` that will be called during important events.
* This skeleton summarizes (most of) those methods.
```js
/**
* A complete Component skeleton
*/
"use strict";
var NoGapDef = require('nogap').Def;
module.exports = NoGapDef.component({
/**
* If no name is given, NoGap will use the filename as name.
* If you define more than one unnamed component per file, you will see an error.
*/
Name = undefined,
/**
* The `Base` definition is merged into both, `Host` and `Client`
*/
Base: NoGapDef.defBase(function(SharedTools, Shared, SharedContext) {
return {
/**
* Called right before `__ctor` of `Host` and `Client`
*/
__ctor: function() {
},
/**
* Called right before `initHost` and `initClient`.
*/
initBase: function() {
},
/**
* Private instance members.
*/
Private: {
},
/**
* Public instance methods that can be called by the other side.
*/
Public: {
}
};
}),
Host: NoGapDef.defHost(function(SharedTools, Shared, SharedContext) {
return {
__ctor: function () {
},
initHost: function() {
},
/**
* Private instance members.
*/
Private: {
__ctor: function () {
},
/**
* Called when a client connected.
*/
onNewClient: function() {
},
/**
* Called after `onNewClient`, once this component is bootstrapped on the client side.
* Since components can be deployed dynamically, this might happen much later, or never.
*/
onClientBootstrap: function() {
}
},
/**
* Public instance methods that can be called by the other side.
*/
Public: {
},
};
}),
Client: NoGapDef.defClient(function(Tools, Instance, Context) {
return {
__ctor: function () {
},
initClient: function() {
},
Public: {
}
};
})
});
```
<a name="getting_started"></a>Getting Started

@@ -226,2 +366,3 @@ =============

It should help you bridge the gap from the [Code Snippets](#samples) to a real-world application.
Note that the [Simple Sample App](https://github.com/Domiii/NoGap/tree/master/samples/sample_app) is also following these guidelines.

@@ -279,9 +420,6 @@ ## Recommended File Structure

It contains some basic constant data that your application needs, such as database login and other setup information.
The following is an example of a `NoGap` configuration. It requires at least three entries:
The following is an example of a `NoGap` configuration. It requires at least two entries:
* `baseFolder`
* This is the folder, relative to your application (e.g. `app.js`) where you defined all NoGap components.
* `publicFolder`
* The folder to find all client asset files that cannot be found relative to a component.
* Usually this is used to store client-only and shared javascript libraries that do not have `NoGap` support.
* `files`

@@ -291,2 +429,17 @@ * The actual component files (sans ".js"). Whenever you add a component, don't forget to list it here!

#### Optional Configuration parameters
* `publicFolder` (Default = `pub/`)
* The folder to find all client asset files that cannot be found relative to a component.
* Usually this is used to store client-only and shared javascript libraries that do not have `NoGap` support (they are not defined as components).
* `endpointImplementation.name` (Default = `HttpPost`)
* Currently, only POST is available. Websockets will follow soon.
* You can also implement your own transport layer if you want, but you probably don't.
* If you are interested into the dirty details, have a look at [`HttpPostImpl` in `ComponentCommunications.js`](https://github.com/Domiii/NoGap/blob/master/lib/ComponentCommunications.js#L564)
There are more, optional parameters. Documentation will come soon.
#### Example Config
```js

@@ -312,5 +465,3 @@ "nogap": {

There are more, optional parameters. Documentation will come soon.
### package.json

@@ -339,2 +490,2 @@

In case of questions, feel free to contact me.
In case of questions, feel free to contact me.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc