mosaic 1.0.1 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +63 -8
- package/cjs/attribute.js +90 -0
- package/cjs/constants.js +15 -0
- package/cjs/context.js +66 -0
- package/cjs/define.js +152 -0
- package/cjs/formControl.js +42 -0
- package/cjs/helpers.js +140 -0
- package/cjs/index.js +9 -0
- package/cjs/list.js +109 -0
- package/cjs/mergeSlots.js +37 -0
- package/cjs/proxy.js +42 -0
- package/cjs/render.js +395 -0
- package/cjs/token.js +63 -0
- package/cjs/update.js +128 -0
- package/dist/mosaic.js +1142 -0
- package/dist/mosaic.min.js +1 -0
- package/package.json +42 -25
- package/src/attribute.js +84 -0
- package/src/constants.js +5 -0
- package/src/context.js +60 -0
- package/src/define.js +158 -0
- package/src/formControl.js +36 -0
- package/src/helpers.js +123 -0
- package/src/index.js +1 -0
- package/src/list.js +100 -0
- package/src/mergeSlots.js +31 -0
- package/src/proxy.js +36 -0
- package/src/render.js +397 -0
- package/src/token.js +55 -0
- package/src/update.js +122 -0
- package/SCRATCH.md +0 -31
- package/cli.js +0 -17
- package/conf.json +0 -0
- package/docs/assets/css/main.css +0 -2638
- package/docs/assets/images/icons.png +0 -0
- package/docs/assets/images/icons@2x.png +0 -0
- package/docs/assets/images/widgets.png +0 -0
- package/docs/assets/images/widgets@2x.png +0 -0
- package/docs/assets/js/main.js +0 -248
- package/docs/assets/js/search.js +0 -1
- package/docs/index.html +0 -111
- package/docs/modules.html +0 -131
- package/example/components/x-drawer.html +0 -41
- package/example/mosaic/templates/mocha/index.html +0 -39
- package/example/mosaic/tests.d.ts +0 -13
- package/example/mosaic/tests.js +0 -28
- package/example/mosaic/website.d.ts +0 -31
- package/example/mosaic/website.js +0 -64
- package/example/mosaic.config.d.ts +0 -7
- package/example/mosaic.config.js +0 -8
- package/example/package-lock.json +0 -899
- package/example/package.json +0 -20
- package/example/pages/index.html +0 -12
- package/example/test/x-drawer.d.ts +0 -0
- package/example/test/x-drawer.js +0 -94
- package/index.d.ts +0 -85
- package/index.js +0 -122
- package/index.wdocs.js +0 -37
- package/out/fonts/OpenSans-Bold-webfont.eot +0 -0
- package/out/fonts/OpenSans-Bold-webfont.svg +0 -1830
- package/out/fonts/OpenSans-Bold-webfont.woff +0 -0
- package/out/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
- package/out/fonts/OpenSans-BoldItalic-webfont.svg +0 -1830
- package/out/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
- package/out/fonts/OpenSans-Italic-webfont.eot +0 -0
- package/out/fonts/OpenSans-Italic-webfont.svg +0 -1830
- package/out/fonts/OpenSans-Italic-webfont.woff +0 -0
- package/out/fonts/OpenSans-Light-webfont.eot +0 -0
- package/out/fonts/OpenSans-Light-webfont.svg +0 -1831
- package/out/fonts/OpenSans-Light-webfont.woff +0 -0
- package/out/fonts/OpenSans-LightItalic-webfont.eot +0 -0
- package/out/fonts/OpenSans-LightItalic-webfont.svg +0 -1835
- package/out/fonts/OpenSans-LightItalic-webfont.woff +0 -0
- package/out/fonts/OpenSans-Regular-webfont.eot +0 -0
- package/out/fonts/OpenSans-Regular-webfont.svg +0 -1831
- package/out/fonts/OpenSans-Regular-webfont.woff +0 -0
- package/out/global.html +0 -912
- package/out/index.html +0 -65
- package/out/index.js.html +0 -239
- package/out/scripts/linenumber.js +0 -25
- package/out/scripts/prettify/Apache-License-2.0.txt +0 -202
- package/out/scripts/prettify/lang-css.js +0 -2
- package/out/scripts/prettify/prettify.js +0 -28
- package/out/styles/jsdoc-default.css +0 -358
- package/out/styles/prettify-jsdoc.css +0 -111
- package/out/styles/prettify-tomorrow.css +0 -132
- package/tsconfig.json +0 -11
package/example/package.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "example",
|
|
3
|
-
"type": "module",
|
|
4
|
-
"version": "1.0.0",
|
|
5
|
-
"description": "",
|
|
6
|
-
"main": "mosaic.config.js",
|
|
7
|
-
"directories": {
|
|
8
|
-
"test": "test"
|
|
9
|
-
},
|
|
10
|
-
"scripts": {
|
|
11
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
12
|
-
},
|
|
13
|
-
"keywords": [],
|
|
14
|
-
"author": "",
|
|
15
|
-
"license": "ISC",
|
|
16
|
-
"devDependencies": {
|
|
17
|
-
"chai": "^4.2.0",
|
|
18
|
-
"mocha": "^8.2.1"
|
|
19
|
-
}
|
|
20
|
-
}
|
package/example/pages/index.html
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
-
<title>Document</title>
|
|
7
|
-
</head>
|
|
8
|
-
<body>
|
|
9
|
-
<x-drawer title="hello world"><p>BOO!</p></x-drawer>
|
|
10
|
-
<!-- {{ COMPONENTS }} -->
|
|
11
|
-
</body>
|
|
12
|
-
</html>
|
|
File without changes
|
package/example/test/x-drawer.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
describe('x-drawer', () => {
|
|
2
|
-
it('should accept [title]', () => {
|
|
3
|
-
const title = 'test title';
|
|
4
|
-
|
|
5
|
-
mount(html`<x-drawer title="${title}"></x-drawer>`);
|
|
6
|
-
|
|
7
|
-
let h3 = $('h3');
|
|
8
|
-
|
|
9
|
-
assert.equal(h3.textContent.trim(), title);
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it('should be collapsed by default', () => {
|
|
13
|
-
mount(html`<x-drawer></x-drawer>`);
|
|
14
|
-
|
|
15
|
-
let panel = $('[aria-labelledby]');
|
|
16
|
-
let button = $('button');
|
|
17
|
-
|
|
18
|
-
assert.equal(panel.hidden, true);
|
|
19
|
-
assert.equal(button.getAttribute('aria-expanded'), 'false');
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('should accept [expanded]', () => {
|
|
23
|
-
mount(html`<x-drawer expanded></x-drawer>`);
|
|
24
|
-
|
|
25
|
-
let panel = $('[aria-labelledby]');
|
|
26
|
-
let button = $('button');
|
|
27
|
-
|
|
28
|
-
assert.equal(panel.hidden, false);
|
|
29
|
-
assert.equal(button.getAttribute('aria-expanded'), 'true');
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('should accept slotted panel content', () => {
|
|
33
|
-
mount(html`<x-drawer expanded><p>FOO</p></x-drawer>`);
|
|
34
|
-
|
|
35
|
-
let panel = $('[aria-labelledby]');
|
|
36
|
-
|
|
37
|
-
assert.equal(panel.innerHTML.trim(), '<p>FOO</p>');
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('should open when the accordion header button is clicked', async () => {
|
|
41
|
-
mount(html`<x-drawer></x-drawer>`);
|
|
42
|
-
|
|
43
|
-
let panel = $('[aria-labelledby]');
|
|
44
|
-
$('button').click();
|
|
45
|
-
await nextFrame();
|
|
46
|
-
|
|
47
|
-
assert.equal(panel.hidden, false);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('should close when the accordion header button is clicked', async () => {
|
|
51
|
-
mount(html`<x-drawer expanded title="title"> </x-drawer>`);
|
|
52
|
-
|
|
53
|
-
let panel = $('[aria-labelledby]');
|
|
54
|
-
|
|
55
|
-
$('button').click();
|
|
56
|
-
await nextFrame();
|
|
57
|
-
|
|
58
|
-
assert.equal(panel.hidden, true);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it('the title of each accordion header is contained in an element with role button', () => {
|
|
62
|
-
const title = 'test title';
|
|
63
|
-
|
|
64
|
-
mount(html`<x-drawer title="${title}"></x-drawer>`);
|
|
65
|
-
|
|
66
|
-
let button = $('h3 button');
|
|
67
|
-
|
|
68
|
-
assert.equal(button.textContent.trim(), title);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it('each accordion header button is wrapped in an element with role heading', () => {
|
|
72
|
-
/*
|
|
73
|
-
|
|
74
|
-
NB: The full requirements is as follows:
|
|
75
|
-
|
|
76
|
-
each accordion header button is wrapped in an element with role heading that has a value set for aria-level that is appropriate for the information architecture of the page.
|
|
77
|
-
|
|
78
|
-
This test leaves the heading level to your own discretion. Whether it is "appropriate for the information architecture of your page" really depends what your page looks like, so bare this in mind!
|
|
79
|
-
|
|
80
|
-
*/
|
|
81
|
-
|
|
82
|
-
mount(html`<x-drawer></x-drawer>`);
|
|
83
|
-
|
|
84
|
-
let parentNodeName = $('button').parentNode.nodeName;
|
|
85
|
-
|
|
86
|
-
assert.ok(parentNodeName.match(/^H[1-6]{1}$/));
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it('the button element is the only element inside the heading element', () => {
|
|
90
|
-
mount(html`<x-drawer><span slot="head">hi!</span></x-drawer>`);
|
|
91
|
-
|
|
92
|
-
assert.equal($('button').parentNode.children.length, 1);
|
|
93
|
-
});
|
|
94
|
-
});
|
package/index.d.ts
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
export default mosaic;
|
|
2
|
-
export type FileObject = {
|
|
3
|
-
/**
|
|
4
|
-
* - the location of the file on disk
|
|
5
|
-
*/
|
|
6
|
-
filepath: string;
|
|
7
|
-
/**
|
|
8
|
-
* - the file content
|
|
9
|
-
*/
|
|
10
|
-
content: string;
|
|
11
|
-
};
|
|
12
|
-
export type Server = {
|
|
13
|
-
/**
|
|
14
|
-
* - the port to serve on
|
|
15
|
-
*/
|
|
16
|
-
port?: string;
|
|
17
|
-
/**
|
|
18
|
-
* - An optional static path
|
|
19
|
-
*/
|
|
20
|
-
staticPath?: string;
|
|
21
|
-
/**
|
|
22
|
-
* - A dictionary of key value pairs, where each key is the name of a route path, and the value is the string content that should be served for that route
|
|
23
|
-
*/
|
|
24
|
-
routes: {
|
|
25
|
-
[x: string]: string;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
export type OutputMapFn = any;
|
|
29
|
-
/**
|
|
30
|
-
* - Mosaic configuration
|
|
31
|
-
*/
|
|
32
|
-
export type Config = {
|
|
33
|
-
/**
|
|
34
|
-
* - a dictionary of key value pairs where key is the name of a set of files and value is a glob pattern describing the location of those files on disk
|
|
35
|
-
*/
|
|
36
|
-
input: {
|
|
37
|
-
[x: string]: string;
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* - an array of functions to be called in series in order to transform the input
|
|
41
|
-
*/
|
|
42
|
-
transform: Function[];
|
|
43
|
-
/**
|
|
44
|
-
* - a function that takes the output of the transform pipeline and then returns an FileObject array representing the files to be saved to disk
|
|
45
|
-
*/
|
|
46
|
-
output: any;
|
|
47
|
-
/**
|
|
48
|
-
* - optionally serve files using an express server
|
|
49
|
-
*/
|
|
50
|
-
serve?: Server;
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* @typedef {object} FileObject
|
|
54
|
-
* @property {string} filepath - the location of the file on disk
|
|
55
|
-
* @property {string} content - the file content
|
|
56
|
-
*/
|
|
57
|
-
/**
|
|
58
|
-
*
|
|
59
|
-
* @typedef {object} Server
|
|
60
|
-
* @property {string} [port=3000] - the port to serve on
|
|
61
|
-
* @property {string} [staticPath] - An optional static path
|
|
62
|
-
* @property {Object.<string, string>} routes - A dictionary of key value pairs, where each key is the name of a route path, and the value is the string content that should be served for that route
|
|
63
|
-
*
|
|
64
|
-
*/
|
|
65
|
-
/**
|
|
66
|
-
* @typedef OutputMapFn
|
|
67
|
-
*
|
|
68
|
-
* @returns {FileObject[]}
|
|
69
|
-
*/
|
|
70
|
-
/**
|
|
71
|
-
*
|
|
72
|
-
* @typedef {Object} Config - Mosaic configuration
|
|
73
|
-
* @property {Object.<string,string>} input - a dictionary of key value pairs where key is the name of a set of files and value is a glob pattern describing the location of those files on disk
|
|
74
|
-
* @property {function[]} transform - an array of functions to be called in series in order to transform the input
|
|
75
|
-
* @property {OutputMapFn} output - a function that takes the output of the transform pipeline and then returns an FileObject array representing the files to be saved to disk
|
|
76
|
-
* @property {Server} [serve] - optionally serve files using an express server
|
|
77
|
-
*
|
|
78
|
-
*/
|
|
79
|
-
/**
|
|
80
|
-
*
|
|
81
|
-
* @param {Config} config
|
|
82
|
-
*
|
|
83
|
-
* @returns {Promise<void>}
|
|
84
|
-
*/
|
|
85
|
-
declare function mosaic(config: Config): Promise<void>;
|
package/index.js
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import chokidar from 'chokidar';
|
|
2
|
-
import express from 'express';
|
|
3
|
-
import fs from 'fs-extra';
|
|
4
|
-
import glob from 'glob-promise';
|
|
5
|
-
import path from 'path';
|
|
6
|
-
import debounce from 'lodash.debounce';
|
|
7
|
-
import WebSocket from 'ws';
|
|
8
|
-
|
|
9
|
-
function injectHotReloadScript(v, port) {
|
|
10
|
-
return typeof v === 'string'
|
|
11
|
-
? v.replace(
|
|
12
|
-
'</body>',
|
|
13
|
-
`
|
|
14
|
-
<script>new WebSocket("ws://localhost:80").addEventListener("message", event => {
|
|
15
|
-
if (event.data === "reload") window.location.reload();
|
|
16
|
-
})</script>
|
|
17
|
-
`
|
|
18
|
-
)
|
|
19
|
-
: v;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const mosaic = (config) => {
|
|
23
|
-
let app, routes, socket;
|
|
24
|
-
|
|
25
|
-
const hotReload = config.serve && config.watch;
|
|
26
|
-
|
|
27
|
-
if (hotReload) {
|
|
28
|
-
const wss = new WebSocket.Server({ port: 80 });
|
|
29
|
-
wss.on('connection', (s) => {
|
|
30
|
-
socket = s;
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (config.serve) {
|
|
35
|
-
let { port = 3000, staticPath = './' } = config.serve;
|
|
36
|
-
app = new express();
|
|
37
|
-
app.use(express.static(staticPath));
|
|
38
|
-
app.use(function (req, res, next) {
|
|
39
|
-
let k = req.originalUrl.split('?')[0];
|
|
40
|
-
if (k in routes) {
|
|
41
|
-
let payload = routes[k];
|
|
42
|
-
|
|
43
|
-
if (hotReload) {
|
|
44
|
-
payload = injectHotReloadScript(payload);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
res.send(payload);
|
|
48
|
-
} else {
|
|
49
|
-
next();
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
app.listen(port, () => console.log(`Express server listening on port ${port}`));
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const cache = {};
|
|
56
|
-
|
|
57
|
-
const getCacheValues = () =>
|
|
58
|
-
Object.keys(cache).reduce((a, k) => {
|
|
59
|
-
let isGlob = config.input[k].includes('*');
|
|
60
|
-
let values = Object.values(cache[k]);
|
|
61
|
-
a[k] = isGlob ? values : values[0];
|
|
62
|
-
return a;
|
|
63
|
-
}, {});
|
|
64
|
-
|
|
65
|
-
const update = () => {
|
|
66
|
-
let values = getCacheValues();
|
|
67
|
-
let { transform = [] } = config;
|
|
68
|
-
|
|
69
|
-
let transformResult = transform.reduce((output, fn) => fn(output), values);
|
|
70
|
-
|
|
71
|
-
if (config.serve) {
|
|
72
|
-
let { mapRoutes = () => ({}) } = config.serve;
|
|
73
|
-
routes = mapRoutes(transformResult);
|
|
74
|
-
if (hotReload && socket) socket.send('reload');
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (config.output) {
|
|
78
|
-
let { map = (v = v) } = config.output;
|
|
79
|
-
let output = map(transformResult);
|
|
80
|
-
|
|
81
|
-
return Promise.all(
|
|
82
|
-
output.map(({ filepath, content }) => {
|
|
83
|
-
return fs
|
|
84
|
-
.ensureDir(path.dirname(filepath))
|
|
85
|
-
.then(() => fs.promises.writeFile(filepath, content));
|
|
86
|
-
})
|
|
87
|
-
);
|
|
88
|
-
} else {
|
|
89
|
-
return Promise.resolve();
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
const updateCache = (key, filepath) =>
|
|
94
|
-
fs.promises.readFile(filepath, 'utf8').then((content) => {
|
|
95
|
-
cache[key][filepath] = { content, filepath };
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
const populateCache = () =>
|
|
99
|
-
Promise.all(
|
|
100
|
-
Object.entries(config.input).map(([key, globPath]) => {
|
|
101
|
-
cache[key] = {};
|
|
102
|
-
return glob(globPath).then((paths) => Promise.all(paths.map((f) => updateCache(key, f))));
|
|
103
|
-
})
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
const scheduleUpdate = debounce(update);
|
|
107
|
-
|
|
108
|
-
return populateCache()
|
|
109
|
-
.then(update)
|
|
110
|
-
.then(() => {
|
|
111
|
-
if (config.watch) {
|
|
112
|
-
Object.entries(config.input).forEach(([key, glob]) => {
|
|
113
|
-
chokidar.watch(glob).on('change', (filepath) => {
|
|
114
|
-
updateCache(key, filepath).then(scheduleUpdate);
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
//@todo: handle unlink, add
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
export default mosaic;
|
package/index.wdocs.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {object} FileObject
|
|
3
|
-
* @property {string} filepath - the location of the file on disk
|
|
4
|
-
* @property {string} content - the file content
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
*
|
|
9
|
-
* @typedef {object} Server
|
|
10
|
-
* @property {string} [port=3000] - the port to serve on
|
|
11
|
-
* @property {string} [staticPath] - An optional static path
|
|
12
|
-
* @property {Object.<string, string>} routes - A dictionary of key value pairs, where each key is the name of a route path, and the value is the string content that should be served for that route
|
|
13
|
-
*
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @typedef OutputMapFn
|
|
18
|
-
*
|
|
19
|
-
* @returns {FileObject[]}
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
24
|
-
* @typedef {Object} Config - Mosaic configuration
|
|
25
|
-
* @property {Object.<string,string>} input - a dictionary of key value pairs where key is the name of a set of files and value is a glob pattern describing the location of those files on disk
|
|
26
|
-
* @property {function[]} transform - an array of functions to be called in series in order to transform the input
|
|
27
|
-
* @property {OutputMapFn} output - a function that takes the output of the transform pipeline and then returns an FileObject array representing the files to be saved to disk
|
|
28
|
-
* @property {Server} [serve] - optionally serve files using an express server
|
|
29
|
-
*
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
*
|
|
34
|
-
* @param {Config} config
|
|
35
|
-
*
|
|
36
|
-
* @returns {Promise<void>}
|
|
37
|
-
*/
|
|
Binary file
|