Initial testing, cerxes-npm

This commit is contained in:
Miel Truyen 2019-01-27 23:02:37 +01:00
commit 7f66a907e0
34 changed files with 4266 additions and 0 deletions

9
README.md Normal file
View File

@ -0,0 +1,9 @@
<h1 align="left">
Cerxes-samples
</h1>
<p align="left">
Samples using CXS-UI library
</p>
## License
This project is under MIT License [https://opensource.org/licenses/MIT](https://opensource.org/licenses/MIT)

14
cfg/.babelrc Normal file
View File

@ -0,0 +1,14 @@
{
"sourceMaps": "inline",
"presets": [
["@babel/preset-env", {
"targets": {
"node": "current"
}
}]
],
"plugins": [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-optional-chaining"
]
}

283
cfg/buildup.run.js Normal file
View File

@ -0,0 +1,283 @@
// Node imports
import path from 'path';
import process from "process";
import { exec } from "child_process";
// Rollup plugin imports
import less from 'rollup-plugin-less';
import sourcemaps from 'rollup-plugin-sourcemaps';
import stringLoader from "rollup-plugin-string";
import jsonPlugin from "rollup-plugin-json";
// Build/dev imports
import {Buildup, assetPlugin, babelPlugin, copyPlugin, handlebarsPlugin, minifyPlugin, commonJSPlugin} from "@cerxes/buildup";
// Util imports
import readArgs from "./util/read-args";
// Control
async function build(options) {
// Build
let error = false, result;
let watch = options.get("watch","w");
let development = options.get("dev", "d");
let server = options.get("server", "s");
let minify = options.get("minify", "m");
if(minify===undefined){minify = !development;}
try {
let settings = {
target: "web",
dev: development,
minify: minify,
es6: false //development
};
let builder = new Buildup(({meta: settings})=>({
outDir: "dist/" + settings.target,
inDir: "src",
clean: true,
alias: [
["common", "src/common"]
],
sourcemap: settings.dev?"inline":true, // 'inline' tends to work more reliably in chrome than just true (which is default and should be preferred)
plugins: [
// Import less as strings
less({// TODO fork/clone the less plugin, it's npm package is annoyingly transpiled (requiring us to have a babel-runtime) and it has other minor issues...
output: (args)=>args// This is how we avoid the .css file from being made, and it feels hacky
}),
// Resolve maps from node_modules
sourcemaps(),
// Resolve non-es6 node_module libraries
commonJSPlugin({
include: /node_modules\/.*$/,
exclude: /.*[\/\.]es6?[\/\.].*/
}),
],
steps: (config)=>[
[
{ // Site Build (www, targeting browsers)
inDir: "src/www",
outDir: config.outDir + (settings.outDir? "/"+settings.outDir : "")+"/www",
plugins: [
...config.plugins,
// Add ability to pass non-js files through the build-system
assetPlugin({
exclude: [/\.svg$/]
}),
// Load gcodes and svgs as strings
stringLoader({
include: ['**/*.gcode', '**/*.svg']
}),
// Transform source files with babel (uses src/.babelrc for configuration)
babelPlugin({
"target":"source"// transform the source inputs (could leave this undefined, its the default)
}),
// Transform output files with babel for browser compatibility
settings.es6? null : babelPlugin({
"target": "bundle", // only transform the output bundle, not the source inputs
"presets": [
[
"@babel/preset-env",
{
"targets": {
"browsers": [
"last 6 Chrome versions",
"last 1 Edge versions",
"last 2 Firefox versions",
]
},
"modules": false // Leave module processing to the custom transform-es-module plugin
}
]
],
"plugins": [
"@babel/plugin-syntax-dynamic-import",
"@cerxes/buildup/dist/babel-transform-es-modules"
],
}),
// Compress output
settings.minify? minifyPlugin() : null,
],
steps: (wwwConfig)=>[
// Serial compilation steps:
// - Compile vendor bundle first (needed/used in the next chunks)
[
{
// array in, single out
in: [
"@cerxes/cxs",
],
out: "lib/vendor.js",
bundle:"flat",
},
],
// - Copy polyfills
Buildup.scanDir(
"node_modules/@webcomponents/webcomponentsjs/bundles/",
/(webcomponents-([\-a-zA-Z]+)\.js)$/
).then(wcPolyfills=>wcPolyfills.map(polyfill=>({
meta: polyfill,
in: polyfill.files,
out: "lib/polyfills/[1]",
plugins: [
copyPlugin()
]
}))),
// - Compile pages
Buildup.scanDir(
wwwConfig.resolveIn("pages"), // Scan directory src/pages for files
/(.*)\.page\.js$/ // (...) RegEx capture-group feeds into chunk-meta step allowing us to use [1]...[n] in strings below
).then(pages=>pages.map(page=>({
meta: page,
in: page.files,
out: "[1].page.js",
steps: (pageChunk)=>[
{
in: {
alias: "[1].polyfill-loader.virtual.js", // Passing in an alias within the src/ map will allow babel to find the appropriate .babelrc to transpile it
content: `import {loadPolyfills} from "pages/polyfill-loader"; loadPolyfills();`
},
out: "[1].loader.virtual.js",
emit: false,
steps: (polyloaderChunk)=>({
in: {
alias: "[1].loader.virtual.js", // Passing in an alias within the src/ map will allow babel to find the appropriate .babelrc to transpile it
content: `import {loadPage} from "pages/page-loader"; import(\`${"./" + path.basename(pageChunk.outPath)}\`).then(module=>loadPage(module));` // Loader-code
},
out: "[1].loader.virtual.js",
emit: false,
steps: (loaderChunk)=>[
{
// Feed the loader as input to html-generator
in: "page.hbs",
plugins: [handlebarsPlugin({
context: {
polyfill: polyloaderChunk.compiled.code,
pageCode: loaderChunk.compiled.code,
es6: settings.es6
}
})],
out: "[1].html"
}
]
})
}
]
}))),
// - Copy assets
Buildup.scanDir(
wwwConfig.resolveIn(""), // Scan directory src/pages for files
/(.*)\.(eot|svg|ttf|woff|png|jpg)$/ // (...) RegEx capture-group feeds into chunk-meta step allowing us to use [1]...[n] in strings below
).then(assets=>assets.map(asset=>({
meta: asset,
in: asset.files[0],
out: "[1].[2]",
asset: true
})))
]
}
],
[
{ // Server Build (targetting node-environment)
inDir: "src/server",
outDir: config.outDir + (settings.outDir? "/"+settings.outDir : ""),
plugins: [
jsonPlugin({
// for tree-shaking, properties will be declared as
// variables, using either `var` or `const`
preferConst: true, // Default: false
}),
...config.plugins,
// Transform source files with babel (uses src/.babelrc for configuration) for nodejs compatibility
babelPlugin({
"target":"source"// transform the source inputs (could leave this undefined, its the default)
}),
// Transform output files with babel for nodejs compatibility
babelPlugin({
"target": "bundle", // only transform the output bundle, not the source inputs
"presets": [
["@babel/preset-env", {
"targets": {
"node": "current"
},
}]
],
}),
// Compress output
settings.minify? minifyPlugin() : null,
],
nodeResolve: {
browser: false,
external: ({importee, importer, resolved, pkg})=> pkg.builtin||(pkg&&pkg.name==='mongodb')// Flag builtins as external
},
steps: (serverConfig)=>[
[
{
in: "main.js",
out: "main.js",
bundle:"flat",
},
],
]
}
],
]
}));
result = await builder.run(settings, {
watch: watch
}
);
}catch(err){
error = true;
console.error(err);
}
// Start server?
if(result&&server) {
console.log("Starting server...");
let started = exec("node \"./main.js\"",{
cwd: './dist/web'
});
started?.stdout.on('data', (data)=>{
console.log(data.toString());
});
started?.stderr.on('data', (data)=>{
console.error(data.toString());
});
}
if(watch) {
// If in watch/dev-server mode, enter this crappy infinite loop (TODO?)
let done = false;
let interval = 500;
while (!done) {
let msg = await new Promise((resolve) => setTimeout(() => resolve(error ? "KILL" : "TICK"), interval));
if (msg === "KILL") {
done = true;
}
}
}
return error;
}
// Start
try {
let args = process.argv.slice(2);
let options = readArgs(args);
build(options).catch(ex=>{
console.error(ex);
});
}catch(ex){
console.error(ex);
}

46
cfg/util/read-args.js Normal file
View File

@ -0,0 +1,46 @@
function readArgs(args){
let result = {
switches: new Set(),// Single letter toggles
params: new Map(),// Named params/toggles
args: [],
get: function(...keys){
let value;
for (let k of keys) {
let newValue = result.params.get(k);
if(newValue!==undefined) {
value = newValue;
} else if (result.switches.has(k)){
value = true;
}
}
return value;
}
};
for(let arg of args){
if(arg[0]==='-'){
if(arg[1]==='-'){
// Full name
let argName = arg.slice(2);
let argValue = true;
let eqIndex = argName.indexOf("=");
if(eqIndex>0){
argValue = argName.slice(eqIndex+1);
try{
argValue = JSON.parse(argValue);
}catch(ex){}
argName = argName.slice(0,eqIndex);
}
result.params.set(argName, argValue);
}else{
// Switches
let switches = arg.slice(1);
for(let l of switches){result.switches.add(l);}
}
}else{
result.args.push(arg);
}
}
return result;
}
module.exports = readArgs;

35
package.json Normal file
View File

@ -0,0 +1,35 @@
{
"name": "cerxes-examples",
"version": "0.0.1",
"devDependencies": {
"@babel/core": "^7.1.2",
"@babel/plugin-external-helpers": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.1.0",
"@babel/plugin-proposal-optional-chaining": "^7.0.0",
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/plugin-transform-runtime": "^7.1.0",
"@babel/polyfill": "^7.0.0",
"@babel/preset-env": "^7.1.0",
"@babel/register": "^7.0.0",
"@cerxes/buildup": "^0.0.16",
"@cerxes/cxs-ui": "^0.0.3",
"@webcomponents/webcomponentsjs": "~2.1.3",
"compression": "^1.7.3",
"express": "^4.16.4",
"less": "^3.8.1",
"rollup": "^0.66.6",
"rollup-plugin-json": "^3.1.0",
"rollup-plugin-less": "^0.1.4",
"rollup-plugin-sourcemaps": "^0.4.2",
"rollup-plugin-string": "^2.0.2",
"rollup-pluginutils": "^2.3.3",
"xml2js": "^0.4.19",
"zen-observable": "^0.8.9"
},
"dependencies": {},
"scripts": {
"dev": "node -r @babel/register ./cfg/buildup.run.js --watch --server --dev",
"build": "node -r @babel/register ./cfg/buildup.run.js --minify=true",
"server": "node -r @babel/register ./cfg/buildup.run.js --server --minify=false"
}
}

1
src/common/readme Normal file
View File

@ -0,0 +1 @@
This file exists as a placeholder. Currently there is no common code!

14
src/server/.babelrc Normal file
View File

@ -0,0 +1,14 @@
{
"presets": [
["@babel/preset-env", {
"targets": {
"node": "current"
},
"modules": false // Leave module processing to the custom transform-es-module plugin
}]
],
"plugins": [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-optional-chaining"
]
}

62
src/server/main.js Normal file
View File

@ -0,0 +1,62 @@
import express from "express";
import compression from "compression";
import http from "http";
import path from "path";
import fs from "fs";
class DevServer{
constructor(config){
this.config = Object.assign(
{
//https: false
},
config
);
}
start(){
const app = express();
let hostedDir = this.config.outDir||"./";
let relativeDir = path.relative(path.resolve("."), hostedDir);
// Configure proxy settings
app.set('trust proxy', true);
// GZIP all assets
app.use(compression());
app.use(express.static(hostedDir));
let listenServer = (server)=>((err)=>{
if (this.config.port === undefined) {
this.config.port = server.address().port;
}
if (this.config.host === undefined) {
if(server.address().address && server.address().address !== '::'){
this.config.host = server.address().address;
}else{
this.config.host = "127.0.0.1";
}
}
console.log(`DevServer started ${relativeDir} -> http://${this.config.host}:${this.config.port } !`);
});
let httpServer = http.createServer(app);
httpServer.listen({
port:this.config.port,
host:this.config.host
}, listenServer(httpServer));
}
}
let devConfig = {
outDir: "www",
port: 41025,// (leave port undefined to have the dev server auto-assign a port again)
};
// Webserver
console.log("Starting webserver...");
let devServer = new DevServer(devConfig);
devServer.start();

9
src/www/.babelrc Normal file
View File

@ -0,0 +1,9 @@
{
"presets": [
],
"plugins": [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-proposal-optional-chaining"
]
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,62 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
<svg xmlns="http://www.w3.org/2000/svg">
<metadata>Generated by IcoMoon</metadata>
<defs>
<font id="Cerxes" horiz-adv-x="1024">
<font-face units-per-em="1024" ascent="796.16" descent="-227.84" />
<missing-glyph horiz-adv-x="1024" />
<glyph unicode="&#x20;" horiz-adv-x="51.2" d="" />
<glyph unicode="&#x41;" glyph-name="u_A" horiz-adv-x="787" d="M350.302 666.436l-261.374-664.324h110.588l65.336 180.264h274.45l66.35-180.264h116.6l-254.324 664.324zM401.578 556.876l104.538-284.852h-208.088z" />
<glyph unicode="&#x42;" glyph-name="u_B" horiz-adv-x="671" d="M89.307 666.434v-664.326h271.424c75.734 0 135.718 15.935 179.95 47.806s66.346 80.343 66.346 145.414c0 41.831-11.059 76.36-33.178 103.584-22.113 27.224-50.593 46.812-85.442 58.764 24.797 15.271 44.232 32.203 58.304 50.794 14.746 19.257 22.118 45.153 22.118 77.688 0 57.768-19.099 102.255-57.3 133.462-37.533 31.209-95.507 46.814-173.92 46.814zM199.885 573.804h141.752c37.527 0 66.007-7.303 85.442-21.91 20.109-14.608 30.162-39.507 30.162-74.698 0-33.2-10.053-56.109-30.162-68.726-19.435-12.615-44.9-18.922-76.396-18.922h-150.798zM200.895 300.904h155.818c40.88 0 73.719-6.973 98.516-20.916 25.465-13.281 38.198-39.841 38.198-79.68s-12.063-67.728-36.186-83.664c-24.129-15.272-56.633-22.908-97.512-22.908h-158.834z" />
<glyph unicode="&#x43;" glyph-name="u_C" horiz-adv-x="637" d="M372.947 673.312c-139.701 0.78-284.124-98.521-284.124-332.984 0-361.58 343.479-412.464 483.416-272.528l-89.054 89.050c-76.33-76.329-267.15-40.129-267.15 183.478s190.82 236.331 267.15 160.002l89.054 89.050c-49.196 53.669-123.55 83.509-199.292 83.932z" />
<glyph unicode="&#x44;" glyph-name="u_D" horiz-adv-x="711" d="M88.922 666.434v-664.328h235.238c214.461 0 321.692 110.887 321.692 332.662 0 221.111-107.231 331.666-321.692 331.666zM199.508 574.802h113.592c75.060 0 130.351-19.255 165.874-57.766 35.517-38.512 53.276-99.269 53.276-182.268s-17.759-143.757-53.276-182.268c-35.523-38.512-90.814-57.768-165.874-57.768h-113.592z" />
<glyph unicode="&#x45;" glyph-name="u_E" horiz-adv-x="593" d="M88.792 666.434v-664.328h439.31v92.628h-328.724v193.222h286.5v93.624h-285.498v192.224h327.722v92.63z" />
<glyph unicode="&#x46;" glyph-name="u_F" horiz-adv-x="584" d="M88.896 666.434v-664.328h110.576v279.874h279.468v93.624h-279.468v198.2h319.678v92.63z" />
<glyph unicode="&#x47;" glyph-name="u_G" horiz-adv-x="720" d="M405.431 677.388c-102.536 0-180.948-28.553-235.238-85.656-54.283-56.439-81.424-142.093-81.424-256.964 0-115.535 27.141-201.855 81.424-258.958 54.29-57.104 133.040-85.656 236.25-85.656 87.122 0 169.889 20.252 248.302 60.756v304.774h-251.328v-93.624h140.74v-158.364c-36.185-13.279-78.739-19.918-127.666-19.918-72.382 0-126.669 19.919-162.86 59.758-35.517 39.839-53.274 103.584-53.274 191.232 0 87.647 17.757 151.39 53.274 191.23 36.191 39.84 91.484 59.76 165.876 59.76 33.513 0 66.688-5.312 99.526-15.936 32.838-9.96 69.697-24.568 110.576-43.824v105.574c-69.697 30.543-144.423 45.816-224.178 45.816z" />
<glyph unicode="&#x48;" glyph-name="u_H" horiz-adv-x="685" d="M88.847 666.434v-664.328h110.576v282.862h309.63v-282.862h111.578v664.328h-111.578v-285.85h-309.63v285.85z" />
<glyph unicode="&#x49;" glyph-name="u_I" horiz-adv-x="265" d="M88.829 666.434v-664.328h111.588v664.328z" />
<glyph unicode="&#x4a;" glyph-name="u_J" horiz-adv-x="499" d="M322.825 666.434v-458.158c0-43.16-9.38-74.367-28.14-93.622-18.099-18.593-46.583-27.89-85.452-27.89-37.533 0-77.744 15.604-120.634 46.812v-105.574c44.9-23.904 92.485-35.856 142.754-35.856 56.962 0 104.877 15.604 143.746 46.812 39.543 31.871 59.314 85.986 59.314 162.346v465.13z" />
<glyph unicode="&#x4b;" glyph-name="u_K" horiz-adv-x="697" d="M89.348 666.434v-664.328h111.588v216.13l61.33 66.732 225.18-282.862h145.758l-294.544 366.526 272.434 297.802h-140.74l-269.418-322.702v322.702z" />
<glyph unicode="&#x4c;" glyph-name="u_L" horiz-adv-x="586" d="M88.81 666.434v-664.328h432.268v93.622h-320.688v570.706z" />
<glyph unicode="&#x4d;" glyph-name="u_M" horiz-adv-x="794" d="M88.8 668v-665.6h115.2v448l166.4-204.8h76.8l166.4 204.8v-448h115.2v665.6h-115.2l-204.8-270.905-204.8 270.905z" />
<glyph unicode="&#x4e;" glyph-name="u_N" horiz-adv-x="722" d="M88.828 666.434v-664.328h105.56v494.012l362.904-494.012h99.516v664.328h-105.548v-488.036l-355.872 488.036z" />
<glyph unicode="&#x4f;" glyph-name="u_O" horiz-adv-x="778" d="M400.534 677.388c-101.869 0-179.277-29.217-232.224-87.648-52.948-57.767-79.422-143.089-79.422-255.968 0-113.543 26.808-199.2 80.424-256.968s130.689-86.65 231.222-86.65c101.867 0 179.271 28.883 232.212 86.65 53.615 58.432 80.422 144.089 80.422 256.968 0 114.207-26.807 199.862-80.422 256.966-53.615 57.767-131.019 86.65-232.212 86.65zM400.534 581.774c67.686 0 117.613-19.587 149.784-58.762 32.164-39.177 48.246-101.925 48.246-188.244 0-86.983-16.082-150.396-48.246-190.236-31.503-39.176-81.43-58.764-149.784-58.764-67.694 0-117.624 19.588-149.788 58.764-32.171 39.175-48.256 102.256-48.256 189.24 0 86.983 16.085 150.063 48.256 189.24 32.164 39.175 82.094 58.762 149.788 58.762z" />
<glyph unicode="&#x50;" glyph-name="u_P" horiz-adv-x="659" d="M89.051 666.434v-664.328h110.586v238.042h154.806c76.403 0 135.381 18.593 176.934 55.776 42.222 37.847 63.332 91.3 63.332 160.356s-20.777 121.176-62.332 156.368c-41.547 35.857-100.857 53.786-177.934 53.786zM199.637 573.804h140.74c52.941 0 89.13-10.955 108.564-32.866 20.108-21.912 30.162-51.46 30.162-88.644 0-35.855-10.054-64.739-30.162-86.65-19.434-21.248-55.623-31.872-108.564-31.872h-140.74z" />
<glyph unicode="&#x51;" glyph-name="u_Q" horiz-adv-x="778" d="M400.497 680.37c-207.756 0-311.634-115.536-311.634-346.606s103.878-346.604 311.634-346.604c33.507 0 63.665 2.987 90.472 8.964 15.413-30.543 35.518-53.119 60.316-67.728 24.797-15.272 51.94-22.908 81.426-22.908 29.492 5 55.965 6.309 79.42 18.926v78.684c-13.404-7.971-24.459-13.285-33.168-15.938-8.715-2.653-18.437-3.978-29.164-3.978-24.796 0-46.574 16.267-65.334 48.8 85.778 53.12 128.668 153.712 128.668 301.782 0 231.070-104.212 346.606-312.636 346.606zM400.497 587.75c68.355 0 118.284-19.92 149.786-59.76 32.171-39.839 48.256-104.247 48.256-193.222 0-51.128-4.693-93.956-14.076-128.484-9.383-33.863-23.791-61.088-43.226-81.672-18.766 35.193-42.224 62.417-70.374 81.672-27.476 19.921-58.639 29.88-93.488 29.88-28.15 0-53.281-5.643-75.394-16.932-21.451-10.624-38.879-23.241-52.282-37.848v-45.816c-31.496 41.167-47.244 107.236-47.244 198.204 0 89.639 16.086 154.379 48.256 194.218 32.165 39.84 82.093 59.76 149.786 59.76zM360.285 153.496c39.537 0 71.371-24.569 95.5-73.704-16.082-2.659-34.511-4.651-55.288-5.974-57.635 0-101.865 13.945-132.694 41.832 27.476 25.231 58.303 37.846 92.482 37.846z" />
<glyph unicode="&#x52;" glyph-name="u_R" horiz-adv-x="700" d="M88.891 666.434v-664.328h110.586v250.99h141.742l156.828-250.99h137.716l-178.938 269.914c44.906 9.959 80.425 32.869 106.558 68.724 26.807 35.856 40.212 77.687 40.212 125.494 0 66.399-18.764 116.198-56.29 149.398-36.859 33.865-90.474 50.798-160.846 50.798zM199.477 573.804h173.91c40.211 0 69.028-9.627 86.452-28.882 18.099-19.256 27.15-47.809 27.15-85.656 0-39.176-11.061-68.39-33.18-87.646-21.445-19.255-54.283-28.884-98.514-28.884h-155.818z" />
<glyph unicode="&#x53;" glyph-name="u_S" horiz-adv-x="606" d="M319.030 678.386c-51.605 0-94.498-9.296-128.678-27.888-34.181-17.928-59.313-41.168-75.394-69.72-16.089-28.551-24.134-58.762-24.134-90.634 0-38.511 8.045-70.052 24.134-94.62 16.081-24.568 35.85-43.491 59.306-56.77 24.129-13.28 54.623-26.229 91.482-38.846l22.12-7.968c32.838-11.953 58.304-22.245 76.396-30.876 18.099-8.631 33.179-19.587 45.24-32.868 12.061-13.279 18.092-30.212 18.092-50.796 0-30.544-10.385-54.115-31.156-70.714-20.777-16.6-51.608-24.9-92.494-24.9-41.547 0-81.423 6.307-119.624 18.922-37.533 13.28-69.365 30.544-95.498 51.792v-109.558c36.191-18.592 70.367-32.204 102.532-40.836 32.17-7.968 72.047-11.952 119.632-11.952v0.002c51.605 0 94.499 8.963 128.68 26.892 34.848 18.591 60.313 42.827 76.396 72.706 16.756 30.544 25.134 64.076 25.134 100.596 0 38.512-8.713 70.051-26.138 94.618-17.424 25.231-39.876 44.819-67.358 58.764-26.807 14.608-60.652 28.553-101.532 41.832-34.848 11.288-61.655 20.916-80.422 28.884-18.093 8.632-32.836 19.588-44.23 32.868-11.394 13.944-17.090 31.872-17.090 53.784 0 25.895 10.388 46.811 31.166 62.748 20.771 15.935 50.928 23.902 90.472 23.902 34.18 0 63.669-5.312 88.466-15.936 24.799-9.961 54.288-25.563 88.468-46.81v107.566c-34.855 16.597-65.015 28.216-90.48 34.858-24.798 7.305-55.961 10.958-93.488 10.958z" />
<glyph unicode="&#x54;" glyph-name="u_T" horiz-adv-x="691" d="M88.8 668v-115.2h204.8v-550.4h128v550.4h204.8v115.2z" />
<glyph unicode="&#x55;" glyph-name="u_U" horiz-adv-x="704" d="M88.837 666.434v-403.378c0-90.968 24.127-159.691 72.38-206.17s118.287-69.72 210.104-69.72c83.775 0 149.451 23.572 197.030 70.716 47.584 47.144 71.376 115.535 71.376 205.174v403.378h-106.56v-402.382c0-122.839-55.29-184.258-165.874-184.258-54.951 0-96.165 14.939-123.642 44.818-27.481 30.544-41.22 77.025-41.22 139.44v402.382z" />
<glyph unicode="&#x56;" glyph-name="u_V" horiz-adv-x="783" d="M88.713 666.434l254.332-664.328h115.616l259.36 664.328-116.616-0.998-193.012-534.848-195.028 535.846z" />
<glyph unicode="&#x57;" glyph-name="u_W" horiz-adv-x="1026" d="M52.428 666.434l203.062-664.328h111.588l157.83 498.994 157.832-498.994h110.578l204.072 664.328h-119.634l-146.77-524.89-157.83 524.89h-95.5l-156.82-525.886-148.784 525.886z" />
<glyph unicode="&#x58;" glyph-name="u_X" horiz-adv-x="756" d="M89.897 666.434l230.21-328.678-231.222-335.65h126.666l164.874 248.002 173.908-248.002 136.722 0.002-233.234 332.66 227.194 331.666h-126.664l-161.85-243.022-170.892 243.022z" />
<glyph unicode="&#x59;" glyph-name="u_Y" horiz-adv-x="760" d="M88.554 666.434l252.318-366.526v-297.802h110.586v296.806l243.274 367.522h-119.624l-171.904-275.89-178.938 275.89z" />
<glyph unicode="&#x5a;" glyph-name="u_Z" horiz-adv-x="652" d="M96.838 666.434v-92.63h357.876l-365.92-485.046v-86.652h498.616v92.626h-359.89l359.89 488.036v83.666z" />
<glyph unicode="&#x61;" glyph-name="l_A" horiz-adv-x="592" d="M325.005 538.494c-38.201 0-75.397-4.125-111.588-12.374-35.523-8.251-62.665-18.563-81.426-30.938v-101.060c19.435 16.499 43.895 29.218 73.382 38.156 29.486 9.624 58.974 14.436 88.466 14.436 82.434 0 123.652-35.062 123.652-105.186v-49.498c-40.212 24.75-90.479 37.124-150.8 37.124-58.304 0-103.54-14.093-135.71-42.28-31.496-28.187-47.244-70.467-47.244-126.842 0-59.811 19.435-102.435 58.304-127.872 38.869-25.438 88.125-38.156 147.77-38.156 74.393 0 131.696 8.937 171.908 26.812 40.211 18.562 60.316 51.219 60.316 97.968v247.494c0.668 60.499-18.433 104.154-57.302 130.966-38.201 27.499-84.777 41.25-139.728 41.25zM304.899 247.688c40.88 0 78.411-7.562 112.592-22.688v-100.028c0-18.563-8.713-30.938-26.138-37.126s-47.248-9.282-89.47-9.282v0.002c-30.827 0-57.635 7.219-80.422 21.656-22.12 14.437-33.18 36.092-33.18 64.966-6.144 27.499 9.717 48.126 29.152 61.876 20.109 13.751 49.265 20.624 87.466 20.624z" />
<glyph unicode="&#x62;" glyph-name="l_B" horiz-adv-x="617" d="M84.031 661.904v-574.356c0-72.269 72.046-108.404 216.136-108.404 71.706 0 130.679 19.335 176.922 58.006 46.917 39.304 70.376 105.869 70.376 199.694 0 77.975-19.435 138.198-58.304 180.672-38.875 42.475-95.843 63.712-170.904 63.712-18.092 0-39.536-2.852-64.334-8.558-24.129-5.071-45.912-12.043-65.346-20.918v210.152zM302.179 396.596c45.569 0 79.745-13.946 102.532-41.84 23.455-27.893 35.184-68.467 35.184-121.718 0-51.983-11.057-92.872-33.17-122.668-21.445-29.795-59.647-44.694-114.604-44.694v0.006c-69.029 0-103.544 15.532-103.544 46.596v256.748c16.088 8.875 34.183 15.531 54.286 19.968 20.777 5.069 40.55 7.602 59.316 7.602z" />
<glyph unicode="&#x63;" glyph-name="l_C" horiz-adv-x="557" d="M330.612 538.494c-71.707 0-131.015-21.657-177.926-64.968-46.242-42.624-69.362-112.059-69.362-208.308 0-93.498 23.454-161.217 70.364-203.154 47.584-41.937 106.897-62.904 177.938-62.904 54.957 0 106.561 11 154.814 33v96.934c-46.243-22.687-92.152-34.030-137.726-34.030-56.3 0-97.183 14.093-122.648 42.28-25.465 28.875-38.198 74.25-38.198 136.124 0 59.124 13.067 102.091 39.2 128.902 26.139 27.499 65.684 41.25 118.632 41.25 42.221 0 88.797-11.001 139.728-33v96.938c-48.921 20.624-100.527 30.936-154.816 30.936z" />
<glyph unicode="&#x64;" glyph-name="l_D" horiz-adv-x="620" d="M445.968 670.464v-214.91c-18.766 8.876-40.211 15.533-64.334 19.97-23.461 4.437-44.237 6.656-62.33 6.656-77.744 0-136.385-21.555-175.922-64.664-39.543-43.108-59.316-103.015-59.316-179.722 0-95.726 23.121-162.925 69.362-201.596 46.249-38.037 105.227-57.054 176.934-57.054 35.517 0 70.032 4.119 103.544 12.36 33.507 8.241 61.321 20.921 83.44 38.038 22.113 17.751 33.17 39.304 33.17 64.662v576.26zM334.382 396.592c18.765 0 37.865-2.535 57.3-7.604 20.109-4.437 38.204-11.093 54.286-19.968v-265.312c0-11.411-10.723-20.603-32.168-27.576-20.776-6.973-46.577-10.46-77.406-10.46-53.615 0-91.145 14.897-112.59 44.692-21.444 30.429-32.166 72.272-32.166 125.524 0 107.137 47.581 160.704 142.744 160.704z" />
<glyph unicode="&#x65;" glyph-name="l_E" horiz-adv-x="592" d="M304.801 552.8c-132.913 0-221.060-100.514-221.060-275.996 0-164.706 80.26-278.555 221.060-278.555s186.621 74.967 208.162 141.978l-103.568 20.48c-12.8-28.625-35.293-61.794-104.594-61.732-58.514 1.097-117.456 44.225-118.776 146.625h336.376v51.2c0 179.2-100.076 256-217.6 256zM304.801 460.823c82.218 0 114.32-61.623 119.628-134.4h-236.853c7.877 72.777 35.005 134.4 117.225 134.4z" />
<glyph unicode="&#x66;" glyph-name="l_F" horiz-adv-x="467" d="M339.624 672.364c-48.253 0-89.803-12.046-124.652-36.136-34.181-24.090-51.272-72.902-51.272-146.44v-19.020h-81.424v-82.728h80.422v-394.638h105.558v394.63h127.666v82.73h-126.666v27.578c0 26.625 3.687 46.277 11.060 58.956 8.042 13.31 17.761 21.869 29.154 25.676 12.061 3.806 26.47 5.708 43.226 5.708 8.71 0 16.083-0.95 22.12-2.85 6.031-1.906 13.065-4.758 21.106-8.558v88.436c-18.767 4.437-37.532 6.656-56.298 6.656z" />
<glyph unicode="&#x67;" glyph-name="l_G" horiz-adv-x="616" d="M349.411 538.494v-0.002c-80.423 0-144.759-20.625-193.012-61.874s-72.38-115.497-72.38-222.746c0-82.499 19.098-146.093 57.294-190.78 38.875-44.684 95.172-67.715 168.89-69.092 22.119 0 44.571 3.44 67.358 10.318 23.455 6.875 44.901 15.811 64.336 26.81v-35.060c0-32.312-9.717-58.094-29.152-77.344-19.435-19.937-55.961-29.904-109.576-29.904-47.585 0-99.19 10.656-154.816 31.968v-99c48.921-18.563 103.206-27.844 162.852-27.844 81.765 0 141.413 18.563 178.946 55.688 37.527 37.124 56.292 85.249 56.292 144.372v410.43c0 43.999-18.765 77.343-56.292 100.030-36.865 22.687-83.778 34.030-140.74 34.030zM343.381 446.714c30.154 0 53.943-4.469 71.368-13.406 18.099-8.938 27.148-25.438 27.148-49.5v-271.212c-32.839-19.937-71.040-29.906-114.604-29.906-44.9 0-78.743 15.468-101.53 46.404-22.788 31.625-34.182 74.249-34.182 127.874 0 59.123 11.057 105.529 33.17 139.216 22.119 33.687 61.663 50.53 118.63 50.53z" />
<glyph unicode="&#x68;" glyph-name="l_H" horiz-adv-x="599" d="M83.819 672.364v-678.956h104.546l1.022 370.858c38.202 20.92 77.743 31.38 118.622 31.38 38.2 0 67.017-10.143 86.452-30.43 19.435-20.285 29.152-49.763 29.152-88.434v-283.376h105.558v295.738c0 128.057-63.671 192.084-191.010 192.084h-0.010c-48.92 0-98.511-12.996-148.774-38.988v230.124z" />
<glyph unicode="&#x69;" glyph-name="l_I" horiz-adv-x="269" d="M79.95 668v-115.2h115.2v115.2zM79.95 488.8v-486.4h115.2v486.4z" />
<glyph unicode="&#x6a;" glyph-name="l_J" horiz-adv-x="355" d="M170.436 640.032v-90.336h111.578v90.336zM173.45 470.768v-492.576c0-29.161-6.701-50.398-20.104-63.712-13.404-13.357-37.535-19.695-72.39-19.016l0.018-85.584c132.697 0 199.046 55.469 199.046 166.41l-1.020 494.478z" />
<glyph unicode="&#x6b;" glyph-name="l_K" horiz-adv-x="598" d="M83.807 651.444v-658.036h104.554v213.956l203.062-213.956 136.702-0.002-255.334 270.062 229.198 207.3h-129.68l-183.968-178.772 1.022 359.448z" />
<glyph unicode="&#x6c;" glyph-name="l_L" horiz-adv-x="276" d="M88.019 665.708v-661.516h114.492v661.516zM195.235 668h-115.2c0-221.867 0-443.733 0-665.6h115.2c0 221.867 0 443.733 0 665.6z" />
<glyph unicode="&#x6d;" glyph-name="l_M" horiz-adv-x="907" d="M321.65 538.494c-39.537 0-81.087-5.156-124.652-15.468-42.896-9.625-79.421-22.343-109.574-38.156v-475.398h105.548v416.618c34.855 13.062 70.375 19.594 106.56 19.594 79.755 0 119.632-36.094 119.632-108.28v-327.932h105.556v342.368c0 25.437-2.343 47.437-7.032 66 29.486 18.561 61.989 27.844 97.512 27.844 79.749 0 119.624-36.094 119.624-108.28v-327.932h105.558v342.368c0 63.936-16.42 111.030-49.258 141.28-32.17 30.249-83.441 45.374-153.812 45.374-58.31 0-114.608-13.061-168.892-39.186-32.171 26.125-81.094 39.186-146.77 39.186z" />
<glyph unicode="&#x6e;" glyph-name="l_N" horiz-adv-x="602" d="M204.15 501.6v38.4h-115.2v-537.6h115.2v294.4c0 158.805 217.6 153.6 217.6 0v-294.4h115.2v320c0 256-278.411 256-332.8 179.2z" />
<glyph unicode="&#x6f;" glyph-name="l_O" horiz-adv-x="639" d="M325.56 539.526c-160.846 0-241.27-90.404-241.27-271.214 0-89.373 20.105-157.434 60.316-204.184 40.88-46.749 101.531-70.124 181.954-70.124 77.739 0 137.719 23.719 179.94 71.156s63.332 115.154 63.332 203.152-20.439 155.027-61.318 201.088c-40.88 46.75-101.864 70.126-182.954 70.126zM325.54 448.778c48.252 0 83.437-15.125 105.556-45.374 22.113-29.562 33.17-74.593 33.17-135.092 0-121.685-46.242-182.528-138.726-182.528-47.585 0-82.433 15.467-104.546 46.404-21.445 31.625-32.166 77-32.166 136.124s10.385 103.811 31.154 134.060c21.451 30.937 56.637 46.406 105.558 46.406z" />
<glyph unicode="&#x70;" glyph-name="l_P" horiz-adv-x="617" d="M304.191 539.526v-0.002c-60.321 0-112.259-8.938-155.816-26.814-42.896-17.873-64.344-46.403-64.344-85.59v-624.928h104.554v221.716c18.76-9.627 39.872-16.845 63.334-21.656 23.455-4.811 44.227-7.216 62.32-7.216 73.724 0 131.027 23.717 171.906 71.154s61.318 111.716 61.318 192.84c0 98.998-22.449 170.498-67.348 214.498-44.231 43.999-102.874 65.998-175.924 65.998zM300.165 445.684c52.278 0 88.471-16.157 108.574-48.47 20.776-32.311 31.164-77.684 31.164-136.12 0-56.375-12.399-99.687-37.196-129.936-24.13-29.563-59.984-44.344-107.562-44.344-38.201 0-73.721 9.97-106.56 29.908v286.682c0 13.062 10.053 23.373 30.156 30.936 20.777 7.562 47.917 11.344 81.424 11.344z" />
<glyph unicode="&#x71;" glyph-name="l_Q" horiz-adv-x="617" d="M342.389 538.496c-172.239 0-258.358-93.841-258.358-281.524 0-82.499 20.439-146.782 61.318-192.844 40.885-46.061 99.192-69.092 174.92-69.092 18.099 0 38.206 2.405 60.318 7.216 22.789 4.813 43.565 12.376 62.33 22.688v-228.932h104.548v609.458c0 88.686-68.359 133.028-205.076 133.028zM341.377 444.652c26.807 0 50.267-4.469 70.376-13.406 20.777-8.937 31.164-21.654 31.164-38.154v-276.37c-32.838-19.938-68.695-29.908-107.57-29.908-45.569 0-81.088 15.125-106.56 45.374-24.796 30.25-37.194 73.219-37.194 128.906 0 57.748 10.725 102.778 32.176 135.090 22.112 32.312 61.315 48.468 117.608 48.468z" />
<glyph unicode="&#x72;" glyph-name="l_R" horiz-adv-x="486" d="M345.704 548.172c-55.969-0.124-116.065-17.399-141.704-61.812v53.64h-115.2v-537.6h115.2v331.302c25.436 89.051 141.279 132.757 217.6 89.141v114.403c-20.871 6.957-48.562 10.987-75.896 10.926z" />
<glyph unicode="&#x73;" glyph-name="l_S" horiz-adv-x="523" d="M269.956 549.628c-98.176-0.010-184.604-59.208-185.283-156.039-0.71-94.782 73.217-150.625 182.045-152.668 81.951-1.538 92.615-43.778 92.615-80.107 0-81.614-134.657-99.502-210.47-30.414l-65.933-60.84c114.489-120.914 368.915-89.58 369.492 98.068 0.31 112.932-86.14 162.2-179.303 163.808-65.908 1.138-100.288 29.364-96.376 68.481 7.609 76.083 147.158 83.739 211.495 7.027l63.608 63.608c-51.639 54.663-118.956 79.082-181.89 79.076z" />
<glyph unicode="&#x74;" glyph-name="l_T" horiz-adv-x="523" d="M159.769 665.708v-127.214l-76.84 0.226 0.51-101.998h76.33v-267.15c0-147.563 99.243-224.092 292.596-139.936v114.492c-127.213-50.886-178.106-38.165-178.106 38.164v254.43h127.212v101.772h-127.212v127.214z" />
<glyph unicode="&#x75;" glyph-name="l_U" horiz-adv-x="602" d="M88.95 540v-312.112c0-263.888 300.48-251.088 332.8-187.088v-38.4h115.2v537.6h-115.2v-307.2c0-140.8-217.6-140.8-217.6 0v307.2z" />
<glyph unicode="&#x76;" glyph-name="l_V" horiz-adv-x="684" d="M84.82 527.15l212.118-517.678h105.546l213.118 517.678h-109.574l-147.772-399.086-159.834 399.086z" />
<glyph unicode="&#x77;" glyph-name="l_W" horiz-adv-x="906" d="M87.412 527.15l167.878-517.678h99.528l107.562 368.15 108.572-368.15h100.53l167.878 517.678h-108.564l-114.604-391.868-109.574 391.868h-87.466l-106.558-389.806-112.592 389.806z" />
<glyph unicode="&#x78;" glyph-name="l_X" horiz-adv-x="586" d="M160.181 551.216l-76.33-76.328 152.48-203.544-152.66-203.544 76.33-76.33 139.936 190.822 139.938-190.822 76.33 76.33-152.66 203.544 152.84 206.676-76.33 73.196-140.118-190.824z" />
<glyph unicode="&#x79;" glyph-name="l_Y" horiz-adv-x="675" d="M84.712 538.494l203.542-508.86-12.714-38.164c-23.838-71.525-63.606-89.051-139.936-76.33v-114.492c190.82-12.721 216.265 54.066 267.15 190.822l203.542 547.024h-127.212l-127.224-356.202-127.212 356.202z" />
<glyph unicode="&#x7a;" glyph-name="l_Z" horiz-adv-x="537" d="M89.12 527.15v-85.59h260.372l-266.404-341.34v-90.748h383.012v90.748h-256.346l256.346 338.244v88.686z" />
</font></defs></svg>

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Binary file not shown.

48
src/www/assets/main.less Normal file
View File

@ -0,0 +1,48 @@
@font-face {
font-family: 'Cerxes';
src: url('assets/fonts/cerxes.eot');
src: url('assets/fonts/cerxes.eot#iefix') format('embedded-opentype'),
url('assets/fonts/cerxes.ttf') format('truetype'),
url('assets/fonts/cerxes.woff') format('woff'),
url('assets/fonts/cerxes.svg#Cerxes') format('svg');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 400;
src: local('Open Sans Regular'), local('OpenSans-Regular'), url("assets/fonts/OpenSans-Regular.ttf") format('truetype');
}
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 600;
src: local('Open Sans SemiBold'), local('OpenSans-SemiBold'), url("assets/fonts/OpenSans-SemiBold.ttf") format('truetype');
}
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 700;
src: local('Open Sans Bold'), local('OpenSans-Bold'), url("assets/fonts/OpenSans-Bold.ttf") format('truetype');
}
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 800;
src: local('Open Sans ExtraBold'), local('OpenSans-ExtraBold'), url("assets/fonts/OpenSans-ExtraBold.ttf") format('truetype');
}
body, html {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
font-family: "Open Sans", "Roboto", "Segoe UI", sans-serif;
}

