lilact 0.31.12 → 0.31.14
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 +48 -42
- package/dist/lilact.development.js.map +2 -2
- package/dist/lilact.development.min.js +31 -28
- package/dist/lilact.development.min.js.map +3 -3
- package/dist/lilact.production.min.js +31 -28
- 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 +48 -42
- package/docs/static/lilact.development.js.map +2 -2
- package/docs/static/lilact.development.min.js +31 -28
- package/docs/static/lilact.development.min.js.map +3 -3
- package/docs/static/lilact.production.min.js +31 -28
- package/examples/lilact.development.js +48 -42
- package/examples/lilact.development.js.map +2 -2
- package/examples/lilact.development.min.js +31 -28
- package/examples/lilact.development.min.js.map +3 -3
- package/examples/lilact.production.min.js +31 -28
- package/package.json +1 -1
- package/src/events.jsx +71 -76
- package/src/expscan.js +10 -9
- package/src/jsx.js +11 -1
- 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/expscan.js
CHANGED
|
@@ -337,17 +337,18 @@ export function processImportExports(node, jsx, meta)
|
|
|
337
337
|
continue;
|
|
338
338
|
}
|
|
339
339
|
case 'F':{
|
|
340
|
-
|
|
341
|
-
node.out[i] = null;
|
|
340
|
+
|
|
342
341
|
i++;
|
|
343
|
-
|
|
342
|
+
|
|
343
|
+
while(s[i]===' ' || s[i]==='\n' || s[i]==='C') {
|
|
344
|
+
i++;
|
|
345
|
+
}
|
|
346
|
+
|
|
344
347
|
const name = node.out[i];
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
node.out[m.index].cjs = `module.exports.${name} = ${tp} `;
|
|
348
|
+
|
|
349
|
+
node.out[m.index].cjs = '';
|
|
350
|
+
node.out[m.index].appendix_js = `module.exports.${name} = ${name};`;
|
|
351
|
+
|
|
351
352
|
continue;
|
|
352
353
|
}
|
|
353
354
|
case '*':
|
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)=>{
|
|
@@ -1081,6 +1085,7 @@ export function transpileJSX( jsx, {
|
|
|
1081
1085
|
preprocessPragmas(json);
|
|
1082
1086
|
|
|
1083
1087
|
const flattened_nodes = [];
|
|
1088
|
+
let appendix_js = '\n';
|
|
1084
1089
|
|
|
1085
1090
|
const codify = (outlen, node, is_attr=false, is_xml=false)=> {
|
|
1086
1091
|
|
|
@@ -1094,7 +1099,10 @@ export function transpileJSX( jsx, {
|
|
|
1094
1099
|
|
|
1095
1100
|
if(node.type==='string') return jsx.substring(node.begin, node.end);
|
|
1096
1101
|
if(node.type==='import') return node.cjs;
|
|
1097
|
-
if(node.type==='export')
|
|
1102
|
+
if(node.type==='export') {
|
|
1103
|
+
if(node.appendix_js) appendix_js+=node.appendix_js;
|
|
1104
|
+
return node.cjs;
|
|
1105
|
+
}
|
|
1098
1106
|
if(node.type==='regex') return jsx.substring(node.begin, node.end);
|
|
1099
1107
|
if(node.type==='comment') return (discardComments || is_attr)?'':jsx.substring(node.begin, node.end);
|
|
1100
1108
|
if(node.type==='directive') return node.value;
|
|
@@ -1191,6 +1199,8 @@ export function transpileJSX( jsx, {
|
|
|
1191
1199
|
}
|
|
1192
1200
|
out+=codify(out.length, json);
|
|
1193
1201
|
|
|
1202
|
+
out+=appendix_js.length>1?appendix_js:'';
|
|
1203
|
+
|
|
1194
1204
|
if(injectTraceLabels) {
|
|
1195
1205
|
if(transpilerConfig.enableLabelStack) {
|
|
1196
1206
|
out += `}catch(e){ if(typeof(e)!=='object') e=new Error(e);e.lilact_trace=[${blocksInfo.counter},e.lilact_trace];throw e}`;
|
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
|
|