@hypen-space/web 0.4.3 → 0.4.11
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/canvas/index.js +30 -2
- package/dist/canvas/index.js.map +4 -4
- package/dist/canvas/input.d.ts +8 -1
- package/dist/canvas/input.js +14 -2
- package/dist/canvas/input.js.map +3 -3
- package/dist/canvas/renderer.d.ts +4 -0
- package/dist/canvas/renderer.js +30 -2
- package/dist/canvas/renderer.js.map +4 -4
- package/dist/client.js +71 -26
- package/dist/client.js.map +6 -6
- package/dist/dom/applicators/advanced-layout.js +1 -4
- package/dist/dom/applicators/advanced-layout.js.map +3 -3
- package/dist/dom/applicators/events.js +53 -2
- package/dist/dom/applicators/events.js.map +3 -3
- package/dist/dom/applicators/index.js +53 -5
- package/dist/dom/applicators/index.js.map +4 -4
- package/dist/dom/index.js +66 -8
- package/dist/dom/index.js.map +5 -5
- package/dist/dom/renderer.d.ts +7 -3
- package/dist/dom/renderer.js +66 -8
- package/dist/dom/renderer.js.map +5 -5
- package/dist/hypen.js +71 -26
- package/dist/hypen.js.map +6 -6
- package/dist/index.js +95 -9
- package/dist/index.js.map +7 -7
- package/package.json +2 -2
- package/src/canvas/input.ts +23 -1
- package/src/canvas/renderer.ts +23 -0
- package/src/dom/applicators/advanced-layout.ts +0 -4
- package/src/dom/applicators/events.ts +71 -0
- package/src/dom/renderer.ts +18 -4
- package/src/hypen.ts +7 -24
package/dist/index.js
CHANGED
|
@@ -2351,7 +2351,58 @@ var eventHandlers = {
|
|
|
2351
2351
|
onFocus: createEventHandler("focus", { extractPayload: focusPayload }),
|
|
2352
2352
|
onBlur: createEventHandler("blur", { extractPayload: focusPayload }),
|
|
2353
2353
|
onMouseEnter: createEventHandler("mouseenter", { extractPayload: mousePayload }),
|
|
2354
|
-
onMouseLeave: createEventHandler("mouseleave", { extractPayload: mousePayload })
|
|
2354
|
+
onMouseLeave: createEventHandler("mouseleave", { extractPayload: mousePayload }),
|
|
2355
|
+
bind: (element, value) => {
|
|
2356
|
+
const bindPath = typeof value === "string" ? value : null;
|
|
2357
|
+
if (!bindPath)
|
|
2358
|
+
return;
|
|
2359
|
+
const disposables = getElementDisposables2(element);
|
|
2360
|
+
const eventKey = `bind:${bindPath}`;
|
|
2361
|
+
if (getRegisteredEvents(element).has(eventKey))
|
|
2362
|
+
return;
|
|
2363
|
+
registerEvent(element, eventKey);
|
|
2364
|
+
const hypenType = element.dataset?.hypenType;
|
|
2365
|
+
if (hypenType === "checkbox" || hypenType === "switch") {
|
|
2366
|
+
const input = element.querySelector('input[type="checkbox"]');
|
|
2367
|
+
if (!input)
|
|
2368
|
+
return;
|
|
2369
|
+
const listener = () => {
|
|
2370
|
+
const engine = getEngine(element);
|
|
2371
|
+
if (engine) {
|
|
2372
|
+
engine.dispatchAction("__hypen_bind", {
|
|
2373
|
+
path: bindPath,
|
|
2374
|
+
value: input.checked
|
|
2375
|
+
});
|
|
2376
|
+
}
|
|
2377
|
+
};
|
|
2378
|
+
disposables.add(disposableListener(input, "change", listener, { passive: true }));
|
|
2379
|
+
} else if (element instanceof HTMLSelectElement) {
|
|
2380
|
+
const listener = () => {
|
|
2381
|
+
const engine = getEngine(element);
|
|
2382
|
+
if (engine) {
|
|
2383
|
+
engine.dispatchAction("__hypen_bind", {
|
|
2384
|
+
path: bindPath,
|
|
2385
|
+
value: element.value
|
|
2386
|
+
});
|
|
2387
|
+
}
|
|
2388
|
+
};
|
|
2389
|
+
disposables.add(disposableListener(element, "change", listener, { passive: true }));
|
|
2390
|
+
} else if (element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement) {
|
|
2391
|
+
const listener = () => {
|
|
2392
|
+
const engine = getEngine(element);
|
|
2393
|
+
if (engine) {
|
|
2394
|
+
engine.dispatchAction("__hypen_bind", {
|
|
2395
|
+
path: bindPath,
|
|
2396
|
+
value: element.value
|
|
2397
|
+
});
|
|
2398
|
+
}
|
|
2399
|
+
};
|
|
2400
|
+
disposables.add(disposableListener(element, "input", listener, { passive: true }));
|
|
2401
|
+
} else {
|
|
2402
|
+
return;
|
|
2403
|
+
}
|
|
2404
|
+
disposables.addCallback(() => unregisterEvent(element, eventKey));
|
|
2405
|
+
}
|
|
2355
2406
|
};
|
|
2356
2407
|
|
|
2357
2408
|
// src/dom/applicators/typography.ts
|
|
@@ -2612,9 +2663,6 @@ var advancedLayoutHandlers = {
|
|
|
2612
2663
|
alignContent: (el, value) => {
|
|
2613
2664
|
el.style.alignContent = String(value);
|
|
2614
2665
|
},
|
|
2615
|
-
alignSelf: (el, value) => {
|
|
2616
|
-
el.style.alignSelf = String(value);
|
|
2617
|
-
},
|
|
2618
2666
|
order: (el, value) => {
|
|
2619
2667
|
el.style.order = String(value);
|
|
2620
2668
|
},
|
|
@@ -3320,7 +3368,7 @@ class DOMRenderer {
|
|
|
3320
3368
|
applicators;
|
|
3321
3369
|
engine;
|
|
3322
3370
|
currentState = {};
|
|
3323
|
-
|
|
3371
|
+
router = null;
|
|
3324
3372
|
globalContext = null;
|
|
3325
3373
|
componentInstances = new Map;
|
|
3326
3374
|
debugTracker;
|
|
@@ -3335,8 +3383,8 @@ class DOMRenderer {
|
|
|
3335
3383
|
this.applicators.register(name, handler);
|
|
3336
3384
|
}
|
|
3337
3385
|
}
|
|
3338
|
-
setContext(
|
|
3339
|
-
this.
|
|
3386
|
+
setContext(router, globalContext) {
|
|
3387
|
+
this.router = router;
|
|
3340
3388
|
this.globalContext = globalContext;
|
|
3341
3389
|
}
|
|
3342
3390
|
applyPatches(patches) {
|
|
@@ -3395,6 +3443,9 @@ class DOMRenderer {
|
|
|
3395
3443
|
case "setProp":
|
|
3396
3444
|
this.onSetProp(id, patch.name, patch.value);
|
|
3397
3445
|
break;
|
|
3446
|
+
case "removeProp":
|
|
3447
|
+
this.onRemoveProp(id, patch.name);
|
|
3448
|
+
break;
|
|
3398
3449
|
case "setText":
|
|
3399
3450
|
this.onSetText(id, patch.text);
|
|
3400
3451
|
break;
|
|
@@ -3462,6 +3513,13 @@ class DOMRenderer {
|
|
|
3462
3513
|
}
|
|
3463
3514
|
this.applicators.apply(element, name, value);
|
|
3464
3515
|
}
|
|
3516
|
+
onRemoveProp(id, name) {
|
|
3517
|
+
const element = this.nodes.get(id);
|
|
3518
|
+
if (!element)
|
|
3519
|
+
return;
|
|
3520
|
+
this.debugTracker.trackRerender(id, element, `removeProp:${name}`);
|
|
3521
|
+
this.applicators.apply(element, name, undefined);
|
|
3522
|
+
}
|
|
3465
3523
|
onSetText(id, text) {
|
|
3466
3524
|
const element = this.nodes.get(id);
|
|
3467
3525
|
if (!element)
|
|
@@ -5228,13 +5286,17 @@ class InputOverlay {
|
|
|
5228
5286
|
overlay = null;
|
|
5229
5287
|
focusedNode = null;
|
|
5230
5288
|
onChangeCallback = null;
|
|
5289
|
+
bindPath = null;
|
|
5290
|
+
engine = null;
|
|
5231
5291
|
constructor(container) {
|
|
5232
5292
|
this.container = container || {};
|
|
5233
5293
|
}
|
|
5234
|
-
showInput(node, canvasBounds, onChange) {
|
|
5294
|
+
showInput(node, canvasBounds, onChange, engine) {
|
|
5235
5295
|
if (typeof document === "undefined")
|
|
5236
5296
|
return;
|
|
5237
5297
|
this.hideInput();
|
|
5298
|
+
this.bindPath = node.props.bind || null;
|
|
5299
|
+
this.engine = engine || null;
|
|
5238
5300
|
const bounds = getAbsoluteBounds(node);
|
|
5239
5301
|
if (!bounds)
|
|
5240
5302
|
return;
|
|
@@ -5258,6 +5320,8 @@ class InputOverlay {
|
|
|
5258
5320
|
}
|
|
5259
5321
|
this.focusedNode = null;
|
|
5260
5322
|
this.onChangeCallback = null;
|
|
5323
|
+
this.bindPath = null;
|
|
5324
|
+
this.engine = null;
|
|
5261
5325
|
}
|
|
5262
5326
|
updatePosition(node, canvasBounds) {
|
|
5263
5327
|
if (!this.overlay || node !== this.focusedNode)
|
|
@@ -5319,6 +5383,12 @@ class InputOverlay {
|
|
|
5319
5383
|
return;
|
|
5320
5384
|
const value = this.overlay.value;
|
|
5321
5385
|
this.onChangeCallback(value);
|
|
5386
|
+
if (this.bindPath && this.engine) {
|
|
5387
|
+
this.engine.dispatchAction("__hypen_bind", {
|
|
5388
|
+
path: this.bindPath,
|
|
5389
|
+
value
|
|
5390
|
+
});
|
|
5391
|
+
}
|
|
5322
5392
|
}
|
|
5323
5393
|
onBlur() {
|
|
5324
5394
|
this.hideInput();
|
|
@@ -5559,6 +5629,9 @@ class CanvasRenderer {
|
|
|
5559
5629
|
case "setProp":
|
|
5560
5630
|
this.onSetProp(patch.id, patch.name, patch.value);
|
|
5561
5631
|
break;
|
|
5632
|
+
case "removeProp":
|
|
5633
|
+
this.onRemoveProp(patch.id, patch.name);
|
|
5634
|
+
break;
|
|
5562
5635
|
case "setText":
|
|
5563
5636
|
this.onSetText(patch.id, patch.text);
|
|
5564
5637
|
break;
|
|
@@ -5603,6 +5676,19 @@ class CanvasRenderer {
|
|
|
5603
5676
|
}
|
|
5604
5677
|
this.accessibilityLayer.updateNode(node);
|
|
5605
5678
|
}
|
|
5679
|
+
onRemoveProp(id, name) {
|
|
5680
|
+
const node = this.nodes.get(id);
|
|
5681
|
+
if (!node)
|
|
5682
|
+
return;
|
|
5683
|
+
delete node.props[name];
|
|
5684
|
+
if (name === "visible") {
|
|
5685
|
+
node.visible = true;
|
|
5686
|
+
}
|
|
5687
|
+
if (name === "opacity") {
|
|
5688
|
+
node.opacity = 1;
|
|
5689
|
+
}
|
|
5690
|
+
this.accessibilityLayer.updateNode(node);
|
|
5691
|
+
}
|
|
5606
5692
|
onSetText(id, text) {
|
|
5607
5693
|
const node = this.nodes.get(id);
|
|
5608
5694
|
if (!node)
|
|
@@ -5755,4 +5841,4 @@ export {
|
|
|
5755
5841
|
ApplicatorRegistry
|
|
5756
5842
|
};
|
|
5757
5843
|
|
|
5758
|
-
//# debugId=
|
|
5844
|
+
//# debugId=BCCCE4DA4D43838E64756E2164756E21
|