View File

@ -0,0 +1,2 @@
@accent-bg: #2aa8b5;
@accent-fg: #ffffff;

111
src/www/lib/observable.js Normal file
View File

@ -0,0 +1,111 @@
import Observable from "zen-observable";
if(!Observable.combineLatest) {
/**
* Combines an array of observable streams into one observable stream where the value is an array latest values of each individual stream
*
* @param observables Array of observable streams to be combined as one (
* @returns {Observable<Array>}
*/
let combineLatest = function(observables){
let observablesState = observables.map((observable, index) => ({
index: index,
observable: observable,
subscription: undefined,
value: undefined,
returned: false,
completed: false,
}));
let observers = new Set();
return new Observable(observer => {
// Subscribe to child observables (if this is the first observer)
if (observers.size === 0) {
for (let observableState of observablesState) {
observableState.subscription = observableState.observable.subscribe({
next: (val) => {
observableState.value = val;
observableState.returned = true;
if (!observablesState.find(oS => oS.returned === false)) {
// If all observables returned a value
let values = observablesState.map(x => x.value);
for (let observer of observers) observer.next(values);
}
},
error: (err) => {
for (let observer of observers) observer.error(err);
},
complete: () => {
observableState.completed = true;
if (!observablesState.find(oS => oS.completed === false)) {
// If all observables completed, mark combined observable as completed
let values = observablesState.map(x => x.value);
for (let observer of observers) observer.complete(values);
for (let oS of observablesState) {
if (oS.subscription) {
oS.subscription.unsubscribe();
oS.subscription = undefined;
}
}
}
}
});
}
}
// Track observer
observers.add(observer);
// Return unsubscribe callback
return () => {
observers.delete(observer);
if (observers.size === 0) {
// If no one is watching, Unbind
for (let oS of observablesState) {
if (oS.subscription) {
oS.subscription.unsubscribe();
oS.subscription = undefined;
}
}
}
}
})
};
Observable.combineLatest = combineLatest;
}else{
console.warn("Observable already has an implementation of combineLatest! (this was not tested, yet!)")
}
if(!Observable.prototype.first){
/**
* Return first value of a stream as a promise
*
* @param filterFn Optional filter function that receives next value as a parameter (return true to return as first element)
* @returns {Promise<any>}
*/
Observable.prototype.first = function(filterFn){
return new Promise((resolve,reject)=>{
let subscription = this.subscribe({
next(value){
if(!filterFn || filterFn(value)){
subscription.unsubscribe();
resolve(value);
}
},
error(err){
reject(err);
},
complete(){
resolve(undefined);
}
})
})
}
}else{
console.warn("Observable.prototype already has an implementation of first! (this was not tested, yet!)")
}
// Note/TODO: Append a slice-method to observable? functions replaces skip/take in RXjs and functions similar to slice in arrays? (note, don't know the length of observable stream so might not be possible to implement slice's interpretation of negative numbers)
//if(window && !window.Observable) window.Observable = Observable;
export {Observable};

