ziex 0.1.0-dev.598 → 0.1.0-dev.618

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