ziex 0.1.0-dev.852 → 0.1.0-dev.865

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/react/index.js DELETED
@@ -1,144 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __export = (target, all) => {
3
- for (var name in all)
4
- __defProp(target, name, {
5
- get: all[name],
6
- enumerable: true,
7
- configurable: true,
8
- set: (newValue) => all[name] = () => newValue
9
- });
10
- };
11
-
12
- // src/react/dom.ts
13
- function findCommentMarker(id) {
14
- const startPrefix = `$${id} `;
15
- const endMarker = `/$${id}`;
16
- const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_COMMENT, null);
17
- let startComment = null;
18
- let endComment = null;
19
- let name = "";
20
- let props = {};
21
- let node;
22
- while (node = walker.nextNode()) {
23
- const text = node.textContent?.trim() || "";
24
- if (text.startsWith(startPrefix)) {
25
- startComment = node;
26
- const content = text.slice(startPrefix.length);
27
- const jsonStart = content.indexOf("{");
28
- if (jsonStart !== -1) {
29
- name = content.slice(0, jsonStart).trim();
30
- const jsonStr = content.slice(jsonStart);
31
- try {
32
- props = JSON.parse(jsonStr);
33
- } catch {}
34
- } else {
35
- name = content.trim();
36
- }
37
- }
38
- if (text === endMarker) {
39
- endComment = node;
40
- break;
41
- }
42
- }
43
- if (startComment && endComment) {
44
- return { startComment, endComment, name, props };
45
- }
46
- return null;
47
- }
48
- function createContainerBetweenMarkers(startComment, endComment) {
49
- const container = document.createElement("div");
50
- container.style.display = "contents";
51
- let current = startComment.nextSibling;
52
- while (current && current !== endComment) {
53
- const next = current.nextSibling;
54
- container.appendChild(current);
55
- current = next;
56
- }
57
- endComment.parentNode?.insertBefore(container, endComment);
58
- return container;
59
- }
60
- async function prepareComponent(component) {
61
- const marker = findCommentMarker(component.id);
62
- if (!marker) {
63
- throw new Error(`Comment marker for ${component.id} not found`, { cause: component });
64
- }
65
- const props = marker.props;
66
- const domNode = createContainerBetweenMarkers(marker.startComment, marker.endComment);
67
- const Component = await component.import();
68
- return { domNode, props, Component };
69
- }
70
- function filterComponents(components) {
71
- const currentPath = window.location.pathname;
72
- return components.filter((component) => component.route === currentPath || !component.route);
73
- }
74
- function discoverComponents() {
75
- const components = [];
76
- const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_COMMENT, null);
77
- const markers = [];
78
- let node;
79
- while (node = walker.nextNode()) {
80
- const text = node.textContent?.trim() || "";
81
- if (text.startsWith("$") && !text.startsWith("/$")) {
82
- const spaceIdx = text.indexOf(" ");
83
- if (spaceIdx !== -1) {
84
- const id = text.slice(1, spaceIdx);
85
- const content = text.slice(spaceIdx + 1);
86
- if (content.startsWith("[")) {
87
- continue;
88
- }
89
- const jsonStart = content.indexOf("{");
90
- let name = "";
91
- let props = {};
92
- if (jsonStart !== -1) {
93
- name = content.slice(0, jsonStart).trim();
94
- try {
95
- props = JSON.parse(content.slice(jsonStart));
96
- } catch {}
97
- } else {
98
- name = content.trim();
99
- }
100
- markers.push({ id, name, props, startComment: node, endComment: null });
101
- }
102
- } else if (text.startsWith("/$")) {
103
- const id = text.slice(2);
104
- const marker = markers.find((m) => m.id === id && !m.endComment);
105
- if (marker) {
106
- marker.endComment = node;
107
- }
108
- }
109
- }
110
- for (const marker of markers) {
111
- if (!marker.endComment)
112
- continue;
113
- const container = createContainerBetweenMarkers(marker.startComment, marker.endComment);
114
- components.push({
115
- id: marker.id,
116
- name: marker.name,
117
- props: marker.props,
118
- container
119
- });
120
- }
121
- return components;
122
- }
123
- async function hydrateAll(registry, render) {
124
- const components = discoverComponents();
125
- await Promise.all(components.map(async ({ name, props, container }) => {
126
- const importer = registry[name];
127
- if (!importer) {
128
- console.warn(`Component "${name}" not found in registry`);
129
- return;
130
- }
131
- try {
132
- const Component = await importer();
133
- render(container, Component, props);
134
- } catch (error) {
135
- console.error(`Failed to hydrate "${name}":`, error);
136
- }
137
- }));
138
- }
139
- export {
140
- prepareComponent,
141
- hydrateAll,
142
- filterComponents,
143
- discoverComponents
144
- };
package/vercel/index.js DELETED
@@ -1,18 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __export = (target, all) => {
3
- for (var name in all)
4
- __defProp(target, name, {
5
- get: all[name],
6
- enumerable: true,
7
- configurable: true,
8
- set: (newValue) => all[name] = () => newValue
9
- });
10
- };
11
-
12
- // src/vercel/index.ts
13
- function handle(app) {
14
- return (req) => app.fetch(req);
15
- }
16
- export {
17
- handle
18
- };