jora-sandbox
Advanced tools
Comparing version 1.2.1 to 1.3.0
@@ -1,9 +0,16 @@ | ||
## 1.2.1 (May 20, 2019) | ||
## 1.3.0 (July 29, 2021) | ||
- Reworked data injection into html | ||
- Dropped support for Node.js prior 12.0 | ||
- Bumped jora to 1.0.0-beta.5 | ||
- Bumped discovery to 1.0.0-beta.61 | ||
## 1.2.1 (May 20, 2020) | ||
- Fixed data injection | ||
## 1.2.0 (May 20, 2019) | ||
## 1.2.0 (May 20, 2020) | ||
- Bumped jora to 1.0.0-beta.2 | ||
- Bumber discovery to 1.0.0-beta.38 | ||
- Bumped discovery to 1.0.0-beta.38 | ||
@@ -13,3 +20,3 @@ ## 1.1.0 (December 17, 2019) | ||
- Bumped jora to 1.0.0-alpha.11 | ||
- Bumber discovery to 1.0.0-beta.26 | ||
- Bumped discovery to 1.0.0-beta.26 | ||
@@ -16,0 +23,0 @@ ## 1.0.1 (September 19, 2019) |
53
index.js
@@ -5,2 +5,37 @@ const fs = require('fs'); | ||
function* dataToHtml(source) { | ||
const CHUNK_SIZE = 1024 * 1024; | ||
const open = () => | ||
'\n<template id="chunk' + idx + '"><script>'; | ||
const close = () => | ||
'</script></template>' + | ||
'\n<script>discoveryLoader.push(document.getElementById("chunk' + (idx++) + '").content.textContent)</script>'; | ||
let idx = 0; | ||
let bufferSize = 0; | ||
yield open(); | ||
while (bufferSize < source.length) { | ||
const chunk = source.slice(bufferSize, CHUNK_SIZE); | ||
bufferSize += chunk.length; | ||
yield chunk.replace(/<\/(script)/gi, '</</script><script>$1'); | ||
if (/<(\/(s(c(r(ip?)?)?)?)?)?$/i.test(chunk.slice(-7))) { | ||
yield '</script><script>'; | ||
} | ||
if (bufferSize > CHUNK_SIZE) { | ||
bufferSize = 0; | ||
yield close() + open(); | ||
} | ||
} | ||
if (bufferSize > 0) { | ||
yield close(); | ||
} | ||
// yield '<script>[...document.querySelectorAll("[id^=chunk]")].forEach(x => discoveryLoader.push(x.content.textContent))</script>'; | ||
yield '<script>discoveryLoader.finish()</script>'; | ||
} | ||
function build(data, name, createdAt, query) { | ||
@@ -14,8 +49,20 @@ return fs | ||
.replace( | ||
/(\.loadDataFromUrl\()[^,]+/, | ||
(m, mc) => mc + JSON.stringify({ | ||
/"load-data"\.replace\(([^\)]+)\)/, | ||
`const loader = $1.lib.utils.loadDataFromPush(); | ||
$1.trackLoadDataProgress(loader); | ||
window.discoveryLoader = { | ||
push: loader.push, | ||
finish: () => { | ||
delete window.discoveryLoader; | ||
loader.finish(); | ||
} | ||
};` | ||
) | ||
.replace( | ||
/$/, | ||
[...dataToHtml(JSON.stringify({ | ||
name, | ||
createdAt, | ||
data | ||
}) | ||
}))].join('') | ||
); | ||
@@ -22,0 +69,0 @@ } |
{ | ||
"name": "jora-sandbox", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"description": "Sandbox for Jora (a JSON query language)", | ||
@@ -19,3 +19,3 @@ "author": "Roman Dvornov <rdvornov@gmail.com>", | ||
"build:dist": "discovery-build -o dist --single-file", | ||
"build:docs": "discovery-build -o docs --cleanup", | ||
"build:docs": "discovery-build -o docs --clean", | ||
"prepublishOnly": "npm run build:dist" | ||
@@ -25,10 +25,10 @@ }, | ||
"devDependencies": { | ||
"@discoveryjs/discovery": "^1.0.0-beta.38", | ||
"@discoveryjs/cli": "^1.10.2", | ||
"jora": "1.0.0-beta.2", | ||
"eslint": "^7.0.0", | ||
"mocha": "^6.2.3" | ||
"@discoveryjs/discovery": "^1.0.0-beta.61", | ||
"@discoveryjs/cli": "^2.0.0-beta.12", | ||
"jora": "1.0.0-beta.5", | ||
"eslint": "^7.31.0", | ||
"mocha": "^8.3.2" | ||
}, | ||
"engines": { | ||
"node": ">=8.0.0" | ||
"node": ">=12.0.0" | ||
}, | ||
@@ -35,0 +35,0 @@ "files": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
645614
67