mosaic 1.0.3 → 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.
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 +152 -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 +395 -0
  14. package/cjs/token.js +63 -0
  15. package/cjs/update.js +128 -0
  16. package/dist/mosaic.js +1142 -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 +158 -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 +397 -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
package/cjs/update.js ADDED
@@ -0,0 +1,128 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ function systemReducer(state, action) {
6
+ switch (action.type) {
7
+ case "SET": {
8
+ const { name, value } = action.payload;
9
+ return {
10
+ ...state,
11
+ [name]: value,
12
+ }
13
+ }
14
+ case "MERGE": {
15
+ return {
16
+ ...state,
17
+ ...action.payload,
18
+ }
19
+ }
20
+ }
21
+ }
22
+
23
+ /*
24
+
25
+ Notes
26
+
27
+ - any call to dispatch will immediately invoke the reducer
28
+ - any call to dispatch within middleware is also immediately processed
29
+ - SET and MERGE are not interceptable by middleware
30
+ - middleware functions are assumed to call next synchronously
31
+ - the render function (subscriber) is invoked once for every call to dispatch
32
+ - the render function is debounced
33
+
34
+ */
35
+
36
+ function configure(
37
+ { update = {}, middleware = [], derivations = {}, initialState = {} },
38
+ node
39
+ ) {
40
+ let subscribers = [];
41
+ let state;
42
+ let updatedCallback = () => {};
43
+
44
+ function updateState(o) {
45
+ state = { ...o };
46
+ for (let k in derivations) {
47
+ state[k] = derivations[k](o);
48
+ }
49
+ }
50
+
51
+ updateState(initialState);
52
+
53
+ function getState() {
54
+ return { ...state }
55
+ }
56
+
57
+ function subscribe(fn) {
58
+ subscribers.push(fn);
59
+ }
60
+
61
+ function flush() {
62
+ subscribers.forEach((fn) => fn());
63
+ subscribers = [];
64
+ }
65
+
66
+ function onUpdate(fn) {
67
+ updatedCallback = fn;
68
+ }
69
+
70
+ function dispatch(action) {
71
+ const { type } = action;
72
+ if (type === "SET" || type === "MERGE") {
73
+ updateState(systemReducer(getState(), action));
74
+ } else {
75
+ if (middleware.length) {
76
+ let mw = middleware.slice();
77
+
78
+ let next = (action) => {
79
+ if (mw.length) {
80
+ let x = mw.shift();
81
+
82
+ if (action.type in x) {
83
+ x[action.type](action, next, {
84
+ getState,
85
+ dispatch,
86
+ afterNextRender: subscribe,
87
+ });
88
+ } else {
89
+ next(action);
90
+ }
91
+ } else if (action.type in update) {
92
+ updateState(update[action.type](getState(), action));
93
+ }
94
+ };
95
+
96
+ let x = mw.shift();
97
+
98
+ if (type in x) {
99
+ x[type](action, next, {
100
+ getState,
101
+ dispatch,
102
+ afterNextRender: subscribe,
103
+ });
104
+ } else {
105
+ next(action);
106
+ }
107
+ } else if (type in update) {
108
+ updateState(update[type](getState(), action));
109
+ }
110
+ }
111
+ updatedCallback();
112
+ }
113
+
114
+ for (let actionName in update) {
115
+ if (actionName.startsWith("$")) {
116
+ node.addEventListener(actionName, ({ detail }) => dispatch(detail));
117
+ }
118
+ }
119
+
120
+ return {
121
+ dispatch,
122
+ getState,
123
+ onUpdate,
124
+ flush,
125
+ }
126
+ }
127
+
128
+ exports.configure = configure;