@twobirds/microcomponents 0.1.21 → 0.2.0
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 +91 -92
- package/dist/MC.min.js +1 -345
- package/dist/autoload.min.js +1 -0
- package/dist/core/MC.d.ts +401 -0
- package/dist/core/MC.d.ts.map +1 -0
- package/dist/core/MC.js +471 -0
- package/dist/core/autoload.d.ts +54 -0
- package/dist/core/autoload.d.ts.map +1 -0
- package/dist/core/autoload.js +158 -0
- package/dist/core/elements.d.ts +232 -0
- package/dist/core/elements.d.ts.map +1 -0
- package/dist/core/elements.js +123 -0
- package/dist/core/events.d.ts +231 -0
- package/dist/core/events.d.ts.map +1 -0
- package/dist/core/events.js +228 -0
- package/dist/core/mcGuards.d.ts +49 -0
- package/dist/core/mcGuards.d.ts.map +1 -0
- package/dist/core/mcGuards.js +19 -0
- package/dist/elements.min.js +1 -1
- package/dist/events.min.js +1 -0
- package/dist/formValues.min.js +1 -1
- package/dist/mcGuards.min.js +1 -0
- package/dist/microcomponents.d.ts +8 -5
- package/dist/microcomponents.d.ts.map +1 -1
- package/dist/microcomponents.js +8 -5
- package/dist/microcomponents.min.js +1 -1
- package/dist/observables.min.js +1 -1
- package/dist/state/formValues.d.ts +70 -0
- package/dist/state/formValues.d.ts.map +1 -0
- package/dist/state/formValues.js +334 -0
- package/dist/state/observables.d.ts +276 -0
- package/dist/state/observables.d.ts.map +1 -0
- package/dist/state/observables.js +382 -0
- package/dist/state/placeholders.d.ts +62 -0
- package/dist/state/placeholders.d.ts.map +1 -0
- package/dist/state/placeholders.js +181 -0
- package/dist/types/mcTypes.d.ts +201 -0
- package/dist/types/mcTypes.d.ts.map +1 -0
- package/dist/types/mcTypes.js +9 -0
- package/dist/utils/helpers.d.ts +195 -0
- package/dist/utils/helpers.d.ts.map +1 -0
- package/dist/utils/helpers.js +340 -0
- package/package.json +96 -62
- package/dist/MC.d.ts +0 -31
- package/dist/MC.d.ts.map +0 -1
- package/dist/MC.js +0 -249
- package/dist/MC.ts +0 -613
- package/dist/MicroComponents.svg +0 -15
- package/dist/elements.d.ts +0 -5
- package/dist/elements.d.ts.map +0 -1
- package/dist/elements.js +0 -49
- package/dist/elements.ts +0 -114
- package/dist/events.d.ts +0 -11
- package/dist/events.d.ts.map +0 -1
- package/dist/events.js +0 -55
- package/dist/events.ts +0 -158
- package/dist/formValues.d.ts +0 -3
- package/dist/formValues.d.ts.map +0 -1
- package/dist/formValues.js +0 -156
- package/dist/formValues.ts +0 -371
- package/dist/helpers.d.ts +0 -15
- package/dist/helpers.d.ts.map +0 -1
- package/dist/helpers.js +0 -113
- package/dist/helpers.ts +0 -219
- package/dist/main.mjs +0 -1
- package/dist/microcomponents.ts +0 -6
- package/dist/observables.d.ts +0 -11
- package/dist/observables.d.ts.map +0 -1
- package/dist/observables.js +0 -228
- package/dist/observables.ts +0 -449
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
/**
|
|
2
|
+
@module Helpers
|
|
3
|
+
|
|
4
|
+
Small runtime-agnostic utilities shared across the library: environment
|
|
5
|
+
detection, object flattening/comparison, debouncing, accessor copying, and
|
|
6
|
+
kebab-to-PascalCase conversion.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Determines whether the current runtime environment is a web browser.
|
|
10
|
+
*
|
|
11
|
+
* This function works by attempting to access `this` within an anonymous function
|
|
12
|
+
* and checking if it refers to the global `window` object. It returns `true`
|
|
13
|
+
* when executed in a browser context, and `false` otherwise (e.g., Node.js).
|
|
14
|
+
*
|
|
15
|
+
* Note: While modern environments typically provide more reliable detection mechanisms,
|
|
16
|
+
* this fallback remains compatible across older runtimes where other detection techniques
|
|
17
|
+
* may be unreliable.
|
|
18
|
+
*
|
|
19
|
+
* @returns `true` if the code is running in a browser environment, `false` otherwise.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* if (isBrowser()) {
|
|
24
|
+
* console.log('Running in a browser');
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export function isBrowser() {
|
|
29
|
+
return typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Checks if a value is a native JavaScript object (created via {} or new Object()).
|
|
33
|
+
* @param value - The value to check.
|
|
34
|
+
* @returns True if the value is a plain object, false otherwise.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* isNativeObject({}); // true
|
|
39
|
+
* isNativeObject(new Object()); // true
|
|
40
|
+
* isNativeObject([]); // false
|
|
41
|
+
* isNativeObject(null); // false
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export function isNativeObject(value) {
|
|
45
|
+
return typeof value === 'object' && value !== null && value.constructor === Object;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Recursively sorts all keys in an object alphabetically, preserving nested structure.
|
|
49
|
+
* @param source - The object to sort.
|
|
50
|
+
* @returns A new object with sorted keys at all levels.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* const obj = { z: 1, a: { y: 2, b: 3 } };
|
|
55
|
+
* sortObject(obj); // { a: { b: 3, y: 2 }, z: 1 }
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export function sortObject(source) {
|
|
59
|
+
const result = {}, keys = Object.keys(source).sort();
|
|
60
|
+
// Indexed for: no per-key callback/iterator overhead. ~15x faster than .forEach,
|
|
61
|
+
// ~10x faster than for-of over the loop body itself (V8, 5M elems), and ~15x faster than .forEach()
|
|
62
|
+
for (let i = 0; i < keys.length; i++) {
|
|
63
|
+
const key = keys[i], value = source[key];
|
|
64
|
+
if (isNativeObject(value)) {
|
|
65
|
+
result[key] = sortObject(value);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
result[key] = value;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Flattens a nested object into a single-level object with dot-separated keys.
|
|
75
|
+
* Optionally sorts the resulting flat keys alphabetically (default: true).
|
|
76
|
+
* @param source - The object to flatten.
|
|
77
|
+
* @param doSort - Whether to sort the resulting keys (default: true).
|
|
78
|
+
* @returns A flattened object with dot-notation keys.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* const obj = { user: { name: 'Alice', age: 30 } };
|
|
83
|
+
* flattenObject(obj); // { 'user.age': 30, 'user.name': 'Alice' }
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export function flattenObject(source, doSort = true) {
|
|
87
|
+
const result = {};
|
|
88
|
+
const record = source;
|
|
89
|
+
const names = Object.getOwnPropertyNames(source);
|
|
90
|
+
// Indexed for: no per-key callback overhead, and no extra copy from spreading
|
|
91
|
+
// ~10x faster than for-of over the loop body itself (V8, 5M elems), and ~15x faster than .forEach()
|
|
92
|
+
for (let i = 0; i < names.length; i++) {
|
|
93
|
+
const propName = names[i], value = record[propName];
|
|
94
|
+
if (value instanceof Object) {
|
|
95
|
+
const temp = flattenObject(value, false);
|
|
96
|
+
for (const j in temp) {
|
|
97
|
+
result[propName + '.' + j] = temp[j];
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
result[propName] = value;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return doSort ? sortObject(result) : result;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Structural deep-equality using SameValueZero for primitives.
|
|
108
|
+
*
|
|
109
|
+
* See {@link https://tc39.es/ecma262/multipage/abstract-operations.html#sec-samevaluezero}.
|
|
110
|
+
*
|
|
111
|
+
* Note: `Map`/`Set` are not structurally compared.
|
|
112
|
+
*
|
|
113
|
+
* @param a - The first value to compare.
|
|
114
|
+
* @param b - The second value to compare.
|
|
115
|
+
* @returns True if the values are deeply equal, false otherwise.
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```ts
|
|
119
|
+
* deepEqual({ a: 1 }, { a: 1 }); // true
|
|
120
|
+
* deepEqual({ a: { b: 2 } }, { a: {} }); // false
|
|
121
|
+
* deepEqual({ a: NaN }, { a: NaN }); // true (SameValueZero)
|
|
122
|
+
* deepEqual({ a: NaN }, { a: null }); // false
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
export function deepEqual(a, b) {
|
|
126
|
+
// SameValueZero: identical primitives/refs, plus NaN === NaN.
|
|
127
|
+
if (a === b || (a !== a && b !== b))
|
|
128
|
+
return true;
|
|
129
|
+
/* v8 ignore start */
|
|
130
|
+
// Beyond SameValueZero, equality needs two non-null objects of the same kind.
|
|
131
|
+
if (typeof a !== 'object' || a === null || typeof b !== 'object' || b === null)
|
|
132
|
+
return false;
|
|
133
|
+
if (a.constructor !== b.constructor)
|
|
134
|
+
return false;
|
|
135
|
+
if (a instanceof Date)
|
|
136
|
+
return a.getTime() === b.getTime();
|
|
137
|
+
if (a instanceof RegExp)
|
|
138
|
+
return a.toString() === b.toString();
|
|
139
|
+
/* v8 ignore end */
|
|
140
|
+
if (Array.isArray(a)) {
|
|
141
|
+
const bArr = b;
|
|
142
|
+
/* v8 ignore next */
|
|
143
|
+
if (a.length !== bArr.length)
|
|
144
|
+
return false;
|
|
145
|
+
for (let i = 0; i < a.length; i++) {
|
|
146
|
+
if (!deepEqual(a[i], bArr[i]))
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
const aObj = a, bObj = b, keys = Object.keys(aObj);
|
|
152
|
+
if (keys.length !== Object.keys(bObj).length)
|
|
153
|
+
return false;
|
|
154
|
+
for (let i = 0; i < keys.length; i++) {
|
|
155
|
+
const key = keys[i];
|
|
156
|
+
if (!Object.prototype.hasOwnProperty.call(bObj, key) || !deepEqual(aObj[key], bObj[key]))
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Retrieves a nested value from an object using a namespace path (dot-separated).
|
|
163
|
+
* @param ns - The namespace string or array of keys representing the path.
|
|
164
|
+
* @param obj - The object to traverse.
|
|
165
|
+
* @returns The value at the specified namespace path, or undefined if not found.
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```ts
|
|
169
|
+
* const data = { user: { profile: { name: 'Alice' } } };
|
|
170
|
+
* nameSpace('user.profile.name', data); // 'Alice'
|
|
171
|
+
* nameSpace(['user', 'profile'], data); // { name: 'Alice' }
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
export function nameSpace(ns, obj = {}) {
|
|
175
|
+
const source = obj;
|
|
176
|
+
const nsa = typeof ns === 'string' ? ns.split('.') : ns;
|
|
177
|
+
if (!source || !nsa[0] || !source[nsa[0]]) {
|
|
178
|
+
return undefined;
|
|
179
|
+
}
|
|
180
|
+
if (nsa.length > 1) {
|
|
181
|
+
const next = source[nsa[0]];
|
|
182
|
+
if (isNativeObject(next)) {
|
|
183
|
+
return nameSpace(nsa.slice(1), next);
|
|
184
|
+
}
|
|
185
|
+
return undefined;
|
|
186
|
+
}
|
|
187
|
+
return source[nsa[0]];
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Parses a template string or object, replacing placeholders in the form of {key.path} with
|
|
191
|
+
* corresponding values from the provided data object using namespace resolution.
|
|
192
|
+
* Also recursively processes objects and arrays within the input.
|
|
193
|
+
* @param template - The string or object to parse (can contain {{placeholder}} expressions).
|
|
194
|
+
* @param parseThis - The object containing values for placeholder substitution.
|
|
195
|
+
* @returns The parsed result, with placeholders replaced by actual values.
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* ```ts
|
|
199
|
+
* const data = { user: { name: 'Alice' } };
|
|
200
|
+
* parse('Hello {user.name}!', data); // 'Hello Alice!'
|
|
201
|
+
*
|
|
202
|
+
* parse(['Hi {user.name}', 'Bye {user.name}'], data); // ['Hi Alice', 'Bye Alice']
|
|
203
|
+
* ```
|
|
204
|
+
*/
|
|
205
|
+
export function parse(template, parseThis, ...rest) {
|
|
206
|
+
const args = [template, parseThis, ...rest];
|
|
207
|
+
if (args.length > 2) {
|
|
208
|
+
while (args.length > 1) {
|
|
209
|
+
args[0] = parse(args[0], args[1]);
|
|
210
|
+
args.splice(1, 1);
|
|
211
|
+
}
|
|
212
|
+
return args[0];
|
|
213
|
+
}
|
|
214
|
+
if (typeof template === 'string') {
|
|
215
|
+
let result = template;
|
|
216
|
+
template.match(/\{[^\{\}]*\}/g)?.forEach((pPropname) => {
|
|
217
|
+
const propname = pPropname.substring(1, pPropname.length - 1), value = nameSpace(propname, parseThis);
|
|
218
|
+
if (typeof value !== 'undefined') {
|
|
219
|
+
result = result.replace(pPropname, String(value));
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
return result;
|
|
223
|
+
}
|
|
224
|
+
else if (isNativeObject(template)) {
|
|
225
|
+
const record = template;
|
|
226
|
+
Object.keys(record).forEach((pKey) => {
|
|
227
|
+
/* v8 ignore next */
|
|
228
|
+
if (Object.prototype.hasOwnProperty.call(record, pKey)) {
|
|
229
|
+
record[pKey] = parse(record[pKey], parseThis);
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
return template;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Converts a kebab-case string to PascalCase.
|
|
237
|
+
* Example: 'my-component-name' -> 'MyComponentName'
|
|
238
|
+
* @param str - The kebab-case string to convert.
|
|
239
|
+
* @returns The converted PascalCase string.
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* ```ts
|
|
243
|
+
* kebabToPascal('my-element'); // 'MyElement'
|
|
244
|
+
* ```
|
|
245
|
+
*/
|
|
246
|
+
export function kebabToPascal(str) {
|
|
247
|
+
return str
|
|
248
|
+
.split('-') // Split by hyphens
|
|
249
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1)) // Capitalize each part
|
|
250
|
+
.join(''); // Join without spaces
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Creates a debounced version of a function that delays execution until after the specified
|
|
254
|
+
* number of milliseconds have elapsed since the last time this function was invoked.
|
|
255
|
+
* Useful for rate-limiting expensive operations like event handlers or API calls.
|
|
256
|
+
* @param func - The function to debounce.
|
|
257
|
+
* @param milliseconds - The number of milliseconds to delay execution.
|
|
258
|
+
* @returns A debounced version of the input function.
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* ```ts
|
|
262
|
+
* const log = debounce(() => console.log('called'), 300);
|
|
263
|
+
* log(); // will only execute once after 300ms of inactivity
|
|
264
|
+
* ```
|
|
265
|
+
*/
|
|
266
|
+
export function debounce(func, milliseconds) {
|
|
267
|
+
let timeout;
|
|
268
|
+
return (...args) => {
|
|
269
|
+
clearTimeout(timeout);
|
|
270
|
+
timeout = setTimeout(() => {
|
|
271
|
+
func(...args);
|
|
272
|
+
}, milliseconds);
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Parses an HTML string and returns an array of DOM elements.
|
|
277
|
+
* Handles self-closing tags (XHTML style) by converting them to full closing tags first.
|
|
278
|
+
* @param html - The HTML string to parse.
|
|
279
|
+
* @returns An array of HTMLElement objects representing the parsed HTML nodes.
|
|
280
|
+
*
|
|
281
|
+
* @example
|
|
282
|
+
* ```ts
|
|
283
|
+
* const elems = htmlToElements('<div>Hello</div><span>World</span>');
|
|
284
|
+
* // [HTMLElement<div>, HTMLElement<span>]
|
|
285
|
+
* ```
|
|
286
|
+
*/
|
|
287
|
+
export function htmlToElements(html) {
|
|
288
|
+
const template = document.createElement('template');
|
|
289
|
+
html = html.replace(/<([A-Za-z0-9\-]*)([^>\/]*)(\/>)/gi, '<$1$2></$1>'); // replace XHTML closing tags by full closing tags
|
|
290
|
+
template.innerHTML = html;
|
|
291
|
+
template.content.normalize();
|
|
292
|
+
return Array.from(template.content.childNodes);
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Returns the correct event name to listen for on a DOM element.
|
|
296
|
+
*
|
|
297
|
+
* If `eventName` (case-insensitive) matches a native HTML event handler property
|
|
298
|
+
* (`'on' + eventName.toLowerCase()`) on the target, returns the lowercase native
|
|
299
|
+
* name so that standard DOM events like `'click'` are listened to correctly.
|
|
300
|
+
* Otherwise, prefixes with `_mc` for microcomponent custom events.
|
|
301
|
+
*
|
|
302
|
+
* @param target - The DOM element whose native event support is checked.
|
|
303
|
+
* @param eventName - The event name as provided by the caller (e.g., `'click'`, `'Update'`).
|
|
304
|
+
* @returns The resolved event name: lowercase native or `_mc`-prefixed custom.
|
|
305
|
+
*
|
|
306
|
+
* @example
|
|
307
|
+
* ```ts
|
|
308
|
+
* const btn = document.createElement('button');
|
|
309
|
+
* trueEventName(btn, 'Click'); // 'click' — native handler exists
|
|
310
|
+
* trueEventName(btn, 'Update'); // '_mcUpdate' — custom event
|
|
311
|
+
* ```
|
|
312
|
+
*/
|
|
313
|
+
export function trueEventName(target, eventName) {
|
|
314
|
+
const lower = eventName.toLowerCase();
|
|
315
|
+
if ('on' + lower in target)
|
|
316
|
+
return lower;
|
|
317
|
+
return '_mc' + eventName[0].toUpperCase() + eventName.substring(1);
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Copies all getter and setter properties from a source object to a target object.
|
|
321
|
+
* Does not copy methods or regular data properties—only accessor properties (get/set).
|
|
322
|
+
* @param source - The source object with getters and/or setters to copy.
|
|
323
|
+
* @param target - The target object to which the accessors will be copied.
|
|
324
|
+
*
|
|
325
|
+
* @example
|
|
326
|
+
* ```ts
|
|
327
|
+
* const src = { get name() { return 'Alice'; } };
|
|
328
|
+
* const tgt = {};
|
|
329
|
+
* copyGettersSetters(src, tgt);
|
|
330
|
+
* console.log(tgt.name); // 'Alice'
|
|
331
|
+
* ```
|
|
332
|
+
*/
|
|
333
|
+
export function copyGettersSetters(source, target) {
|
|
334
|
+
const descriptors = Object.getOwnPropertyDescriptors(source);
|
|
335
|
+
for (const [key, descriptor] of Object.entries(descriptors)) {
|
|
336
|
+
if ('get' in descriptor || 'set' in descriptor) {
|
|
337
|
+
Object.defineProperty(target, key, descriptor);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
package/package.json
CHANGED
|
@@ -1,77 +1,111 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twobirds/microcomponents",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Micro Components Organization Class",
|
|
5
|
-
"main": "./dist/microcomponents.ts",
|
|
6
|
-
"types": "./dist/microcomponents.d.ts",
|
|
7
|
-
"exports": {
|
|
8
|
-
".": {
|
|
9
|
-
"import": "./dist/microcomponents.js"
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
"type": "module",
|
|
13
|
-
"files": [
|
|
14
|
-
"dist"
|
|
15
|
-
],
|
|
16
|
-
"sideEffects": false,
|
|
17
|
-
"scripts": {
|
|
18
|
-
"format": "prettier --write \"src/**/*.{ts,js}\"",
|
|
19
|
-
"lint": "eslint \"src/**/*.ts\" --fix > eslint.log",
|
|
20
|
-
"typedoc": "typedoc || true",
|
|
21
|
-
"webpack": "webpack",
|
|
22
|
-
"clean": "rm -rf build/*; rm -rf dist/*; rm -rf public/*;",
|
|
23
|
-
"prep": " mkdir build || true; cp -r src/* build/ || true; mkdir public || true; npm run format; npm run lint;",
|
|
24
|
-
"copyToDist": "cp build/*.js dist; cp -r build/*.ts* dist; cp *.svg dist;",
|
|
25
|
-
"copyToPublic1": "cp -r build/test public; cp build/* public/test/; cp build/* public; cp -r assets/* public || true; cp -r build/src/test/* public/test || true;",
|
|
26
|
-
"copyToPublic2": "cp dist/MicroComponents.svg public; cp public/MicroComponents.svg public/test;",
|
|
27
|
-
"build": "npm run clean; npm run prep; tsc; npm run webpack; npm run copyToDist; npm run copyToPublic1; npm run copyToPublic2;",
|
|
28
|
-
"dev": "cd public; php -S 0.0.0.0:10000; cd ..",
|
|
29
|
-
"doc": "cd public/typedoc; php -S 0.0.0.0:11000; cd ../..",
|
|
30
|
-
"watch": "inotifywait -m -r -e close_write,create,delete --format '%w%f' src | while read f; do echo \"\nCHANGED: $f\n\"; npm run build > build.log; cat build.log; done"
|
|
31
|
-
},
|
|
32
|
-
"author": "Frank Thürigen",
|
|
33
|
-
"license": "ISC",
|
|
34
|
-
"devDependencies": {
|
|
35
|
-
"@typescript-eslint/eslint-plugin": "^8.46.4",
|
|
36
|
-
"@typescript-eslint/parser": "^8.46.4",
|
|
37
|
-
"eslint": "^9.39.1",
|
|
38
|
-
"eslint-config-prettier": "^10.1.8",
|
|
39
|
-
"eslint-plugin-prettier": "^5.5.4",
|
|
40
|
-
"jsmin": "^1.0.1",
|
|
41
|
-
"prettier": "^3.6.2",
|
|
42
|
-
"ts-loader": "^9.5.2",
|
|
43
|
-
"typedoc": "^0.26.11",
|
|
44
|
-
"typescript": "^5.5.4",
|
|
45
|
-
"vite": "^7.3.1",
|
|
46
|
-
"webpack": "^5.97.1",
|
|
47
|
-
"webpack-cli": "^6.0.1"
|
|
48
|
-
},
|
|
49
5
|
"keywords": [
|
|
50
|
-
"
|
|
51
|
-
"library",
|
|
52
|
-
"native",
|
|
6
|
+
"API",
|
|
53
7
|
"DOM manipulation",
|
|
54
|
-
"lightweight",
|
|
55
|
-
"standalone",
|
|
56
|
-
"SPA",
|
|
57
|
-
"PWA",
|
|
58
|
-
"ES3",
|
|
59
|
-
"ES5",
|
|
60
|
-
"ES6",
|
|
61
|
-
"ES7",
|
|
62
8
|
"ES2015",
|
|
63
9
|
"ES2016",
|
|
10
|
+
"ES6",
|
|
11
|
+
"ES7",
|
|
12
|
+
"PWA",
|
|
13
|
+
"SPA",
|
|
64
14
|
"client",
|
|
65
|
-
"
|
|
15
|
+
"javascript",
|
|
16
|
+
"library",
|
|
17
|
+
"lightweight",
|
|
18
|
+
"native",
|
|
19
|
+
"standalone"
|
|
66
20
|
],
|
|
67
|
-
"
|
|
68
|
-
|
|
69
|
-
"url": "https://gitlab.com/twoBirds/microcomponents"
|
|
70
|
-
},
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"author": "Frank Thürigen",
|
|
71
23
|
"contributors": [
|
|
72
24
|
{
|
|
73
25
|
"name": "Frank Thürigen",
|
|
74
26
|
"email": "fthuerigen@gmail.com"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"name": "Samuel Braun",
|
|
30
|
+
"email": "sam@webry.com"
|
|
75
31
|
}
|
|
76
|
-
]
|
|
32
|
+
],
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git+https://gitlab.com/twoBirds/microcomponents.git"
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"dist"
|
|
39
|
+
],
|
|
40
|
+
"type": "module",
|
|
41
|
+
"sideEffects": false,
|
|
42
|
+
"main": "./dist/microcomponents.js",
|
|
43
|
+
"types": "./dist/microcomponents.d.ts",
|
|
44
|
+
"exports": {
|
|
45
|
+
".": {
|
|
46
|
+
"types": "./dist/microcomponents.d.ts",
|
|
47
|
+
"import": "./dist/microcomponents.js"
|
|
48
|
+
},
|
|
49
|
+
"./guards": {
|
|
50
|
+
"types": "./dist/core/mcGuards.d.ts",
|
|
51
|
+
"import": "./dist/core/mcGuards.js"
|
|
52
|
+
},
|
|
53
|
+
"./events": {
|
|
54
|
+
"types": "./dist/core/events.d.ts",
|
|
55
|
+
"import": "./dist/core/events.js"
|
|
56
|
+
},
|
|
57
|
+
"./elements": {
|
|
58
|
+
"types": "./dist/core/elements.d.ts",
|
|
59
|
+
"import": "./dist/core/elements.js"
|
|
60
|
+
},
|
|
61
|
+
"./observables": {
|
|
62
|
+
"types": "./dist/state/observables.d.ts",
|
|
63
|
+
"import": "./dist/state/observables.js"
|
|
64
|
+
},
|
|
65
|
+
"./formValues": {
|
|
66
|
+
"types": "./dist/state/formValues.d.ts",
|
|
67
|
+
"import": "./dist/state/formValues.js"
|
|
68
|
+
},
|
|
69
|
+
"./package.json": "./package.json"
|
|
70
|
+
},
|
|
71
|
+
"scripts": {
|
|
72
|
+
"format": "oxfmt .",
|
|
73
|
+
"lint": "oxlint \"src\"",
|
|
74
|
+
"fix": "oxfmt . && oxlint \"src\" --fix",
|
|
75
|
+
"check": "tsc --noEmit -p tsconfig.lib.json && tsc -p tsconfig.test.json && tsc -p tsconfig.demo.json && tsc -p tsconfig.node.json",
|
|
76
|
+
"check:pack": "publint && attw --pack . --profile esm-only",
|
|
77
|
+
"test": "vitest",
|
|
78
|
+
"test:run": "vitest run --reporter=verbose",
|
|
79
|
+
"test:coverage": "vitest run --coverage",
|
|
80
|
+
"demo:shop": "vite --config demo/shop/vite.config.ts",
|
|
81
|
+
"demo:shop:bundled": "node vite.shop.bundle.ts",
|
|
82
|
+
"demo:shop:build": "node vite.shop.ts && pnpm run demo:shop:bundled",
|
|
83
|
+
"demo:shop:serve": "vite preview --outDir public/shop --port 5174 --host",
|
|
84
|
+
"typedoc": "typedoc",
|
|
85
|
+
"bundle": "node vite.build.ts",
|
|
86
|
+
"clean": "rm -rf dist public",
|
|
87
|
+
"build": "pnpm run clean && tsc -p tsconfig.lib.json && pnpm run test:coverage && pnpm run bundle && pnpm run check:pack && pnpm run typedoc && pnpm run demo:build && pnpm run demo:shop:build",
|
|
88
|
+
"demo:build": "node vite.demo.ts",
|
|
89
|
+
"dev": "vite preview --outDir public/test --port 10000 --host",
|
|
90
|
+
"doc": "vite preview --outDir public/typedoc --port 11000 --host",
|
|
91
|
+
"watch": "node watch.ts",
|
|
92
|
+
"prepublishOnly": "pnpm run build && pnpm run check"
|
|
93
|
+
},
|
|
94
|
+
"devDependencies": {
|
|
95
|
+
"@arethetypeswrong/cli": "^0.18.5",
|
|
96
|
+
"@types/node": "^22.20.1",
|
|
97
|
+
"@vitest/coverage-v8": "^4.1.10",
|
|
98
|
+
"jsdom": "^29.1.1",
|
|
99
|
+
"oxfmt": "^0.59.0",
|
|
100
|
+
"oxlint": "^1.74.0",
|
|
101
|
+
"publint": "^0.3.21",
|
|
102
|
+
"typedoc": "^0.28.20",
|
|
103
|
+
"typescript": "^6.0.3",
|
|
104
|
+
"vite": "^8.1.5",
|
|
105
|
+
"vitest": "^4.1.10"
|
|
106
|
+
},
|
|
107
|
+
"engines": {
|
|
108
|
+
"node": ">=22.18"
|
|
109
|
+
},
|
|
110
|
+
"packageManager": "pnpm@11.15.1"
|
|
77
111
|
}
|
package/dist/MC.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { LooseObject } from './helpers.js';
|
|
2
|
-
import { BubbleController } from './events.js';
|
|
3
|
-
export interface HTMLMcElement extends HTMLElement {
|
|
4
|
-
_mc: LooseObject;
|
|
5
|
-
}
|
|
6
|
-
declare class McBase {
|
|
7
|
-
private _target;
|
|
8
|
-
constructor(target?: {
|
|
9
|
-
[key: string]: any;
|
|
10
|
-
});
|
|
11
|
-
get target(): any;
|
|
12
|
-
}
|
|
13
|
-
declare class MC extends McBase {
|
|
14
|
-
constructor(target?: any);
|
|
15
|
-
}
|
|
16
|
-
declare class DC extends McBase {
|
|
17
|
-
constructor(target: HTMLElement);
|
|
18
|
-
static add(target: HTMLElement, key: string, element?: any): HTMLMcElement;
|
|
19
|
-
static remove(target: HTMLElement, key: string): void;
|
|
20
|
-
off(eventName: string, handler: EventListenerOrEventListenerObject): void;
|
|
21
|
-
on(eventName: string, handler: EventListenerOrEventListenerObject): EventListenerOrEventListenerObject;
|
|
22
|
-
one(eventName: string, handler: EventListenerOrEventListenerObject): EventListenerOrEventListenerObject;
|
|
23
|
-
trigger(eventName: string, data?: any, bubble?: string, controller?: BubbleController): void;
|
|
24
|
-
ancestors(): DC[] | null;
|
|
25
|
-
closest(): DC | null;
|
|
26
|
-
children(): DC[] | null;
|
|
27
|
-
descendants(): DC[] | null;
|
|
28
|
-
}
|
|
29
|
-
declare function autoload(enable?: boolean): boolean;
|
|
30
|
-
export { MC, DC, McBase, autoload };
|
|
31
|
-
//# sourceMappingURL=MC.d.ts.map
|
package/dist/MC.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MC.d.ts","sourceRoot":"","sources":["../src/MC.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAyB,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAsBtE,MAAM,WAAW,aAAc,SAAQ,WAAW;IAajD,GAAG,EAAE,WAAW,CAAC;CACjB;AA+JD,cAAM,MAAM;IACX,OAAO,CAAC,OAAO,CAAe;gBAUlB,MAAM,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE;IAmB3C,IAAI,MAAM,IAAI,GAAG,CAEhB;CACD;AAQD,cAAM,EAAG,SAAQ,MAAM;gBAMV,MAAM,CAAC,EAAE,GAAG;CAGxB;AASD,cAAM,EAAG,SAAQ,MAAM;gBACV,MAAM,EAAE,WAAW;IAgB/B,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,GAAQ,GAAG,aAAa;IAc9E,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM;IAK9C,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,kCAAkC;IAalE,EAAE,CACD,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,kCAAkC,GACzC,kCAAkC;IAarC,GAAG,CACF,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,kCAAkC,GACzC,kCAAkC;IAcrC,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,GAAE,GAAQ,EAAE,MAAM,GAAE,MAAY,EAAE,UAAU,CAAC,EAAE,gBAAgB;IAc9F,SAAS,IAAI,EAAE,EAAE,GAAG,IAAI;IAsBxB,OAAO,IAAI,EAAE,GAAG,IAAI;IAcpB,QAAQ,IAAI,EAAE,EAAE,GAAG,IAAI;IAcvB,WAAW,IAAI,EAAE,EAAE,GAAG,IAAI;CAQ1B;AAwKD,iBAAS,QAAQ,CAAC,MAAM,GAAE,OAAc,GAAG,OAAO,CAuBjD;AAUD,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC"}
|