@twobirds/microcomponents 0.1.19 → 0.1.20
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/dist/MC.d.ts +39 -0
- package/dist/MC.d.ts.map +1 -0
- package/dist/MC.js +299 -0
- package/dist/MC.min.js +342 -0
- package/dist/MC.ts +1 -1
- package/dist/elements.d.ts +5 -0
- package/dist/elements.d.ts.map +1 -0
- package/dist/elements.js +50 -0
- package/dist/elements.min.js +1 -0
- package/dist/formValues.d.ts +3 -0
- package/dist/formValues.d.ts.map +1 -0
- package/dist/formValues.js +158 -0
- package/dist/formValues.min.js +1 -0
- package/dist/helpers.d.ts +14 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +111 -0
- package/dist/microcomponents.d.ts +6 -0
- package/dist/microcomponents.d.ts.map +1 -0
- package/dist/microcomponents.js +6 -0
- package/dist/microcomponents.min.js +1 -0
- package/dist/observables.d.ts +11 -0
- package/dist/observables.d.ts.map +1 -0
- package/dist/observables.js +228 -0
- package/dist/observables.min.js +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
import { debounce, deepEqual, flattenObject, copyGettersSetters } from './helpers.js';
|
|
3
|
+
import { DC, trigger } from './MC.js';
|
|
4
|
+
function isObservableObject(value) {
|
|
5
|
+
return value != null && typeof value === 'object';
|
|
6
|
+
}
|
|
7
|
+
function getPlaceholders(target) {
|
|
8
|
+
let placeholders = new Set(), regEx = /\{[^\{\}]*\}/g;
|
|
9
|
+
(target.getAttributeNames ? target.getAttributeNames() : [])
|
|
10
|
+
.filter((attr) => target.getAttribute(attr)?.match(regEx))
|
|
11
|
+
.forEach((attr) => {
|
|
12
|
+
let placeholders = new Set(target.getAttribute(attr)?.match(regEx));
|
|
13
|
+
placeholders.forEach((placeholder) => placeholders.add(placeholder.replace(/[\{\}]/g, '')));
|
|
14
|
+
});
|
|
15
|
+
[...target.childNodes]
|
|
16
|
+
.filter((childNode) => {
|
|
17
|
+
return (childNode.nodeType === 3 && (childNode.nodeValue || '').match(regEx));
|
|
18
|
+
})
|
|
19
|
+
.forEach((childNode) => {
|
|
20
|
+
(childNode.nodeValue || '').match(regEx).forEach((placeholder) => {
|
|
21
|
+
placeholders.add(placeholder.replace(/[\{\}]/g, ''));
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
return [...placeholders].map((placeholder) => placeholder.replace(/[\{\}]/g, ''));
|
|
25
|
+
}
|
|
26
|
+
const inputs = [HTMLInputElement, HTMLSelectElement, HTMLTextAreaElement];
|
|
27
|
+
class Placeholders extends DC {
|
|
28
|
+
data = {};
|
|
29
|
+
oldDisplay = '';
|
|
30
|
+
constructor(target) {
|
|
31
|
+
super(target);
|
|
32
|
+
getPlaceholders(target).forEach((property) => (this.data[property] = ''));
|
|
33
|
+
observe(this);
|
|
34
|
+
this.#attachCallbacks();
|
|
35
|
+
}
|
|
36
|
+
#attachCallbacks() {
|
|
37
|
+
let target = this.target, hide = false;
|
|
38
|
+
(target.getAttributeNames ? target.getAttributeNames() : [])
|
|
39
|
+
.filter((attr) => target.getAttribute(attr)?.match(/\{[^\{\}]*\}/g))
|
|
40
|
+
.forEach((attr) => {
|
|
41
|
+
let placeholders = new Set(target.getAttribute(attr)?.match(/\{[^\{\}]*\}/g));
|
|
42
|
+
this.data.observe(((template) => (data) => {
|
|
43
|
+
let result = template;
|
|
44
|
+
placeholders.forEach((placeholder) => {
|
|
45
|
+
result = result.replace(placeholder, data[placeholder.replace(/[\{\}]/g, '')]);
|
|
46
|
+
});
|
|
47
|
+
target.setAttribute(attr, result);
|
|
48
|
+
})(target.getAttribute(attr)));
|
|
49
|
+
});
|
|
50
|
+
[...target.childNodes]
|
|
51
|
+
.filter((childNode) => {
|
|
52
|
+
return (childNode.nodeType === 3 && (childNode.nodeValue || '').match(/\{[^\{\}]*\}/g));
|
|
53
|
+
})
|
|
54
|
+
.forEach((childNode) => {
|
|
55
|
+
hide = true;
|
|
56
|
+
let placeholders = new Set(childNode.nodeValue.match(/\{[^\{\}]*\}/g));
|
|
57
|
+
this.data.observe(((template) => (data) => {
|
|
58
|
+
let result = template;
|
|
59
|
+
placeholders.forEach((placeholder) => {
|
|
60
|
+
result = result.replace(placeholder, data[placeholder.replace(/[\{\}]/g, '')]);
|
|
61
|
+
});
|
|
62
|
+
if (this.oldDisplay) {
|
|
63
|
+
target.style = this.oldDisplay;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
target.removeAttribute('style');
|
|
67
|
+
}
|
|
68
|
+
delete this.oldDisplay;
|
|
69
|
+
childNode.nodeValue = result;
|
|
70
|
+
})(childNode.nodeValue));
|
|
71
|
+
this.oldDisplay = target.getAttribute('style') || '';
|
|
72
|
+
if (hide &&
|
|
73
|
+
!inputs.includes(target.constructor) &&
|
|
74
|
+
target.tagName !== 'FIELDSET') {
|
|
75
|
+
target.style.display = 'none';
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
onData(ev) {
|
|
80
|
+
let data = {};
|
|
81
|
+
Object.keys(ev.detail.data).forEach((key) => {
|
|
82
|
+
if (this.data.hasOwnProperty(key))
|
|
83
|
+
data[key] = ev.detail.data[key];
|
|
84
|
+
});
|
|
85
|
+
if (JSON.stringify(data) !== JSON.stringify(this.data))
|
|
86
|
+
Object.assign(this.data, data);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function getPlaceholderElements(target) {
|
|
90
|
+
let elements = [target]
|
|
91
|
+
.concat([...target.querySelectorAll('*')])
|
|
92
|
+
.filter((e) => !!getPlaceholders(e).length)
|
|
93
|
+
.filter((e) => e?.tagName !== 'STYLE')
|
|
94
|
+
.reverse();
|
|
95
|
+
return elements;
|
|
96
|
+
}
|
|
97
|
+
function makePlaceholders(element) {
|
|
98
|
+
getPlaceholderElements(element).forEach((e) => {
|
|
99
|
+
if (e?._mc?._placeholders)
|
|
100
|
+
return;
|
|
101
|
+
DC.add(e, '_placeholders', new Placeholders(e));
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
const classRepo = {};
|
|
105
|
+
function makeObservable(val) {
|
|
106
|
+
const Constructor = val.constructor, ConstructorName = Constructor.name;
|
|
107
|
+
let ObservableClass = class extends Constructor {
|
|
108
|
+
#notify = true;
|
|
109
|
+
#callbacks = [];
|
|
110
|
+
constructor(val) {
|
|
111
|
+
super(val);
|
|
112
|
+
this.constructor.callbacks = [];
|
|
113
|
+
if (isObservableObject(val)) {
|
|
114
|
+
Object.getOwnPropertyNames(val).forEach((key) => {
|
|
115
|
+
this[key] = val[key];
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
get callbacks() {
|
|
120
|
+
return this.#callbacks;
|
|
121
|
+
}
|
|
122
|
+
set callbacks(callbacks) {
|
|
123
|
+
this.#callbacks = callbacks;
|
|
124
|
+
}
|
|
125
|
+
observe(callback) {
|
|
126
|
+
this.#callbacks.push(callback);
|
|
127
|
+
return this;
|
|
128
|
+
}
|
|
129
|
+
bind(target) {
|
|
130
|
+
const iso = isObservableObject(this.valueOf());
|
|
131
|
+
if (iso) {
|
|
132
|
+
makePlaceholders(target);
|
|
133
|
+
const placeholders = [target, ...target.querySelectorAll('[data-mc]')].filter((e) => !!e?._mc?._placeholders);
|
|
134
|
+
const func = function callback(data) {
|
|
135
|
+
let flattenedData = flattenObject(data);
|
|
136
|
+
placeholders.forEach((node) => {
|
|
137
|
+
if (!node)
|
|
138
|
+
return;
|
|
139
|
+
trigger(node, 'data', flattenedData);
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
this.#callbacks.push(func);
|
|
143
|
+
this.notify();
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
console.warn('IGNORED - cannot bind a non-Object to the dom, IS:', typeof this.valueOf(), this);
|
|
147
|
+
}
|
|
148
|
+
return this;
|
|
149
|
+
}
|
|
150
|
+
notify(notify) {
|
|
151
|
+
let data = isObservableObject(this.valueOf()) && this.valueOf() instanceof Array === false
|
|
152
|
+
? structuredClone(Object.assign({}, this))
|
|
153
|
+
: this.valueOf();
|
|
154
|
+
if (notify !== undefined) {
|
|
155
|
+
this.#notify = notify;
|
|
156
|
+
}
|
|
157
|
+
if (this.#notify) {
|
|
158
|
+
this.#callbacks.forEach((f) => {
|
|
159
|
+
f(data);
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
return this;
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
classRepo[ConstructorName] = ObservableClass;
|
|
166
|
+
return ObservableClass;
|
|
167
|
+
}
|
|
168
|
+
function getConstructor(val) {
|
|
169
|
+
let key = val.constructor.name;
|
|
170
|
+
return classRepo[key] || makeObservable(val);
|
|
171
|
+
}
|
|
172
|
+
export const observe = (target, propertyName) => {
|
|
173
|
+
let keys = !propertyName ? [...Object.getOwnPropertyNames(target)] : [propertyName];
|
|
174
|
+
keys.forEach((key) => {
|
|
175
|
+
if (target.hasOwnProperty(key) &&
|
|
176
|
+
typeof target[key] !== 'function' &&
|
|
177
|
+
!target?.[key]?.constructor?.prototype?.observe) {
|
|
178
|
+
if (key[0] === '_' || target?.[key] === undefined)
|
|
179
|
+
return target;
|
|
180
|
+
let val = target[key];
|
|
181
|
+
let o = new (getConstructor(val))(val);
|
|
182
|
+
let debouncedNotify = debounce(function debouncedNotify() {
|
|
183
|
+
o.notify();
|
|
184
|
+
}, 0);
|
|
185
|
+
Object.defineProperty(target, key, {
|
|
186
|
+
enumerable: true,
|
|
187
|
+
get() {
|
|
188
|
+
if (isObservableObject(o.valueOf())) {
|
|
189
|
+
let check = structuredClone(Object.assign({}, o));
|
|
190
|
+
setTimeout(function checkChanges() {
|
|
191
|
+
let state = structuredClone(Object.assign({}, o));
|
|
192
|
+
if (!deepEqual(state, check)) {
|
|
193
|
+
debouncedNotify();
|
|
194
|
+
}
|
|
195
|
+
}, 0);
|
|
196
|
+
}
|
|
197
|
+
return o;
|
|
198
|
+
},
|
|
199
|
+
set(val) {
|
|
200
|
+
if (typeof val === typeof o.valueOf()) {
|
|
201
|
+
let iso = isObservableObject(o.valueOf()) && o.valueOf() instanceof Array === false;
|
|
202
|
+
if (iso) {
|
|
203
|
+
if (o?.constructor?.prototype?.observe === undefined) {
|
|
204
|
+
o = new (getConstructor(val))(structuredClone(Object.assign({}, val)));
|
|
205
|
+
copyGettersSetters(val, o);
|
|
206
|
+
}
|
|
207
|
+
Object.assign(o, val);
|
|
208
|
+
o.notify();
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
let old = o.valueOf(), callbacks = o.callbacks;
|
|
212
|
+
if (val !== old) {
|
|
213
|
+
o = new (getConstructor(val))(val);
|
|
214
|
+
o.callbacks = callbacks;
|
|
215
|
+
debouncedNotify();
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
console.warn('IGNORED - cannot change observable types, IS:', typeof o.valueOf(), o, '- CANNOT BECOME:', typeof val);
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
});
|
|
224
|
+
target[key] = val;
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
return target;
|
|
228
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};function r(t){let e={};return[...Object.keys(t)].sort().forEach((n=>{var c;(c=t[n])&&c.constructor&&c.constructor===Object?e[n]=r(t[n]):e[n]=t[n]})),e}function n(t,e=!0){let c={};return[...Object.getOwnPropertyNames(t)].forEach((e=>{if(t[e]instanceof Object){const r=n(t[e],!1);c[e]={};for(const t in r)c[e+"."+t]=r[t]}else c[e]=t[e]})),e?r(c):c}t.d(e,{l:()=>y});const c=new Function("try {return this===window;}catch(e){ return false;}");function a(t){return t&&t instanceof HTMLElement}function o(t){return"_mc"+t[0].toUpperCase()+t.substring(1)}function s(t,e,r,n=!1){return t.addEventListener(o(e),r,{capture:!1,once:n}),r}class i{stopped=!1;constructor(){}stop(){this.stopped=!0}}function l(t,e,r={},n="l",c){const a=/^_mc/.test(e)?e:o(e),s=c||new i,l=new CustomEvent(a,{detail:{data:r,control:s},bubbles:!1});s.stopped||/l/.test(n)&&(t.dispatchEvent(l),l.stopImmediatePropagation(),s.stopped)||/[ud]/.test(n)&&(-1===n.indexOf("l")&&(n+="l"),setTimeout((()=>{if(n.indexOf("u")>-1){let e=t.parentElement?.closest("[data-mc]");e&&e?._mc.trigger(a,r,n,s)}if(n.indexOf("d")>-1){let e=t._mc.children();e&&e.forEach((t=>t.trigger(a,r,n)))}}),0))}class u{_target;constructor(t){var e;this._target=new WeakRef(t||{}),function(t){if(!c()||t.constructor===f)return;const e=t.target;if(e instanceof HTMLElement){let r=t;Object.getOwnPropertyNames(r.constructor.prototype).filter((t=>/^(on[A-Z]|one[A-Z])/.test(t)&&"function"==typeof r.constructor.prototype[t])).forEach((t=>{let n=/^one/.test(t),c=t.replace(/^on[e]{0,1}/,""),a=c.toLowerCase();if("on"+a in e){let n=e=>{r[t](e)};e.addEventListener(a,n)}else s(e,c,(e=>{r[t](e)}),n)}))}}(this),e=this,setTimeout((()=>{e.constructor!==f&&e.trigger("Init")}),0)}get target(){return this._target.deref()}}class f extends u{constructor(t){super(t)}static add(t,e,r={}){return function(t,e,r={}){let n=t;n._mc||(n._mc=new f(t));const c=n._mc;return e.length&&!c[e]&&(c[e]=r,t instanceof HTMLElement&&!t.getAttribute("data-mc")&&t.setAttribute("data-mc","")),n}(t,e,r)}static remove(t,e){!function(t,e){if(!e)return;const r=t?._mc||{};r&&r[e]&&delete r[e],!Object.keys(r).length&&t instanceof HTMLElement&&t.hasAttribute("data-mc")&&t.removeAttribute("data-mc")}(t,e)}off(t,e){!function(t,e,r){t.removeEventListener(o(e),r)}(this.target,t,e)}on(t,e){return s(this.target,t,e)}one(t,e){return function(t,e,r){return s(t,e,r,!0),r}(this.target,t,e)}trigger(t,e={},r="l",n){l(this.target,t,e,r,n)}ancestors(){let t=this?.target,e=[];if(!a(t))return[];for(;t=t.closest("[data-mc]");)t?._mc&&e.push(t?._mc);return e.length?e:null}closest(){let t=this.target;return a(t)&&t.closest("[data-mc]")?._mc||null}children(){let t=this?.target;return a(t)?function(t){const e=Math.random().toString().replace(".",""),r='[data-mc]:not([temp_id="'+e+'"] [data-mc] [data-mc])';t.setAttribute("temp_id",e);const n=[...t.querySelectorAll(r)].filter((t=>!!t._mc)).map((t=>t._mc));return t.removeAttribute("temp_id"),n.length?n:null}(t):null}descendants(){const t=this?.target;if(!a(t))return[];const e=[...t.querySelectorAll("[data-mc]")].filter((t=>!!t._mc)).map((t=>t._mc));return e.length?e:null}}function d(t){return null!=t&&"object"==typeof t}function h(t){let e=new Set,r=/\{[^\{\}]*\}/g;return(t.getAttributeNames?t.getAttributeNames():[]).filter((e=>t.getAttribute(e)?.match(r))).forEach((e=>{let n=new Set(t.getAttribute(e)?.match(r));n.forEach((t=>n.add(t.replace(/[\{\}]/g,""))))})),[...t.childNodes].filter((t=>3===t.nodeType&&(t.nodeValue||"").match(r))).forEach((t=>{(t.nodeValue||"").match(r).forEach((t=>{e.add(t.replace(/[\{\}]/g,""))}))})),[...e].map((t=>t.replace(/[\{\}]/g,"")))}new Set;const p=[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement];class m extends f{data={};oldDisplay="";constructor(t){super(t),h(t).forEach((t=>this.data[t]="")),y(this),this.#t()}#t(){let t=this.target,e=!1;(t.getAttributeNames?t.getAttributeNames():[]).filter((e=>t.getAttribute(e)?.match(/\{[^\{\}]*\}/g))).forEach((e=>{let r=new Set(t.getAttribute(e)?.match(/\{[^\{\}]*\}/g));var n;this.data.observe((n=t.getAttribute(e),c=>{let a=n;r.forEach((t=>{a=a.replace(t,c[t.replace(/[\{\}]/g,"")])})),t.setAttribute(e,a)}))})),[...t.childNodes].filter((t=>3===t.nodeType&&(t.nodeValue||"").match(/\{[^\{\}]*\}/g))).forEach((r=>{e=!0;let n=new Set(r.nodeValue.match(/\{[^\{\}]*\}/g));this.data.observe((e=>c=>{let a=e;n.forEach((t=>{a=a.replace(t,c[t.replace(/[\{\}]/g,"")])})),this.oldDisplay?t.style=this.oldDisplay:t.removeAttribute("style"),delete this.oldDisplay,r.nodeValue=a})(r.nodeValue)),this.oldDisplay=t.getAttribute("style")||"",e&&!p.includes(t.constructor)&&"FIELDSET"!==t.tagName&&(t.style.display="none")}))}onData(t){let e={};Object.keys(t.detail.data).forEach((r=>{this.data.hasOwnProperty(r)&&(e[r]=t.detail.data[r])})),JSON.stringify(e)!==JSON.stringify(this.data)&&Object.assign(this.data,e)}}const g={};function b(t){let e=t.constructor.name;return g[e]||function(t){const e=t.constructor,r=e.name;let c=class extends e{#e=!0;#r=[];constructor(t){super(t),this.constructor.callbacks=[],d(t)&&Object.getOwnPropertyNames(t).forEach((e=>{this[e]=t[e]}))}get callbacks(){return this.#r}set callbacks(t){this.#r=t}observe(t){return this.#r.push(t),this}bind(t){if(d(this.valueOf())){!function(t){var e;(e=t,[e].concat([...e.querySelectorAll("*")]).filter((t=>!!h(t).length)).filter((t=>"STYLE"!==t?.tagName)).reverse()).forEach((t=>{t?._mc?._placeholders||f.add(t,"_placeholders",new m(t))}))}(t);const e=[t,...t.querySelectorAll("[data-mc]")].filter((t=>!!t?._mc?._placeholders)),r=function(t){let r=n(t);e.forEach((t=>{t&&l(t,"data",r)}))};this.#r.push(r),this.notify()}else console.warn("IGNORED - cannot bind a non-Object to the dom, IS:",typeof this.valueOf(),this);return this}notify(t){let e=d(this.valueOf())&&this.valueOf()instanceof Array==0?structuredClone(Object.assign({},this)):this.valueOf();return void 0!==t&&(this.#e=t),this.#e&&this.#r.forEach((t=>{t(e)})),this}};return g[r]=c,c}(t)}const y=(t,e)=>((e?[e]:[...Object.getOwnPropertyNames(t)]).forEach((e=>{if(t.hasOwnProperty(e)&&"function"!=typeof t[e]&&!t?.[e]?.constructor?.prototype?.observe){if("_"===e[0]||void 0===t?.[e])return t;let r=t[e],c=new(b(r))(r),a=function(){let t;return()=>{clearTimeout(t),t=setTimeout((function(){!function(){c.notify()}(...arguments)}),0)}}();Object.defineProperty(t,e,{enumerable:!0,get(){if(d(c.valueOf())){let t=structuredClone(Object.assign({},c));setTimeout((function(){var e,r;e=structuredClone(Object.assign({},c)),r=t,JSON.stringify(n(e))!==JSON.stringify(n(r))&&a()}),0)}return c},set(t){if(typeof t==typeof c.valueOf())if(d(c.valueOf())&&c.valueOf()instanceof Array==0)void 0===c?.constructor?.prototype?.observe&&(c=new(b(t))(structuredClone(Object.assign({},t))),function(t,e){const r=Object.getOwnPropertyDescriptors(t);for(const[t,n]of Object.entries(r))("get"in n||"set"in n)&&Object.defineProperty(e,t,n)}(t,c)),Object.assign(c,t),c.notify();else{let e=c.valueOf(),r=c.callbacks;t!==e&&(c=new(b(t))(t),c.callbacks=r,a())}else console.warn("IGNORED - cannot change observable types, IS:",typeof c.valueOf(),c,"- CANNOT BECOME:",typeof t)}}),t[e]=r}})),t);var O=e.l;export{O as observe};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twobirds/microcomponents",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.20",
|
|
4
4
|
"description": "Micro Components Organization Class",
|
|
5
5
|
"main": "./dist/microcomponents.ts",
|
|
6
6
|
"types": "./dist/microcomponents.d.ts",
|
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
"sideEffects": false,
|
|
17
17
|
"scripts": {
|
|
18
18
|
"format": "prettier --write \"src/**/*.{ts,js}\"",
|
|
19
|
-
"lint": "eslint \"src/**/*.{ts
|
|
19
|
+
"lint": "eslint \"src/**/*.{ts}\" --fix > eslint.log",
|
|
20
20
|
"typedoc": "typedoc",
|
|
21
21
|
"webpack": "webpack",
|
|
22
22
|
"clean": "rm -rf build/*; rm -rf dist/*; rm -rf public/*;",
|
|
23
|
-
"prep": "cp -R src/* build || true;
|
|
23
|
+
"prep": "cp -R src/* build/ || true; mkdir public || true; npm run typedoc; npm run format; npm run lint;",
|
|
24
24
|
"copyToDist": "cp build/*.js dist; cp public/microcomponents.min.js public/test; cp -R build/*.ts* dist; cp *.svg dist;",
|
|
25
25
|
"copyToPublic1": "cp dist/*.* public; cp dist/*.* public/test;",
|
|
26
|
-
"copyToPublic2": "cp -R assets/* public || true; cp -R build
|
|
26
|
+
"copyToPublic2": "cp -R assets/* public || true; cp -R build/* public/; cp dist/MicroComponents.svg public; cp public/MicroComponents.svg public/test;",
|
|
27
27
|
"build": "npm run clean; npm run prep; tsc; npm run webpack; npm run copyToDist; npm run copyToPublic1; npm run copyToPublic2;",
|
|
28
28
|
"dev": "cd public; php -S 0.0.0.0:10000; cd ..",
|
|
29
29
|
"doc": "cd public/typedoc; php -S 0.0.0.0:11000; cd ../..",
|