Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gaiman

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gaiman - npm Package Compare versions

Comparing version 1.0.0-beta.2 to 1.0.0-beta.3

36

bin/compile.js

@@ -10,2 +10,4 @@ #!/usr/bin/env node

const fs = require('fs');
const Babel = require('@babel/standalone');
const { minify } = require('terser');

@@ -16,7 +18,7 @@ const { writeFile, stat, mkdir } = fs.promises;

const abs_path = require.resolve(filepath);
return fs.promises.readFile(abs_path);
return fs.promises.readFile(abs_path, 'utf8');
}
const options = lily(process.argv.slice(2), { boolean: ['debug', 'raw'] });
const options = lily(process.argv.slice(2), { boolean: ['debug', 'raw', 'c'] });
const executable = path.basename(process.argv[1]);

@@ -27,3 +29,3 @@

} else if (options._.length !== 1) {
console.error(`usage: ${executable} -v | -o <output directory> <input.gs>`);
console.error(`usage: ${executable} -v | [-c] [-t <html template>] -o <output directory> <input.gs>`);
} else {

@@ -44,4 +46,21 @@ fs.promises.readFile(options._[0]).then(async buffer => {

const output_code = await wrap_code(code);
writeFile(path.join(options.o, 'index.js'), output_code);
writeFile(path.join(options.o, 'index.html'), await get_terminal());
const minified = await minify(output_code, {
sourceMap: {
filename: "index.module.js",
url: "index.module.js.map"
}
});
writeFile(path.join(options.o, 'index.module.js.map'), minified.map);
var module_code = options.c ? minified.code : output_code;
writeFile(path.join(options.o, 'index.module.js'), module_code);
const output_es5_code = Babel.transform(output_code, { presets: ['env'], targets: {ie: 11} }).code;
const index = options.c ? (await minify(output_es5_code)).code : output_es5_code;
writeFile(path.join(options.o, 'index.js'), index);
let template;
if (options.t) {
template = await fs.promises.readFile(options.t, 'utf8');
} else {
template = await get_terminal();
}
writeFile(path.join(options.o, 'index.html'), template);
} else {

@@ -106,8 +125,9 @@ console.log(code);

async function get_terminal(mapping) {
const html = (await readFile('../src/terminal.html')).toString();
const css = (await readFile('../src/terminal.css')).toString();
const html = await readFile('../src/terminal.html');
const css = await readFile('../src/terminal.css');
return template(html, Object.assign({
STYLE: css,
HTML: '<div id="term"></div>',
FILE: 'index.js',
MODULE: 'index.module.js',
ES5: 'index.js',
VER: json.version

@@ -114,0 +134,0 @@ }, mapping));

@@ -8,3 +8,3 @@ /* ______ _

* Storytelling Text Based Game Engine
* Copyrigth (C) 2021 Jakub T. Jankiewicz <https://jcubic.pl/me>
* Copyrigth (C) 2021-2022 Jakub T. Jankiewicz <https://jcubic.pl/me>
*

@@ -11,0 +11,0 @@ * Released under GNU GPL v3 or later

{
"name": "gaiman",
"version": "1.0.0-beta.2",
"version": "1.0.0-beta.3",
"description": "Gaiman Text based advanture games engine and programming language",

@@ -35,5 +35,9 @@ "main": "index.js",

"dependencies": {
"@babel/cli": "^7.17.10",
"@babel/core": "^7.18.5",
"@babel/standalone": "^7.18.5",
"@jcubic/lily": "^0.3.0",
"escodegen": "^2.0.0"
"escodegen": "^2.0.0",
"terser": "^5.14.2"
}
}
# Gaiman Engine and Programming Language
![Gaiman: Text based advanture games engine and programming language](assets/banner.svg)
![Gaiman: Text based adventure games engine and programming language](https://raw.githubusercontent.com/jcubic/gaiman/master/assets/banner.svg)
[![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.2-blue.svg)](https://www.npmjs.com/package/gaiman)
[![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.3-blue.svg)](https://www.npmjs.com/package/gaiman)
[![Build and test](https://github.com/jcubic/gaiman/actions/workflows/build.yaml/badge.svg)](https://github.com/jcubic/gaiman/actions/workflows/build.yaml)

@@ -12,9 +12,11 @@ [![Coverage Status](https://coveralls.io/repos/github/jcubic/gaiman/badge.svg?branch=master)](https://coveralls.io/github/jcubic/gaiman?branch=master)

Main part of Gaiman is a minimalist programming language and main purpose is to help create
Main part of Gaiman is a minimalist, Ruby inspired, programming language. The main purpose of it is to help creating
[Text Adventure Games](https://en.wikipedia.org/wiki/Interactive_fiction). But it can also be used
to create any interactive CLI applications (Web Based Terminal applications).
It support browser based CLI applications and in the future also native command line.
It supports browser based CLI applications and in the future also native command line.
## Installation
First, you need to install [NodeJS](https://nodejs.org/en/). After you're done, you should open terminal and use npm command (that is included with Node).
```

@@ -39,6 +41,6 @@ npm install -g gaiman@beta

This is Hello world Gaiman DSL example:
```ruby
echo get "https://gaiman.js.org/gaiman.txt"
echo* "Hi, What is your name?", 50 # Typing animation with 50ms delay

@@ -52,2 +54,14 @@ let name = ask "name? "

```ruby
if cookie.visited then
if cookie.user then
let user = cookie.user
echo "Hello $user, welcome back"
else
ask_details("Welcome back stranger")
end
else
cookie.visited = true
ask_details("Welcome stranger")
end
def ask_details(msg)

@@ -85,19 +99,7 @@ echo msg

end
if cookie.visited then
if cookie.user then
let user = cookie.user
echo "Hello $user, welcome back"
else
ask_details("Welcome back strager")
end
else
cookie.visited = true
ask_details("Welcome stranger")
end
```
More examples in [examples directory](https://github.com/jcubic/gaiman/tree/master/examples)
See [Reference Manual](https://github.com/jcubic/gaiman/wiki/Reference-Manual)
See [Reference Manual](https://github.com/jcubic/gaiman/wiki/Reference-Manual) for details about the features

@@ -108,2 +110,6 @@ ## Live Demo

Live Edit of Gaiman Code:
![Gaiman programming language Playground Demo Session](https://github.com/jcubic/gaiman/blob/master/assets/edit.gif?raw=true)
Live edit of style
![Gaiman programming language Playground Demo Session](https://github.com/jcubic/gaiman/blob/master/assets/simple.gif?raw=true)

@@ -135,2 +141,2 @@

Released under GNU GPL v3 or later<br/>
Copyright (c) 2021 [Jakub T. Jankiewicz](https://jcubic.pl/me)
Copyright (c) 2021-2022 [Jakub T. Jankiewicz](https://jcubic.pl/me)

@@ -34,5 +34,7 @@ // Gaiman Codemirror mode based on Ruby and Lua mode

"ask", "def", "echo", "else", "end", "false", "for", "get", "if", "in",
"let", "not", "or", "post", "return", "sleep", "then", "true", "while",
"throw", "lambda", "do", "continue", "break", "store", "config", "parse",
"type", "ask*", "echo*", "input*", "update", "clear", "mask", "import"
"let", "not", "or", "and", "post", "return", "sleep", "then", "true",
"while", "throw", "lambda", "do", "continue", "break", "store", "config",
"parse", "type", "ask*", "echo*", "input*", "update", "clear", "mask",
"import", "prompt", "rpc", "from", "async", "exec", "exec*", "new",
"animate", "enter"
], keywords = wordRE(keywordList);

@@ -39,0 +41,0 @@

@@ -98,2 +98,6 @@ /* ______ _

},
set_cookie(name, value) {
document.cookie = `${name}=${value}`;
cookie[name] = value;
},
post(url, data = {}) {

@@ -105,20 +109,41 @@ return $.post(url, data);

},
get(url) {
get(url, data) {
if (data) {
return $.get(url, data);
}
return $.get(url);
},
get_extra(url) {
get_extra(url, data) {
if (data) {
return $.get(url, data, $.noop, "text");
}
return $.get(url, $.noop, "text");
},
set_cookie(name, value) {
document.cookie = `${name}=${value}`;
cookie[name] = value;
load(url) {
return $.getScript(url);
},
['async'](fn) {
setTimeout(fn, 0);
},
async rpc(url) {
// TODO: add Open-RPC
return new Proxy({}, {
get(target, name) {
if (name in target) {
return target[name];
}
if (name === 'then') {
return undefined;
}
return (...args) => {
return $.rpc(url, name, args);
};
},
set() {
throw new Error("You can't set properties on rpc object");
}
});
}
};
if (!('Map' in this)) {
$.getScript('https://cdn.jsdelivr.net/gh/jcubic/static/js/map.min.js').then(() => {
window.Map = ES6_Map;
});
}
function to_string(object) {

@@ -161,5 +186,14 @@ if (object instanceof Array) {

}
var playground = window.parent?.__GAIMAN_PLAYGROUND__;
if (playground) {
options.enabled = false;
}
this._term = root.terminal($.noop, $.extend({
greetings: false,
exit: false,
keydown: () => {
if (this._animation) {
return false;
}
},
exceptionHandler(e) {

@@ -226,4 +260,7 @@ if (is_iframe) {

}
echo(arg) {
this._term.echo(to_string(arg), { newline: this._config.newline });
echo(arg = "") {
if (typeof arg !== 'function') {
arg = to_string(arg);
}
this._term.echo(arg, { newline: this._config.newline });
}

@@ -233,2 +270,8 @@ echo_extra(string, delay) {

}
enter(string) {
return this._term.enter(string);
}
enter_extra(string, delay) {
return this._term.enter(string, { typing: true, delay });
}
ask(message, validator = () => true) {

@@ -290,2 +333,13 @@ return new Promise(resolve => {

}
exec(command) {
return this._term.exec(command);
}
exec_extra(command, delay) {
return this._term.exec(command, { typing: true, delay });
}
async animate(fn) {
this._animation = true;
await fn();
this._animation = false;
}
clear() {

@@ -515,3 +569,16 @@ this._term.clear();

let $_SQRT2 = Math.SQRT2;
let $_to_base64 = btoa;
let $_from_base64 = atob;
let $_sprintf = sprintf;
let $_cols = function() {
return gaiman._term.cols();
};
let $_rows = function() {
return gaiman._term.rows();
};
let $_delay = function(time) {
return new Promise(resolve => setTimeout(resolve, time));
};
// Fisher-Yates (aka Knuth) Shuffle

@@ -552,2 +619,3 @@ // ref: https://stackoverflow.com/a/2450976/387194

});
throw e;
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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