mosaic 1.0.3 → 1.0.6

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.
Files changed (88) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +63 -8
  3. package/cjs/attribute.js +90 -0
  4. package/cjs/constants.js +15 -0
  5. package/cjs/context.js +66 -0
  6. package/cjs/define.js +117 -0
  7. package/cjs/formControl.js +42 -0
  8. package/cjs/helpers.js +140 -0
  9. package/cjs/index.js +9 -0
  10. package/cjs/list.js +109 -0
  11. package/cjs/mergeSlots.js +37 -0
  12. package/cjs/proxy.js +42 -0
  13. package/cjs/render.js +384 -0
  14. package/cjs/token.js +63 -0
  15. package/cjs/update.js +128 -0
  16. package/dist/mosaic.js +1096 -0
  17. package/dist/mosaic.min.js +1 -0
  18. package/package.json +42 -25
  19. package/src/attribute.js +84 -0
  20. package/src/constants.js +5 -0
  21. package/src/context.js +60 -0
  22. package/src/define.js +116 -0
  23. package/src/formControl.js +36 -0
  24. package/src/helpers.js +123 -0
  25. package/src/index.js +1 -0
  26. package/src/list.js +100 -0
  27. package/src/mergeSlots.js +31 -0
  28. package/src/proxy.js +36 -0
  29. package/src/render.js +386 -0
  30. package/src/token.js +55 -0
  31. package/src/update.js +122 -0
  32. package/SCRATCH.md +0 -31
  33. package/cli.js +0 -17
  34. package/conf.json +0 -0
  35. package/docs/assets/css/main.css +0 -2638
  36. package/docs/assets/images/icons.png +0 -0
  37. package/docs/assets/images/icons@2x.png +0 -0
  38. package/docs/assets/images/widgets.png +0 -0
  39. package/docs/assets/images/widgets@2x.png +0 -0
  40. package/docs/assets/js/main.js +0 -248
  41. package/docs/assets/js/search.js +0 -1
  42. package/docs/index.html +0 -111
  43. package/docs/modules.html +0 -131
  44. package/example/components/x-drawer.html +0 -41
  45. package/example/mosaic/templates/mocha/index.html +0 -39
  46. package/example/mosaic/tests.d.ts +0 -13
  47. package/example/mosaic/tests.js +0 -28
  48. package/example/mosaic/website.d.ts +0 -31
  49. package/example/mosaic/website.js +0 -64
  50. package/example/mosaic.config.d.ts +0 -7
  51. package/example/mosaic.config.js +0 -8
  52. package/example/package-lock.json +0 -899
  53. package/example/package.json +0 -20
  54. package/example/pages/index.html +0 -12
  55. package/example/test/x-drawer.d.ts +0 -0
  56. package/example/test/x-drawer.js +0 -94
  57. package/index.d.ts +0 -85
  58. package/index.js +0 -125
  59. package/index.wdocs.js +0 -37
  60. package/out/fonts/OpenSans-Bold-webfont.eot +0 -0
  61. package/out/fonts/OpenSans-Bold-webfont.svg +0 -1830
  62. package/out/fonts/OpenSans-Bold-webfont.woff +0 -0
  63. package/out/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
  64. package/out/fonts/OpenSans-BoldItalic-webfont.svg +0 -1830
  65. package/out/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
  66. package/out/fonts/OpenSans-Italic-webfont.eot +0 -0
  67. package/out/fonts/OpenSans-Italic-webfont.svg +0 -1830
  68. package/out/fonts/OpenSans-Italic-webfont.woff +0 -0
  69. package/out/fonts/OpenSans-Light-webfont.eot +0 -0
  70. package/out/fonts/OpenSans-Light-webfont.svg +0 -1831
  71. package/out/fonts/OpenSans-Light-webfont.woff +0 -0
  72. package/out/fonts/OpenSans-LightItalic-webfont.eot +0 -0
  73. package/out/fonts/OpenSans-LightItalic-webfont.svg +0 -1835
  74. package/out/fonts/OpenSans-LightItalic-webfont.woff +0 -0
  75. package/out/fonts/OpenSans-Regular-webfont.eot +0 -0
  76. package/out/fonts/OpenSans-Regular-webfont.svg +0 -1831
  77. package/out/fonts/OpenSans-Regular-webfont.woff +0 -0
  78. package/out/global.html +0 -912
  79. package/out/index.html +0 -65
  80. package/out/index.js.html +0 -239
  81. package/out/scripts/linenumber.js +0 -25
  82. package/out/scripts/prettify/Apache-License-2.0.txt +0 -202
  83. package/out/scripts/prettify/lang-css.js +0 -2
  84. package/out/scripts/prettify/prettify.js +0 -28
  85. package/out/styles/jsdoc-default.css +0 -358
  86. package/out/styles/prettify-jsdoc.css +0 -111
  87. package/out/styles/prettify-tomorrow.css +0 -132
  88. package/tsconfig.json +0 -11
