Skip to content

meteor-shuttler/scripts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Scripts

GitHub Atmosphere.js

Reactive compilable and executable scripts on client and server with mongodb.

Install

meteor add shuttler:scripts

Theory

Two-step compilation

  1. Update source value
  2. Server observe changed compile source into script

If the compilation was an error, information about it will be in the error field.

Example

if (Meteor.isClient) {
	Shuttler.Scripts.find().observe({
		changed(newDocument, oldDocument) {
			console.log(newDocument);
			(function(abc){
				eval(newDocument.script);
			})({ cde: 123 });
			
		}
	});
	Shuttler.Scripts.insert({ source: '(()=>{console.log(abc)})()', type: 'js' });
}
// After time:
// {"_id":"iyAsxHdZ5Skmqo5BA","source":"(()=>{console.log(abc)})()","type":"js","script":"(function () {↵  console.log(abc);↵})();"}
// { cde: 123 }

Documentation

Shuttler.Scripts.Schema

SimpleSchema

Shuttler.Scripts._types

{ type: Function.call(collection, userId, doc, fieldNames?, modifier?, options?) }

Here you can add your own types for compilation.

Out of box types support:

  • js Meteor Babel version of JavaScript
  • jsx React.js version of Meteor Babel JavaScript

Shuttler.Scripts.attachScripts

()

It will make any collection storage script.

scriptsCollection.isScripts

Boolean = true

Allows you to check the collection as scripts storage.

var document = Shuttler.Scripts.findOne();
if (Shuttler.collection(document.Collection()).isScripts) {
	console.log('Is a script!');
}

scriptDocument.isScript

Boolean

Allows you to check the document as a script.

var document = Shuttler.Scripts.findOne();
if (document.isScript) {
	console.log('Is a script!');
}

scriptDocument.eval

module = { exports: {} }

require/import some script and return module exports.

var document = Shuttler.Scripts.findOne();
// document.source = "export default 123";
var module = document.eval();
module.exports.default; // 123

Versions

0.0.5

  • .eval

0.0.4

  • fix big bug

0.0.3

  • jsx type

0.0.1

  • isScript and isScripts

About

Reactive executable client scripts from mongodb.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published