mirror of
https://github.com/amark/gun.git
synced 2025-03-30 15:08:33 +00:00
commit
7c6886857c
2
.gitignore
vendored
2
.gitignore
vendored
@ -10,4 +10,4 @@ yarn.lock
|
||||
*.DS_store
|
||||
.esm-cache
|
||||
.sessionStorage
|
||||
.localStorage
|
||||
.localStorage
|
10
README.md
10
README.md
@ -115,7 +115,8 @@ Thanks to:<br/>
|
||||
<a href="http://github.com/alanmimms">Alan Mimms</a>,
|
||||
<a href="https://github.com/dfreire">Dário Freire</a>,
|
||||
<a href="http://github.com/velua">John Williamson</a>,
|
||||
<a href="http://github.com/finwo">Robin Bron</a>
|
||||
<a href="http://github.com/finwo">Robin Bron</a>,
|
||||
<a href="http://github.com/ElieMakhoul">Elie Makhoul</a>
|
||||
</p>
|
||||
|
||||
- Join others in sponsoring code: https://www.patreon.com/gunDB !
|
||||
@ -232,6 +233,13 @@ now --npm amark/gun
|
||||
|
||||
Then visit the URL in the output of the 'now --npm' step, in your browser.
|
||||
|
||||
### [Unebo](https://unubo.app/)
|
||||
|
||||
Fork this GUN repo (Unebo only deploys from your own GitHub repo's).
|
||||
Add a Node.js app, select your GUN fork, set `npm start` start as the command and deploy.
|
||||
|
||||
Then visit the deployed app by following the 'view app' button, in your browser.
|
||||
|
||||
### [Docker](https://www.docker.com/)
|
||||
|
||||
[](https://hub.docker.com/r/gundb/gun/) [](https://microbadger.com/images/gundb/gun "Get your own image badge on microbadger.com") [](https://hub.docker.com/r/gundb/gun/) [](https://hub.docker.com/r/gundb/gun/)
|
||||
|
78
lib/meta.js
78
lib/meta.js
@ -1,5 +1,18 @@
|
||||
;(function(){
|
||||
function USE(arg, req){
|
||||
return req? require(arg) : arg.slice? USE[R(arg)] : function(mod, path){
|
||||
arg(mod = {exports: {}});
|
||||
USE[R(path)] = mod.exports;
|
||||
}
|
||||
function R(p){
|
||||
return p.split('/').slice(-1).toString().replace('.js','');
|
||||
}
|
||||
}
|
||||
|
||||
/* UNBUILD */
|
||||
;USE(function(module){
|
||||
var noop = function(){}, u;
|
||||
$.fn.or = function(s){ return this.length ? this : $(s||'body') };
|
||||
var m = window.meta = {edit:[]};
|
||||
var k = m.key = {};
|
||||
k.meta = {17:17, 91:17, 93:17, 224:17};
|
||||
@ -34,7 +47,7 @@
|
||||
}
|
||||
m.flip = function(tmp){
|
||||
var board = $('#meta .meta-menu');
|
||||
((tmp === false) || (!tmp && board.is(':visible')))?
|
||||
((tmp === false) || (!tmp && board.is(':visible')))?
|
||||
board.addClass('meta-none')
|
||||
: board.removeClass('meta-none');
|
||||
}
|
||||
@ -89,7 +102,7 @@
|
||||
m.ask = function(help, cb){
|
||||
var $ul = $('#meta .meta-menu ul').empty();
|
||||
var $put = $('<input>').attr('id', 'meta-ask').attr('placeholder', help);
|
||||
var $form = $('<form>').append($put).on('submit', function(eve){
|
||||
var $form = $('<form>').append($put).on('submit', function(eve){
|
||||
eve.preventDefault();
|
||||
cb($put.val());
|
||||
$li.remove();
|
||||
@ -112,27 +125,6 @@
|
||||
.or($(document.elementFromPoint(meta.tap.x, meta.tap.y)));
|
||||
return on;
|
||||
}
|
||||
$(window).on('blur', k.wipe).on('focus', k.wipe);
|
||||
$(document).on('mousedown mousemove mouseup', function(eve){
|
||||
m.tap.eve = eve;
|
||||
m.tap.x = eve.pageX||0;
|
||||
m.tap.y = eve.pageY||0;
|
||||
m.tap.on = $(eve.target);
|
||||
}).on('mousedown touchstart', function(eve){
|
||||
var tmp = m.tap.edit;
|
||||
if(!tmp || !tmp.on){ return }
|
||||
tmp.on(eve);
|
||||
m.tap.edit = null;
|
||||
});
|
||||
$(document).on('touchstart', '#meta .meta-start', function(eve){ m.tap.stun = true });
|
||||
$(document).on('click', '#meta .meta-menu li', function(eve){
|
||||
if(m.tap.stun){ return m.tap.stun = false }
|
||||
if(!(eve.fake = eve.which = (($(this).text().match(/[A-Z]/)||{})[0]||'').toUpperCase().charCodeAt(0))){ return }
|
||||
eve.tap = true;
|
||||
k.down(eve);
|
||||
k.up(eve);
|
||||
});
|
||||
$(document).on('keydown', k.down).on('keyup', k.up);
|
||||
meta.edit = function(edit){
|
||||
var tmp = edit.combow = [];
|
||||
$.each(edit.combo || (edit.combo = []), function(i,k){
|
||||
@ -144,8 +136,9 @@
|
||||
edit.combow = edit.combow.join(',');
|
||||
m.list(meta.edit);
|
||||
}
|
||||
$.fn.or = function(s){ return this.length ? this : $(s||'body') };
|
||||
;(function(){try{
|
||||
})(USE, './metaCore');
|
||||
|
||||
;USE(function(module){try{
|
||||
/* UI */
|
||||
if(meta.css){ return }
|
||||
var $m = $('<div>').attr('id', 'meta');
|
||||
@ -235,8 +228,9 @@
|
||||
tag.innerHTML = tmp;
|
||||
document.body.appendChild(tag);
|
||||
}
|
||||
}catch(e){}}());
|
||||
;(function(){
|
||||
}catch(e){}})(USE, './metaUI');
|
||||
|
||||
;USE(function(module){
|
||||
// include basic text editing by default.
|
||||
var monotype = window.monotype || function(){console.log("monotype needed")};
|
||||
var m = meta;
|
||||
@ -256,7 +250,6 @@
|
||||
return ((tmp = window.getSelection) && tmp().toString()) ||
|
||||
((tmp = document.selection) && tmp.createRange().text) || '';
|
||||
}
|
||||
$(document).on('select contextmenu keyup mouseup', '[contenteditable=true]', m.text.on);
|
||||
m.text.editor = function(opt, as){ var tmp;
|
||||
if(!opt){ return }
|
||||
opt = (typeof opt == 'string')? {edit: opt} : opt.tag? opt : {tag: opt};
|
||||
@ -379,5 +372,32 @@
|
||||
on: function(eve){ meta.text.editor('fontSize', 7) },
|
||||
up: function(){}
|
||||
});
|
||||
}());
|
||||
})(USE, './metaText');
|
||||
|
||||
|
||||
;USE(function(module){
|
||||
$(window).on('blur', k.wipe).on('focus', k.wipe);
|
||||
$(document).on('mousedown mousemove mouseup', function(eve){
|
||||
m.tap.eve = eve;
|
||||
m.tap.x = eve.pageX||0;
|
||||
m.tap.y = eve.pageY||0;
|
||||
m.tap.on = $(eve.target);
|
||||
}).on('mousedown touchstart', function(eve){
|
||||
var tmp = m.tap.edit;
|
||||
if(!tmp || !tmp.on){ return }
|
||||
tmp.on(eve);
|
||||
m.tap.edit = null;
|
||||
});
|
||||
$(document).on('touchstart', '#meta .meta-start', function(eve){ m.tap.stun = true });
|
||||
$(document).on('click', '#meta .meta-menu li', function(eve){
|
||||
if(m.tap.stun){ return m.tap.stun = false }
|
||||
if(!(eve.fake = eve.which = (($(this).text().match(/[A-Z]/)||{})[0]||'').toUpperCase().charCodeAt(0))){ return }
|
||||
eve.tap = true;
|
||||
k.down(eve);
|
||||
k.up(eve);
|
||||
});
|
||||
$(document).on('keydown', k.down).on('keyup', k.up);
|
||||
$(document).on('select contextmenu keyup mouseup', '[contenteditable=true]', m.text.on);
|
||||
})(USE, './metaEvents');
|
||||
|
||||
}());
|
@ -19,7 +19,11 @@ Gun.on('create', function(root){
|
||||
|
||||
try{ dgram = require("dgram") }catch(e){ return }
|
||||
var socket = dgram.createSocket({type: "udp4", reuseAddr: true});
|
||||
socket.bind(udp.port);
|
||||
socket.bind({port: udp.port, exclusive: true}, function(){
|
||||
socket.setBroadcast(true);
|
||||
socket.setMulticastTTL(128);
|
||||
socket.addMembership(udp.address);
|
||||
});
|
||||
|
||||
socket.on("listening", function(){
|
||||
try { socket.addMembership(udp.address) }catch(e){ return }
|
||||
|
@ -14,7 +14,8 @@
|
||||
"e2e": "mocha e2e/distributed.js",
|
||||
"docker": "hooks/build",
|
||||
"minify": "uglifyjs gun.js -o gun.min.js -c -m",
|
||||
"unbuild": "node lib/unbuild.js & npm run minify"
|
||||
"unbuild": "node lib/unbuild.js & npm run minify",
|
||||
"unbuildMeta": "node lib/unbuild.js lib/meta"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
Loading…
x
Reference in New Issue
Block a user