lilact 0.23.0 → 0.24.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 +19 -5
- package/dist/lilact.development.js +490 -464
- package/dist/lilact.development.js.map +4 -4
- package/dist/lilact.development.min.js +24 -24
- package/dist/lilact.development.min.js.map +4 -4
- package/dist/lilact.production.min.js +24 -24
- package/docs/assets/hierarchy.js +1 -1
- package/docs/classes/components.Component.html +1 -1
- package/docs/classes/components.HTMLComponent.html +1 -1
- package/docs/classes/components.RootComponent.html +1 -1
- package/docs/functions/components.cloneComponent.html +1 -1
- package/docs/functions/run.lazy.html +1 -1
- package/docs/functions/run.require.html +3 -4
- package/docs/functions/run.runScripts.html +1 -1
- package/docs/functions/timers.timeoutPromise.html +4 -4
- package/docs/hierarchy.html +1 -1
- package/docs/index.html +21 -5
- package/docs/static/demos/cloneelement.jsx +6 -0
- package/docs/static/demos/lazy.jsx +1 -1
- package/docs/static/demos/legacy-context.jsx +0 -7
- package/docs/static/index.html +3 -3
- package/docs/static/lilact.development.js +490 -464
- package/docs/static/lilact.development.js.map +4 -4
- package/docs/static/lilact.development.min.js +24 -24
- package/docs/static/lilact.development.min.js.map +4 -4
- package/docs/static/lilact.production.min.js +24 -24
- package/docs/variables/components.cloneElement.html +1 -1
- package/examples/demos/cloneelement.jsx +6 -0
- package/examples/demos/lazy.jsx +1 -1
- package/examples/demos/legacy-context.jsx +0 -7
- package/examples/index.html +3 -3
- package/examples/lilact.development.js +490 -464
- package/examples/lilact.development.js.map +4 -4
- package/examples/lilact.development.min.js +24 -24
- package/examples/lilact.development.min.js.map +4 -4
- package/examples/lilact.production.min.js +24 -24
- package/package.json +1 -1
- package/src/components.jsx +3 -3
- package/src/lilact.jsx +1 -1
- package/src/proptypes.jsx +38 -0
- package/src/run.jsx +10 -11
package/package.json
CHANGED
package/src/components.jsx
CHANGED
|
@@ -1142,7 +1142,7 @@ export function createComponent(entity, props={}, ...children)
|
|
|
1142
1142
|
props.key = generateComponentKey(entity, props);
|
|
1143
1143
|
props.children = children;
|
|
1144
1144
|
|
|
1145
|
-
return { entity, props };
|
|
1145
|
+
return { entity, props, [CORE]: null };
|
|
1146
1146
|
}
|
|
1147
1147
|
|
|
1148
1148
|
/**
|
|
@@ -1208,7 +1208,7 @@ export function createPortal(children, element)
|
|
|
1208
1208
|
|
|
1209
1209
|
export function cloneComponent(component, propsPatch, ...children)
|
|
1210
1210
|
{
|
|
1211
|
-
return { entity: component.entity, props: {...component.props, ...propsPatch, children} };
|
|
1211
|
+
return { entity: component.entity, props: {...component.props, ...propsPatch, children}, [CORE]: null };
|
|
1212
1212
|
}
|
|
1213
1213
|
|
|
1214
1214
|
export const cloneElement = cloneComponent;
|
|
@@ -1247,7 +1247,7 @@ export function memo(component)
|
|
|
1247
1247
|
component[MEMOIZED] = true;
|
|
1248
1248
|
}
|
|
1249
1249
|
else {
|
|
1250
|
-
component = { component, [MEMOIZED]: true };
|
|
1250
|
+
component = { component, [MEMOIZED]: true, [CORE]: null };
|
|
1251
1251
|
}
|
|
1252
1252
|
return component;
|
|
1253
1253
|
}
|
package/src/lilact.jsx
CHANGED
package/src/proptypes.jsx
CHANGED
|
@@ -28,6 +28,9 @@
|
|
|
28
28
|
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
|
+
import { isValidComponent } from "./misc.jsx";
|
|
32
|
+
|
|
33
|
+
|
|
31
34
|
function isNullOrUndefined(v) {
|
|
32
35
|
return v === null || v === undefined;
|
|
33
36
|
}
|
|
@@ -45,6 +48,28 @@ function defaultGetDisplayName(x) {
|
|
|
45
48
|
return x.displayName || x.name || "Unknown";
|
|
46
49
|
}
|
|
47
50
|
|
|
51
|
+
|
|
52
|
+
// ---- node validator ----
|
|
53
|
+
function isNode(x) {
|
|
54
|
+
// ignored-by-render children should be accepted by node
|
|
55
|
+
if (x === null || x === undefined) return true;
|
|
56
|
+
if (x === false || x === true) return true;
|
|
57
|
+
|
|
58
|
+
// primitives render
|
|
59
|
+
if (typeof x === "string" || typeof x === "number") return true;
|
|
60
|
+
|
|
61
|
+
if (isValidComponent(x)) return true;
|
|
62
|
+
|
|
63
|
+
// arrays are accepted as children; renderer will flatten later
|
|
64
|
+
if (Array.isArray(x)) return x.every(isNode);
|
|
65
|
+
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function isValidElementType(x) {
|
|
70
|
+
return typeof x === "function" || typeof x === "string";
|
|
71
|
+
}
|
|
72
|
+
|
|
48
73
|
/**
|
|
49
74
|
* Build a prop validator with a consistent contract:
|
|
50
75
|
* validator(props, propName, componentName, location, propFullName)
|
|
@@ -117,6 +142,19 @@ function createPropTypes() {
|
|
|
117
142
|
PropTypes.symbol = createPrimitiveValidator((v) => typeof v === "symbol");
|
|
118
143
|
PropTypes.symbol.expectedType = "symbol";
|
|
119
144
|
|
|
145
|
+
PropTypes.component = createPrimitiveValidator((v) => isValidComponent(v));
|
|
146
|
+
PropTypes.component.expectedType = "component";
|
|
147
|
+
|
|
148
|
+
PropTypes.element = createPrimitiveValidator((v) => isValidComponent(v));
|
|
149
|
+
PropTypes.element.expectedType = "element";
|
|
150
|
+
|
|
151
|
+
PropTypes.node = createPrimitiveValidator((v) => isNode(v));
|
|
152
|
+
PropTypes.node.expectedType = "node";
|
|
153
|
+
|
|
154
|
+
PropTypes.elementType = createPrimitiveValidator((v) => isValidElementType(v));
|
|
155
|
+
PropTypes.elementType.expectedType = "elementType";
|
|
156
|
+
|
|
157
|
+
|
|
120
158
|
// ----- combinators -----
|
|
121
159
|
|
|
122
160
|
PropTypes.oneOf = function oneOf(values) {
|
package/src/run.jsx
CHANGED
|
@@ -147,25 +147,25 @@ if(DEBUG) {
|
|
|
147
147
|
* @param path - The path to the required file. Must be either absolute path or relative to the current
|
|
148
148
|
* module or document’s URL (the page/location that initiated the request).
|
|
149
149
|
*
|
|
150
|
-
* @param [forceUpdate] - Force re-run module. By default an imported module is only run once.
|
|
151
|
-
*
|
|
152
|
-
* @param [checkExport] - An array of module properties to be checked upon import. This is used for import error detection.
|
|
153
|
-
*
|
|
154
|
-
* @param [isLazy] - if loading is should be async. Returns a promise if true.
|
|
155
|
-
*
|
|
156
|
-
* @param [requirer] - The module that is importing the other module. This is used internally to resolve relative paths.
|
|
157
|
-
*
|
|
158
150
|
* @returns An array representation of the children.
|
|
159
151
|
*/
|
|
160
|
-
export function require(path
|
|
152
|
+
export function require(path)
|
|
161
153
|
{
|
|
154
|
+
let forceUpdate, checkExport, requirer, isLazy;
|
|
155
|
+
|
|
156
|
+
// note: instead of named props, just to bypass typedoc.
|
|
157
|
+
if(arguments.length===2 && typeof(arguments[1]==='object')) {
|
|
158
|
+
forceUpdate = arguments[1]?.forceUpdate;
|
|
159
|
+
checkExport = arguments[1]?.checkExport;
|
|
160
|
+
requirer = arguments[1]?.requirer;
|
|
161
|
+
isLazy = arguments[1]?.isLazy;
|
|
162
|
+
}
|
|
162
163
|
|
|
163
164
|
if(Lilact.importObjectPaths?.[path]) return Lilact.importObjectPaths[path];
|
|
164
165
|
if(required_scripts[path] && !forceUpdate) return required_scripts[path].exports;
|
|
165
166
|
|
|
166
167
|
|
|
167
168
|
if(path[0]==='#') {
|
|
168
|
-
|
|
169
169
|
const el = document.getElementById(path);
|
|
170
170
|
|
|
171
171
|
if(el) {
|
|
@@ -188,7 +188,6 @@ export function require(path, {forceUpdate, checkExport, requirer, isLazy})
|
|
|
188
188
|
})
|
|
189
189
|
.then(res => {
|
|
190
190
|
res = run(res, path, false);
|
|
191
|
-
// todo: this is for the lazy, so we detect default to match react behaviour, but should we do it in sync mode too?
|
|
192
191
|
return res?.default ?? res;
|
|
193
192
|
})
|
|
194
193
|
.catch(err => {
|