30
src/www/lib/subject.js Normal file
View File

@ -0,0 +1,30 @@
import {Observable} from "./observable";
export class Subject extends Observable{
_observers = [];
constructor(){
super((observer=>{
this._observers.push(observer);
// Return a cleanup function which will unsubscribe the observer
return ()=>{
this._observers = this._observers.filter(obs=>obs!==observer);
}
}));
this._observers = [];
}
close(){
for(let obs of this._observers){
obs.complete();
}
}
next(newValue){
for(let obs of this._observers){
obs.next(newValue);
}
}
}
//if(window && !window.ValueSubject) window.ValueSubject = ValueSubject;

View File

@ -0,0 +1,105 @@
import {Observable} from "./observable";
export class ValueSubject extends Observable{
_observers = [];
constructor(data){
super(observer=>{
this._observers.push(observer);
if(this._timestamp!==undefined){
// Already have a value
observer.next(this._value);
}else if(this._request === undefined){
// No request has been made yet
this.refresh();
}
// Return a cleanup function which will unsubscribe the observer
return ()=>{
this._observers = this._observers.filter(obs=>obs!==observer);
}
});
if(typeof(data)==="function"){
this._refreshFn = data;
this._value = undefined;
this._timestamp = undefined;
}else if(data!==undefined){
this._refreshFn = undefined;
this._value = data;
this._timestamp = new Date();
}
}
refresh(){
if(this._refreshFn){
let req = this._request = Promise.resolve(this._refreshFn()).then(result=>{
this.update(result);
this._request = undefined;
return this._value;
}).catch(err=>{
for(let obs of this._observers){
obs.error(err);
}
});
return req;
}else{
return new Promise((resolve)=>resolve());// NO-OP
}
}
close(){
for(let obs of this._observers){
obs.complete();
}
}
update(newValue){
if(newValue!==this._value){
this._value = newValue;
this._timestamp = new Date();
for(let obs of this._observers){
obs.next(newValue);
}
}
}
getObservable({passive=false}= {}){
return new Observable(observer=>{
this._observers.push(observer);
if(!passive){
if(this._timestamp!==undefined){
// Already have a value
observer.next(this._value);
}else if(this._request === undefined){
// No request has been made yet
this.refresh();
}
}
// Return a cleanup function which will unsubscribe the observer
return ()=>{
this._observers = this._observers.filter(obs=>obs!==observer);
}
})
}
// Properties
get timestamp(){
return this._timestamp;
}
get value(){
return this._value;
}
set value(value){
this.update(value);
}
get updates(){
return this.getObservable({passive: true});
}
}
//if(window && !window.ValueSubject) window.ValueSubject = ValueSubject;

