lilact 0.19.0 → 0.20.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/README.md +1 -1
- package/dist/lilact.development.js +129 -29
- package/dist/lilact.development.js.map +2 -2
- package/dist/lilact.development.min.js +18 -18
- package/dist/lilact.development.min.js.map +3 -3
- package/dist/lilact.production.min.js +17 -17
- package/docs/assets/search.js +1 -1
- package/docs/functions/misc.deepEqual.html +1 -1
- package/docs/functions/misc.forwardRef.html +1 -1
- package/docs/functions/misc.getComponentByPointer.html +1 -1
- package/docs/functions/misc.isAsync.html +1 -1
- package/docs/functions/misc.isClass.html +1 -1
- package/docs/functions/misc.isEmpty.html +1 -1
- package/docs/functions/misc.isError.html +1 -1
- package/docs/functions/misc.isThenable.html +1 -1
- package/docs/functions/misc.shallowEqual.html +1 -1
- package/docs/functions/misc.toBool.html +1 -1
- package/docs/functions/timers.timeoutPromise.html +20 -11
- package/docs/index.html +1 -1
- package/docs/static/lilact.development.js +129 -29
- package/docs/static/lilact.development.js.map +2 -2
- package/docs/static/lilact.development.min.js +18 -18
- package/docs/static/lilact.development.min.js.map +3 -3
- package/docs/static/lilact.production.min.js +17 -17
- package/docs/variables/misc.Children.html +19 -10
- package/examples/lilact.development.js +129 -29
- package/examples/lilact.development.js.map +2 -2
- package/examples/lilact.development.min.js +18 -18
- package/examples/lilact.development.min.js.map +3 -3
- package/examples/lilact.production.min.js +17 -17
- package/package.json +1 -1
- package/src/lilact.jsx +1 -1
- package/src/misc.jsx +164 -46
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ If you find Lilact useful, please consider sponsoring. Your support funds ongoin
|
|
|
29
29
|
|
|
30
30
|
## Overview
|
|
31
31
|
|
|
32
|
-
`Lilact` is a very lightweight implementation of the React API designed to run in the browser. It can be used as a single script that is around `90kb` minified and around `32kb` gzipped and includes its whole API.
|
|
32
|
+
`Lilact` is a very lightweight implementation of the React API designed to run in the browser. It can be used as a single script that is around `90kb` minified and around `32kb` gzipped and includes its whole API. It is tested and works on **Chrome**, **Firefox**, **Edge**, and **Safari**.
|
|
33
33
|
|
|
34
34
|
`Lilact` is very fast, uses minimal resources, and handles memory very efficiently.
|
|
35
35
|
|
|
@@ -2076,43 +2076,143 @@ function Portal({ children, view }) {
|
|
|
2076
2076
|
Portal.displayName = "Portal";
|
|
2077
2077
|
var Children = {
|
|
2078
2078
|
/**
|
|
2079
|
-
*
|
|
2079
|
+
* @param {any} x
|
|
2080
|
+
* @returns {boolean}
|
|
2081
|
+
*/
|
|
2082
|
+
_isNil(x) {
|
|
2083
|
+
return x === null || x === void 0;
|
|
2084
|
+
},
|
|
2085
|
+
/**
|
|
2086
|
+
* Recursively flattens nested arrays into `out`, omitting null/undefined.
|
|
2087
|
+
* @param {Array<any>} out
|
|
2088
|
+
* @param {any} input
|
|
2089
|
+
*/
|
|
2090
|
+
_flattenInto(out, input) {
|
|
2091
|
+
if (this._isNil(input)) return;
|
|
2092
|
+
if (Array.isArray(input)) {
|
|
2093
|
+
for (const v of input) this._flattenInto(out, v);
|
|
2094
|
+
return;
|
|
2095
|
+
}
|
|
2096
|
+
out.push(input);
|
|
2097
|
+
},
|
|
2098
|
+
/**
|
|
2099
|
+
* Converts an iterable children collection into a flat array,
|
|
2100
|
+
* omitting `null`/`undefined`.
|
|
2101
|
+
*
|
|
2102
|
+
* @param {Iterable<any>} children
|
|
2103
|
+
* @returns {Array<any>}
|
|
2104
|
+
*/
|
|
2105
|
+
toArray(children) {
|
|
2106
|
+
const out = [];
|
|
2107
|
+
if (!children) return out;
|
|
2108
|
+
for (const item of children) {
|
|
2109
|
+
this._flattenInto(out, item);
|
|
2110
|
+
}
|
|
2111
|
+
return out;
|
|
2112
|
+
},
|
|
2113
|
+
/**
|
|
2114
|
+
* Returns the number of non-null/undefined children (after flattening).
|
|
2115
|
+
* @param {Iterable<any>} children
|
|
2116
|
+
* @returns {number}
|
|
2117
|
+
*/
|
|
2118
|
+
count(children) {
|
|
2119
|
+
return this.toArray(children).length;
|
|
2120
|
+
},
|
|
2121
|
+
/**
|
|
2122
|
+
* Returns the single child from a children collection (after flattening & omitting nil),
|
|
2123
|
+
* or throws if the remaining count is not exactly 1.
|
|
2080
2124
|
*
|
|
2081
|
-
* @param
|
|
2082
|
-
* @returns
|
|
2125
|
+
* @param {Iterable<any>} children
|
|
2126
|
+
* @returns {any}
|
|
2083
2127
|
*/
|
|
2084
2128
|
only(children) {
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
children.splice(i2, 1, ...children[i2]);
|
|
2091
|
-
i2--;
|
|
2092
|
-
} else if (children[i2] === null || children[i2] === void 0) {
|
|
2093
|
-
children.splice(i2, 1);
|
|
2094
|
-
i2--;
|
|
2095
|
-
}
|
|
2096
|
-
if (i2 > 1) {
|
|
2097
|
-
throw new Error("No child or child is not the only one");
|
|
2098
|
-
}
|
|
2099
|
-
i2++;
|
|
2129
|
+
const arr = this.toArray(children);
|
|
2130
|
+
if (arr.length !== 1) {
|
|
2131
|
+
throw new Error(
|
|
2132
|
+
arr.length === 0 ? "Expected exactly one child, but received none." : "Expected exactly one child, but received more than one."
|
|
2133
|
+
);
|
|
2100
2134
|
}
|
|
2101
|
-
|
|
2135
|
+
return arr[0];
|
|
2102
2136
|
},
|
|
2103
2137
|
/**
|
|
2104
|
-
*
|
|
2138
|
+
* Maps over children (after flattening & omitting nil).
|
|
2105
2139
|
*
|
|
2106
|
-
* @param
|
|
2107
|
-
* @
|
|
2140
|
+
* @param {Iterable<any>} children
|
|
2141
|
+
* @param {(child:any, index:number)=>any} fn
|
|
2142
|
+
* @returns {Array<any>}
|
|
2108
2143
|
*/
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2144
|
+
map(children, fn) {
|
|
2145
|
+
const arr = this.toArray(children);
|
|
2146
|
+
const out = [];
|
|
2147
|
+
for (let i2 = 0; i2 < arr.length; i2++) out.push(fn(arr[i2], i2));
|
|
2148
|
+
return out;
|
|
2149
|
+
},
|
|
2150
|
+
/**
|
|
2151
|
+
* Iterates over children (after flattening & omitting nil).
|
|
2152
|
+
* @param {Iterable<any>} children
|
|
2153
|
+
* @param {(child:any, index:number)=>void} fn
|
|
2154
|
+
*/
|
|
2155
|
+
forEach(children, fn) {
|
|
2156
|
+
const arr = this.toArray(children);
|
|
2157
|
+
for (let i2 = 0; i2 < arr.length; i2++) fn(arr[i2], i2);
|
|
2158
|
+
},
|
|
2159
|
+
/**
|
|
2160
|
+
* Finds the first child for which predicate returns true.
|
|
2161
|
+
*
|
|
2162
|
+
* @param {Iterable<any>} children
|
|
2163
|
+
* @param {(child:any, index:number)=>boolean} predicate
|
|
2164
|
+
* @returns {any|undefined}
|
|
2165
|
+
*/
|
|
2166
|
+
find(children, predicate) {
|
|
2167
|
+
const arr = this.toArray(children);
|
|
2168
|
+
for (let i2 = 0; i2 < arr.length; i2++) {
|
|
2169
|
+
if (predicate(arr[i2], i2)) return arr[i2];
|
|
2114
2170
|
}
|
|
2115
|
-
return
|
|
2171
|
+
return void 0;
|
|
2172
|
+
},
|
|
2173
|
+
/**
|
|
2174
|
+
* Finds exactly one matching child.
|
|
2175
|
+
* Throws if matched count is not exactly 1.
|
|
2176
|
+
*
|
|
2177
|
+
* @param {Iterable<any>} children
|
|
2178
|
+
* @param {(child:any, index:number)=>boolean} predicate
|
|
2179
|
+
* @returns {any}
|
|
2180
|
+
*/
|
|
2181
|
+
pickOne(children, predicate) {
|
|
2182
|
+
const arr = this.toArray(children);
|
|
2183
|
+
let found;
|
|
2184
|
+
let matches = 0;
|
|
2185
|
+
for (let i2 = 0; i2 < arr.length; i2++) {
|
|
2186
|
+
if (predicate(arr[i2], i2)) {
|
|
2187
|
+
matches++;
|
|
2188
|
+
found = arr[i2];
|
|
2189
|
+
if (matches > 1) break;
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2192
|
+
if (matches !== 1) {
|
|
2193
|
+
throw new Error(
|
|
2194
|
+
matches === 0 ? "pickOne expected exactly one matching child, but matched none." : "pickOne expected exactly one matching child, but matched multiple."
|
|
2195
|
+
);
|
|
2196
|
+
}
|
|
2197
|
+
return found;
|
|
2198
|
+
},
|
|
2199
|
+
/**
|
|
2200
|
+
* Returns the first non-nil child (after flattening), or undefined.
|
|
2201
|
+
* @param {Iterable<any>} children
|
|
2202
|
+
* @returns {any|undefined}
|
|
2203
|
+
*/
|
|
2204
|
+
first(children) {
|
|
2205
|
+
const arr = this.toArray(children);
|
|
2206
|
+
return arr[0];
|
|
2207
|
+
},
|
|
2208
|
+
/**
|
|
2209
|
+
* Returns the last non-nil child (after flattening), or undefined.
|
|
2210
|
+
* @param {Iterable<any>} children
|
|
2211
|
+
* @returns {any|undefined}
|
|
2212
|
+
*/
|
|
2213
|
+
last(children) {
|
|
2214
|
+
const arr = this.toArray(children);
|
|
2215
|
+
return arr.length ? arr[arr.length - 1] : void 0;
|
|
2116
2216
|
}
|
|
2117
2217
|
};
|
|
2118
2218
|
var forwardRef = (render2) => {
|
|
@@ -5850,7 +5950,7 @@ function transpileJSX(jsx2, {
|
|
|
5850
5950
|
|
|
5851
5951
|
// .tmp/src/lilact.jsx
|
|
5852
5952
|
var Lilact2 = {
|
|
5853
|
-
VERSION: "beta.
|
|
5953
|
+
VERSION: "beta.20",
|
|
5854
5954
|
// Configuration
|
|
5855
5955
|
defaultTransitionTimeout: 300,
|
|
5856
5956
|
defaultIsEqual: Object.is,
|