workshopping
Version:
make workshop pages
1,611 lines (1,366 loc) • 2.97 MB
JavaScript
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/demo/demo.js":[function(require,module,exports){
const bel = require('bel')
const belmark = require('belmark')
const demo1 = require('./demo1.js')
const demo2 = require('./demo2.js')
document.head.innerHTML = `<style> body, html {
box-sizing: border-box; display: flex;
margin: 0; min-height: 100vh; width: 100%;
padding: 10px;
}</style>`
;(async () => {
if (location.pathname.endsWith('/demo/')) {
if (location.search === '?demo1') {
document.body.style = document.documentElement.style = 'padding: 0px;'
document.body.innerHTML = ''
var element = await demo1()
document.body.appendChild(element)
} else if (location.search === '?demo2') {
document.body.style = document.documentElement.style = 'padding: 0px;'
var element = await demo2()
document.body.appendChild(element)
} else {
document.body.style = document.documentElement.style = ''
const href = location.href.replace(location.search, '')
const home = href.replace('/demo/', '/')
document.body.innerHTML = `<div>
<h1> see demos </h1>
<a href="${new URL('demo?demo1', home).href}">demo1</a>
<a href="${new URL('demo?demo2', home).href}">demo2</a>
<br>or<br>
<a href="${home}">back</a>
</div>`
}
} else {
const href = location.href.replace(location.search, '')
const href_demo = new URL('demo', location.href).href
const href_readme = new URL('README.md', location.href).href
const content = await fetch(href_readme).then(response => response.text())
const markdown = belmark(content)
const codes = markdown.querySelectorAll('pre > code')
codes.forEach(x => x.innerHTML = x.textContent)
document.body.appendChild(bel`<div>
<h1> demos </h1>
<a href="${href_demo}">demos</a>
${markdown}
</div>`)
}
})()
},{"./demo1.js":"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/demo/demo1.js","./demo2.js":"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/demo/demo2.js","bel":"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/bel/browser.js","belmark":"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/belmark/source/belmark.js"}],"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/demo/demo1.js":[function(require,module,exports){
const workshop = require('../')
// const logo = require('play-logo') // @TODO: play-logo + default logo
const csjs = require('csjs-inject')
module.exports = async function demo () {
console.log(workshop.defaults)
const overwrite_any_defaults = { config, theme, css }
return await workshop(overwrite_any_defaults)
}
const config = {
// home_link: 'http://github.com/ethereum/play',
// home_text: 'yay! workshopping',
intro_prefix_text: 'earn while you learn',
}
const theme = {
'--font': 'https://github.com/ethereum-play/play-workshop/blob/master/src/OverpassMono-Regular.ttf?raw=true',
menu_padding: '5px 0px',
menu_and_minimap_and_wide_backgroundColor: 'magenta',
}
const css = { }
},{"../":"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/src/workshopping.js","csjs-inject":"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs-inject/index.js"}],"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/demo/demo2.js":[function(require,module,exports){
const workshop = require('../')
// const logo = require('play-logo')
const csjs = require('csjs-inject')
module.exports = async function demo () {
const defaults = workshop.defaults
console.log(defaults)
var default1 = workshop.customize(workshop.defaults) // default initialised
var default2 = workshop.customize({}) // default initialised
var default3 = workshop.customize() // default initialised
console.log(workshop === default1) // true
console.log(workshop === default2) // true
console.log(workshop === default3) // true
const custom_defaults = { config, theme, css }
const custom_workshop = workshop.customize(custom_defaults)
console.log(workshop === custom_workshop) // false
const overwrite_any_defaults = { config: {}, theme: {}, css: {} }
return await custom_workshop(/*overwrite_any_defaults*/)
}
const config = {
// home_text: 'powered by love',
intro_prefix_text: 'workshop',
}
// --------------------------------------------
// @TODO: `theme` example below is out of date
const theme = {
'--lessonBGcolor' : '#0000ff',
'--arrowColor' : 'magenta',
'--titleSize' : '50px',
}
// @TODO: `css` example below is out of date
const css = csjs`
.workshop {
--lessonBGcolor : ${theme['--lessonBGcolor']};
--arrowColor : ${theme['--arrowColor']};
--titleSize : ${theme['--titleSize']};
box-sizing : border-box;
display : flex;
flex-direction : column;
width : 100%;
height : 100%;
background-color : green;
}
.navbar {
display : flex;
width : 100%;
margin : 0;
}
.arrow {
background-color : grey;
font-size : 150px;
font-weight : 900;
cursor : pointer;
}
.arrow:hover {
background-color : black;
color : var(--arrowColor);
}
.status {
display : flex;
justify-content : center;
align-items : center;
flex-grow : 1;
}
.icon {
height : var(--titleSize};
margin-right : 10px;
}
.title {
font-size : var(--titleSize};
font-family : arial;
font-weight : 900;
}
.lesson {
display : flex;
background-color : var(--lessonBGcolor);
flex-grow : 1;
}`
},{"../":"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/src/workshopping.js","csjs-inject":"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs-inject/index.js"}],"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/bel/appendChild.js":[function(require,module,exports){
var trailingNewlineRegex = /\n[\s]+$/
var leadingNewlineRegex = /^\n[\s]+/
var trailingSpaceRegex = /[\s]+$/
var leadingSpaceRegex = /^[\s]+/
var multiSpaceRegex = /[\n\s]+/g
var TEXT_TAGS = [
'a', 'abbr', 'b', 'bdi', 'bdo', 'br', 'cite', 'data', 'dfn', 'em', 'i',
'kbd', 'mark', 'q', 'rp', 'rt', 'rtc', 'ruby', 's', 'amp', 'small', 'span',
'strong', 'sub', 'sup', 'time', 'u', 'var', 'wbr'
]
var VERBATIM_TAGS = [
'code', 'pre', 'textarea'
]
module.exports = function appendChild (el, childs) {
if (!Array.isArray(childs)) return
var nodeName = el.nodeName.toLowerCase()
var hadText = false
var value, leader
for (var i = 0, len = childs.length; i < len; i++) {
var node = childs[i]
if (Array.isArray(node)) {
appendChild(el, node)
continue
}
if (typeof node === 'number' ||
typeof node === 'boolean' ||
typeof node === 'function' ||
node instanceof Date ||
node instanceof RegExp) {
node = node.toString()
}
var lastChild = el.childNodes[el.childNodes.length - 1]
// Iterate over text nodes
if (typeof node === 'string') {
hadText = true
// If we already had text, append to the existing text
if (lastChild && lastChild.nodeName === '#text') {
lastChild.nodeValue += node
// We didn't have a text node yet, create one
} else {
node = document.createTextNode(node)
el.appendChild(node)
lastChild = node
}
// If this is the last of the child nodes, make sure we close it out
// right
if (i === len - 1) {
hadText = false
// Trim the child text nodes if the current node isn't a
// node where whitespace matters.
if (TEXT_TAGS.indexOf(nodeName) === -1 &&
VERBATIM_TAGS.indexOf(nodeName) === -1) {
value = lastChild.nodeValue
.replace(leadingNewlineRegex, '')
.replace(trailingSpaceRegex, '')
.replace(trailingNewlineRegex, '')
.replace(multiSpaceRegex, ' ')
if (value === '') {
el.removeChild(lastChild)
} else {
lastChild.nodeValue = value
}
} else if (VERBATIM_TAGS.indexOf(nodeName) === -1) {
// The very first node in the list should not have leading
// whitespace. Sibling text nodes should have whitespace if there
// was any.
leader = i === 0 ? '' : ' '
value = lastChild.nodeValue
.replace(leadingNewlineRegex, leader)
.replace(leadingSpaceRegex, ' ')
.replace(trailingSpaceRegex, '')
.replace(trailingNewlineRegex, '')
.replace(multiSpaceRegex, ' ')
lastChild.nodeValue = value
}
}
// Iterate over DOM nodes
} else if (node && node.nodeType) {
// If the last node was a text node, make sure it is properly closed out
if (hadText) {
hadText = false
// Trim the child text nodes if the current node isn't a
// text node or a code node
if (TEXT_TAGS.indexOf(nodeName) === -1 &&
VERBATIM_TAGS.indexOf(nodeName) === -1) {
value = lastChild.nodeValue
.replace(leadingNewlineRegex, '')
.replace(trailingNewlineRegex, '')
.replace(multiSpaceRegex, ' ')
// Remove empty text nodes, append otherwise
if (value === '') {
el.removeChild(lastChild)
} else {
lastChild.nodeValue = value
}
// Trim the child nodes if the current node is not a node
// where all whitespace must be preserved
} else if (VERBATIM_TAGS.indexOf(nodeName) === -1) {
value = lastChild.nodeValue
.replace(leadingSpaceRegex, ' ')
.replace(leadingNewlineRegex, '')
.replace(trailingNewlineRegex, '')
.replace(multiSpaceRegex, ' ')
lastChild.nodeValue = value
}
}
// Store the last nodename
var _nodeName = node.nodeName
if (_nodeName) nodeName = _nodeName.toLowerCase()
// Append the node to the DOM
el.appendChild(node)
}
}
}
},{}],"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/bel/browser.js":[function(require,module,exports){
var hyperx = require('hyperx')
var appendChild = require('./appendChild')
var SVGNS = 'http://www.w3.org/2000/svg'
var XLINKNS = 'http://www.w3.org/1999/xlink'
var BOOL_PROPS = [
'autofocus', 'checked', 'defaultchecked', 'disabled', 'formnovalidate',
'indeterminate', 'readonly', 'required', 'selected', 'willvalidate'
]
var COMMENT_TAG = '!--'
var SVG_TAGS = [
'svg', 'altGlyph', 'altGlyphDef', 'altGlyphItem', 'animate', 'animateColor',
'animateMotion', 'animateTransform', 'circle', 'clipPath', 'color-profile',
'cursor', 'defs', 'desc', 'ellipse', 'feBlend', 'feColorMatrix',
'feComponentTransfer', 'feComposite', 'feConvolveMatrix',
'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feFlood',
'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage',
'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight',
'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence', 'filter',
'font', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src',
'font-face-uri', 'foreignObject', 'g', 'glyph', 'glyphRef', 'hkern', 'image',
'line', 'linearGradient', 'marker', 'mask', 'metadata', 'missing-glyph',
'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect',
'set', 'stop', 'switch', 'symbol', 'text', 'textPath', 'title', 'tref',
'tspan', 'use', 'view', 'vkern'
]
function belCreateElement (tag, props, children) {
var el
// If an svg tag, it needs a namespace
if (SVG_TAGS.indexOf(tag) !== -1) {
props.namespace = SVGNS
}
// If we are using a namespace
var ns = false
if (props.namespace) {
ns = props.namespace
delete props.namespace
}
// Create the element
if (ns) {
el = document.createElementNS(ns, tag)
} else if (tag === COMMENT_TAG) {
return document.createComment(props.comment)
} else {
el = document.createElement(tag)
}
// Create the properties
for (var p in props) {
if (props.hasOwnProperty(p)) {
var key = p.toLowerCase()
var val = props[p]
// Normalize className
if (key === 'classname') {
key = 'class'
p = 'class'
}
// The for attribute gets transformed to htmlFor, but we just set as for
if (p === 'htmlFor') {
p = 'for'
}
// If a property is boolean, set itself to the key
if (BOOL_PROPS.indexOf(key) !== -1) {
if (val === 'true') val = key
else if (val === 'false') continue
}
// If a property prefers being set directly vs setAttribute
if (key.slice(0, 2) === 'on') {
el[p] = val
} else {
if (ns) {
if (p === 'xlink:href') {
el.setAttributeNS(XLINKNS, p, val)
} else if (/^xmlns($|:)/i.test(p)) {
// skip xmlns definitions
} else {
el.setAttributeNS(null, p, val)
}
} else {
el.setAttribute(p, val)
}
}
}
}
appendChild(el, children)
return el
}
module.exports = hyperx(belCreateElement, {comments: true})
module.exports.default = module.exports
module.exports.createElement = belCreateElement
},{"./appendChild":"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/bel/appendChild.js","hyperx":"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/hyperx/index.js"}],"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/belmark/node_modules/bel/index.js":[function(require,module,exports){
var document = require('global/document')
var hyperx = require('hyperx')
var onload = require('on-load')
var SVGNS = 'http://www.w3.org/2000/svg'
var XLINKNS = 'http://www.w3.org/1999/xlink'
var BOOL_PROPS = {
autofocus: 1,
checked: 1,
defaultchecked: 1,
disabled: 1,
formnovalidate: 1,
indeterminate: 1,
readonly: 1,
required: 1,
selected: 1,
willvalidate: 1
}
var COMMENT_TAG = '!--'
var SVG_TAGS = [
'svg',
'altGlyph', 'altGlyphDef', 'altGlyphItem', 'animate', 'animateColor',
'animateMotion', 'animateTransform', 'circle', 'clipPath', 'color-profile',
'cursor', 'defs', 'desc', 'ellipse', 'feBlend', 'feColorMatrix',
'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting',
'feDisplacementMap', 'feDistantLight', 'feFlood', 'feFuncA', 'feFuncB',
'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode',
'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting',
'feSpotLight', 'feTile', 'feTurbulence', 'filter', 'font', 'font-face',
'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri',
'foreignObject', 'g', 'glyph', 'glyphRef', 'hkern', 'image', 'line',
'linearGradient', 'marker', 'mask', 'metadata', 'missing-glyph', 'mpath',
'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect',
'set', 'stop', 'switch', 'symbol', 'text', 'textPath', 'title', 'tref',
'tspan', 'use', 'view', 'vkern'
]
function belCreateElement (tag, props, children) {
var el
// If an svg tag, it needs a namespace
if (SVG_TAGS.indexOf(tag) !== -1) {
props.namespace = SVGNS
}
// If we are using a namespace
var ns = false
if (props.namespace) {
ns = props.namespace
delete props.namespace
}
// Create the element
if (ns) {
el = document.createElementNS(ns, tag)
} else if (tag === COMMENT_TAG) {
return document.createComment(props.comment)
} else {
el = document.createElement(tag)
}
// If adding onload events
if (props.onload || props.onunload) {
var load = props.onload || function () {}
var unload = props.onunload || function () {}
onload(el, function belOnload () {
load(el)
}, function belOnunload () {
unload(el)
},
// We have to use non-standard `caller` to find who invokes `belCreateElement`
belCreateElement.caller.caller.caller)
delete props.onload
delete props.onunload
}
// Create the properties
for (var p in props) {
if (props.hasOwnProperty(p)) {
var key = p.toLowerCase()
var val = props[p]
// Normalize className
if (key === 'classname') {
key = 'class'
p = 'class'
}
// The for attribute gets transformed to htmlFor, but we just set as for
if (p === 'htmlFor') {
p = 'for'
}
// If a property is boolean, set itself to the key
if (BOOL_PROPS[key]) {
if (val === 'true') val = key
else if (val === 'false') continue
}
// If a property prefers being set directly vs setAttribute
if (key.slice(0, 2) === 'on') {
el[p] = val
} else {
if (ns) {
if (p === 'xlink:href') {
el.setAttributeNS(XLINKNS, p, val)
} else if (/^xmlns($|:)/i.test(p)) {
// skip xmlns definitions
} else {
el.setAttributeNS(null, p, val)
}
} else {
el.setAttribute(p, val)
}
}
}
}
function appendChild (childs) {
if (!Array.isArray(childs)) return
for (var i = 0; i < childs.length; i++) {
var node = childs[i]
if (Array.isArray(node)) {
appendChild(node)
continue
}
if (typeof node === 'number' ||
typeof node === 'boolean' ||
typeof node === 'function' ||
node instanceof Date ||
node instanceof RegExp) {
node = node.toString()
}
if (typeof node === 'string') {
if (el.lastChild && el.lastChild.nodeName === '#text') {
el.lastChild.nodeValue += node
continue
}
node = document.createTextNode(node)
}
if (node && node.nodeType) {
el.appendChild(node)
}
}
}
appendChild(children)
return el
}
module.exports = hyperx(belCreateElement, {comments: true})
module.exports.default = module.exports
module.exports.createElement = belCreateElement
},{"global/document":"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/global/document.js","hyperx":"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/hyperx/index.js","on-load":"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/on-load/index.js"}],"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/belmark/source/belmark.js":[function(require,module,exports){
var bel = require('bel')
var marked = require('marked')
module.exports = belmark
function belmark (source = '', ...values) {
source = [].concat(source)
var opts = this || {}
marked.setOptions(opts)
var _class = opts.classname || 'markdown'
var _id = '{{'+Math.random()+'}}'
var _source = marked(source.join(_id)).split(_id)
var _values = values.map((v,i) => 'values['+i+']').concat()
var fbody = 'return bel`<div class="'+_class+'">'
_source.forEach((s,i)=>{
var v = _values[i]!==undefined?'${'+_values[i]+'}':''
fbody+=s+v
})
fbody += '</div>`'
var render = new Function('bel', 'values', fbody)
return render(bel, values)
}
},{"bel":"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/belmark/node_modules/bel/index.js","marked":"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/marked/lib/marked.js"}],"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/browser-resolve/empty.js":[function(require,module,exports){
},{}],"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs-inject/csjs.js":[function(require,module,exports){
(function (global){
'use strict';
var csjs = require('csjs');
var insertCss = require('insert-css');
function csjsInserter() {
var args = Array.prototype.slice.call(arguments);
var result = csjs.apply(null, args);
if (global.document) {
insertCss(csjs.getCss(result));
}
return result;
}
module.exports = csjsInserter;
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"csjs":"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs/index.js","insert-css":"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/insert-css/index.js"}],"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs-inject/get-css.js":[function(require,module,exports){
'use strict';
module.exports = require('csjs/get-css');
},{"csjs/get-css":"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs/get-css.js"}],"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs-inject/index.js":[function(require,module,exports){
'use strict';
var csjs = require('./csjs');
module.exports = csjs;
module.exports.csjs = csjs;
module.exports.getCss = require('./get-css');
},{"./csjs":"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs-inject/csjs.js","./get-css":"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs-inject/get-css.js"}],"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs/csjs.js":[function(require,module,exports){
'use strict';
module.exports = require('./lib/csjs');
},{"./lib/csjs":"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs/lib/csjs.js"}],"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs/get-css.js":[function(require,module,exports){
'use strict';
module.exports = require('./lib/get-css');
},{"./lib/get-css":"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs/lib/get-css.js"}],"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs/index.js":[function(require,module,exports){
'use strict';
var csjs = require('./csjs');
module.exports = csjs();
module.exports.csjs = csjs;
module.exports.noScope = csjs({ noscope: true });
module.exports.getCss = require('./get-css');
},{"./csjs":"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs/csjs.js","./get-css":"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs/get-css.js"}],"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs/lib/base62-encode.js":[function(require,module,exports){
'use strict';
/**
* base62 encode implementation based on base62 module:
* https://github.com/andrew/base62.js
*/
var CHARS = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
module.exports = function encode(integer) {
if (integer === 0) {
return '0';
}
var str = '';
while (integer > 0) {
str = CHARS[integer % 62] + str;
integer = Math.floor(integer / 62);
}
return str;
};
},{}],"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs/lib/build-exports.js":[function(require,module,exports){
'use strict';
var makeComposition = require('./composition').makeComposition;
module.exports = function createExports(classes, keyframes, compositions) {
var keyframesObj = Object.keys(keyframes).reduce(function(acc, key) {
var val = keyframes[key];
acc[val] = makeComposition([key], [val], true);
return acc;
}, {});
var exports = Object.keys(classes).reduce(function(acc, key) {
var val = classes[key];
var composition = compositions[key];
var extended = composition ? getClassChain(composition) : [];
var allClasses = [key].concat(extended);
var unscoped = allClasses.map(function(name) {
return classes[name] ? classes[name] : name;
});
acc[val] = makeComposition(allClasses, unscoped);
return acc;
}, keyframesObj);
return exports;
}
function getClassChain(obj) {
var visited = {}, acc = [];
function traverse(obj) {
return Object.keys(obj).forEach(function(key) {
if (!visited[key]) {
visited[key] = true;
acc.push(key);
traverse(obj[key]);
}
});
}
traverse(obj);
return acc;
}
},{"./composition":"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs/lib/composition.js"}],"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs/lib/composition.js":[function(require,module,exports){
'use strict';
module.exports = {
makeComposition: makeComposition,
isComposition: isComposition,
ignoreComposition: ignoreComposition
};
/**
* Returns an immutable composition object containing the given class names
* @param {array} classNames - The input array of class names
* @return {Composition} - An immutable object that holds multiple
* representations of the class composition
*/
function makeComposition(classNames, unscoped, isAnimation) {
var classString = classNames.join(' ');
return Object.create(Composition.prototype, {
classNames: { // the original array of class names
value: Object.freeze(classNames),
configurable: false,
writable: false,
enumerable: true
},
unscoped: { // the original array of class names
value: Object.freeze(unscoped),
configurable: false,
writable: false,
enumerable: true
},
className: { // space-separated class string for use in HTML
value: classString,
configurable: false,
writable: false,
enumerable: true
},
selector: { // comma-separated, period-prefixed string for use in CSS
value: classNames.map(function(name) {
return isAnimation ? name : '.' + name;
}).join(', '),
configurable: false,
writable: false,
enumerable: true
},
toString: { // toString() method, returns class string for use in HTML
value: function() {
return classString;
},
configurable: false,
writeable: false,
enumerable: false
}
});
}
/**
* Returns whether the input value is a Composition
* @param value - value to check
* @return {boolean} - whether value is a Composition or not
*/
function isComposition(value) {
return value instanceof Composition;
}
function ignoreComposition(values) {
return values.reduce(function(acc, val) {
if (isComposition(val)) {
val.classNames.forEach(function(name, i) {
acc[name] = val.unscoped[i];
});
}
return acc;
}, {});
}
/**
* Private constructor for use in `instanceof` checks
*/
function Composition() {}
},{}],"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs/lib/csjs.js":[function(require,module,exports){
'use strict';
var extractExtends = require('./css-extract-extends');
var composition = require('./composition');
var isComposition = composition.isComposition;
var ignoreComposition = composition.ignoreComposition;
var buildExports = require('./build-exports');
var scopify = require('./scopeify');
var cssKey = require('./css-key');
var extractExports = require('./extract-exports');
module.exports = function csjsTemplate(opts) {
opts = (typeof opts === 'undefined') ? {} : opts;
var noscope = (typeof opts.noscope === 'undefined') ? false : opts.noscope;
return function csjsHandler(strings, values) {
// Fast path to prevent arguments deopt
var values = Array(arguments.length - 1);
for (var i = 1; i < arguments.length; i++) {
values[i - 1] = arguments[i];
}
var css = joiner(strings, values.map(selectorize));
var ignores = ignoreComposition(values);
var scope = noscope ? extractExports(css) : scopify(css, ignores);
var extracted = extractExtends(scope.css);
var localClasses = without(scope.classes, ignores);
var localKeyframes = without(scope.keyframes, ignores);
var compositions = extracted.compositions;
var exports = buildExports(localClasses, localKeyframes, compositions);
return Object.defineProperty(exports, cssKey, {
enumerable: false,
configurable: false,
writeable: false,
value: extracted.css
});
}
}
/**
* Replaces class compositions with comma seperated class selectors
* @param value - the potential class composition
* @return - the original value or the selectorized class composition
*/
function selectorize(value) {
return isComposition(value) ? value.selector : value;
}
/**
* Joins template string literals and values
* @param {array} strings - array of strings
* @param {array} values - array of values
* @return {string} - strings and values joined
*/
function joiner(strings, values) {
return strings.map(function(str, i) {
return (i !== values.length) ? str + values[i] : str;
}).join('');
}
/**
* Returns first object without keys of second
* @param {object} obj - source object
* @param {object} unwanted - object with unwanted keys
* @return {object} - first object without unwanted keys
*/
function without(obj, unwanted) {
return Object.keys(obj).reduce(function(acc, key) {
if (!unwanted[key]) {
acc[key] = obj[key];
}
return acc;
}, {});
}
},{"./build-exports":"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs/lib/build-exports.js","./composition":"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs/lib/composition.js","./css-extract-extends":"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs/lib/css-extract-extends.js","./css-key":"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs/lib/css-key.js","./extract-exports":"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs/lib/extract-exports.js","./scopeify":"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs/lib/scopeify.js"}],"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs/lib/css-extract-extends.js":[function(require,module,exports){
'use strict';
var makeComposition = require('./composition').makeComposition;
var regex = /\.([^\s]+)(\s+)(extends\s+)(\.[^{]+)/g;
module.exports = function extractExtends(css) {
var found, matches = [];
while (found = regex.exec(css)) {
matches.unshift(found);
}
function extractCompositions(acc, match) {
var extendee = getClassName(match[1]);
var keyword = match[3];
var extended = match[4];
// remove from output css
var index = match.index + match[1].length + match[2].length;
var len = keyword.length + extended.length;
acc.css = acc.css.slice(0, index) + " " + acc.css.slice(index + len + 1);
var extendedClasses = splitter(extended);
extendedClasses.forEach(function(className) {
if (!acc.compositions[extendee]) {
acc.compositions[extendee] = {};
}
if (!acc.compositions[className]) {
acc.compositions[className] = {};
}
acc.compositions[extendee][className] = acc.compositions[className];
});
return acc;
}
return matches.reduce(extractCompositions, {
css: css,
compositions: {}
});
};
function splitter(match) {
return match.split(',').map(getClassName);
}
function getClassName(str) {
var trimmed = str.trim();
return trimmed[0] === '.' ? trimmed.substr(1) : trimmed;
}
},{"./composition":"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs/lib/composition.js"}],"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs/lib/css-key.js":[function(require,module,exports){
'use strict';
/**
* CSS identifiers with whitespace are invalid
* Hence this key will not cause a collision
*/
module.exports = ' css ';
},{}],"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs/lib/extract-exports.js":[function(require,module,exports){
'use strict';
var regex = require('./regex');
var classRegex = regex.classRegex;
var keyframesRegex = regex.keyframesRegex;
module.exports = extractExports;
function extractExports(css) {
return {
css: css,
keyframes: getExport(css, keyframesRegex),
classes: getExport(css, classRegex)
};
}
function getExport(css, regex) {
var prop = {};
var match;
while((match = regex.exec(css)) !== null) {
var name = match[2];
prop[name] = name;
}
return prop;
}
},{"./regex":"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs/lib/regex.js"}],"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs/lib/get-css.js":[function(require,module,exports){
'use strict';
var cssKey = require('./css-key');
module.exports = function getCss(csjs) {
return csjs[cssKey];
};
},{"./css-key":"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs/lib/css-key.js"}],"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs/lib/hash-string.js":[function(require,module,exports){
'use strict';
/**
* djb2 string hash implementation based on string-hash module:
* https://github.com/darkskyapp/string-hash
*/
module.exports = function hashStr(str) {
var hash = 5381;
var i = str.length;
while (i) {
hash = (hash * 33) ^ str.charCodeAt(--i)
}
return hash >>> 0;
};
},{}],"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs/lib/regex.js":[function(require,module,exports){
'use strict';
var findClasses = /(\.)(?!\d)([^\s\.,{\[>+~#:)]*)(?![^{]*})/.source;
var findKeyframes = /(@\S*keyframes\s*)([^{\s]*)/.source;
var ignoreComments = /(?!(?:[^*/]|\*[^/]|\/[^*])*\*+\/)/.source;
var classRegex = new RegExp(findClasses + ignoreComments, 'g');
var keyframesRegex = new RegExp(findKeyframes + ignoreComments, 'g');
module.exports = {
classRegex: classRegex,
keyframesRegex: keyframesRegex,
ignoreComments: ignoreComments,
};
},{}],"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs/lib/replace-animations.js":[function(require,module,exports){
var ignoreComments = require('./regex').ignoreComments;
module.exports = replaceAnimations;
function replaceAnimations(result) {
var animations = Object.keys(result.keyframes).reduce(function(acc, key) {
acc[result.keyframes[key]] = key;
return acc;
}, {});
var unscoped = Object.keys(animations);
if (unscoped.length) {
var regexStr = '((?:animation|animation-name)\\s*:[^};]*)('
+ unscoped.join('|') + ')([;\\s])' + ignoreComments;
var regex = new RegExp(regexStr, 'g');
var replaced = result.css.replace(regex, function(match, preamble, name, ending) {
return preamble + animations[name] + ending;
});
return {
css: replaced,
keyframes: result.keyframes,
classes: result.classes
}
}
return result;
}
},{"./regex":"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs/lib/regex.js"}],"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs/lib/scoped-name.js":[function(require,module,exports){
'use strict';
var encode = require('./base62-encode');
var hash = require('./hash-string');
module.exports = function fileScoper(fileSrc) {
var suffix = encode(hash(fileSrc));
return function scopedName(name) {
return name + '_' + suffix;
}
};
},{"./base62-encode":"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs/lib/base62-encode.js","./hash-string":"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs/lib/hash-string.js"}],"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs/lib/scopeify.js":[function(require,module,exports){
'use strict';
var fileScoper = require('./scoped-name');
var replaceAnimations = require('./replace-animations');
var regex = require('./regex');
var classRegex = regex.classRegex;
var keyframesRegex = regex.keyframesRegex;
module.exports = scopify;
function scopify(css, ignores) {
var makeScopedName = fileScoper(css);
var replacers = {
classes: classRegex,
keyframes: keyframesRegex
};
function scopeCss(result, key) {
var replacer = replacers[key];
function replaceFn(fullMatch, prefix, name) {
var scopedName = ignores[name] ? name : makeScopedName(name);
result[key][scopedName] = name;
return prefix + scopedName;
}
return {
css: result.css.replace(replacer, replaceFn),
keyframes: result.keyframes,
classes: result.classes
};
}
var result = Object.keys(replacers).reduce(scopeCss, {
css: css,
keyframes: {},
classes: {}
});
return replaceAnimations(result);
}
},{"./regex":"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs/lib/regex.js","./replace-animations":"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs/lib/replace-animations.js","./scoped-name":"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/csjs/lib/scoped-name.js"}],"/home/serapath/Desktop/dev/code/@docs/repo/workshopping/node_modules/d3-array/dist/d3-array.js":[function(require,module,exports){
// https://d3js.org/d3-array/ v1.2.4 Copyright 2018 Mike Bostock
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.d3 = global.d3 || {})));
}(this, (function (exports) { 'use strict';
function ascending(a, b) {
return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
}
function bisector(compare) {
if (compare.length === 1) compare = ascendingComparator(compare);
return {
left: function(a, x, lo, hi) {
if (lo == null) lo = 0;
if (hi == null) hi = a.length;
while (lo < hi) {
var mid = lo + hi >>> 1;
if (compare(a[mid], x) < 0) lo = mid + 1;
else hi = mid;
}
return lo;
},
right: function(a, x, lo, hi) {
if (lo == null) lo = 0;
if (hi == null) hi = a.length;
while (lo < hi) {
var mid = lo + hi >>> 1;
if (compare(a[mid], x) > 0) hi = mid;
else lo = mid + 1;
}
return lo;
}
};
}
function ascendingComparator(f) {
return function(d, x) {
return ascending(f(d), x);
};
}
var ascendingBisect = bisector(ascending);
var bisectRight = ascendingBisect.right;
var bisectLeft = ascendingBisect.left;
function pairs(array, f) {
if (f == null) f = pair;
var i = 0, n = array.length - 1, p = array[0], pairs = new Array(n < 0 ? 0 : n);
while (i < n) pairs[i] = f(p, p = array[++i]);
return pairs;
}
function pair(a, b) {
return [a, b];
}
function cross(values0, values1, reduce) {
var n0 = values0.length,
n1 = values1.length,
values = new Array(n0 * n1),
i0,
i1,
i,
value0;
if (reduce == null) reduce = pair;
for (i0 = i = 0; i0 < n0; ++i0) {
for (value0 = values0[i0], i1 = 0; i1 < n1; ++i1, ++i) {
values[i] = reduce(value0, values1[i1]);
}
}
return values;
}
function descending(a, b) {
return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN;
}
function number(x) {
return x === null ? NaN : +x;
}
function variance(values, valueof) {
var n = values.length,
m = 0,
i = -1,
mean = 0,
value,
delta,
sum = 0;
if (valueof == null) {
while (++i < n) {
if (!isNaN(value = number(values[i]))) {
delta = value - mean;
mean += delta / ++m;
sum += delta * (value - mean);
}
}
}
else {
while (++i < n) {
if (!isNaN(value = number(valueof(values[i], i, values)))) {
delta = value - mean;
mean += delta / ++m;
sum += delta * (value - mean);
}
}
}
if (m > 1) return sum / (m - 1);
}
function deviation(array, f) {
var v = variance(array, f);
return v ? Math.sqrt(v) : v;
}
function extent(values, valueof) {
var n = values.length,
i = -1,
value,
min,
max;
if (valueof == null) {
while (++i < n) { // Find the first comparable value.
if ((value = values[i]) != null && value >= value) {
min = max = value;
while (++i < n) { // Compare the remaining values.
if ((value = values[i]) != null) {
if (min > value) min = value;
if (max < value) max = value;
}
}
}
}
}
else {
while (++i < n) { // Find the first comparable value.
if ((value = valueof(values[i], i, values)) != null && value >= value) {
min = max = value;
while (++i < n) { // Compare the remaining values.
if ((value = valueof(values[i], i, values)) != null) {
if (min > value) min = value;
if (max < value) max = value;
}
}
}
}
}
return [min, max];
}
var array = Array.prototype;
var slice = array.slice;
var map = array.map;
function constant(x) {
return function() {
return x;
};
}
function identity(x) {
return x;
}
function range(start, stop, step) {
start = +start, stop = +stop, step = (n = arguments.length) < 2 ? (stop = start, start = 0, 1) : n < 3 ? 1 : +step;
var i = -1,
n = Math.max(0, Math.ceil((stop - start) / step)) | 0,
range = new Array(n);
while (++i < n) {
range[i] = start + i * step;
}
return range;
}
var e10 = Math.sqrt(50),
e5 = Math.sqrt(10),
e2 = Math.sqrt(2);
function ticks(start, stop, count) {
var reverse,
i = -1,
n,
ticks,
step;
stop = +stop, start = +start, count = +count;
if (start === stop && count > 0) return [start];
if (reverse = stop < start) n = start, start = stop, stop = n;
if ((step = tickIncrement(start, stop, count)) === 0 || !isFinite(step)) return [];
if (step > 0) {
start = Math.ceil(start / step);
stop = Math.floor(stop / step);
ticks = new Array(n = Math.ceil(stop - start + 1));
while (++i < n) ticks[i] = (start + i) * step;
} else {
start = Math.floor(start * step);
stop = Math.ceil(stop * step);
ticks = new Array(n = Math.ceil(start - stop + 1));
while (++i < n) ticks[i] = (start - i) / step;
}
if (reverse) ticks.reverse();
return ticks;
}
function tickIncrement(start, stop, count) {
var step = (stop - start) / Math.max(0, count),
power = Math.floor(Math.log(step) / Math.LN10),
error = step / Math.pow(10, power);
return power >= 0
? (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1) * Math.pow(10, power)
: -Math.pow(10, -power) / (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1);
}
function tickStep(start, stop, count) {
var step0 = Math.abs(stop - start) / Math.max(0, count),
step1 = Math.pow(10, Math.floor(Math.log(step0) / Math.LN10)),
error = step0 / step1;
if (error >= e10) step1 *= 10;
else if (error >= e5) step1 *= 5;
else if (error >= e2) step1 *= 2;
return stop < start ? -step1 : step1;
}
function sturges(values) {
return Math.ceil(Math.log(values.length) / Math.LN2) + 1;
}
function histogram() {
var value = identity,
domain = extent,
threshold = sturges;
function histogram(data) {
var i,
n = data.length,
x,
values = new Array(n);
for (i = 0; i < n; ++i) {
values[i] = value(data[i], i, data);
}
var xz = domain(values),
x0 = xz[0],
x1 = xz[1],
tz = threshold(values, x0, x1);
// Convert number of thresholds into uniform thresholds.
if (!Array.isArray(tz)) {
tz = tickStep(x0, x1, tz);
tz = range(Math.ceil(x0 / tz) * tz, x1, tz); // exclusive
}
// Remove any thresholds outside the domain.
var m = tz.length;
while (tz[0] <= x0) tz.shift(), --m;
while (tz[m - 1] > x1) tz.pop(), --m;
var bins = new Array(m + 1),
bin;
// Initialize bins.
for (i = 0; i <= m; ++i) {
bin = bins[i] = [];
bin.x0 = i > 0 ? tz[i - 1] : x0;
bin.x1 = i < m ? tz[i] : x1;
}
// Assign data to bins by value, ignoring any outside the domain.
for (i = 0; i < n; ++i) {
x = values[i];
if (x0 <= x && x <= x1) {
bins[bisectRight(tz, x, 0, m)].push(data[i]);
}
}
return bins;
}
histogram.value = function(_) {
return arguments.length ? (value = typeof _ === "function" ? _ : constant(_), histogram) : value;
};
histogram.domain = function(_) {
return arguments.length ? (domain = typeof _ === "function" ? _ : constant([_[0], _[1]]), histogram) : domain;
};
histogram.thresholds = function(_) {
return arguments.length ? (threshold = typeof _ === "function" ? _ : Array.isArray(_) ? constant(slice.call(_)) : constant(_), histogram) : threshold;
};
return histogram;
}
function quantile(values, p, valueof) {
if (valueof == null) valueof = number;
if (!(n = values.length)) return;
if ((p = +p) <= 0 || n < 2) return +valueof(values[0], 0, values);
if (p >= 1) return +valueof(values[n - 1], n - 1, values);
var n,
i = (n - 1) * p,
i0 = Math.floor(i),
value0 = +valueof(values[i0], i0, values),
value1 = +valueof(values[i0 + 1], i0 + 1, values);
return value0 + (value1 - value0) * (i - i0);
}
function freedmanDiaconis(values, min, max) {
values = map.call(values, number).sort(ascending);
return Math.ceil((max - min) / (2 * (quantile(values, 0.75) - quantile(values, 0.25)) * Math.pow(values.length, -1 / 3)));
}
function scott(values, min, max) {
return Math.ceil((max - min) / (3.5 * deviation(values) * Math.pow(values.length, -1 / 3)));
}
function max(values, valueof) {
var n = values.length,
i = -1,
value,
max;
if (valueof == null) {
while (++i < n) { // Find the first comparable value.
if ((value = values[i]) != null && value >= value) {
max = value;
while (++i < n) { // Compare the remaining values.
if ((value = values[i]) != null && value > max) {
max = value;
}
}
}
}
}
else {
while (++i < n) { // Find the first comparable value.
if ((value = valueof(values[i], i, values)) != null && value >= value) {
max = value;
while (++i < n) { // Compare the remaining values.
if ((value = valueof(values[i], i, values)) != null && value > max) {
max = value;
}
}
}
}
}
return max;
}
function mean(values, valueof) {
var n = values.length,
m = n,
i = -1,
value,
sum = 0;
if (valueof == null) {
while (++i < n) {
if (!isNaN(value = number(values[i]))) sum += value;
else --m;
}
}
else {
while (++i < n) {
if (!isNaN(value = number(valueof(values[i], i, values)))) sum += value;
else --m;
}
}
if (m) return sum / m;
}
function median(values, valueof) {
var n = values.length,
i = -1,
value,
numbers = [];
if (valueof == null) {
while (++i < n) {
if (!isNaN(value = number(values[i]))) {
numbers.push(value);
}
}
}
else {
while (++i < n) {
if (!isNaN(value = number(valueof(values[i], i, values)))) {
numbers.push(value);
}
}
}
return quantile(numbers.sort(ascending), 0.5);
}
function merge(arrays) {
var n = arrays.length,
m,
i = -1,
j = 0,
merged,
array;
while (++i < n) j += arrays[i].length;
merged = new Array(j);
while (--n >= 0) {
array = arrays[n];
m = array.length;
while (--m >= 0) {
merged[--j] = array[m];
}
}
return merged;
}
function min(values, valueof) {
var n = values.length,
i = -1,
value,
min;
if (valueof == null) {
while (++i < n) { // Find the first comparable value.
if ((value = values[i]) != null && value >= value) {
min = value;
while (++i < n) { // Compare the remaining values.
if ((value = values[i]) != null && min > value) {
min = value;
}
}
}
}
}
else {
while (++i < n) { // Find the first comparable value.
if ((value = valueof(values[i], i, values)) != null && value >= value) {
min = value;
while (++i < n) { // Compare the remaining values.
if ((value = valueof(values[i], i, values)) != null && min > value) {
min = value;
}
}
}
}
}
return min;
}
function permute(array, indexes) {
var i = indexes.length, permutes = new Array(i);
while (i--) permutes[i] = array[indexes[i]];
return permutes;
}
function scan(values, compare) {
if (!(n = values.length)) return;
var n,
i = 0,
j = 0,
xi,
xj = values[j];
if (compare == null) compare = ascending;
while (++i < n) {
if (compare(xi = values[i], xj) < 0 || compare(xj, xj) !== 0) {
xj = xi, j = i;
}
}
if (compare(xj, xj) === 0) return j;
}
function shuffle(array, i0, i1) {
var m = (i1 == null ? array.length : i1) - (i0 = i0 == null ? 0 : +i0),
t,
i;
while (m) {
i = Math.random() * m-- | 0;
t = array[m + i0];
array[m + i0] = array[i + i0];
array[i + i0] = t;
}
return array;
}
function sum(values, valueof) {
var n = values.length,
i = -1,
value,
sum = 0;
if (valueof == null) {
while (++i < n) {
if (value = +values[i]) sum += value; // Note: zero and null are equivalent.
}
}
else {
while (++i < n) {
if (value = +valueof(values[i], i, values)) sum += value;
}
}
return sum;
}
function