lilact 0.31.12 → 0.31.13
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/lilact.development.js +37 -37
- package/dist/lilact.development.js.map +2 -2
- package/dist/lilact.development.min.js +27 -26
- package/dist/lilact.development.min.js.map +3 -3
- package/dist/lilact.production.min.js +27 -26
- package/docs/functions/run.lazy.html +1 -1
- package/docs/functions/run.require.html +1 -1
- package/docs/functions/run.run.html +1 -1
- package/docs/functions/run.runScripts.html +1 -1
- package/docs/static/lilact.development.js +37 -37
- package/docs/static/lilact.development.js.map +2 -2
- package/docs/static/lilact.development.min.js +27 -26
- package/docs/static/lilact.development.min.js.map +3 -3
- package/docs/static/lilact.production.min.js +27 -26
- package/examples/lilact.development.js +37 -37
- package/examples/lilact.development.js.map +2 -2
- package/examples/lilact.development.min.js +27 -26
- package/examples/lilact.development.min.js.map +3 -3
- package/examples/lilact.production.min.js +27 -26
- package/package.json +1 -1
- package/src/events.jsx +71 -76
- package/src/jsx.js +4 -0
- package/src/run.jsx +2 -3
package/package.json
CHANGED
package/src/events.jsx
CHANGED
|
@@ -29,91 +29,86 @@
|
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
31
|
|
|
32
|
+
export class SyntheticEvent {
|
|
33
|
+
constructor(nativeEvent, currentTarget) {
|
|
34
|
+
this.nativeEvent = nativeEvent;
|
|
35
|
+
this.type = nativeEvent.type;
|
|
36
|
+
this.target = nativeEvent.target || nativeEvent.srcElement || null;
|
|
37
|
+
this.currentTarget = currentTarget || nativeEvent.currentTarget || null;
|
|
38
|
+
this.timeStamp = nativeEvent.timeStamp ?? Date.now();
|
|
39
|
+
this.defaultPrevented = !!nativeEvent.defaultPrevented;
|
|
40
|
+
|
|
41
|
+
let propagationStopped = false;
|
|
42
|
+
|
|
43
|
+
this.isDefaultPrevented = () => this.defaultPrevented;
|
|
44
|
+
this.isPropagationStopped = () => propagationStopped;
|
|
45
|
+
this.preventDefault = () => {
|
|
46
|
+
nativeEvent.preventDefault?.();
|
|
47
|
+
this.defaultPrevented = true;
|
|
48
|
+
};
|
|
49
|
+
this.stopPropagation = () => {
|
|
50
|
+
nativeEvent.stopPropagation?.();
|
|
51
|
+
propagationStopped = true;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// Modern React doesn't pool events, so persist is a no-op.
|
|
55
|
+
this.persist = () => {};
|
|
56
|
+
this.isPersistent = () => true;
|
|
57
|
+
|
|
58
|
+
for (
|
|
59
|
+
let source = nativeEvent;
|
|
60
|
+
source && source !== Object.prototype;
|
|
61
|
+
source = Object.getPrototypeOf(source)
|
|
62
|
+
) {
|
|
63
|
+
for (const key of Object.getOwnPropertyNames(source)) {
|
|
64
|
+
if (key === "constructor" || key in this) continue;
|
|
65
|
+
|
|
66
|
+
Object.defineProperty(this, key, {
|
|
67
|
+
configurable: true,
|
|
68
|
+
enumerable: true,
|
|
69
|
+
get() {
|
|
70
|
+
const value = nativeEvent[key];
|
|
71
|
+
return typeof value === "function"
|
|
72
|
+
? value.bind(nativeEvent)
|
|
73
|
+
: value;
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
32
81
|
export function createSyntheticEvent(nativeEvent, currentTarget) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const event = {
|
|
36
|
-
nativeEvent,
|
|
37
|
-
type: nativeEvent.type,
|
|
38
|
-
target: nativeEvent.target || nativeEvent.srcElement || null,
|
|
39
|
-
currentTarget: currentTarget || nativeEvent.currentTarget || null,
|
|
40
|
-
timeStamp: nativeEvent.timeStamp ?? Date.now(),
|
|
41
|
-
defaultPrevented: !!nativeEvent.defaultPrevented,
|
|
42
|
-
|
|
43
|
-
isDefaultPrevented() {
|
|
44
|
-
return event.defaultPrevented;
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
isPropagationStopped() {
|
|
48
|
-
return propagationStopped;
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
preventDefault() {
|
|
52
|
-
nativeEvent.preventDefault?.();
|
|
53
|
-
event.defaultPrevented = true;
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
stopPropagation() {
|
|
57
|
-
nativeEvent.stopPropagation?.();
|
|
58
|
-
propagationStopped = true;
|
|
59
|
-
},
|
|
60
|
-
|
|
61
|
-
// Like React 17+ web SyntheticEvents: no pooling, persist is a no-op.
|
|
62
|
-
persist() {},
|
|
63
|
-
|
|
64
|
-
isPersistent() {
|
|
65
|
-
return true;
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
// Forward event-specific properties (such as WheelEvent.deltaX/deltaY)
|
|
70
|
-
// and native methods that are not explicitly defined above.
|
|
71
|
-
return new Proxy(event, {
|
|
72
|
-
get(target, property, receiver) {
|
|
73
|
-
if (Reflect.has(target, property)) {
|
|
74
|
-
return Reflect.get(target, property, receiver);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const value = Reflect.get(nativeEvent, property, nativeEvent);
|
|
78
|
-
return typeof value === "function" ? value.bind(nativeEvent) : value;
|
|
79
|
-
},
|
|
80
|
-
|
|
81
|
-
has(target, property) {
|
|
82
|
-
return Reflect.has(target, property) || property in nativeEvent;
|
|
83
|
-
},
|
|
84
|
-
});
|
|
82
|
+
return new SyntheticEvent(nativeEvent, currentTarget);
|
|
85
83
|
}
|
|
86
84
|
|
|
87
85
|
export function releaseSyntheticEvent(event) {
|
|
88
|
-
|
|
89
|
-
if (event) event.currentTarget = null;
|
|
86
|
+
if (event) event.currentTarget = null;
|
|
90
87
|
}
|
|
91
88
|
|
|
92
89
|
export function wrapListener(fn, opts = {}) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
};
|
|
90
|
+
const { stopPropagationOnTrueReturn = false } = opts;
|
|
91
|
+
|
|
92
|
+
return function handler(nativeEvent) {
|
|
93
|
+
const event = createSyntheticEvent(
|
|
94
|
+
nativeEvent,
|
|
95
|
+
this || nativeEvent.currentTarget || null
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
try {
|
|
99
|
+
const result = fn(event);
|
|
100
|
+
if (stopPropagationOnTrueReturn && result === true) {
|
|
101
|
+
event.stopPropagation();
|
|
102
|
+
}
|
|
103
|
+
} finally {
|
|
104
|
+
releaseSyntheticEvent(event);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
111
107
|
}
|
|
112
108
|
|
|
113
109
|
export function addWrappedEventListener(target, type, fn, options = {}) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
target.addEventListener(type, handler, options);
|
|
110
|
+
const handler = wrapListener(fn, options);
|
|
111
|
+
target.addEventListener(type, handler, options);
|
|
117
112
|
|
|
118
|
-
|
|
113
|
+
return () => target.removeEventListener(type, handler, options);
|
|
119
114
|
}
|
package/src/jsx.js
CHANGED
|
@@ -170,6 +170,8 @@ function parseComment(code, index, container)
|
|
|
170
170
|
index++;
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
+
|
|
174
|
+
|
|
173
175
|
raiseError(`Unterminated comment`, b.begin);
|
|
174
176
|
}
|
|
175
177
|
|
|
@@ -997,6 +999,8 @@ export function transpileJSX( jsx, {
|
|
|
997
999
|
transpilerConfig.preprocessorDelimiter ??= 'ʔ'; // alt+shift+. on apple abc extended layout
|
|
998
1000
|
transpilerConfig.injectTraceLabels ??= injectTraceLabels;
|
|
999
1001
|
|
|
1002
|
+
jsx+='\n';
|
|
1003
|
+
|
|
1000
1004
|
const eols = scanEOLs(jsx);
|
|
1001
1005
|
|
|
1002
1006
|
raiseError = ((eols, msg, index)=>{
|
package/src/run.jsx
CHANGED
|
@@ -137,9 +137,8 @@ function loadModule(path, options = {}) {
|
|
|
137
137
|
path = joinPaths(options.requirer.path, path);
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
const loadAsync =
|
|
141
|
-
|
|
142
|
-
Boolean(options.isLazy);
|
|
140
|
+
const loadAsync = Boolean(Lilact[LAZY]) ||
|
|
141
|
+
Boolean(options.isLazy);
|
|
143
142
|
|
|
144
143
|
const module = getOrCreateModule(path, {});
|
|
145
144
|
|