20
src/www/page.hbs Normal file
View File

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Cxs Examples</title>
<style>
body{
margin: 0;
padding: 0;
font-family: "Segoe UI", Arial, Helvetica, sans-serif;
}
</style>
<link rel="icon" href="assets/favicon196.png">
<meta name="viewport" content="width=device-width, initial-scale=1">
{{#if polyfill}}<script{{#if es6}} type="module"{{/if}}>{{{polyfill}}}</script>{{/if}}
</head>
<body>
<script{{#if es6}} type="module"{{/if}}>{{{pageCode}}}</script>
</body>
</html>

237
src/www/pages/index.page.js Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,80 @@
@import "../assets/theme.less";
body {
flex: 1 1 auto;
display: flex;
flex-direction: column;
margin: 0;
}
[class^="cxs-font"], [class*=" cxs-font"] {
/* use !important to prevent issues with browser extensions that change fonts */
font-family: 'Cerxes' !important;
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
/* Better Font Rendering =========== */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
main{
display: flex;
flex-direction: column;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
.results{
width: 100%;
table-layout: fixed;
th, td{
text-align: center;
.time{
display: flex;
flex-direction: column;
justify-items: flex-start;
align-items: center;
.first-time{
font-size: 80%;
}
}
}
}
.test-host{
flex: 1 1 auto;
padding: 1rem;
position: relative;
overflow: hidden;
.test-output{
flex: 1 1 auto;
overflow: auto;
border: 1px solid #999;
position: absolute;
top: 1rem;
left: 1rem;
right: 1rem;
bottom: 1rem;
.data{
width: 100%;
table-layout: fixed;
.highlight{
color: #2aa8b5;
font-weight: bold;
}
}
}
}
}

View File

@ -0,0 +1,15 @@
export function loadPage(module, target){
let createFn = module.default||module.create;
if(!target){target = document.body;}
if(createFn){
let ctarget = target.cloneNode(false);
target.parentNode.replaceChild(ctarget,target);
// TODO pass query params
let elements = createFn();
for(let element of elements){
ctarget.appendChild(element);
}
}else{
console.error("No default! Cannot create", module);
}
}

View File

@ -0,0 +1,61 @@
export function loadPolyfills(){
/**
* Shamelessly taken from @webcomponents, adapted to fit own bundling purposes
*/
// global for (1) existence means `WebComponentsReady` will fire,
// (2) WebComponents.ready == true means event has fired.
window.WebComponents = window.WebComponents || {};
// Feature detect which polyfill needs to be imported.
let polyfills = [];
if (!('attachShadow' in Element.prototype && 'getRootNode' in Element.prototype) ||
(window.ShadyDOM && window.ShadyDOM.force)) {
polyfills.push('sd');
}
if (!window.customElements || window.customElements.forcePolyfill) {
polyfills.push('ce');
}
// NOTE: any browser that does not have template or ES6 features
// must load the full suite (called `lite` for legacy reasons) of polyfills.
if (!('content' in document.createElement('template')) || !window.Promise || !Array.from ||
// Edge has broken fragment cloning which means you cannot clone template.content
!(document.createDocumentFragment().cloneNode() instanceof DocumentFragment)) {
polyfills = ['lite'];
}
if (polyfills.length) {
let newScript = document.createElement('script');
// Load it from the right place.
let url = `/lib/polyfills/webcomponents-${polyfills.join('-')}.js`;
newScript.src = url;
// NOTE: this is required to ensure the polyfills are loaded before
// *native* html imports load on older Chrome versions. This *is* CSP
// compliant since CSP rules must have allowed this script to run.
// In all other cases, this can be async.
if (document.readyState === 'loading' && ('import' in document.createElement('link'))) {
document.write(newScript.outerHTML);
} else {
document.head.appendChild(newScript);
}
} else {
// Ensure `WebComponentsReady` is fired also when there are no polyfills loaded.
// however, we have to wait for the document to be in 'interactive' state,
// otherwise a rAF may fire before scripts in <body>
var fire = function() {
requestAnimationFrame(function() {
window.WebComponents.ready = true;
document.dispatchEvent(new CustomEvent('WebComponentsReady', {bubbles: true}));
});
};
if (document.readyState !== 'loading') {
fire();
} else {
document.addEventListener('readystatechange', function wait() {
fire();
document.removeEventListener('readystatechange', wait);
});
}
}
}

3022
yarn.lock Normal file

File diff suppressed because it is too large Load Diff