@hypen-space/web 0.4.1 → 0.4.3
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/accessibility.d.ts +47 -0
- package/dist/canvas/events.d.ts +87 -0
- package/dist/canvas/index.d.ts +11 -0
- package/dist/canvas/index.js +19 -13
- package/dist/canvas/index.js.map +6 -6
- package/dist/canvas/input.d.ts +56 -0
- package/dist/canvas/layout.d.ts +10 -0
- package/dist/canvas/layout.js +17 -12
- package/dist/canvas/layout.js.map +4 -4
- package/dist/canvas/paint.d.ts +14 -0
- package/dist/canvas/paint.js +3 -2
- package/dist/canvas/paint.js.map +4 -4
- package/dist/canvas/renderer.d.ts +99 -0
- package/dist/canvas/renderer.js +19 -13
- package/dist/canvas/renderer.js.map +6 -6
- package/dist/canvas/text.d.ts +22 -0
- package/dist/canvas/text.js +2 -2
- package/dist/canvas/text.js.map +2 -2
- package/dist/canvas/types.d.ts +96 -0
- package/dist/canvas/utils.d.ts +44 -0
- package/dist/client.d.ts +19 -0
- package/dist/client.js +46 -21
- package/dist/client.js.map +12 -11
- package/dist/dom/applicators/advanced-layout.d.ts +5 -0
- package/dist/dom/applicators/advanced-layout.js +1 -114
- package/dist/dom/applicators/advanced-layout.js.map +4 -5
- package/dist/dom/applicators/background.d.ts +5 -0
- package/dist/dom/applicators/border.d.ts +5 -0
- package/dist/dom/applicators/color.d.ts +5 -0
- package/dist/dom/applicators/display.d.ts +5 -0
- package/dist/dom/applicators/effects.d.ts +5 -0
- package/dist/dom/applicators/events.d.ts +8 -0
- package/dist/dom/applicators/events.js +3 -2
- package/dist/dom/applicators/events.js.map +3 -3
- package/dist/dom/applicators/font.d.ts +29 -0
- package/dist/dom/applicators/index.d.ts +76 -0
- package/dist/dom/applicators/index.js +3 -8
- package/dist/dom/applicators/index.js.map +4 -4
- package/dist/dom/applicators/layout.d.ts +10 -0
- package/dist/dom/applicators/margin.d.ts +11 -0
- package/dist/dom/applicators/padding.d.ts +11 -0
- package/dist/dom/applicators/size.d.ts +14 -0
- package/dist/dom/applicators/transform.d.ts +5 -0
- package/dist/dom/applicators/transition.d.ts +5 -0
- package/dist/dom/applicators/types.d.ts +6 -0
- package/dist/dom/applicators/typography.d.ts +5 -0
- package/dist/dom/canvas/index.d.ts +12 -0
- package/dist/dom/components/app.d.ts +8 -0
- package/dist/dom/components/app.js +55 -0
- package/dist/dom/components/app.js.map +10 -0
- package/dist/dom/components/audio.d.ts +5 -0
- package/dist/dom/components/avatar.d.ts +5 -0
- package/dist/dom/components/badge.d.ts +5 -0
- package/dist/dom/components/button.d.ts +9 -0
- package/dist/dom/components/card.d.ts +5 -0
- package/dist/dom/components/center.d.ts +9 -0
- package/dist/dom/components/checkbox.d.ts +5 -0
- package/dist/dom/components/column.d.ts +8 -0
- package/dist/dom/components/container.d.ts +5 -0
- package/dist/dom/components/divider.d.ts +5 -0
- package/dist/dom/components/grid.d.ts +7 -0
- package/dist/dom/components/heading.d.ts +5 -0
- package/dist/dom/components/hypenapp.d.ts +19 -0
- package/dist/dom/components/hypenapp.js +2 -4
- package/dist/dom/components/hypenapp.js.map +3 -3
- package/dist/dom/components/image.d.ts +5 -0
- package/dist/dom/components/index.d.ts +29 -0
- package/dist/dom/components/index.js +29 -5
- package/dist/dom/components/index.js.map +7 -6
- package/dist/dom/components/input.d.ts +5 -0
- package/dist/dom/components/link.d.ts +5 -0
- package/dist/dom/components/list.d.ts +5 -0
- package/dist/dom/components/paragraph.d.ts +5 -0
- package/dist/dom/components/progressbar.d.ts +5 -0
- package/dist/dom/components/route.d.ts +6 -0
- package/dist/dom/components/route.js +2 -2
- package/dist/dom/components/route.js.map +2 -2
- package/dist/dom/components/router.d.ts +5 -0
- package/dist/dom/components/row.d.ts +7 -0
- package/dist/dom/components/select.d.ts +5 -0
- package/dist/dom/components/slider.d.ts +5 -0
- package/dist/dom/components/spacer.d.ts +5 -0
- package/dist/dom/components/spinner.d.ts +5 -0
- package/dist/dom/components/stack.d.ts +5 -0
- package/dist/dom/components/switch.d.ts +5 -0
- package/dist/dom/components/text.d.ts +5 -0
- package/dist/dom/components/textarea.d.ts +5 -0
- package/dist/dom/components/video.d.ts +5 -0
- package/dist/dom/debug.d.ts +63 -0
- package/dist/dom/debug.js +2 -2
- package/dist/dom/debug.js.map +2 -2
- package/dist/dom/element-data.d.ts +94 -0
- package/dist/dom/events.d.ts +39 -0
- package/dist/dom/events.js +2 -2
- package/dist/dom/events.js.map +2 -2
- package/dist/dom/index.d.ts +10 -0
- package/dist/dom/index.js +46 -21
- package/dist/dom/index.js.map +12 -11
- package/dist/dom/renderer.d.ts +115 -0
- package/dist/dom/renderer.js +45 -20
- package/dist/dom/renderer.js.map +11 -10
- package/dist/hypen.d.ts +140 -0
- package/dist/hypen.js +46 -21
- package/dist/hypen.js.map +12 -11
- package/dist/index.d.ts +28 -0
- package/dist/index.js +64 -33
- package/dist/index.js.map +16 -15
- package/package.json +3 -2
- package/src/dom/components/index.ts +2 -0
- package/src/dom/renderer.ts +18 -6
package/dist/hypen.d.ts
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hypen - High-Level API for Web Applications
|
|
3
|
+
*
|
|
4
|
+
* Simple API for rendering Hypen applications (like ReactDOM.render)
|
|
5
|
+
*/
|
|
6
|
+
import { HypenModuleInstance } from "@hypen-space/core/app";
|
|
7
|
+
import type { HypenModuleDefinition } from "@hypen-space/core/app";
|
|
8
|
+
import { HypenRouter } from "@hypen-space/core/router";
|
|
9
|
+
import { HypenGlobalContext } from "@hypen-space/core/context";
|
|
10
|
+
export interface HypenConfig {
|
|
11
|
+
/** Base directory for components (default: "./src/components") */
|
|
12
|
+
componentsDir?: string;
|
|
13
|
+
/** Enable debug logging */
|
|
14
|
+
debug?: boolean;
|
|
15
|
+
/** Custom WASM URL */
|
|
16
|
+
wasmUrl?: string;
|
|
17
|
+
/** Custom WASM JS glue URL */
|
|
18
|
+
jsUrl?: string;
|
|
19
|
+
/** Enable re-render heatmap debugging */
|
|
20
|
+
debugHeatmap?: boolean;
|
|
21
|
+
/** Heatmap increment per re-render (default: 5%) */
|
|
22
|
+
heatmapIncrement?: number;
|
|
23
|
+
/** Heatmap fade out duration in ms (default: 2000) */
|
|
24
|
+
heatmapFadeOut?: number;
|
|
25
|
+
}
|
|
26
|
+
export declare class Hypen {
|
|
27
|
+
private engine;
|
|
28
|
+
private renderer;
|
|
29
|
+
private moduleInstance;
|
|
30
|
+
private container;
|
|
31
|
+
private config;
|
|
32
|
+
private router;
|
|
33
|
+
private globalContext;
|
|
34
|
+
private moduleInstances;
|
|
35
|
+
constructor(config?: HypenConfig);
|
|
36
|
+
/**
|
|
37
|
+
* Initialize the Hypen runtime
|
|
38
|
+
* Must be called before render()
|
|
39
|
+
*/
|
|
40
|
+
init(): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Load all components from the components directory
|
|
43
|
+
*/
|
|
44
|
+
loadComponents(componentsDir?: string): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Render a component to a DOM container
|
|
47
|
+
*
|
|
48
|
+
* @param componentName - Name of the component to render (e.g., "HomePage")
|
|
49
|
+
* @param containerSelector - CSS selector or HTMLElement for the mount point
|
|
50
|
+
*/
|
|
51
|
+
render(componentName: string, containerSelector: string | HTMLElement): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Unmount and cleanup
|
|
54
|
+
*/
|
|
55
|
+
unmount(): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Get the current module instance
|
|
58
|
+
*/
|
|
59
|
+
getModuleInstance(): HypenModuleInstance<any> | null;
|
|
60
|
+
/**
|
|
61
|
+
* Get the current state
|
|
62
|
+
*/
|
|
63
|
+
getState(): any;
|
|
64
|
+
/**
|
|
65
|
+
* Get the router instance
|
|
66
|
+
*/
|
|
67
|
+
getRouter(): HypenRouter;
|
|
68
|
+
/**
|
|
69
|
+
* Get the global context
|
|
70
|
+
*/
|
|
71
|
+
getGlobalContext(): HypenGlobalContext;
|
|
72
|
+
/**
|
|
73
|
+
* Enable or disable debug heatmap mode
|
|
74
|
+
*/
|
|
75
|
+
setDebugHeatmap(enabled: boolean): void;
|
|
76
|
+
/**
|
|
77
|
+
* Reset debug tracking for all elements
|
|
78
|
+
*/
|
|
79
|
+
resetDebugTracking(): void;
|
|
80
|
+
/**
|
|
81
|
+
* Get debug statistics
|
|
82
|
+
*/
|
|
83
|
+
getDebugStats(): {
|
|
84
|
+
totalRerenders: number;
|
|
85
|
+
elementCount: number;
|
|
86
|
+
avgRerenders: number;
|
|
87
|
+
} | null;
|
|
88
|
+
/**
|
|
89
|
+
* Render a lazy route component into a specific route element
|
|
90
|
+
* This is called by the Router when a route becomes active
|
|
91
|
+
*/
|
|
92
|
+
renderLazyRoute(routePath: string, componentName: string, routeElement: HTMLElement): Promise<void>;
|
|
93
|
+
/**
|
|
94
|
+
* Extract module ID from component name or .id() applicator
|
|
95
|
+
*/
|
|
96
|
+
private extractModuleId;
|
|
97
|
+
/**
|
|
98
|
+
* Create module instances for all components that have state
|
|
99
|
+
*/
|
|
100
|
+
private createNestedModuleInstances;
|
|
101
|
+
/**
|
|
102
|
+
* Get merged state from all module instances
|
|
103
|
+
*/
|
|
104
|
+
private getMergedState;
|
|
105
|
+
/**
|
|
106
|
+
* Set up component resolver for the engine
|
|
107
|
+
*/
|
|
108
|
+
private setupComponentResolver;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Quick render function (like ReactDOM.render)
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```typescript
|
|
115
|
+
* import { render } from "@hypen-space/web/client";
|
|
116
|
+
*
|
|
117
|
+
* await render("HomePage", "#app");
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
export declare function render(componentName: string, containerSelector: string | HTMLElement, config?: HypenConfig): Promise<Hypen>;
|
|
121
|
+
/**
|
|
122
|
+
* Render with explicit component loading
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```typescript
|
|
126
|
+
* import { renderWithComponents } from "@hypen-space/web/client";
|
|
127
|
+
* import HomePage from "./components/HomePage/component";
|
|
128
|
+
* import homePageTemplate from "./components/HomePage/component.hypen";
|
|
129
|
+
*
|
|
130
|
+
* await renderWithComponents(
|
|
131
|
+
* { HomePage: { module: HomePage, template: homePageTemplate } },
|
|
132
|
+
* "HomePage",
|
|
133
|
+
* "#app"
|
|
134
|
+
* );
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
export declare function renderWithComponents(components: Record<string, {
|
|
138
|
+
module: HypenModuleDefinition;
|
|
139
|
+
template: string;
|
|
140
|
+
}>, componentName: string, containerSelector: string | HTMLElement, config?: HypenConfig): Promise<Hypen>;
|
package/dist/hypen.js
CHANGED
|
@@ -1011,7 +1011,7 @@ var exports_route = {};
|
|
|
1011
1011
|
__export(exports_route, {
|
|
1012
1012
|
routeHandler: () => routeHandler
|
|
1013
1013
|
});
|
|
1014
|
-
import { frameworkLoggers } from "@hypen-space/core";
|
|
1014
|
+
import { frameworkLoggers } from "@hypen-space/core/logger";
|
|
1015
1015
|
var log, routeHandler;
|
|
1016
1016
|
var init_route = __esm(() => {
|
|
1017
1017
|
log = frameworkLoggers.router;
|
|
@@ -1046,7 +1046,7 @@ __export(exports_hypenapp, {
|
|
|
1046
1046
|
disconnectHypenApp: () => disconnectHypenApp
|
|
1047
1047
|
});
|
|
1048
1048
|
import { RemoteEngine } from "@hypen-space/core/remote/client";
|
|
1049
|
-
import { frameworkLoggers as frameworkLoggers2 } from "@hypen-space/core";
|
|
1049
|
+
import { frameworkLoggers as frameworkLoggers2 } from "@hypen-space/core/logger";
|
|
1050
1050
|
function applyPatches(container, nodes, patches, engine, onRoot) {
|
|
1051
1051
|
for (const patch of patches) {
|
|
1052
1052
|
switch (patch.type) {
|
|
@@ -1202,8 +1202,6 @@ function applyProp(el, name, value) {
|
|
|
1202
1202
|
border: "border",
|
|
1203
1203
|
gap: "gap",
|
|
1204
1204
|
flex: "flex",
|
|
1205
|
-
alignItems: "alignItems",
|
|
1206
|
-
justifyContent: "justifyContent",
|
|
1207
1205
|
opacity: "opacity",
|
|
1208
1206
|
overflow: "overflow"
|
|
1209
1207
|
};
|
|
@@ -1301,6 +1299,26 @@ var init_hypenapp = __esm(() => {
|
|
|
1301
1299
|
};
|
|
1302
1300
|
});
|
|
1303
1301
|
|
|
1302
|
+
// src/dom/components/app.ts
|
|
1303
|
+
var exports_app = {};
|
|
1304
|
+
__export(exports_app, {
|
|
1305
|
+
appHandler: () => appHandler
|
|
1306
|
+
});
|
|
1307
|
+
var appHandler;
|
|
1308
|
+
var init_app = __esm(() => {
|
|
1309
|
+
appHandler = {
|
|
1310
|
+
create() {
|
|
1311
|
+
const el = document.createElement("div");
|
|
1312
|
+
el.style.display = "flex";
|
|
1313
|
+
el.style.flexDirection = "column";
|
|
1314
|
+
el.style.minHeight = "100vh";
|
|
1315
|
+
el.style.width = "100%";
|
|
1316
|
+
el.dataset.hypenType = "app";
|
|
1317
|
+
return el;
|
|
1318
|
+
}
|
|
1319
|
+
};
|
|
1320
|
+
});
|
|
1321
|
+
|
|
1304
1322
|
// src/dom/components/index.ts
|
|
1305
1323
|
class ComponentRegistry {
|
|
1306
1324
|
handlers = new Map;
|
|
@@ -1311,9 +1329,13 @@ class ComponentRegistry {
|
|
|
1311
1329
|
this.handlers.set(type.toLowerCase(), handler);
|
|
1312
1330
|
}
|
|
1313
1331
|
get(type) {
|
|
1332
|
+
if (!type)
|
|
1333
|
+
return;
|
|
1314
1334
|
return this.handlers.get(type.toLowerCase());
|
|
1315
1335
|
}
|
|
1316
1336
|
createElement(type, props = {}) {
|
|
1337
|
+
if (!type)
|
|
1338
|
+
return null;
|
|
1317
1339
|
const handler = this.get(type);
|
|
1318
1340
|
if (!handler)
|
|
1319
1341
|
return null;
|
|
@@ -1355,6 +1377,8 @@ class ComponentRegistry {
|
|
|
1355
1377
|
const { routerHandler: routerHandler2 } = (init_router(), __toCommonJS(exports_router));
|
|
1356
1378
|
const { routeHandler: routeHandler2 } = (init_route(), __toCommonJS(exports_route));
|
|
1357
1379
|
const { hypenAppHandler: hypenAppHandler2 } = (init_hypenapp(), __toCommonJS(exports_hypenapp));
|
|
1380
|
+
const { appHandler: appHandler2 } = (init_app(), __toCommonJS(exports_app));
|
|
1381
|
+
this.register("app", appHandler2);
|
|
1358
1382
|
this.register("column", columnHandler2);
|
|
1359
1383
|
this.register("row", rowHandler2);
|
|
1360
1384
|
this.register("text", textHandler2);
|
|
@@ -2038,7 +2062,7 @@ import {
|
|
|
2038
2062
|
disposableListener,
|
|
2039
2063
|
disposableTimeout
|
|
2040
2064
|
} from "@hypen-space/core/disposable";
|
|
2041
|
-
import { frameworkLoggers as frameworkLoggers3 } from "@hypen-space/core";
|
|
2065
|
+
import { frameworkLoggers as frameworkLoggers3 } from "@hypen-space/core/logger";
|
|
2042
2066
|
var log3 = frameworkLoggers3.events;
|
|
2043
2067
|
function toPlainObject(value) {
|
|
2044
2068
|
if (value instanceof Map) {
|
|
@@ -2323,6 +2347,7 @@ var eventHandlers = {
|
|
|
2323
2347
|
extractPayload: scrollPayload
|
|
2324
2348
|
}),
|
|
2325
2349
|
onLongClick: createLongClickHandler(500),
|
|
2350
|
+
onLongPress: createLongClickHandler(500),
|
|
2326
2351
|
onFocus: createEventHandler("focus", { extractPayload: focusPayload }),
|
|
2327
2352
|
onBlur: createEventHandler("blur", { extractPayload: focusPayload }),
|
|
2328
2353
|
onMouseEnter: createEventHandler("mouseenter", { extractPayload: mousePayload }),
|
|
@@ -2584,12 +2609,6 @@ var advancedLayoutHandlers = {
|
|
|
2584
2609
|
flexBasis: (el, value) => {
|
|
2585
2610
|
el.style.flexBasis = typeof value === "number" ? `${value}px` : String(value);
|
|
2586
2611
|
},
|
|
2587
|
-
justifyContent: (el, value) => {
|
|
2588
|
-
el.style.justifyContent = mapAlignmentValue(String(value));
|
|
2589
|
-
},
|
|
2590
|
-
alignItems: (el, value) => {
|
|
2591
|
-
el.style.alignItems = mapAlignmentValue(String(value));
|
|
2592
|
-
},
|
|
2593
2612
|
alignContent: (el, value) => {
|
|
2594
2613
|
el.style.alignContent = String(value);
|
|
2595
2614
|
},
|
|
@@ -3127,7 +3146,7 @@ var canvasApplicators = {
|
|
|
3127
3146
|
};
|
|
3128
3147
|
|
|
3129
3148
|
// src/dom/debug.ts
|
|
3130
|
-
import { frameworkLoggers as frameworkLoggers4 } from "@hypen-space/core";
|
|
3149
|
+
import { frameworkLoggers as frameworkLoggers4 } from "@hypen-space/core/logger";
|
|
3131
3150
|
var log4 = frameworkLoggers4.debug;
|
|
3132
3151
|
var defaultDebugConfig = {
|
|
3133
3152
|
enabled: false,
|
|
@@ -3290,7 +3309,7 @@ class RerenderTracker {
|
|
|
3290
3309
|
}
|
|
3291
3310
|
|
|
3292
3311
|
// src/dom/renderer.ts
|
|
3293
|
-
import { frameworkLoggers as frameworkLoggers5 } from "@hypen-space/core";
|
|
3312
|
+
import { frameworkLoggers as frameworkLoggers5 } from "@hypen-space/core/logger";
|
|
3294
3313
|
var log5 = frameworkLoggers5.renderer;
|
|
3295
3314
|
|
|
3296
3315
|
class DOMRenderer {
|
|
@@ -3363,24 +3382,30 @@ class DOMRenderer {
|
|
|
3363
3382
|
});
|
|
3364
3383
|
}
|
|
3365
3384
|
applyPatch(patch) {
|
|
3385
|
+
const p = patch;
|
|
3386
|
+
const id = patch.id ?? p.id;
|
|
3387
|
+
const elementType = patch.elementType ?? p.element_type;
|
|
3388
|
+
const parentId = patch.parentId ?? p.parent_id;
|
|
3389
|
+
const beforeId = patch.beforeId ?? p.before_id;
|
|
3390
|
+
const eventName = patch.eventName ?? p.event_name;
|
|
3366
3391
|
switch (patch.type) {
|
|
3367
3392
|
case "create":
|
|
3368
|
-
this.onCreate(
|
|
3393
|
+
this.onCreate(id, elementType ?? "container", patch.props || {});
|
|
3369
3394
|
break;
|
|
3370
3395
|
case "setProp":
|
|
3371
|
-
this.onSetProp(
|
|
3396
|
+
this.onSetProp(id, patch.name, patch.value);
|
|
3372
3397
|
break;
|
|
3373
3398
|
case "setText":
|
|
3374
|
-
this.onSetText(
|
|
3399
|
+
this.onSetText(id, patch.text);
|
|
3375
3400
|
break;
|
|
3376
3401
|
case "insert":
|
|
3377
|
-
this.onInsert(
|
|
3402
|
+
this.onInsert(parentId, id, beforeId);
|
|
3378
3403
|
break;
|
|
3379
3404
|
case "move":
|
|
3380
|
-
this.onMove(
|
|
3405
|
+
this.onMove(parentId, id, beforeId);
|
|
3381
3406
|
break;
|
|
3382
3407
|
case "remove":
|
|
3383
|
-
this.onRemove(
|
|
3408
|
+
this.onRemove(id);
|
|
3384
3409
|
break;
|
|
3385
3410
|
}
|
|
3386
3411
|
}
|
|
@@ -3517,7 +3542,7 @@ import { HypenRouter } from "@hypen-space/core/router";
|
|
|
3517
3542
|
import { HypenGlobalContext } from "@hypen-space/core/context";
|
|
3518
3543
|
import { componentLoader } from "@hypen-space/core/loader";
|
|
3519
3544
|
import { Router, Route, Link } from "@hypen-space/core/components";
|
|
3520
|
-
import { frameworkLoggers as frameworkLoggers6, setDebugMode } from "@hypen-space/core";
|
|
3545
|
+
import { frameworkLoggers as frameworkLoggers6, setDebugMode } from "@hypen-space/core/logger";
|
|
3521
3546
|
var log6 = frameworkLoggers6.hypen;
|
|
3522
3547
|
|
|
3523
3548
|
class Hypen {
|
|
@@ -3816,4 +3841,4 @@ export {
|
|
|
3816
3841
|
Hypen
|
|
3817
3842
|
};
|
|
3818
3843
|
|
|
3819
|
-
//# debugId=
|
|
3844
|
+
//# debugId=79019BA840D0560F64756E2164756E21
|