chispa 0.1.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/README.md +108 -0
- package/dist/html-compiler/cli.d.ts +1 -0
- package/dist/html-compiler/cli.js +300 -0
- package/dist/html-compiler/cli.js.map +1 -0
- package/dist/html-compiler/vite-plugin.d.ts +14 -0
- package/dist/html-compiler/vite-plugin.js +335 -0
- package/dist/html-compiler/vite-plugin.js.map +1 -0
- package/dist/index.d.ts +150 -0
- package/dist/index.js +551 -0
- package/dist/index.js.map +1 -0
- package/package.json +47 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,551 @@
|
|
|
1
|
+
// src/context.ts
|
|
2
|
+
var AppContext = class {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.reactivityContextStack = [];
|
|
5
|
+
this.refreshTimeout = 0;
|
|
6
|
+
//private contexts = new Set<RenderContext>();
|
|
7
|
+
this.dirtyReactivities = /* @__PURE__ */ new Set();
|
|
8
|
+
this.executionStack = [];
|
|
9
|
+
this.componentStack = [];
|
|
10
|
+
}
|
|
11
|
+
pushComponentStack(cmp) {
|
|
12
|
+
this.componentStack.push(cmp);
|
|
13
|
+
}
|
|
14
|
+
popComponentStack() {
|
|
15
|
+
this.componentStack.pop();
|
|
16
|
+
}
|
|
17
|
+
getCurrentComponent() {
|
|
18
|
+
if (this.componentStack.length === 0) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return this.componentStack[this.componentStack.length - 1];
|
|
22
|
+
}
|
|
23
|
+
setCurrentReactivityContext(context) {
|
|
24
|
+
this.reactivityContextStack.push(context);
|
|
25
|
+
}
|
|
26
|
+
restorePreviousReactivityContext() {
|
|
27
|
+
this.reactivityContextStack.pop();
|
|
28
|
+
}
|
|
29
|
+
getCurrentRenderContext() {
|
|
30
|
+
if (this.reactivityContextStack.length === 0) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
return this.reactivityContextStack[this.reactivityContextStack.length - 1];
|
|
34
|
+
}
|
|
35
|
+
scheduleRefresh() {
|
|
36
|
+
if (this.refreshTimeout) {
|
|
37
|
+
clearTimeout(this.refreshTimeout);
|
|
38
|
+
}
|
|
39
|
+
this.refreshTimeout = setTimeout(() => {
|
|
40
|
+
const dirtyContexts = Array.from(this.dirtyReactivities);
|
|
41
|
+
dirtyContexts.forEach((ctx) => ctx.process());
|
|
42
|
+
}, 0);
|
|
43
|
+
}
|
|
44
|
+
addReactivity(executor) {
|
|
45
|
+
const ctx = new Reactivity(executor);
|
|
46
|
+
globalContext.pushExecutionStack("addReactivity");
|
|
47
|
+
ctx.exec();
|
|
48
|
+
globalContext.popExecutionStack();
|
|
49
|
+
return ctx;
|
|
50
|
+
}
|
|
51
|
+
createRoot(component2, mountPoint) {
|
|
52
|
+
this.dirtyReactivities.clear();
|
|
53
|
+
mountPoint.innerHTML = "";
|
|
54
|
+
const cmp = component2();
|
|
55
|
+
cmp.mount(mountPoint, null);
|
|
56
|
+
}
|
|
57
|
+
canReadSignal() {
|
|
58
|
+
const length = this.executionStack.length;
|
|
59
|
+
if (length === 0) return true;
|
|
60
|
+
const current = this.executionStack[length - 1];
|
|
61
|
+
return current !== "createComponent";
|
|
62
|
+
}
|
|
63
|
+
pushExecutionStack(type) {
|
|
64
|
+
this.executionStack.push(type);
|
|
65
|
+
}
|
|
66
|
+
popExecutionStack() {
|
|
67
|
+
this.executionStack.pop();
|
|
68
|
+
}
|
|
69
|
+
addDirtyContext(ctx) {
|
|
70
|
+
this.dirtyReactivities.add(ctx);
|
|
71
|
+
}
|
|
72
|
+
removeDirtyContext(ctx) {
|
|
73
|
+
this.dirtyReactivities.delete(ctx);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
var Reactivity = class {
|
|
77
|
+
constructor(action) {
|
|
78
|
+
this.action = action;
|
|
79
|
+
this.dirty = false;
|
|
80
|
+
this.signals = /* @__PURE__ */ new Set();
|
|
81
|
+
const currentComponent = globalContext.getCurrentComponent();
|
|
82
|
+
if (currentComponent) {
|
|
83
|
+
currentComponent.disposables.push(this);
|
|
84
|
+
} else {
|
|
85
|
+
console.warn("Creating a Reactivity outside of a component");
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
markDirty() {
|
|
89
|
+
this.dirty = true;
|
|
90
|
+
globalContext.addDirtyContext(this);
|
|
91
|
+
globalContext.scheduleRefresh();
|
|
92
|
+
}
|
|
93
|
+
addSignal(signal2) {
|
|
94
|
+
this.signals.add(signal2);
|
|
95
|
+
}
|
|
96
|
+
removeSignal(signal2) {
|
|
97
|
+
this.signals.delete(signal2);
|
|
98
|
+
}
|
|
99
|
+
process() {
|
|
100
|
+
if (!this.dirty) return;
|
|
101
|
+
this.exec();
|
|
102
|
+
this.dirty = false;
|
|
103
|
+
globalContext.removeDirtyContext(this);
|
|
104
|
+
}
|
|
105
|
+
exec() {
|
|
106
|
+
this.signals.forEach((s) => s.removeContext(this));
|
|
107
|
+
this.signals.clear();
|
|
108
|
+
globalContext.setCurrentReactivityContext(this);
|
|
109
|
+
this.action();
|
|
110
|
+
globalContext.restorePreviousReactivityContext();
|
|
111
|
+
}
|
|
112
|
+
dispose() {
|
|
113
|
+
this.signals.forEach((s) => s.removeContext(this));
|
|
114
|
+
this.signals.clear();
|
|
115
|
+
this.dirty = false;
|
|
116
|
+
globalContext.removeDirtyContext(this);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
var globalContext = new AppContext();
|
|
120
|
+
|
|
121
|
+
// src/signals.ts
|
|
122
|
+
var Signal = class {
|
|
123
|
+
constructor() {
|
|
124
|
+
this.contexts = /* @__PURE__ */ new Set();
|
|
125
|
+
this.computed = new Proxy(
|
|
126
|
+
{},
|
|
127
|
+
{
|
|
128
|
+
get: (_, prop) => {
|
|
129
|
+
return computed(() => this.get()[prop]);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
get() {
|
|
135
|
+
if (!globalContext.canReadSignal()) {
|
|
136
|
+
throw new Error("Cannot read a signal value during component creation. Did you mean to use a computed signal instead?");
|
|
137
|
+
}
|
|
138
|
+
const ctx = globalContext.getCurrentRenderContext();
|
|
139
|
+
if (ctx) {
|
|
140
|
+
this.contexts.add(ctx);
|
|
141
|
+
ctx.addSignal(this);
|
|
142
|
+
}
|
|
143
|
+
return this.value;
|
|
144
|
+
}
|
|
145
|
+
removeContext(ctx) {
|
|
146
|
+
this.contexts.delete(ctx);
|
|
147
|
+
}
|
|
148
|
+
dispose() {
|
|
149
|
+
console.log("disposing signal", this);
|
|
150
|
+
this.contexts.forEach((ctx) => {
|
|
151
|
+
ctx.removeSignal(this);
|
|
152
|
+
});
|
|
153
|
+
this.contexts.clear();
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
var WritableSignal = class extends Signal {
|
|
157
|
+
constructor(initialValue) {
|
|
158
|
+
super();
|
|
159
|
+
this.initialValue = initialValue;
|
|
160
|
+
this.value = initialValue;
|
|
161
|
+
}
|
|
162
|
+
set(newValue) {
|
|
163
|
+
this.value = newValue;
|
|
164
|
+
this.contexts.forEach((ctx) => ctx.markDirty());
|
|
165
|
+
}
|
|
166
|
+
update(updater) {
|
|
167
|
+
this.value = updater(this.value);
|
|
168
|
+
this.contexts.forEach((ctx) => ctx.markDirty());
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
var ComputedSignal = class extends Signal {
|
|
172
|
+
constructor(computeFn) {
|
|
173
|
+
super();
|
|
174
|
+
globalContext.pushExecutionStack("computed");
|
|
175
|
+
this.value = computeFn();
|
|
176
|
+
globalContext.popExecutionStack();
|
|
177
|
+
this.computeFn = computeFn;
|
|
178
|
+
}
|
|
179
|
+
recompute() {
|
|
180
|
+
const newValue = this.computeFn();
|
|
181
|
+
if (newValue !== this.value) {
|
|
182
|
+
this.value = newValue;
|
|
183
|
+
this.contexts.forEach((ctx) => ctx.markDirty());
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
function isSignal(value) {
|
|
188
|
+
return value instanceof Signal;
|
|
189
|
+
}
|
|
190
|
+
function signal(initialValue) {
|
|
191
|
+
const sig = new WritableSignal(initialValue);
|
|
192
|
+
return sig;
|
|
193
|
+
}
|
|
194
|
+
function computed(fn) {
|
|
195
|
+
let sig;
|
|
196
|
+
const ctx = new Reactivity(() => {
|
|
197
|
+
sig.recompute();
|
|
198
|
+
});
|
|
199
|
+
globalContext.setCurrentReactivityContext(ctx);
|
|
200
|
+
sig = new ComputedSignal(fn);
|
|
201
|
+
globalContext.restorePreviousReactivityContext();
|
|
202
|
+
return sig;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// src/components.ts
|
|
206
|
+
var Component = class {
|
|
207
|
+
constructor(factoryFn, key = null, props = null) {
|
|
208
|
+
this.factoryFn = factoryFn;
|
|
209
|
+
this.key = key;
|
|
210
|
+
this.props = props;
|
|
211
|
+
this.onUnmount = null;
|
|
212
|
+
this.nodes = null;
|
|
213
|
+
this.container = null;
|
|
214
|
+
this.anchor = null;
|
|
215
|
+
this.disposables = [];
|
|
216
|
+
this.silent = true;
|
|
217
|
+
}
|
|
218
|
+
mount(container, anchor) {
|
|
219
|
+
if (!this.silent) console.log("Mounting Component", this);
|
|
220
|
+
this.container = container;
|
|
221
|
+
this.anchor = anchor;
|
|
222
|
+
globalContext.pushExecutionStack("createComponent");
|
|
223
|
+
globalContext.pushComponentStack(this);
|
|
224
|
+
const node = this.factoryFn ? this.factoryFn(this.props) : null;
|
|
225
|
+
globalContext.popComponentStack();
|
|
226
|
+
globalContext.popExecutionStack();
|
|
227
|
+
if (node) {
|
|
228
|
+
if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
|
|
229
|
+
this.nodes = Array.from(node.childNodes);
|
|
230
|
+
} else {
|
|
231
|
+
this.nodes = [node];
|
|
232
|
+
}
|
|
233
|
+
} else {
|
|
234
|
+
this.nodes = null;
|
|
235
|
+
}
|
|
236
|
+
this.insertNodes();
|
|
237
|
+
}
|
|
238
|
+
reanchor(anchor) {
|
|
239
|
+
this.anchor = anchor;
|
|
240
|
+
if (!this.container || !this.nodes) return;
|
|
241
|
+
this.insertNodes();
|
|
242
|
+
}
|
|
243
|
+
insertNodes() {
|
|
244
|
+
this.nodes.forEach((node) => {
|
|
245
|
+
if (this.anchor) {
|
|
246
|
+
this.container.insertBefore(node, this.anchor);
|
|
247
|
+
} else {
|
|
248
|
+
this.container.appendChild(node);
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
unmount() {
|
|
253
|
+
if (!this.silent) console.log("Unmounting Component", this);
|
|
254
|
+
if (this.onUnmount) {
|
|
255
|
+
this.onUnmount();
|
|
256
|
+
this.onUnmount = null;
|
|
257
|
+
}
|
|
258
|
+
if (this.nodes) {
|
|
259
|
+
this.nodes.forEach((node) => {
|
|
260
|
+
if (node && node.parentNode) {
|
|
261
|
+
node.parentNode.removeChild(node);
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
this.disposables.forEach((d) => {
|
|
266
|
+
d.dispose();
|
|
267
|
+
});
|
|
268
|
+
this.disposables = [];
|
|
269
|
+
this.nodes = null;
|
|
270
|
+
this.container = null;
|
|
271
|
+
this.anchor = null;
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
function component(factory) {
|
|
275
|
+
return (props) => {
|
|
276
|
+
return new Component(factory, null, props);
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
var ComponentList = class {
|
|
280
|
+
constructor(itemFactoryFn, keyFn, itemsSignal) {
|
|
281
|
+
this.itemFactoryFn = itemFactoryFn;
|
|
282
|
+
this.keyFn = keyFn;
|
|
283
|
+
this.itemsSignal = itemsSignal;
|
|
284
|
+
// Nodes must be inserted before this node
|
|
285
|
+
this.currentKeys = [];
|
|
286
|
+
this.disposables = [];
|
|
287
|
+
this.components = /* @__PURE__ */ new Map();
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Obtiene todos los componentes
|
|
291
|
+
*/
|
|
292
|
+
getAllComponents() {
|
|
293
|
+
return Array.from(this.components.values());
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Limpia todos los componentes
|
|
297
|
+
*/
|
|
298
|
+
clear() {
|
|
299
|
+
Array.from(this.components.values()).forEach((component2) => {
|
|
300
|
+
this.removeComponent(component2);
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Elimina un componente completo
|
|
305
|
+
*/
|
|
306
|
+
removeComponent(component2) {
|
|
307
|
+
component2.unmount();
|
|
308
|
+
if (component2.key) {
|
|
309
|
+
this.components.delete(component2.key);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Crea un nuevo componente
|
|
314
|
+
*/
|
|
315
|
+
createNewComponent(key) {
|
|
316
|
+
const factory = () => {
|
|
317
|
+
const item = computed(() => this.itemsSignal.get().find((v, index2) => this.keyFn(v, index2) === key));
|
|
318
|
+
const index = computed(() => this.itemsSignal.get().findIndex((v, index2) => this.keyFn(v, index2) === key));
|
|
319
|
+
return this.itemFactoryFn ? this.itemFactoryFn(item, index, this.itemsSignal) : null;
|
|
320
|
+
};
|
|
321
|
+
const component2 = new Component(factory, key);
|
|
322
|
+
this.components.set(key, component2);
|
|
323
|
+
return component2;
|
|
324
|
+
}
|
|
325
|
+
getTargetAnchor(items, index) {
|
|
326
|
+
const nextItem = index + 1 < items.length ? items[index + 1] : null;
|
|
327
|
+
const nextComp = nextItem ? this.components.get(this.keyFn(nextItem, index + 1)) : null;
|
|
328
|
+
if (nextComp && nextComp.nodes) {
|
|
329
|
+
return nextComp.nodes[0];
|
|
330
|
+
} else {
|
|
331
|
+
return this.anchor;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Función principal que sincroniza los componentes DOM con un array de keys
|
|
336
|
+
*/
|
|
337
|
+
synchronizeComponents() {
|
|
338
|
+
const existingComponents = this.getAllComponents();
|
|
339
|
+
const items = this.itemsSignal.get();
|
|
340
|
+
const keys = items.map((item, index) => this.keyFn(item, index));
|
|
341
|
+
const componentsToRemove = existingComponents.filter((component2) => component2.key && !keys.includes(component2.key));
|
|
342
|
+
componentsToRemove.forEach((component2) => this.removeComponent(component2));
|
|
343
|
+
this.currentKeys = this.currentKeys.filter((key) => keys.includes(key));
|
|
344
|
+
const container = this.container;
|
|
345
|
+
items.forEach((item, index) => {
|
|
346
|
+
const targetKey = this.keyFn(item, index);
|
|
347
|
+
const currentKey = this.currentKeys[index];
|
|
348
|
+
if (targetKey === currentKey) {
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
const existingComponent = this.components.get(targetKey);
|
|
352
|
+
if (existingComponent) {
|
|
353
|
+
const prevComp = this.components.get(currentKey);
|
|
354
|
+
existingComponent.reanchor(prevComp.nodes[0]);
|
|
355
|
+
this.currentKeys = this.currentKeys.filter((k) => k !== targetKey);
|
|
356
|
+
this.currentKeys.splice(index, 0, targetKey);
|
|
357
|
+
} else {
|
|
358
|
+
const targetAnchor = this.getTargetAnchor(items, index);
|
|
359
|
+
const newComponent = this.createNewComponent(targetKey);
|
|
360
|
+
newComponent.mount(container, targetAnchor);
|
|
361
|
+
this.currentKeys.splice(index, 0, targetKey);
|
|
362
|
+
}
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
mount(container, anchor) {
|
|
366
|
+
this.container = container;
|
|
367
|
+
this.anchor = anchor;
|
|
368
|
+
globalContext.pushComponentStack(this);
|
|
369
|
+
globalContext.addReactivity(() => {
|
|
370
|
+
this.synchronizeComponents();
|
|
371
|
+
});
|
|
372
|
+
globalContext.popComponentStack();
|
|
373
|
+
}
|
|
374
|
+
unmount() {
|
|
375
|
+
this.clear();
|
|
376
|
+
this.container = null;
|
|
377
|
+
this.anchor = null;
|
|
378
|
+
this.disposables.forEach((d) => {
|
|
379
|
+
d.dispose();
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
function componentList(itemFactoryFn, keyFn) {
|
|
384
|
+
return (listSignal) => {
|
|
385
|
+
const list = new ComponentList(itemFactoryFn, keyFn, listSignal);
|
|
386
|
+
return list;
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// src/builder.ts
|
|
391
|
+
function makeclass(classes) {
|
|
392
|
+
let finalClasses = [];
|
|
393
|
+
for (const className in classes) {
|
|
394
|
+
if (classes[className]) {
|
|
395
|
+
finalClasses.push(className);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
return finalClasses.join(" ").trim();
|
|
399
|
+
}
|
|
400
|
+
function buildClass(literalValue, additionalValue, classes) {
|
|
401
|
+
const parts = [];
|
|
402
|
+
if (literalValue) parts.push(literalValue);
|
|
403
|
+
if (additionalValue) parts.push(additionalValue);
|
|
404
|
+
parts.push(makeclass(classes ?? {}));
|
|
405
|
+
return parts.join(" ").trim();
|
|
406
|
+
}
|
|
407
|
+
var forbiddenProps = ["addClass", "classes", "items", "inner", "_ref"];
|
|
408
|
+
function getValidProps(props) {
|
|
409
|
+
const finalProps = {};
|
|
410
|
+
for (const propName in props) {
|
|
411
|
+
if (forbiddenProps.indexOf(propName) === -1) {
|
|
412
|
+
finalProps[propName] = props[propName];
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
if (props._ref !== void 0) {
|
|
416
|
+
}
|
|
417
|
+
return finalProps;
|
|
418
|
+
}
|
|
419
|
+
function getItem(Components, items, itemName) {
|
|
420
|
+
if (!items || !items[itemName]) {
|
|
421
|
+
return null;
|
|
422
|
+
}
|
|
423
|
+
const item = items[itemName];
|
|
424
|
+
if (item.constructor && item.constructor.name === "Object" && !(item instanceof Element)) {
|
|
425
|
+
const Comp = Components[itemName];
|
|
426
|
+
const itemProps = item;
|
|
427
|
+
return Comp(itemProps);
|
|
428
|
+
} else {
|
|
429
|
+
return item;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
function setAttributes(node, attributes) {
|
|
433
|
+
for (const attr in attributes) {
|
|
434
|
+
const attrValue = attributes[attr].trim();
|
|
435
|
+
if (!attrValue) continue;
|
|
436
|
+
node.setAttribute(attr, attrValue);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
function setProps(node, props) {
|
|
440
|
+
if (node instanceof HTMLElement) {
|
|
441
|
+
if (props.style !== void 0) {
|
|
442
|
+
const style = props.style;
|
|
443
|
+
for (const styleKey in style) {
|
|
444
|
+
if (isSignal(style[styleKey])) {
|
|
445
|
+
globalContext.addReactivity(() => {
|
|
446
|
+
node.style[styleKey] = style[styleKey].get();
|
|
447
|
+
});
|
|
448
|
+
} else {
|
|
449
|
+
node.style[styleKey] = style[styleKey];
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
delete props.style;
|
|
453
|
+
}
|
|
454
|
+
if (props.dataset !== void 0) {
|
|
455
|
+
const dataset = props.dataset;
|
|
456
|
+
for (const datasetKey in dataset) {
|
|
457
|
+
if (isSignal(dataset[datasetKey])) {
|
|
458
|
+
globalContext.addReactivity(() => {
|
|
459
|
+
node.dataset[datasetKey] = dataset[datasetKey].get();
|
|
460
|
+
});
|
|
461
|
+
} else {
|
|
462
|
+
node.dataset[datasetKey] = dataset[datasetKey];
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
delete props.dataset;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
for (const prop in props) {
|
|
469
|
+
const propValue = props[prop];
|
|
470
|
+
if (isSignal(propValue)) {
|
|
471
|
+
globalContext.addReactivity(() => {
|
|
472
|
+
node[prop] = propValue.get();
|
|
473
|
+
});
|
|
474
|
+
} else if (propValue === void 0) {
|
|
475
|
+
continue;
|
|
476
|
+
} else {
|
|
477
|
+
node[prop] = propValue;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
function appendChild(node, child) {
|
|
482
|
+
if (child === null) return;
|
|
483
|
+
if (isSignal(child)) {
|
|
484
|
+
processSignalChild(node, child);
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
if (child instanceof Component || child instanceof ComponentList) {
|
|
488
|
+
child.mount(node, null);
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
if (Array.isArray(child)) {
|
|
492
|
+
child.forEach((ch) => {
|
|
493
|
+
appendChild(node, ch);
|
|
494
|
+
});
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
node.appendChild(child instanceof Node ? child : document.createTextNode(child.toString()));
|
|
498
|
+
}
|
|
499
|
+
function processSignalChild(node, child) {
|
|
500
|
+
const anchor = document.createTextNode("");
|
|
501
|
+
node.appendChild(anchor);
|
|
502
|
+
let prevValue = null;
|
|
503
|
+
globalContext.addReactivity(() => {
|
|
504
|
+
const ch = child.get();
|
|
505
|
+
if (prevValue) {
|
|
506
|
+
prevValue.unmount();
|
|
507
|
+
}
|
|
508
|
+
if (ch === null) {
|
|
509
|
+
prevValue = null;
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
let component2;
|
|
513
|
+
if (ch instanceof Component || ch instanceof ComponentList) {
|
|
514
|
+
ch.mount(node, anchor);
|
|
515
|
+
component2 = ch;
|
|
516
|
+
} else {
|
|
517
|
+
const wrCmp = new Component(() => toNode(ch));
|
|
518
|
+
wrCmp.mount(node, anchor);
|
|
519
|
+
component2 = wrCmp;
|
|
520
|
+
}
|
|
521
|
+
prevValue = component2;
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
function toNode(n) {
|
|
525
|
+
if (Array.isArray(n)) {
|
|
526
|
+
const frag = document.createDocumentFragment();
|
|
527
|
+
frag.append(...n.map((c) => toNode(c)));
|
|
528
|
+
return frag;
|
|
529
|
+
} else if (n instanceof Node) {
|
|
530
|
+
return n;
|
|
531
|
+
} else if (typeof n === "string" || typeof n === "number") {
|
|
532
|
+
return document.createTextNode(n.toString());
|
|
533
|
+
} else {
|
|
534
|
+
return null;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
export {
|
|
538
|
+
appendChild,
|
|
539
|
+
buildClass,
|
|
540
|
+
component,
|
|
541
|
+
componentList,
|
|
542
|
+
computed,
|
|
543
|
+
getItem,
|
|
544
|
+
getValidProps,
|
|
545
|
+
globalContext,
|
|
546
|
+
isSignal,
|
|
547
|
+
setAttributes,
|
|
548
|
+
setProps,
|
|
549
|
+
signal
|
|
550
|
+
};
|
|
551
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/context.ts","../src/signals.ts","../src/components.ts","../src/builder.ts"],"sourcesContent":["import { Component, ComponentList } from './components';\nimport { Signal } from './signals';\n\ntype TExecutionProcess = 'createComponent' | 'computed' | 'addReactivity';\n\nexport interface IDisposable {\n\tdispose: () => void;\n}\n\nclass AppContext {\n\tprivate reactivityContextStack: Reactivity[] = [];\n\n\tprivate refreshTimeout: any = 0;\n\n\t//private contexts = new Set<RenderContext>();\n\n\tprivate dirtyReactivities = new Set<Reactivity>();\n\n\tprivate executionStack: TExecutionProcess[] = [];\n\n\tprivate componentStack: (Component | ComponentList)[] = [];\n\n\tpushComponentStack(cmp: Component | ComponentList) {\n\t\tthis.componentStack.push(cmp);\n\t}\n\n\tpopComponentStack() {\n\t\tthis.componentStack.pop();\n\t}\n\n\tgetCurrentComponent() {\n\t\tif (this.componentStack.length === 0) {\n\t\t\t//console.warn('No current component');\n\t\t\treturn null;\n\t\t}\n\t\treturn this.componentStack[this.componentStack.length - 1];\n\t}\n\n\tsetCurrentReactivityContext(context: Reactivity) {\n\t\tthis.reactivityContextStack.push(context);\n\t\t//this.contexts.add(context);\n\t}\n\n\trestorePreviousReactivityContext() {\n\t\tthis.reactivityContextStack.pop();\n\t}\n\n\tgetCurrentRenderContext() {\n\t\tif (this.reactivityContextStack.length === 0) {\n\t\t\t//console.warn('No current render context');\n\t\t\treturn null;\n\t\t}\n\t\treturn this.reactivityContextStack[this.reactivityContextStack.length - 1];\n\t}\n\n\tscheduleRefresh() {\n\t\tif (this.refreshTimeout) {\n\t\t\tclearTimeout(this.refreshTimeout);\n\t\t}\n\t\tthis.refreshTimeout = setTimeout(() => {\n\t\t\tconst dirtyContexts = Array.from(this.dirtyReactivities);\n\t\t\tdirtyContexts.forEach((ctx) => ctx.process());\n\t\t}, 0);\n\t}\n\n\taddReactivity(executor: () => void) {\n\t\tconst ctx = new Reactivity(executor);\n\t\tglobalContext.pushExecutionStack('addReactivity');\n\t\tctx.exec();\n\t\tglobalContext.popExecutionStack();\n\t\treturn ctx;\n\t}\n\n\tcreateRoot(component: () => Component, mountPoint: HTMLElement) {\n\t\tthis.dirtyReactivities.clear();\n\t\tmountPoint.innerHTML = '';\n\t\tconst cmp = component();\n\t\tcmp.mount(mountPoint, null);\n\t}\n\n\tcanReadSignal() {\n\t\tconst length = this.executionStack.length;\n\t\tif (length === 0) return true;\n\t\tconst current = this.executionStack[length - 1];\n\t\treturn current !== 'createComponent';\n\t}\n\n\tpushExecutionStack(type: TExecutionProcess) {\n\t\tthis.executionStack.push(type);\n\t}\n\n\tpopExecutionStack() {\n\t\tthis.executionStack.pop();\n\t}\n\n\taddDirtyContext(ctx: Reactivity) {\n\t\tthis.dirtyReactivities.add(ctx);\n\t}\n\n\tremoveDirtyContext(ctx: Reactivity) {\n\t\tthis.dirtyReactivities.delete(ctx);\n\t}\n}\n\nexport class Reactivity implements IDisposable {\n\tprivate dirty: boolean = false;\n\n\tprivate signals = new Set<Signal<any>>();\n\n\tconstructor(private readonly action: () => void) {\n\t\tconst currentComponent = globalContext.getCurrentComponent();\n\t\tif (currentComponent) {\n\t\t\tcurrentComponent.disposables.push(this);\n\t\t} else {\n\t\t\tconsole.warn('Creating a Reactivity outside of a component');\n\t\t}\n\t}\n\n\tmarkDirty() {\n\t\t// Mark the context as dirty (needing re-render)\n\t\t//console.log('marking context as dirty');\n\t\tthis.dirty = true;\n\t\tglobalContext.addDirtyContext(this);\n\t\tglobalContext.scheduleRefresh();\n\t}\n\n\taddSignal(signal: Signal<any>) {\n\t\tthis.signals.add(signal);\n\t}\n\n\tremoveSignal(signal: Signal<any>) {\n\t\tthis.signals.delete(signal);\n\t}\n\n\tprocess() {\n\t\tif (!this.dirty) return;\n\t\tthis.exec();\n\t\t//console.log('re-render cycle completed');\n\t\tthis.dirty = false;\n\t\tglobalContext.removeDirtyContext(this);\n\t}\n\n\texec() {\n\t\tthis.signals.forEach((s) => s.removeContext(this));\n\t\tthis.signals.clear();\n\t\tglobalContext.setCurrentReactivityContext(this);\n\t\tthis.action();\n\t\tglobalContext.restorePreviousReactivityContext();\n\t}\n\n\tdispose() {\n\t\tthis.signals.forEach((s) => s.removeContext(this));\n\t\tthis.signals.clear();\n\t\tthis.dirty = false;\n\t\tglobalContext.removeDirtyContext(this);\n\t}\n}\n\nexport const globalContext = new AppContext();\n","import { WithSignals } from './components';\nimport { globalContext, Reactivity } from './context';\n\nabstract class Signal<T> {\n\tprotected abstract value: T;\n\n\tprotected contexts: Set<Reactivity> = new Set();\n\n\tconstructor() {}\n\n\tget() {\n\t\tif (!globalContext.canReadSignal()) {\n\t\t\tthrow new Error('Cannot read a signal value during component creation. Did you mean to use a computed signal instead?');\n\t\t}\n\t\t//context.current.register(this);\n\t\tconst ctx = globalContext.getCurrentRenderContext();\n\t\tif (ctx) {\n\t\t\tthis.contexts.add(ctx);\n\t\t\tctx.addSignal(this);\n\t\t}\n\t\treturn this.value;\n\t}\n\n\tpublic readonly computed = new Proxy(\n\t\t{},\n\t\t{\n\t\t\tget: (_, prop) => {\n\t\t\t\treturn computed(() => this.get()[prop]);\n\t\t\t},\n\t\t}\n\t) as WithSignals<T>;\n\n\tremoveContext(ctx: Reactivity) {\n\t\tthis.contexts.delete(ctx);\n\t}\n\n\tdispose() {\n\t\tconsole.log('disposing signal', this);\n\t\tthis.contexts.forEach((ctx) => {\n\t\t\tctx.removeSignal(this);\n\t\t});\n\t\tthis.contexts.clear();\n\t}\n}\n\nclass WritableSignal<T> extends Signal<T> {\n\tprotected override value: T;\n\n\tpublic readonly initialValue: T;\n\n\tconstructor(initialValue: T) {\n\t\tsuper();\n\t\tthis.initialValue = initialValue;\n\t\tthis.value = initialValue;\n\t}\n\n\tset(newValue: T) {\n\t\tthis.value = newValue;\n\t\tthis.contexts.forEach((ctx) => ctx.markDirty());\n\t}\n\n\tupdate(updater: (value: T) => T) {\n\t\tthis.value = updater(this.value);\n\t\tthis.contexts.forEach((ctx) => ctx.markDirty());\n\t}\n}\n\nclass ComputedSignal<T> extends Signal<T> {\n\tprotected override value: T;\n\n\tprivate computeFn: () => T;\n\n\tconstructor(computeFn: () => T) {\n\t\tsuper();\n\t\tglobalContext.pushExecutionStack('computed');\n\t\tthis.value = computeFn();\n\t\tglobalContext.popExecutionStack();\n\t\tthis.computeFn = computeFn;\n\t}\n\n\trecompute() {\n\t\tconst newValue = this.computeFn();\n\t\tif (newValue !== this.value) {\n\t\t\tthis.value = newValue;\n\t\t\tthis.contexts.forEach((ctx) => ctx.markDirty());\n\t\t}\n\t}\n}\n\nexport function isSignal(value: any): value is Signal<any> {\n\treturn value instanceof Signal;\n}\n\nexport function signal<T>(initialValue: T) {\n\tconst sig = new WritableSignal(initialValue);\n\n\t// // Creamos una función que se usará como callable\n\t// const fn = (() => sig.get()) as any;\n\n\t// // Copiamos todas las propiedades y métodos de la instancia a la función\n\t// Object.setPrototypeOf(fn, sig.constructor.prototype);\n\n\t// // Copiamos las propiedades de instancia\n\t// Object.assign(fn, this);\n\n\t// // Retornamos la función como si fuera la instancia\n\t// return fn as WritableSignal<T> & (() => T);\n\n\treturn sig;\n}\n\nexport function computed<T>(fn: () => T) {\n\tlet sig: ComputedSignal<T>;\n\tconst ctx = new Reactivity(() => {\n\t\tsig.recompute();\n\t});\n\tglobalContext.setCurrentReactivityContext(ctx);\n\tsig = new ComputedSignal(fn);\n\tglobalContext.restorePreviousReactivityContext();\n\n\treturn sig as Signal<T>;\n}\n\nexport type { Signal, WritableSignal };\n","import { globalContext, IDisposable } from './context';\nimport { computed, Signal, WritableSignal } from './signals';\n\nexport type TProps = Record<string, Signal<any>>;\nexport type TDict = Record<string, any>;\nexport type WithSignals<T> = { [K in keyof T]: Signal<T[K]> };\nexport type TComponentFactory<T extends TDict> = ((props: WithSignals<T>) => Node) | (() => Node);\n\nexport class Component<T = any> {\n\tpublic onUnmount: (() => void) | null = null;\n\n\tpublic nodes: Node[] | null = null;\n\n\tprivate container: Node | null = null;\n\n\tprivate anchor: Node | null = null;\n\n\tpublic disposables: IDisposable[] = [];\n\n\tpublic silent = true;\n\n\tconstructor(private readonly factoryFn: TComponentFactory<T>, public readonly key: any = null, public readonly props: WithSignals<T> = null) {}\n\n\tmount(container: Node, anchor: Node) {\n\t\tif (!this.silent) console.log('Mounting Component', this);\n\n\t\tthis.container = container;\n\t\tthis.anchor = anchor;\n\t\tglobalContext.pushExecutionStack('createComponent');\n\t\tglobalContext.pushComponentStack(this);\n\t\tconst node = this.factoryFn ? (this.factoryFn as any)(this.props) : null;\n\t\tglobalContext.popComponentStack();\n\t\tglobalContext.popExecutionStack();\n\t\t// if node is fragment, convert to array of nodes\n\t\tif (node) {\n\t\t\tif (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n\t\t\t\tthis.nodes = Array.from(node.childNodes);\n\t\t\t} else {\n\t\t\t\tthis.nodes = [node];\n\t\t\t}\n\t\t} else {\n\t\t\tthis.nodes = null;\n\t\t}\n\t\tthis.insertNodes();\n\t}\n\n\treanchor(anchor: Node | null) {\n\t\tthis.anchor = anchor;\n\t\tif (!this.container || !this.nodes) return;\n\n\t\t//console.log('reanchoring', this.nodes, ' before anchor', this.anchor);\n\t\tthis.insertNodes();\n\t}\n\n\tprivate insertNodes() {\n\t\t// Insertar en la nueva posición\n\t\tthis.nodes.forEach((node) => {\n\t\t\tif (this.anchor) {\n\t\t\t\tthis.container.insertBefore(node, this.anchor);\n\t\t\t} else {\n\t\t\t\tthis.container.appendChild(node);\n\t\t\t}\n\t\t});\n\t}\n\n\tunmount() {\n\t\tif (!this.silent) console.log('Unmounting Component', this);\n\t\tif (this.onUnmount) {\n\t\t\tthis.onUnmount();\n\t\t\tthis.onUnmount = null;\n\t\t}\n\t\tif (this.nodes) {\n\t\t\tthis.nodes.forEach((node) => {\n\t\t\t\tif (node && node.parentNode) {\n\t\t\t\t\tnode.parentNode.removeChild(node);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\tthis.disposables.forEach((d) => {\n\t\t\td.dispose();\n\t\t});\n\t\tthis.disposables = [];\n\t\tthis.nodes = null;\n\t\tthis.container = null;\n\t\tthis.anchor = null;\n\t}\n}\n\nexport function component<T extends Record<string, any>>(factory: TComponentFactory<T>) {\n\treturn (props?: WithSignals<T>) => {\n\t\treturn new Component(factory, null, props);\n\t};\n}\n\ntype ItemFactoryFn<T> = (item: Signal<T>, index: Signal<number>, list: WritableSignal<T[]>) => Node;\ntype KeyFn<T> = (item: T, index: number) => any;\n\nexport class ComponentList<T = any> {\n\tprivate readonly components: Map<string, Component>;\n\tprivate container: Node;\n\tprivate anchor: Node; // Nodes must be inserted before this node\n\tprivate currentKeys: any[] = [];\n\tpublic disposables: any[] = [];\n\n\tconstructor(private readonly itemFactoryFn: ItemFactoryFn<T>, private readonly keyFn: KeyFn<T>, private readonly itemsSignal: WritableSignal<T[]>) {\n\t\tthis.components = new Map();\n\t}\n\n\t/**\n\t * Obtiene todos los componentes\n\t */\n\tprivate getAllComponents(): Component[] {\n\t\treturn Array.from(this.components.values());\n\t}\n\n\t/**\n\t * Limpia todos los componentes\n\t */\n\tprivate clear(): void {\n\t\tArray.from(this.components.values()).forEach((component) => {\n\t\t\tthis.removeComponent(component);\n\t\t});\n\t}\n\n\t/**\n\t * Elimina un componente completo\n\t */\n\tprivate removeComponent(component: Component) {\n\t\tcomponent.unmount();\n\t\tif (component.key) {\n\t\t\tthis.components.delete(component.key);\n\t\t}\n\t}\n\n\t/**\n\t * Crea un nuevo componente\n\t */\n\tprivate createNewComponent(key: any): Component {\n\t\tconst factory = () => {\n\t\t\tconst item = computed(() => this.itemsSignal.get().find((v, index) => this.keyFn(v, index) === key));\n\t\t\tconst index = computed(() => this.itemsSignal.get().findIndex((v, index) => this.keyFn(v, index) === key));\n\t\t\treturn this.itemFactoryFn ? this.itemFactoryFn(item, index, this.itemsSignal) : null;\n\t\t};\n\n\t\tconst component = new Component(factory, key);\n\t\tthis.components.set(key, component);\n\n\t\treturn component;\n\t}\n\n\tprivate getTargetAnchor(items: T[], index: number): Node | null {\n\t\tconst nextItem = index + 1 < items.length ? items[index + 1] : null;\n\t\tconst nextComp = nextItem ? this.components.get(this.keyFn(nextItem, index + 1)) : null;\n\t\tif (nextComp && nextComp.nodes) {\n\t\t\treturn nextComp.nodes[0];\n\t\t} else {\n\t\t\t// Es el último componente, debería insertarse antes del anchor original\n\t\t\treturn this.anchor;\n\t\t}\n\t}\n\n\t/**\n\t * Función principal que sincroniza los componentes DOM con un array de keys\n\t */\n\tprivate synchronizeComponents(): void {\n\t\tconst existingComponents = this.getAllComponents();\n\n\t\t// Identificar qué componentes eliminar (los que no están en keys)\n\t\tconst items = this.itemsSignal.get();\n\t\tconst keys = items.map((item, index) => this.keyFn(item, index));\n\t\tconst componentsToRemove = existingComponents.filter((component) => component.key && !keys.includes(component.key));\n\t\tcomponentsToRemove.forEach((component) => this.removeComponent(component));\n\n\t\tthis.currentKeys = this.currentKeys.filter((key) => keys.includes(key));\n\t\t//console.log('Current keys:', this.currentKeys, 'Target keys:', keys);\n\n\t\t// Procesar cada key en el orden deseado\n\t\tconst container = this.container;\n\n\t\titems.forEach((item, index) => {\n\t\t\tconst targetKey = this.keyFn(item, index);\n\t\t\tconst currentKey = this.currentKeys[index];\n\t\t\tif (targetKey === currentKey) {\n\t\t\t\t// La key no ha cambiado de posición, no hacer nada\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst existingComponent = this.components.get(targetKey);\n\n\t\t\tif (existingComponent) {\n\t\t\t\tconst prevComp = this.components.get(currentKey);\n\t\t\t\texistingComponent.reanchor(prevComp.nodes[0]);\n\t\t\t\t// Reordenar el array de keys actuales\n\t\t\t\tthis.currentKeys = this.currentKeys.filter((k) => k !== targetKey);\n\t\t\t\tthis.currentKeys.splice(index, 0, targetKey);\n\t\t\t} else {\n\t\t\t\t// El componente no existe, crearlo\n\t\t\t\tconst targetAnchor = this.getTargetAnchor(items, index);\n\t\t\t\tconst newComponent = this.createNewComponent(targetKey);\n\t\t\t\tnewComponent.mount(container, targetAnchor);\n\t\t\t\tthis.currentKeys.splice(index, 0, targetKey);\n\t\t\t}\n\t\t});\n\t}\n\n\tmount(container: Node, anchor: Node) {\n\t\t//console.log('Mounting ComponentList');\n\t\tthis.container = container;\n\t\tthis.anchor = anchor;\n\n\t\tglobalContext.pushComponentStack(this);\n\t\tglobalContext.addReactivity(() => {\n\t\t\tthis.synchronizeComponents();\n\t\t});\n\t\tglobalContext.popComponentStack();\n\t}\n\n\tunmount() {\n\t\t//console.log('Unmounting ComponentList');\n\t\tthis.clear();\n\t\tthis.container = null!;\n\t\tthis.anchor = null!;\n\t\tthis.disposables.forEach((d) => {\n\t\t\td.dispose();\n\t\t});\n\t}\n}\n\nexport function componentList<T>(itemFactoryFn: ItemFactoryFn<T>, keyFn: KeyFn<T>) {\n\t// TODO?: add props\n\treturn (listSignal: WritableSignal<T[]>) => {\n\t\tconst list = new ComponentList(itemFactoryFn, keyFn, listSignal);\n\t\treturn list;\n\t};\n}\n","import { Component, ComponentList } from './components';\nimport { globalContext } from './context';\nimport { isSignal, Signal } from './signals';\n\nexport type TClasses = Record<string, boolean>;\nexport type TNode = string | number | Node | null;\nexport type TContent = TNode | TNode[] | Component | ComponentList | Signal<TNode | TNode[] | Component | ComponentList>;\nexport type TCSSPropertiesStrings = {\n\t[K in keyof CSSStyleDeclaration]?: string | Signal<string>;\n};\n\ntype AllowSignals<T> = { [K in keyof T]: T[K] | Signal<T[K]> };\n\ntype TItemBuilderBaseProps<T> = AllowSignals<Omit<Partial<T>, 'style' | 'dataset'>>;\ninterface IItemBuilderAdditionalProps<T, TItems> {\n\taddClass?: string;\n\tclasses?: TClasses;\n\titems?: TItems;\n\tinner?: TContent;\n\tstyle?: TCSSPropertiesStrings;\n\tdataset?: Record<string, string>;\n\t_ref?: (node: T) => void | { current: T | null };\n}\nexport type TItemBuilderProps<T, TItems> = TItemBuilderBaseProps<T> & IItemBuilderAdditionalProps<T, TItems>;\n\nfunction makeclass(classes: TClasses) {\n\tlet finalClasses = [];\n\n\tfor (const className in classes) {\n\t\tif (classes[className]) {\n\t\t\tfinalClasses.push(className);\n\t\t}\n\t}\n\n\treturn finalClasses.join(' ').trim();\n}\n\nexport function buildClass(literalValue: string, additionalValue?: string, classes?: TClasses) {\n\tconst parts = [];\n\tif (literalValue) parts.push(literalValue);\n\tif (additionalValue) parts.push(additionalValue);\n\tparts.push(makeclass(classes ?? {}));\n\treturn parts.join(' ').trim();\n}\n\nconst forbiddenProps = ['addClass', 'classes', 'items', 'inner', '_ref'];\n\nexport function getValidProps(props: any) {\n\tconst finalProps: any = {};\n\n\tfor (const propName in props) {\n\t\tif (forbiddenProps.indexOf(propName) === -1) {\n\t\t\tfinalProps[propName] = props[propName];\n\t\t}\n\t}\n\n\tif (props._ref !== undefined) {\n\t\t//finalProps.ref = props._ref;\n\t}\n\n\treturn finalProps;\n}\n\nexport function getItem<T>(Components: T, items: any, itemName: keyof T) {\n\tif (!items || !items[itemName]) {\n\t\treturn null;\n\t}\n\n\tconst item = items[itemName];\n\n\tif (item.constructor && item.constructor.name === 'Object' && !(item instanceof Element)) {\n\t\tconst Comp = Components[itemName] as (props: any) => Element;\n\t\tconst itemProps = item;\n\n\t\treturn Comp(itemProps);\n\t} else {\n\t\treturn item;\n\t}\n}\n\nexport function setAttributes(node: Element, attributes: Record<string, string>) {\n\tfor (const attr in attributes) {\n\t\tconst attrValue = attributes[attr].trim();\n\t\tif (!attrValue) continue;\n\t\t//console.log('setting attr', attr, attrValue )\n\t\tnode.setAttribute(attr, attrValue);\n\t}\n}\n\nexport function setProps<T extends Element>(node: T, props: any) {\n\tif (node instanceof HTMLElement) {\n\t\tif (props.style !== undefined) {\n\t\t\tconst style = props.style;\n\t\t\tfor (const styleKey in style) {\n\t\t\t\tif (isSignal(style[styleKey])) {\n\t\t\t\t\tglobalContext.addReactivity(() => {\n\t\t\t\t\t\tnode.style[styleKey as any] = style[styleKey].get();\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\tnode.style[styleKey as any] = style[styleKey];\n\t\t\t\t}\n\t\t\t}\n\t\t\tdelete props.style;\n\t\t}\n\t\tif (props.dataset !== undefined) {\n\t\t\tconst dataset = props.dataset;\n\t\t\tfor (const datasetKey in dataset) {\n\t\t\t\tif (isSignal(dataset[datasetKey])) {\n\t\t\t\t\tglobalContext.addReactivity(() => {\n\t\t\t\t\t\tnode.dataset[datasetKey] = dataset[datasetKey].get();\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\tnode.dataset[datasetKey] = dataset[datasetKey];\n\t\t\t\t}\n\t\t\t}\n\t\t\tdelete props.dataset;\n\t\t}\n\t}\n\n\tfor (const prop in props) {\n\t\tconst propValue = props[prop];\n\t\t//console.log('setting prop', prop, propValue )\n\t\tif (isSignal(propValue)) {\n\t\t\tglobalContext.addReactivity(() => {\n\t\t\t\t(node as any)[prop] = propValue.get();\n\t\t\t});\n\t\t} else if (propValue === undefined) {\n\t\t\tcontinue;\n\t\t} else {\n\t\t\t(node as any)[prop] = propValue;\n\t\t}\n\t}\n}\n\nexport function appendChild(node: Element | DocumentFragment, child: TContent) {\n\tif (child === null) return;\n\tif (isSignal(child)) {\n\t\tprocessSignalChild(node, child);\n\t\treturn;\n\t}\n\tif (child instanceof Component || child instanceof ComponentList) {\n\t\tchild.mount(node, null);\n\t\treturn;\n\t}\n\tif (Array.isArray(child)) {\n\t\tchild.forEach((ch) => {\n\t\t\tappendChild(node, ch);\n\t\t});\n\t\treturn;\n\t}\n\tnode.appendChild(child instanceof Node ? child : document.createTextNode(child.toString()));\n}\n\nfunction processSignalChild(node: Element | DocumentFragment, child: Signal<TNode | Component<any> | ComponentList<any> | TNode[]>) {\n\tconst anchor = document.createTextNode('');\n\tnode.appendChild(anchor);\n\tlet prevValue: Component | ComponentList = null;\n\n\tglobalContext.addReactivity(() => {\n\t\t//console.log('Signal child changed', child);\n\t\tconst ch = child.get();\n\t\tif (prevValue) {\n\t\t\tprevValue.unmount();\n\t\t}\n\t\tif (ch === null) {\n\t\t\tprevValue = null;\n\t\t\treturn;\n\t\t}\n\n\t\tlet component: Component | ComponentList;\n\t\tif (ch instanceof Component || ch instanceof ComponentList) {\n\t\t\tch.mount(node, anchor);\n\t\t\tcomponent = ch;\n\t\t} else {\n\t\t\tconst wrCmp = new Component(() => toNode(ch));\n\t\t\t//wrCmp.silent = true;\n\t\t\twrCmp.mount(node, anchor);\n\t\t\tcomponent = wrCmp;\n\t\t}\n\t\tprevValue = component;\n\t});\n}\n\nfunction toNode(n: TNode | TNode[]): Node {\n\tif (Array.isArray(n)) {\n\t\tconst frag = document.createDocumentFragment();\n\t\tfrag.append(...n.map((c) => toNode(c)));\n\t\treturn frag;\n\t} else if (n instanceof Node) {\n\t\treturn n;\n\t} else if (typeof n === 'string' || typeof n === 'number') {\n\t\treturn document.createTextNode(n.toString());\n\t} else {\n\t\treturn null;\n\t\t//throw new Error('Invalid node type');\n\t}\n}\n"],"mappings":";AASA,IAAM,aAAN,MAAiB;AAAA,EAAjB;AACC,SAAQ,yBAAuC,CAAC;AAEhD,SAAQ,iBAAsB;AAI9B;AAAA,SAAQ,oBAAoB,oBAAI,IAAgB;AAEhD,SAAQ,iBAAsC,CAAC;AAE/C,SAAQ,iBAAgD,CAAC;AAAA;AAAA,EAEzD,mBAAmB,KAAgC;AAClD,SAAK,eAAe,KAAK,GAAG;AAAA,EAC7B;AAAA,EAEA,oBAAoB;AACnB,SAAK,eAAe,IAAI;AAAA,EACzB;AAAA,EAEA,sBAAsB;AACrB,QAAI,KAAK,eAAe,WAAW,GAAG;AAErC,a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A,EACR,WAAW,aAAa,MAAM;AAC7B,WAAO;AAAA,EACR,WAAW,OAAO,MAAM,YAAY,OAAO,MAAM,UAAU;AAC1D,WAAO,SAAS,eAAe,EAAE,SAAS,CAAC;AAAA,EAC5C,OAAO;AACN,WAAO;AAAA,EAER;AACD;","names":["component","signal","component","index","component"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "chispa",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A fully declarative UI reactive framework for building web applications.",
|
|
5
|
+
"author": "José Carlos HR <joecarlhr@gmail.com>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./vite-plugin": {
|
|
19
|
+
"types": "./dist/html-compiler/vite-plugin.d.ts",
|
|
20
|
+
"import": "./dist/html-compiler/vite-plugin.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"bin": {
|
|
24
|
+
"chispa-cli": "dist/html-compiler/cli.js"
|
|
25
|
+
},
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/joecarl/chispa.git"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/jsdom": "^27.0.0",
|
|
32
|
+
"jsdom": "^27.4.0",
|
|
33
|
+
"tsup": "^8.5.1",
|
|
34
|
+
"typescript": "^5.9.3",
|
|
35
|
+
"vitest": "^4.0.16"
|
|
36
|
+
},
|
|
37
|
+
"bugs": {
|
|
38
|
+
"url": "https://github.com/joecarl/chispa/issues"
|
|
39
|
+
},
|
|
40
|
+
"homepage": "https://github.com/joecarl/chispa#readme",
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "tsup",
|
|
43
|
+
"start": "echo \"Error: no dev mode available\" && exit 1",
|
|
44
|
+
"test": "vitest",
|
|
45
|
+
"prepublishOnly": "npm run build"
|
|
46
|
+
}
|
|
47
|
+
}
|