@ryupold/vode 0.12.3 → 0.13.1
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/.github/workflows/npm-publish.yml +2 -1
- package/package.json +1 -1
- package/src/vode.ts +12 -21
- package/vode.mjs +4 -15
package/package.json
CHANGED
package/src/vode.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export type Vode<S> = FullVode<S> | JustTagVode | NoPropsVode<S>;
|
|
2
|
-
export type ChildVode<S> = Vode<S> | TextVode | NoVode | Component<S>;
|
|
3
2
|
export type FullVode<S> = [tag: Tag, props: Props<S>, ...children: ChildVode<S>[]];
|
|
4
3
|
export type NoPropsVode<S> = [tag: Tag, ...children: ChildVode<S>[]] | string[];
|
|
5
4
|
export type JustTagVode = [tag: Tag];
|
|
5
|
+
export type ChildVode<S> = Vode<S> | TextVode | NoVode | Component<S>;
|
|
6
6
|
export type TextVode = string;
|
|
7
7
|
export type NoVode = undefined | null | number | boolean | bigint | void;
|
|
8
8
|
export type AttachedVode<S> = Vode<S> & { node: ChildNode, id?: string } | Text & { node?: never, id?: never };
|
|
@@ -11,12 +11,12 @@ export type Component<S> = (s: S) => ChildVode<S>;
|
|
|
11
11
|
|
|
12
12
|
export type Patch<S> =
|
|
13
13
|
| NoRenderPatch // ignored
|
|
14
|
-
|
|
|
14
|
+
| RenderPatch<S>
|
|
15
15
|
| Promise<Patch<S>> | Effect<S>; // effects resulting in patches
|
|
16
16
|
|
|
17
17
|
export type NoRenderPatch = undefined | null | number | boolean | bigint | string | symbol | void;
|
|
18
|
-
|
|
19
|
-
export type DeepPartial<S> = { [P in keyof S]?: S[P] extends Array<infer I> ? Array<
|
|
18
|
+
export type RenderPatch<S> = {} | DeepPartial<S>;
|
|
19
|
+
export type DeepPartial<S> = { [P in keyof S]?: S[P] extends Array<infer I> ? Array<DeepPartial<I>> : DeepPartial<S[P]> };
|
|
20
20
|
|
|
21
21
|
export type Effect<S> =
|
|
22
22
|
| (() => Patch<S>)
|
|
@@ -62,8 +62,10 @@ export type EventsMap =
|
|
|
62
62
|
& { [K in keyof SVGElementEventMap as `on${K}`]: SVGElementEventMap[K] }
|
|
63
63
|
& { onsearch: Event };
|
|
64
64
|
|
|
65
|
-
export type PropertyValue<S> =
|
|
66
|
-
|
|
65
|
+
export type PropertyValue<S> =
|
|
66
|
+
| string | boolean | null | undefined | void
|
|
67
|
+
| StyleProp | ClassProp
|
|
68
|
+
| Patch<S>;
|
|
67
69
|
|
|
68
70
|
export type Dispatch<S> = (action: Patch<S>) => void;
|
|
69
71
|
export type PatchableState<S> = S & { patch: Dispatch<Patch<S>> };
|
|
@@ -319,16 +321,6 @@ export function childrenStart<S>(vode: ChildVode<S> | AttachedVode<S>): number {
|
|
|
319
321
|
return props(vode) ? 2 : 1;
|
|
320
322
|
}
|
|
321
323
|
|
|
322
|
-
/** @returns multiple merged objects as one, applying from left to right ({}, first, ...p) */
|
|
323
|
-
export function merge(first?: object | unknown, ...p: (object | unknown)[]): object {
|
|
324
|
-
first = mergeState({}, first);
|
|
325
|
-
for (const pp of p) {
|
|
326
|
-
if (!pp) continue;
|
|
327
|
-
first = mergeState(first, pp);
|
|
328
|
-
}
|
|
329
|
-
return first!;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
324
|
function mergeState(target: any, source: any) {
|
|
333
325
|
if (!source) return target;
|
|
334
326
|
|
|
@@ -663,13 +655,12 @@ function patchProperty<S>(patch: Dispatch<S>, node: ChildNode, key: string | key
|
|
|
663
655
|
}
|
|
664
656
|
|
|
665
657
|
function classString(classProp: ClassProp): string {
|
|
666
|
-
if (typeof classProp === "string")
|
|
658
|
+
if (typeof classProp === "string")
|
|
667
659
|
return classProp;
|
|
668
|
-
|
|
660
|
+
else if (Array.isArray(classProp))
|
|
669
661
|
return classProp.map(classString).join(" ");
|
|
670
|
-
|
|
662
|
+
else if (typeof classProp === "object")
|
|
671
663
|
return Object.keys(classProp!).filter(k => classProp![k]).join(" ");
|
|
672
|
-
|
|
664
|
+
else
|
|
673
665
|
return "";
|
|
674
|
-
}
|
|
675
666
|
}
|
package/vode.mjs
CHANGED
|
@@ -187,15 +187,6 @@ function child(vode2, index) {
|
|
|
187
187
|
function childrenStart(vode2) {
|
|
188
188
|
return props(vode2) ? 2 : 1;
|
|
189
189
|
}
|
|
190
|
-
function merge(first, ...p) {
|
|
191
|
-
first = mergeState({}, first);
|
|
192
|
-
for (const pp of p) {
|
|
193
|
-
if (!pp)
|
|
194
|
-
continue;
|
|
195
|
-
first = mergeState(first, pp);
|
|
196
|
-
}
|
|
197
|
-
return first;
|
|
198
|
-
}
|
|
199
190
|
function mergeState(target, source) {
|
|
200
191
|
if (!source)
|
|
201
192
|
return target;
|
|
@@ -478,15 +469,14 @@ function patchProperty(patch, node, key, oldValue, newValue, isSvg) {
|
|
|
478
469
|
return newValue;
|
|
479
470
|
}
|
|
480
471
|
function classString(classProp) {
|
|
481
|
-
if (typeof classProp === "string")
|
|
472
|
+
if (typeof classProp === "string")
|
|
482
473
|
return classProp;
|
|
483
|
-
|
|
474
|
+
else if (Array.isArray(classProp))
|
|
484
475
|
return classProp.map(classString).join(" ");
|
|
485
|
-
|
|
476
|
+
else if (typeof classProp === "object")
|
|
486
477
|
return Object.keys(classProp).filter((k) => classProp[k]).join(" ");
|
|
487
|
-
|
|
478
|
+
else
|
|
488
479
|
return "";
|
|
489
|
-
}
|
|
490
480
|
}
|
|
491
481
|
// src/vode-tags.ts
|
|
492
482
|
var A = "a";
|
|
@@ -727,7 +717,6 @@ export {
|
|
|
727
717
|
tag,
|
|
728
718
|
props,
|
|
729
719
|
mergeClass,
|
|
730
|
-
merge,
|
|
731
720
|
memo,
|
|
732
721
|
htmlToVode,
|
|
733
722
|
createState,
|