ziex 0.1.0-dev.593 → 0.1.0-dev.606
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/README.md +5 -5
- package/index.js +1 -1
- package/package.json +1 -1
- package/wasm/index.d.ts +5 -0
- package/wasm/index.js +220 -0
- package/wasm/init.js +204 -0
package/README.md
CHANGED
|
@@ -81,11 +81,10 @@ const zx = @import("zx");
|
|
|
81
81
|
## Feature Checklist
|
|
82
82
|
|
|
83
83
|
- [x] Server Side Rendering (SSR)
|
|
84
|
-
- [ ] `on`event handler
|
|
85
84
|
- [x] Streaming
|
|
86
85
|
- [x] Static Site Generation (SSG)
|
|
87
|
-
- [
|
|
88
|
-
- [ ] Client Side Rendering (CSR) via WebAssembly (
|
|
86
|
+
- [x] `options.static.params`, `options.static.getParams`
|
|
87
|
+
- [ ] Client Side Rendering (CSR) via WebAssembly (_Alpha_)
|
|
89
88
|
- [x] Virtual DOM and diffing
|
|
90
89
|
- [x] Rendering only changed nodes
|
|
91
90
|
- [x] `on`event handler
|
|
@@ -128,7 +127,7 @@ const zx = @import("zx");
|
|
|
128
127
|
- [x] Builtin TailwindCSS and Esbuild
|
|
129
128
|
- [x] Command based plugin system
|
|
130
129
|
- [ ] Source based plugin system
|
|
131
|
-
- [
|
|
130
|
+
- [x] Context (configurable)
|
|
132
131
|
- [x] App
|
|
133
132
|
- [x] Layout
|
|
134
133
|
- [x] Page
|
|
@@ -149,6 +148,7 @@ const zx = @import("zx");
|
|
|
149
148
|
- [ ] Platform
|
|
150
149
|
- [x] Server
|
|
151
150
|
- [x] Browser
|
|
151
|
+
- [ ] Edge Runtime (Cloudflare Workers, Vercel Function, etc)
|
|
152
152
|
- [ ] iOS
|
|
153
153
|
- [ ] Android
|
|
154
154
|
- [ ] macOS
|
|
@@ -191,10 +191,10 @@ const zx = @import("zx");
|
|
|
191
191
|
## Related Projects
|
|
192
192
|
|
|
193
193
|
* [Codeberg Mirror](https://codeberg.org/nurulhudaapon/zx) - ZX repository mirror on Codeberg
|
|
194
|
-
* [zx-vscode](https://github.com/nurulhudaapon/zx-vscode) - Official VSCode/Cursor extension with syntax highlighting, LSP support, and auto-formatting
|
|
195
194
|
* [ziex.dev](https://github.com/nurulhudaapon/zx/tree/main/site) - Official documentation site of ZX made using ZX.
|
|
196
195
|
* [zx-example-portfolio](https://github.com/nurulhudaapon/zx-example-portfolio) - Demo portfolio web application built with ZX
|
|
197
196
|
* [thegates.dev](https://github.com/nurulhudaapon/thegates.dev) - Example clone demonstrating ZX capabilities
|
|
197
|
+
* [zx-numbers-game](https://github.com/Andrew-Velox/zx-numbers-game) - ZX numbers game
|
|
198
198
|
|
|
199
199
|
## Contributing
|
|
200
200
|
|
package/index.js
CHANGED
package/package.json
CHANGED
package/wasm/index.d.ts
CHANGED
|
@@ -61,6 +61,11 @@ export declare function init(options?: InitOptions): Promise<{
|
|
|
61
61
|
source: WebAssembly.WebAssemblyInstantiatedSource;
|
|
62
62
|
bridge: ZxBridge;
|
|
63
63
|
}>;
|
|
64
|
+
/** Initialize WASM with the ZX Bridge */
|
|
65
|
+
export declare function edge(options?: InitOptions): Promise<{
|
|
66
|
+
source: WebAssembly.WebAssemblyInstantiatedSource;
|
|
67
|
+
bridge: ZxBridge;
|
|
68
|
+
}>;
|
|
64
69
|
declare global {
|
|
65
70
|
interface HTMLElement {
|
|
66
71
|
__zx_ref?: number;
|
package/wasm/index.js
CHANGED
|
@@ -435,11 +435,215 @@ class ZxBridge {
|
|
|
435
435
|
},
|
|
436
436
|
_wsClose: (wsId, code, reasonPtr, reasonLen) => {
|
|
437
437
|
bridgeRef.current?.wsClose(wsId, code, reasonPtr, reasonLen);
|
|
438
|
+
},
|
|
439
|
+
_ce: (id) => {
|
|
440
|
+
const el = document.createElement(TAG_NAMES[id]);
|
|
441
|
+
return storeValueGetRef(el);
|
|
438
442
|
}
|
|
439
443
|
}
|
|
440
444
|
};
|
|
441
445
|
}
|
|
442
446
|
}
|
|
447
|
+
var TAG_NAMES = [
|
|
448
|
+
"aside",
|
|
449
|
+
"fragment",
|
|
450
|
+
"iframe",
|
|
451
|
+
"slot",
|
|
452
|
+
"img",
|
|
453
|
+
"html",
|
|
454
|
+
"base",
|
|
455
|
+
"head",
|
|
456
|
+
"link",
|
|
457
|
+
"meta",
|
|
458
|
+
"script",
|
|
459
|
+
"style",
|
|
460
|
+
"title",
|
|
461
|
+
"address",
|
|
462
|
+
"article",
|
|
463
|
+
"body",
|
|
464
|
+
"h1",
|
|
465
|
+
"h6",
|
|
466
|
+
"footer",
|
|
467
|
+
"header",
|
|
468
|
+
"h2",
|
|
469
|
+
"h3",
|
|
470
|
+
"h4",
|
|
471
|
+
"h5",
|
|
472
|
+
"hgroup",
|
|
473
|
+
"nav",
|
|
474
|
+
"section",
|
|
475
|
+
"dd",
|
|
476
|
+
"dl",
|
|
477
|
+
"dt",
|
|
478
|
+
"div",
|
|
479
|
+
"figcaption",
|
|
480
|
+
"figure",
|
|
481
|
+
"hr",
|
|
482
|
+
"li",
|
|
483
|
+
"ol",
|
|
484
|
+
"ul",
|
|
485
|
+
"menu",
|
|
486
|
+
"main",
|
|
487
|
+
"p",
|
|
488
|
+
"pre",
|
|
489
|
+
"a",
|
|
490
|
+
"abbr",
|
|
491
|
+
"b",
|
|
492
|
+
"bdi",
|
|
493
|
+
"bdo",
|
|
494
|
+
"br",
|
|
495
|
+
"cite",
|
|
496
|
+
"code",
|
|
497
|
+
"data",
|
|
498
|
+
"time",
|
|
499
|
+
"dfn",
|
|
500
|
+
"em",
|
|
501
|
+
"i",
|
|
502
|
+
"kbd",
|
|
503
|
+
"mark",
|
|
504
|
+
"q",
|
|
505
|
+
"blockquote",
|
|
506
|
+
"rp",
|
|
507
|
+
"ruby",
|
|
508
|
+
"rt",
|
|
509
|
+
"rtc",
|
|
510
|
+
"rb",
|
|
511
|
+
"s",
|
|
512
|
+
"del",
|
|
513
|
+
"ins",
|
|
514
|
+
"samp",
|
|
515
|
+
"small",
|
|
516
|
+
"span",
|
|
517
|
+
"strong",
|
|
518
|
+
"sub",
|
|
519
|
+
"sup",
|
|
520
|
+
"u",
|
|
521
|
+
"var",
|
|
522
|
+
"wbr",
|
|
523
|
+
"area",
|
|
524
|
+
"map",
|
|
525
|
+
"audio",
|
|
526
|
+
"source",
|
|
527
|
+
"track",
|
|
528
|
+
"video",
|
|
529
|
+
"embed",
|
|
530
|
+
"object",
|
|
531
|
+
"param",
|
|
532
|
+
"canvas",
|
|
533
|
+
"noscript",
|
|
534
|
+
"caption",
|
|
535
|
+
"table",
|
|
536
|
+
"col",
|
|
537
|
+
"colgroup",
|
|
538
|
+
"tbody",
|
|
539
|
+
"tr",
|
|
540
|
+
"thead",
|
|
541
|
+
"tfoot",
|
|
542
|
+
"td",
|
|
543
|
+
"th",
|
|
544
|
+
"button",
|
|
545
|
+
"datalist",
|
|
546
|
+
"option",
|
|
547
|
+
"fieldset",
|
|
548
|
+
"label",
|
|
549
|
+
"form",
|
|
550
|
+
"input",
|
|
551
|
+
"keygen",
|
|
552
|
+
"legend",
|
|
553
|
+
"meter",
|
|
554
|
+
"optgroup",
|
|
555
|
+
"select",
|
|
556
|
+
"output",
|
|
557
|
+
"progress",
|
|
558
|
+
"textarea",
|
|
559
|
+
"details",
|
|
560
|
+
"dialog",
|
|
561
|
+
"menuitem",
|
|
562
|
+
"summary",
|
|
563
|
+
"content",
|
|
564
|
+
"element",
|
|
565
|
+
"shadow",
|
|
566
|
+
"template",
|
|
567
|
+
"acronym",
|
|
568
|
+
"applet",
|
|
569
|
+
"basefont",
|
|
570
|
+
"font",
|
|
571
|
+
"big",
|
|
572
|
+
"blink",
|
|
573
|
+
"center",
|
|
574
|
+
"command",
|
|
575
|
+
"dir",
|
|
576
|
+
"frame",
|
|
577
|
+
"frameset",
|
|
578
|
+
"isindex",
|
|
579
|
+
"listing",
|
|
580
|
+
"marquee",
|
|
581
|
+
"noembed",
|
|
582
|
+
"plaintext",
|
|
583
|
+
"spacer",
|
|
584
|
+
"strike",
|
|
585
|
+
"tt",
|
|
586
|
+
"xmp",
|
|
587
|
+
"animate",
|
|
588
|
+
"animateMotion",
|
|
589
|
+
"animateTransform",
|
|
590
|
+
"circle",
|
|
591
|
+
"clipPath",
|
|
592
|
+
"defs",
|
|
593
|
+
"desc",
|
|
594
|
+
"ellipse",
|
|
595
|
+
"feBlend",
|
|
596
|
+
"feColorMatrix",
|
|
597
|
+
"feComponentTransfer",
|
|
598
|
+
"feComposite",
|
|
599
|
+
"feConvolveMatrix",
|
|
600
|
+
"feDiffuseLighting",
|
|
601
|
+
"feDisplacementMap",
|
|
602
|
+
"feDistantLight",
|
|
603
|
+
"feDropShadow",
|
|
604
|
+
"feFlood",
|
|
605
|
+
"feFuncA",
|
|
606
|
+
"feFuncB",
|
|
607
|
+
"feFuncG",
|
|
608
|
+
"feFuncR",
|
|
609
|
+
"feGaussianBlur",
|
|
610
|
+
"feImage",
|
|
611
|
+
"feMerge",
|
|
612
|
+
"feMergeNode",
|
|
613
|
+
"feMorphology",
|
|
614
|
+
"feOffset",
|
|
615
|
+
"fePointLight",
|
|
616
|
+
"feSpecularLighting",
|
|
617
|
+
"feSpotLight",
|
|
618
|
+
"feTile",
|
|
619
|
+
"feTurbulence",
|
|
620
|
+
"filter",
|
|
621
|
+
"foreignObject",
|
|
622
|
+
"g",
|
|
623
|
+
"image",
|
|
624
|
+
"line",
|
|
625
|
+
"linearGradient",
|
|
626
|
+
"marker",
|
|
627
|
+
"mask",
|
|
628
|
+
"metadata",
|
|
629
|
+
"mpath",
|
|
630
|
+
"path",
|
|
631
|
+
"pattern",
|
|
632
|
+
"polygon",
|
|
633
|
+
"polyline",
|
|
634
|
+
"radialGradient",
|
|
635
|
+
"rect",
|
|
636
|
+
"set",
|
|
637
|
+
"stop",
|
|
638
|
+
"svg",
|
|
639
|
+
"switch",
|
|
640
|
+
"symbol",
|
|
641
|
+
"text",
|
|
642
|
+
"textPath",
|
|
643
|
+
"tspan",
|
|
644
|
+
"use",
|
|
645
|
+
"view"
|
|
646
|
+
];
|
|
443
647
|
var DELEGATED_EVENTS = [
|
|
444
648
|
"click",
|
|
445
649
|
"dblclick",
|
|
@@ -516,11 +720,27 @@ async function init(options = {}) {
|
|
|
516
720
|
main();
|
|
517
721
|
return { source, bridge };
|
|
518
722
|
}
|
|
723
|
+
async function edge(options = {}) {
|
|
724
|
+
const url = options.url ?? DEFAULT_URL;
|
|
725
|
+
const bridgeRef = { current: null };
|
|
726
|
+
const importObject = Object.assign({}, ZxBridge.createImportObject(bridgeRef), options.importObject);
|
|
727
|
+
const source = await WebAssembly.instantiateStreaming(fetch(url), importObject);
|
|
728
|
+
const { instance } = source;
|
|
729
|
+
jsz.memory = instance.exports.memory;
|
|
730
|
+
const bridge = new ZxBridge(instance.exports);
|
|
731
|
+
bridgeRef.current = bridge;
|
|
732
|
+
initEventDelegation(bridge, options.eventDelegationRoot ?? "body");
|
|
733
|
+
const main = instance.exports.main;
|
|
734
|
+
if (typeof main === "function")
|
|
735
|
+
main();
|
|
736
|
+
return { source, bridge };
|
|
737
|
+
}
|
|
519
738
|
export {
|
|
520
739
|
storeValueGetRef,
|
|
521
740
|
jsz,
|
|
522
741
|
initEventDelegation,
|
|
523
742
|
init,
|
|
743
|
+
edge,
|
|
524
744
|
ZxBridge,
|
|
525
745
|
CallbackType
|
|
526
746
|
};
|
package/wasm/init.js
CHANGED
|
@@ -435,11 +435,215 @@ class ZxBridge {
|
|
|
435
435
|
},
|
|
436
436
|
_wsClose: (wsId, code, reasonPtr, reasonLen) => {
|
|
437
437
|
bridgeRef.current?.wsClose(wsId, code, reasonPtr, reasonLen);
|
|
438
|
+
},
|
|
439
|
+
_ce: (id) => {
|
|
440
|
+
const el = document.createElement(TAG_NAMES[id]);
|
|
441
|
+
return storeValueGetRef(el);
|
|
438
442
|
}
|
|
439
443
|
}
|
|
440
444
|
};
|
|
441
445
|
}
|
|
442
446
|
}
|
|
447
|
+
var TAG_NAMES = [
|
|
448
|
+
"aside",
|
|
449
|
+
"fragment",
|
|
450
|
+
"iframe",
|
|
451
|
+
"slot",
|
|
452
|
+
"img",
|
|
453
|
+
"html",
|
|
454
|
+
"base",
|
|
455
|
+
"head",
|
|
456
|
+
"link",
|
|
457
|
+
"meta",
|
|
458
|
+
"script",
|
|
459
|
+
"style",
|
|
460
|
+
"title",
|
|
461
|
+
"address",
|
|
462
|
+
"article",
|
|
463
|
+
"body",
|
|
464
|
+
"h1",
|
|
465
|
+
"h6",
|
|
466
|
+
"footer",
|
|
467
|
+
"header",
|
|
468
|
+
"h2",
|
|
469
|
+
"h3",
|
|
470
|
+
"h4",
|
|
471
|
+
"h5",
|
|
472
|
+
"hgroup",
|
|
473
|
+
"nav",
|
|
474
|
+
"section",
|
|
475
|
+
"dd",
|
|
476
|
+
"dl",
|
|
477
|
+
"dt",
|
|
478
|
+
"div",
|
|
479
|
+
"figcaption",
|
|
480
|
+
"figure",
|
|
481
|
+
"hr",
|
|
482
|
+
"li",
|
|
483
|
+
"ol",
|
|
484
|
+
"ul",
|
|
485
|
+
"menu",
|
|
486
|
+
"main",
|
|
487
|
+
"p",
|
|
488
|
+
"pre",
|
|
489
|
+
"a",
|
|
490
|
+
"abbr",
|
|
491
|
+
"b",
|
|
492
|
+
"bdi",
|
|
493
|
+
"bdo",
|
|
494
|
+
"br",
|
|
495
|
+
"cite",
|
|
496
|
+
"code",
|
|
497
|
+
"data",
|
|
498
|
+
"time",
|
|
499
|
+
"dfn",
|
|
500
|
+
"em",
|
|
501
|
+
"i",
|
|
502
|
+
"kbd",
|
|
503
|
+
"mark",
|
|
504
|
+
"q",
|
|
505
|
+
"blockquote",
|
|
506
|
+
"rp",
|
|
507
|
+
"ruby",
|
|
508
|
+
"rt",
|
|
509
|
+
"rtc",
|
|
510
|
+
"rb",
|
|
511
|
+
"s",
|
|
512
|
+
"del",
|
|
513
|
+
"ins",
|
|
514
|
+
"samp",
|
|
515
|
+
"small",
|
|
516
|
+
"span",
|
|
517
|
+
"strong",
|
|
518
|
+
"sub",
|
|
519
|
+
"sup",
|
|
520
|
+
"u",
|
|
521
|
+
"var",
|
|
522
|
+
"wbr",
|
|
523
|
+
"area",
|
|
524
|
+
"map",
|
|
525
|
+
"audio",
|
|
526
|
+
"source",
|
|
527
|
+
"track",
|
|
528
|
+
"video",
|
|
529
|
+
"embed",
|
|
530
|
+
"object",
|
|
531
|
+
"param",
|
|
532
|
+
"canvas",
|
|
533
|
+
"noscript",
|
|
534
|
+
"caption",
|
|
535
|
+
"table",
|
|
536
|
+
"col",
|
|
537
|
+
"colgroup",
|
|
538
|
+
"tbody",
|
|
539
|
+
"tr",
|
|
540
|
+
"thead",
|
|
541
|
+
"tfoot",
|
|
542
|
+
"td",
|
|
543
|
+
"th",
|
|
544
|
+
"button",
|
|
545
|
+
"datalist",
|
|
546
|
+
"option",
|
|
547
|
+
"fieldset",
|
|
548
|
+
"label",
|
|
549
|
+
"form",
|
|
550
|
+
"input",
|
|
551
|
+
"keygen",
|
|
552
|
+
"legend",
|
|
553
|
+
"meter",
|
|
554
|
+
"optgroup",
|
|
555
|
+
"select",
|
|
556
|
+
"output",
|
|
557
|
+
"progress",
|
|
558
|
+
"textarea",
|
|
559
|
+
"details",
|
|
560
|
+
"dialog",
|
|
561
|
+
"menuitem",
|
|
562
|
+
"summary",
|
|
563
|
+
"content",
|
|
564
|
+
"element",
|
|
565
|
+
"shadow",
|
|
566
|
+
"template",
|
|
567
|
+
"acronym",
|
|
568
|
+
"applet",
|
|
569
|
+
"basefont",
|
|
570
|
+
"font",
|
|
571
|
+
"big",
|
|
572
|
+
"blink",
|
|
573
|
+
"center",
|
|
574
|
+
"command",
|
|
575
|
+
"dir",
|
|
576
|
+
"frame",
|
|
577
|
+
"frameset",
|
|
578
|
+
"isindex",
|
|
579
|
+
"listing",
|
|
580
|
+
"marquee",
|
|
581
|
+
"noembed",
|
|
582
|
+
"plaintext",
|
|
583
|
+
"spacer",
|
|
584
|
+
"strike",
|
|
585
|
+
"tt",
|
|
586
|
+
"xmp",
|
|
587
|
+
"animate",
|
|
588
|
+
"animateMotion",
|
|
589
|
+
"animateTransform",
|
|
590
|
+
"circle",
|
|
591
|
+
"clipPath",
|
|
592
|
+
"defs",
|
|
593
|
+
"desc",
|
|
594
|
+
"ellipse",
|
|
595
|
+
"feBlend",
|
|
596
|
+
"feColorMatrix",
|
|
597
|
+
"feComponentTransfer",
|
|
598
|
+
"feComposite",
|
|
599
|
+
"feConvolveMatrix",
|
|
600
|
+
"feDiffuseLighting",
|
|
601
|
+
"feDisplacementMap",
|
|
602
|
+
"feDistantLight",
|
|
603
|
+
"feDropShadow",
|
|
604
|
+
"feFlood",
|
|
605
|
+
"feFuncA",
|
|
606
|
+
"feFuncB",
|
|
607
|
+
"feFuncG",
|
|
608
|
+
"feFuncR",
|
|
609
|
+
"feGaussianBlur",
|
|
610
|
+
"feImage",
|
|
611
|
+
"feMerge",
|
|
612
|
+
"feMergeNode",
|
|
613
|
+
"feMorphology",
|
|
614
|
+
"feOffset",
|
|
615
|
+
"fePointLight",
|
|
616
|
+
"feSpecularLighting",
|
|
617
|
+
"feSpotLight",
|
|
618
|
+
"feTile",
|
|
619
|
+
"feTurbulence",
|
|
620
|
+
"filter",
|
|
621
|
+
"foreignObject",
|
|
622
|
+
"g",
|
|
623
|
+
"image",
|
|
624
|
+
"line",
|
|
625
|
+
"linearGradient",
|
|
626
|
+
"marker",
|
|
627
|
+
"mask",
|
|
628
|
+
"metadata",
|
|
629
|
+
"mpath",
|
|
630
|
+
"path",
|
|
631
|
+
"pattern",
|
|
632
|
+
"polygon",
|
|
633
|
+
"polyline",
|
|
634
|
+
"radialGradient",
|
|
635
|
+
"rect",
|
|
636
|
+
"set",
|
|
637
|
+
"stop",
|
|
638
|
+
"svg",
|
|
639
|
+
"switch",
|
|
640
|
+
"symbol",
|
|
641
|
+
"text",
|
|
642
|
+
"textPath",
|
|
643
|
+
"tspan",
|
|
644
|
+
"use",
|
|
645
|
+
"view"
|
|
646
|
+
];
|
|
443
647
|
var DELEGATED_EVENTS = [
|
|
444
648
|
"click",
|
|
445
649
|
"dblclick",
|