atmx-web 0.44.0 → 0.46.0
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/atmx.es.js +679 -0
- package/{src/core/vendor/axiom_runtime.js → dist/atmx.umd.js} +20 -18
- package/package.json +4 -1
- package/justfile +0 -8
- package/scripts/upload.sh +0 -61
- package/src/core/callback.ts +0 -92
- package/src/core/context.ts +0 -56
- package/src/core/query.ts +0 -162
- package/src/core/router.ts +0 -91
- package/src/core/types.ts +0 -49
- package/src/core/wasm.ts +0 -223
- package/src/dom/components/engine-status.ts +0 -62
- package/src/dom/indicators.ts +0 -36
- package/src/dom/lifecycle.ts +0 -379
- package/src/dom/scanner.ts +0 -125
- package/src/index.ts +0 -78
- package/src/resolver/evaluator.ts +0 -46
- package/src/resolver/render.ts +0 -196
- package/tsconfig.json +0 -25
- package/vite-env.d.ts +0 -11
- package/vite.config.ts +0 -27
- /package/{public → dist}/.axiom +0 -0
- /package/{public → dist}/axiom_runtime.wasm +0 -0
package/src/resolver/render.ts
DELETED
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
// FILE: src/resolver/render.ts
|
|
2
|
-
import { AtmxContextData } from "../core/context";
|
|
3
|
-
import { evaluateExpression } from "./evaluator";
|
|
4
|
-
|
|
5
|
-
export function renderContext(rootEl: HTMLElement, context: AtmxContextData) {
|
|
6
|
-
walkAndRender(rootEl, context, true, {});
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function walkAndRender(
|
|
10
|
-
node: HTMLElement,
|
|
11
|
-
context: AtmxContextData,
|
|
12
|
-
isRoot: boolean,
|
|
13
|
-
locals: Record<string, any>,
|
|
14
|
-
) {
|
|
15
|
-
// Stop traversal if we hit an independent reactive boundary
|
|
16
|
-
if (
|
|
17
|
-
!isRoot &&
|
|
18
|
-
(node.hasAttribute("ax-query") || node.hasAttribute("ax-mutate"))
|
|
19
|
-
) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// ✨ PHASE 1: DECLARATIVE LIST RENDERING (ax-for)
|
|
24
|
-
if (node.hasAttribute("ax-for")) {
|
|
25
|
-
handleAxFor(node, context, locals);
|
|
26
|
-
return; // Stop normal traversal for the template node!
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// 1. STATE RENDERING (ax-when)
|
|
30
|
-
if (node.hasAttribute("ax-when")) {
|
|
31
|
-
const expectedStates = node
|
|
32
|
-
.getAttribute("ax-when")!
|
|
33
|
-
.split(",")
|
|
34
|
-
.map((s) => s.trim());
|
|
35
|
-
if (!expectedStates.includes(context.state)) {
|
|
36
|
-
node.setAttribute("hidden", "true");
|
|
37
|
-
node.style.setProperty("display", "none", "important");
|
|
38
|
-
} else {
|
|
39
|
-
node.removeAttribute("hidden");
|
|
40
|
-
node.style.removeProperty("display");
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// 2. CONDITIONAL RENDERING (ax-if)
|
|
45
|
-
if (node.hasAttribute("ax-if")) {
|
|
46
|
-
const result = evaluateExpression(
|
|
47
|
-
node.getAttribute("ax-if")!,
|
|
48
|
-
context,
|
|
49
|
-
locals,
|
|
50
|
-
);
|
|
51
|
-
if (!result) {
|
|
52
|
-
node.setAttribute("hidden", "");
|
|
53
|
-
node.style.setProperty("display", "none", "important");
|
|
54
|
-
} else {
|
|
55
|
-
node.removeAttribute("hidden");
|
|
56
|
-
node.style.removeProperty("display");
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// 3. TEXT INTERPOLATION (ax-text)
|
|
61
|
-
if (node.hasAttribute("ax-text")) {
|
|
62
|
-
const result = evaluateExpression(
|
|
63
|
-
node.getAttribute("ax-text")!,
|
|
64
|
-
context,
|
|
65
|
-
locals,
|
|
66
|
-
);
|
|
67
|
-
// ✨ SECURE: textContent completely eliminates XSS vulnerabilities!
|
|
68
|
-
node.textContent =
|
|
69
|
-
result !== undefined && result !== null ? String(result) : "";
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// 4. FIELD-LEVEL ERRORS (ax-error-for)
|
|
73
|
-
if (node.hasAttribute("ax-error-for")) {
|
|
74
|
-
const fieldName = node.getAttribute("ax-error-for")!;
|
|
75
|
-
let errorMessage = "";
|
|
76
|
-
if (
|
|
77
|
-
context.state === "error" &&
|
|
78
|
-
context.error?.code === "ValidationError"
|
|
79
|
-
) {
|
|
80
|
-
const details = context.error.details || "";
|
|
81
|
-
const lines = details.split("\n");
|
|
82
|
-
for (const line of lines) {
|
|
83
|
-
if (line.startsWith(fieldName + ":")) {
|
|
84
|
-
errorMessage = line.substring(fieldName.length + 1).trim();
|
|
85
|
-
break;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
if (errorMessage) {
|
|
90
|
-
node.textContent = errorMessage;
|
|
91
|
-
node.removeAttribute("hidden");
|
|
92
|
-
node.style.removeProperty("display");
|
|
93
|
-
} else {
|
|
94
|
-
node.setAttribute("hidden", "");
|
|
95
|
-
node.style.setProperty("display", "none", "important");
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// 5. ATTRIBUTE BINDING (ax-bind:*)
|
|
100
|
-
Array.from(node.attributes).forEach((attr) => {
|
|
101
|
-
if (attr.name.startsWith("ax-bind:")) {
|
|
102
|
-
const targetAttr = attr.name.substring(8);
|
|
103
|
-
const result = evaluateExpression(attr.value, context, locals);
|
|
104
|
-
if (result === false || result === null || result === undefined) {
|
|
105
|
-
node.removeAttribute(targetAttr);
|
|
106
|
-
} else {
|
|
107
|
-
node.setAttribute(
|
|
108
|
-
targetAttr,
|
|
109
|
-
result === true ? targetAttr : String(result),
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
Array.from(node.children).forEach((child) => {
|
|
116
|
-
walkAndRender(child as HTMLElement, context, false, locals);
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
function handleAxFor(
|
|
121
|
-
templateNode: HTMLElement,
|
|
122
|
-
context: AtmxContextData,
|
|
123
|
-
locals: Record<string, any>,
|
|
124
|
-
) {
|
|
125
|
-
templateNode.style.display = "none"; // Hide the template node
|
|
126
|
-
|
|
127
|
-
if (!templateNode.hasAttribute("data-ax-for-id")) {
|
|
128
|
-
templateNode.setAttribute(
|
|
129
|
-
"data-ax-for-id",
|
|
130
|
-
Math.random().toString(36).substr(2, 9),
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
const forId = templateNode.getAttribute("data-ax-for-id")!;
|
|
134
|
-
const forExpr = templateNode.getAttribute("ax-for")!;
|
|
135
|
-
|
|
136
|
-
// Parse: "$item in $data" or "($item, $index) in $data"
|
|
137
|
-
const match = forExpr.match(
|
|
138
|
-
/^\s*(?:(?:\(\s*([\w\$]+)\s*,\s*([\w\$]+)\s*\))|([\w\$]+))\s+in\s+(.+)$/,
|
|
139
|
-
);
|
|
140
|
-
if (!match) return;
|
|
141
|
-
|
|
142
|
-
const itemVar = match[1] || match[3];
|
|
143
|
-
const indexVar = match[2];
|
|
144
|
-
const iterableExpr = match[4];
|
|
145
|
-
|
|
146
|
-
const iterable = evaluateExpression(iterableExpr, context, locals);
|
|
147
|
-
const parent = templateNode.parentElement;
|
|
148
|
-
if (!parent) return;
|
|
149
|
-
|
|
150
|
-
const existingClones = Array.from(
|
|
151
|
-
parent.querySelectorAll(`[data-ax-clone-of="${forId}"]`),
|
|
152
|
-
) as HTMLElement[];
|
|
153
|
-
|
|
154
|
-
if (!iterable || !Array.isArray(iterable)) {
|
|
155
|
-
existingClones.forEach((el) => el.remove());
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
const keyAttr = templateNode.getAttribute("ax-key");
|
|
160
|
-
const newClones: HTMLElement[] = [];
|
|
161
|
-
|
|
162
|
-
iterable.forEach((item, index) => {
|
|
163
|
-
const childLocals = { ...locals, [itemVar]: item };
|
|
164
|
-
if (indexVar) childLocals[indexVar] = index;
|
|
165
|
-
|
|
166
|
-
let keyValue = String(index);
|
|
167
|
-
if (keyAttr) {
|
|
168
|
-
keyValue = String(evaluateExpression(keyAttr, context, childLocals));
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// Try to reuse an existing DOM node for performance
|
|
172
|
-
let clone = existingClones.find(
|
|
173
|
-
(el) => el.getAttribute("data-ax-key") === keyValue,
|
|
174
|
-
);
|
|
175
|
-
if (!clone) {
|
|
176
|
-
clone = templateNode.cloneNode(true) as HTMLElement;
|
|
177
|
-
clone.removeAttribute("ax-for");
|
|
178
|
-
clone.style.removeProperty("display");
|
|
179
|
-
if (clone.style.length === 0) clone.removeAttribute("style");
|
|
180
|
-
clone.setAttribute("data-ax-clone-of", forId);
|
|
181
|
-
clone.setAttribute("data-ax-key", keyValue);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// Maintain exact order in the DOM
|
|
185
|
-
parent.insertBefore(clone, templateNode);
|
|
186
|
-
|
|
187
|
-
// Render the contents of the clone with the injected locals!
|
|
188
|
-
walkAndRender(clone, context, false, childLocals);
|
|
189
|
-
newClones.push(clone);
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
// Cleanup old clones that are no longer in the list
|
|
193
|
-
existingClones.forEach((el) => {
|
|
194
|
-
if (!newClones.includes(el)) el.remove();
|
|
195
|
-
});
|
|
196
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2020",
|
|
4
|
-
"useDefineForClassFields": true,
|
|
5
|
-
"module": "ESNext",
|
|
6
|
-
"lib": [
|
|
7
|
-
"ES2020",
|
|
8
|
-
"DOM",
|
|
9
|
-
"DOM.Iterable"
|
|
10
|
-
],
|
|
11
|
-
"skipLibCheck": true,
|
|
12
|
-
"moduleResolution": "bundler",
|
|
13
|
-
"allowImportingTsExtensions": true,
|
|
14
|
-
"resolveJsonModule": true,
|
|
15
|
-
"isolatedModules": true,
|
|
16
|
-
"noEmit": true,
|
|
17
|
-
"strict": true,
|
|
18
|
-
"noUnusedLocals": true,
|
|
19
|
-
"noUnusedParameters": true,
|
|
20
|
-
"noFallthroughCasesInSwitch": true
|
|
21
|
-
},
|
|
22
|
-
"include": [
|
|
23
|
-
"src"
|
|
24
|
-
]
|
|
25
|
-
}
|
package/vite-env.d.ts
DELETED
package/vite.config.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'vite';
|
|
2
|
-
import { resolve } from 'path';
|
|
3
|
-
|
|
4
|
-
export default defineConfig({
|
|
5
|
-
server: {
|
|
6
|
-
open: '/example/index.html',
|
|
7
|
-
proxy: {
|
|
8
|
-
// Any request to /api will be proxied to your backend
|
|
9
|
-
'/api': {
|
|
10
|
-
target: 'http://localhost:8000',
|
|
11
|
-
changeOrigin: true,
|
|
12
|
-
rewrite: (path) => path.replace(/^\/api/, '') // Strips /api before sending to backend
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
build: {
|
|
17
|
-
lib: {
|
|
18
|
-
entry: resolve(__dirname, 'src/index.ts'),
|
|
19
|
-
name: 'atmx',
|
|
20
|
-
fileName: (format) => `atmx.${format}.js`,
|
|
21
|
-
formats: ['es', 'umd']
|
|
22
|
-
},
|
|
23
|
-
assetsInlineLimit: 0,
|
|
24
|
-
outDir: 'dist',
|
|
25
|
-
emptyOutDir: true
|
|
26
|
-
}
|
|
27
|
-
});
|
/package/{public → dist}/.axiom
RENAMED
|
File without changes
|
|
File without changes
|