@@ -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
- }
@@ -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
@@ -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,125 +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
- </body>
18
- `
19
- )
20
- : v;
21
- }
22
-
23
- const mosaic = (config) => {
24
- let app, routes, socket;
25
-
26
- const hotReload = config.serve && config.watch;
27
-
28
- if (hotReload) {
29
- const wss = new WebSocket.Server({ port: 80 });
30
- wss.on('connection', (s) => {
31
- socket = s;
32
- });
33
- }
34
-
35
- if (config.serve) {
36
- let { port = 3000, staticPath = './' } = config.serve;
37
- app = new express();
38
- app.use(express.static(staticPath));
39
- app.use(function (req, res, next) {
40
- let k = req.originalUrl.split('?')[0];
41
- if (k in routes) {
42
- let payload = routes[k];
43
-
44
- if (hotReload) {
45
- payload = injectHotReloadScript(payload);
46
- }
47
-
48
- res.send(payload);
49
- } else {
50
- next();
51
- }
52
- });
53
- app.listen(port, () => console.log(`Express server listening on port ${port}`));
54
- }
55
-
56
- const cache = {};
57
-
58
- const getCacheValues = () =>
59
- Object.keys(cache).reduce((a, k) => {
60
- let isGlob = config.input[k].includes('*');
61
- let values = Object.values(cache[k]);
62
- a[k] = isGlob ? values : values[0];
63
- return a;
64
- }, {});
65
-
66
- const update = () => {
67
- let values = getCacheValues();
68
- let { transform = [] } = config;
69
-
70
- let transformResult = transform.reduce((output, fn) => fn(output), values);
71
-
72
- if (config.serve) {
73
- let { mapRoutes = () => ({}) } = config.serve;
74
- routes = mapRoutes(transformResult);
75
- if (hotReload && socket) socket.send('reload');
76
- }
77
-
78
- if (config.output) {
79
- let { map = (v = v) } = config.output;
80
- let output = map(transformResult);
81
-
82
- return Promise.all(
83
- output.map(({ filepath, content }) => {
84
- return fs
85
- .ensureDir(path.dirname(filepath))
86
- .then(() => fs.promises.writeFile(filepath, content));
87
- })
88
- );
89
- } else {
90
- return Promise.resolve();
91
- }
92
- };
93
-
94
- const updateCache = (key, filepath) =>
95
- fs.promises.readFile(filepath, 'utf8').then((content) => {
96
- cache[key][filepath] = { content, filepath };
97
- });
98
-
99
- const populateCache = () =>
100
- Promise.all(
101
- Object.entries(config.input).map(([key, globPath]) => {
102
- cache[key] = {};
103
- return glob(globPath).then((paths) =>
104
- Promise.all(paths.map((f) => updateCache(key, path.normalize(f))))
105
- );
106
- })
107
- );
108
-
109
- const scheduleUpdate = debounce(update);
110
-
111
- return populateCache()
112
- .then(update)
113
- .then(() => {
114
- if (config.watch) {
115
- Object.entries(config.input).forEach(([key, glob]) => {
116
- chokidar.watch(glob).on('change', (filepath) => {
117
- updateCache(key, filepath).then(scheduleUpdate);
118
- });
119
- });
120
- //@todo: handle unlink, add
121
- }
122
- });
123
- };
124
-
125
- 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