@fictjs/runtime 0.0.2 → 0.0.4
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 +1 -1
- package/dist/index.cjs +33 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.dev.js +36 -31
- package/dist/index.dev.js.map +1 -1
- package/dist/index.js +33 -30
- package/dist/index.js.map +1 -1
- package/dist/jsx-dev-runtime.d.cts +671 -0
- package/dist/jsx-dev-runtime.d.ts +671 -0
- package/dist/jsx-runtime.d.cts +671 -0
- package/dist/jsx-runtime.d.ts +671 -0
- package/dist/slim.cjs +32 -29
- package/dist/slim.cjs.map +1 -1
- package/dist/slim.js +32 -29
- package/dist/slim.js.map +1 -1
- package/package.json +6 -6
- package/src/binding.ts +49 -31
- package/src/index.ts +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 fictjs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1840,6 +1840,27 @@ function isReactive(value) {
|
|
|
1840
1840
|
function unwrap2(value) {
|
|
1841
1841
|
return isReactive(value) ? value() : value;
|
|
1842
1842
|
}
|
|
1843
|
+
function callEventHandler(handler, event, node, data) {
|
|
1844
|
+
if (!handler) return;
|
|
1845
|
+
const context = node ?? event.currentTarget ?? void 0;
|
|
1846
|
+
const invoke = (fn) => {
|
|
1847
|
+
if (typeof fn === "function") {
|
|
1848
|
+
const result = data === void 0 ? fn.call(context, event) : fn.call(context, data, event);
|
|
1849
|
+
if (typeof result === "function" && result !== fn) {
|
|
1850
|
+
if (data === void 0) {
|
|
1851
|
+
result.call(context, event);
|
|
1852
|
+
} else {
|
|
1853
|
+
result.call(context, data, event);
|
|
1854
|
+
}
|
|
1855
|
+
} else if (result && typeof result.handleEvent === "function") {
|
|
1856
|
+
result.handleEvent.call(result, event);
|
|
1857
|
+
}
|
|
1858
|
+
} else if (fn && typeof fn.handleEvent === "function") {
|
|
1859
|
+
fn.handleEvent.call(fn, event);
|
|
1860
|
+
}
|
|
1861
|
+
};
|
|
1862
|
+
invoke(handler);
|
|
1863
|
+
}
|
|
1843
1864
|
var PRIMITIVE_PROXY = Symbol("fict:primitive-proxy");
|
|
1844
1865
|
var PRIMITIVE_PROXY_RAW_VALUE = Symbol("fict:primitive-proxy:raw-value");
|
|
1845
1866
|
function unwrapPrimitive(value) {
|
|
@@ -2353,14 +2374,10 @@ function globalEventHandler(e) {
|
|
|
2353
2374
|
const hasData = rawData !== void 0;
|
|
2354
2375
|
const resolvedNodeData = hasData ? resolveData(rawData) : void 0;
|
|
2355
2376
|
if (typeof handler === "function") {
|
|
2356
|
-
|
|
2357
|
-
handler.call(node, resolvedNodeData, e);
|
|
2358
|
-
} else {
|
|
2359
|
-
handler.call(node, e);
|
|
2360
|
-
}
|
|
2377
|
+
callEventHandler(handler, e, node, hasData ? resolvedNodeData : void 0);
|
|
2361
2378
|
} else if (Array.isArray(handler)) {
|
|
2362
2379
|
const tupleData = resolveData(handler[1]);
|
|
2363
|
-
handler[0]
|
|
2380
|
+
callEventHandler(handler[0], e, node, tupleData);
|
|
2364
2381
|
}
|
|
2365
2382
|
if (e.cancelBubble) return false;
|
|
2366
2383
|
}
|
|
@@ -2424,23 +2441,15 @@ function bindEvent(el, eventName, handler, options2) {
|
|
|
2424
2441
|
if (DelegatedEvents.has(eventName) && !options2) {
|
|
2425
2442
|
const key = `$$${eventName}`;
|
|
2426
2443
|
delegateEvents([eventName]);
|
|
2427
|
-
const createWrapped = (resolve) => {
|
|
2428
|
-
const wrapped2 = function(...args) {
|
|
2429
|
-
try {
|
|
2430
|
-
const fn = resolve();
|
|
2431
|
-
if (typeof fn === "function") {
|
|
2432
|
-
return fn.apply(this, args);
|
|
2433
|
-
} else if (fn && typeof fn.handleEvent === "function") {
|
|
2434
|
-
return fn.handleEvent.apply(fn, args);
|
|
2435
|
-
}
|
|
2436
|
-
} catch (err) {
|
|
2437
|
-
handleError(err, { source: "event", eventName }, rootRef);
|
|
2438
|
-
}
|
|
2439
|
-
};
|
|
2440
|
-
return wrapped2;
|
|
2441
|
-
};
|
|
2442
2444
|
const resolveHandler = isReactive(handler) ? handler : () => handler;
|
|
2443
|
-
el[key] =
|
|
2445
|
+
el[key] = function(...args) {
|
|
2446
|
+
try {
|
|
2447
|
+
const fn = resolveHandler();
|
|
2448
|
+
callEventHandler(fn, args[0], el);
|
|
2449
|
+
} catch (err) {
|
|
2450
|
+
handleError(err, { source: "event", eventName }, rootRef);
|
|
2451
|
+
}
|
|
2452
|
+
};
|
|
2444
2453
|
return () => {
|
|
2445
2454
|
el[key] = void 0;
|
|
2446
2455
|
};
|
|
@@ -2449,13 +2458,7 @@ function bindEvent(el, eventName, handler, options2) {
|
|
|
2449
2458
|
const wrapped = (event) => {
|
|
2450
2459
|
try {
|
|
2451
2460
|
const resolved = getHandler();
|
|
2452
|
-
|
|
2453
|
-
;
|
|
2454
|
-
resolved(event);
|
|
2455
|
-
} else if (resolved && typeof resolved.handleEvent === "function") {
|
|
2456
|
-
;
|
|
2457
|
-
resolved.handleEvent(event);
|
|
2458
|
-
}
|
|
2461
|
+
callEventHandler(resolved, event, el);
|
|
2459
2462
|
} catch (err) {
|
|
2460
2463
|
if (handleError(err, { source: "event", eventName }, rootRef)) {
|
|
2461
2464
|
return;
|
|
@@ -4164,6 +4167,7 @@ exports.bindProperty = bindProperty;
|
|
|
4164
4167
|
exports.bindRef = bindRef;
|
|
4165
4168
|
exports.bindStyle = bindStyle;
|
|
4166
4169
|
exports.bindText = bindText;
|
|
4170
|
+
exports.callEventHandler = callEventHandler;
|
|
4167
4171
|
exports.classList = classList;
|
|
4168
4172
|
exports.clearDelegatedEvents = clearDelegatedEvents;
|
|
4169
4173
|
exports.createAttributeBinding = createAttributeBinding;
|