Commit f126b166 authored by Aurel's avatar Aurel

reorganise depository for node packaging

parent c01c8b73
......@@ -200,7 +200,8 @@ module.exports = function (grunt) {
// duplicate files are ignored
src: [
// all the require for nodejs
'src/include-nodejs.js',
'src/nodejs/include.js',
'src/nodejs/html5.js',
// queries
'src/queries/parser-begin.js',
......@@ -297,7 +298,8 @@ module.exports = function (grunt) {
'<%= qunit.files %>',
'test/**/*.js',
'examples/*',
'src/*node*.js'
'src/jio-nodejs.js',
'src/nodejs/*.js'
],
tasks: ['default'],
options: {
......
/**
global.URI = require("urijs");
global.RSVP = require('rsvp');
global.UriTemplate = require("uritemplate");
global.moment = require('moment');
global.navigator = require('navigator');
global.Rusha = require('rusha');
global.FormData = require('form-data');
global.atob = require('atob');
//global.FileReader = require("html5").FileReader;
//global.Blob = require("html5").Blob;
var LocalStorage = require('node-localstorage').LocalStorage;
global.localStorage = new LocalStorage("jio");
global.btoa = require('btoa');
global.XMLHttpRequest = require('xhr2');
var mockdoc = require("mockdoc");
global.document = new mockdoc();
global.sinon = require('sinon');
global.StreamBuffers = require('stream-buffers');
global.window = global;
global.sessionStorage = {};
global.HTMLCanvasElement = {};
;(function (env) {
"use strict";
const process = require("process");
env._html5_weakmap = new WeakMap();
function EventTarget() { env._html5_weakmap.set(this, Object.create(null)); }
EventTarget.prototype.addEventListener = function (type, listener) {
if (typeof listener !== "function") return;
const em = env._html5_weakmap.get(this);
type = "" + type;
if (em[type]) em[type].push(listener);
else em[type] = [listener];
};
EventTarget.prototype.removeEventListener = function (type, listener) {
if (typeof listener !== "function") return;
const em = env._html5_weakmap.get(this);
var i = 0, listeners = em[type];
type = "" + type;
if (listeners) for (; i < listeners.length; ++i) if (listeners[i] === listener) {
if (listeners.length === 1) { delete em[type]; return; }
listeners.splice(i, 1);
return;
}
};
EventTarget.prototype.dispatchEvent = function (event) {
const type = "" + event.type,
em = env._html5_weakmap.get(this),
ontype = "on" + type;
var i = 0, listeners;
if (typeof this[ontype] === "function") {
try { this[ontype](event); } catch (ignore) {}
}
if (listeners = em[type]) for (; i < listeners.length; ++i) {
try { listeners[i](event); } catch (ignore) {}
}
};
env.EventTarget = EventTarget;
function Blob(blobParts, options) {
// https://developer.mozilla.org/en-US/docs/Web/API/Blob
var i = 0; const priv = {}, buffers = [];
env._html5_weakmap.set(this, priv);
for (; i < blobParts.length; ++i) {
if (Buffer.isBuffer(blobParts[i])) {
buffers.push(blobParts[i]);
} else if (blobParts[i] instanceof Blob) {
buffers.push(env._html5_weakmap.get(blobParts[i]).data);
} else if (blobParts[i] instanceof ArrayBuffer) {
buffers.push(new Buffer(new Uint8Array(blobParts[i])));
} else {
buffers.push(new Buffer("" + blobParts[i]));
}
}
priv.data = Buffer.concat(buffers);
Object.defineProperty(this, "size", {enumerable: true, value: priv.data.length});
Object.defineProperty(this, "type", {enumerable: true, value: options ? "" + (options.type || "") : ""});
}
Blob.prototype.size = 0;
Blob.prototype.type = "";
Blob.prototype.slice = function (start, end, contentType) {
return new Blob([env._html5_weakmap.get(this).data.slice(start, end)], {type: contentType});
};
env.Blob = Blob;
global.Blob = Blob;
function FileReader() { EventTarget.call(this); }
FileReader.prototype = Object.create(EventTarget.prototype);
Object.defineProperty(FileReader, "constructor", {value: FileReader});
FileReader.prototype.readAsText = function (blob) {
const priv = env._html5_weakmap.get(blob);
const text = priv.data.toString();
const event = Object.freeze({type: "load", target: this});
process.nextTick(() => {
this.result = text;
this.dispatchEvent(event);
});
};
FileReader.prototype.readAsArrayBuffer = function (blob) {
const priv = env._html5_weakmap.get(blob);
const arrayBuffer = new Uint8Array(priv.data).buffer;
const event = Object.freeze({type: "load", target: this});
process.nextTick(() => {
this.result = arrayBuffer;
this.dispatchEvent(event);
});
};
FileReader.prototype.readAsDataURL = function (blob) {
const priv = env._html5_weakmap.get(blob);
const dataUrl = "data:" + blob.type + ";base64," + priv.data.toString("base64");
const event = Object.freeze({type: "load", target: this});
process.nextTick(() => {
this.result = dataUrl;
this.dispatchEvent(event);
});
};
env.FileReader = FileReader;
global.FileReader = FileReader;
}(this));
;/**
* Parse a text request to a json query object tree
*
* @param {String} string The string to parse
......
{
"name": "html5",
"version": "1.0.0",
"description": "",
"main": "html5.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
{
"name": "jio",
"version": "1.0.0",
"description": "jIO for nodejs",
"main": "jio.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://lab.nexedi.com/nexedi/jio"
},
"keywords": [
"jio"
],
"author": "Aurélien Calonne",
"license": "ISC"
}
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "moment",
"version": "1.0.0",
"description": "",
"main": "moment-2.13.0.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
(function (env) {
"use strict";
/*! html5.node.js Version 1.0.0
Copyright (c) 2017 Tristan Cavelier <t.cavelier@free.fr>
This program is free software. It comes without any warranty, to
the extent permitted by applicable law. You can redistribute it
and/or modify it under the terms of the Do What The Fuck You Want
To Public License, Version 2, as published by Sam Hocevar. See
http://www.wtfpl.net/ for more details. */
// provides:
// _html5_weakmap
// EventTarget
// Blob
// FileReader
// function include(path) { return eval(require("fs").readFileSync(path).toString()); }
const process = require("process");
env._html5_weakmap = new WeakMap();
......@@ -78,6 +62,7 @@
return new Blob([env._html5_weakmap.get(this).data.slice(start, end)], {type: contentType});
};
env.Blob = Blob;
global.Blob = Blob;
function FileReader() { EventTarget.call(this); }
FileReader.prototype = Object.create(EventTarget.prototype);
......@@ -110,5 +95,6 @@
});
};
env.FileReader = FileReader;
global.FileReader = FileReader;
}(this));
......@@ -6,10 +6,10 @@ global.navigator = require('navigator');
global.Rusha = require('rusha');
global.FormData = require('form-data');
global.atob = require('atob');
global.FileReader = require("html5").FileReader;
global.Blob = require("html5").Blob;
//global.FileReader = require("html5").FileReader;
//global.Blob = require("html5").Blob;
var LocalStorage = require('node-localstorage').LocalStorage;
global.localStorage = new LocalStorage("tests");
global.localStorage = new LocalStorage("jio");
global.btoa = require('btoa');
global.XMLHttpRequest = require('xhr2');
var mockdoc = require("mockdoc");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment