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/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;
|