valyrian.js 7.2.12 → 8.0.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.
Files changed (168) hide show
  1. package/README.md +6 -6
  2. package/dist/flux-store/index.d.ts +32 -0
  3. package/dist/flux-store/index.d.ts.map +1 -0
  4. package/dist/flux-store/index.js +267 -0
  5. package/dist/flux-store/index.js.map +7 -0
  6. package/dist/flux-store/index.min.js +1 -0
  7. package/dist/flux-store/index.min.js.map +1 -0
  8. package/dist/flux-store/index.mjs +246 -0
  9. package/dist/flux-store/index.mjs.map +7 -0
  10. package/dist/hooks/index.d.ts.map +1 -1
  11. package/dist/hooks/index.js +35 -51
  12. package/dist/hooks/index.js.map +3 -3
  13. package/dist/hooks/index.min.js +1 -0
  14. package/dist/hooks/index.min.js.map +1 -0
  15. package/dist/hooks/index.mjs +36 -52
  16. package/dist/hooks/index.mjs.map +3 -3
  17. package/dist/index.d.ts +18 -14
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +107 -88
  20. package/dist/index.js.map +3 -3
  21. package/dist/index.min.js +1 -1
  22. package/dist/index.min.js.map +1 -1
  23. package/dist/index.mjs +107 -88
  24. package/dist/index.mjs.map +3 -3
  25. package/dist/native-store/index.d.ts +14 -0
  26. package/dist/native-store/index.d.ts.map +1 -0
  27. package/dist/native-store/index.js +103 -0
  28. package/dist/native-store/index.js.map +7 -0
  29. package/dist/native-store/index.min.js +1 -0
  30. package/dist/native-store/index.min.js.map +1 -0
  31. package/dist/native-store/index.mjs +82 -0
  32. package/dist/native-store/index.mjs.map +7 -0
  33. package/dist/node/index.d.ts +1 -1
  34. package/dist/node/index.d.ts.map +1 -1
  35. package/dist/node/index.js +125 -10
  36. package/dist/node/index.js.map +4 -4
  37. package/dist/node/index.mjs +125 -10
  38. package/dist/node/index.mjs.map +4 -4
  39. package/dist/node/node.sw.js +152 -0
  40. package/dist/node/utils/icons.d.ts +4 -5
  41. package/dist/node/utils/icons.d.ts.map +1 -1
  42. package/dist/node/utils/inline.d.ts +1 -1
  43. package/dist/node/utils/inline.d.ts.map +1 -1
  44. package/dist/node/utils/node.sw.js +152 -0
  45. package/dist/node/utils/session-storage.d.ts +22 -0
  46. package/dist/node/utils/session-storage.d.ts.map +1 -0
  47. package/dist/node/utils/sw.d.ts.map +1 -1
  48. package/dist/node/utils/tree-adapter.d.ts +5 -1
  49. package/dist/node/utils/tree-adapter.d.ts.map +1 -1
  50. package/dist/pulse-store/index.d.ts +16 -0
  51. package/dist/pulse-store/index.d.ts.map +1 -0
  52. package/dist/pulse-store/index.js +143 -0
  53. package/dist/pulse-store/index.js.map +7 -0
  54. package/dist/pulse-store/index.min.js +1 -0
  55. package/dist/pulse-store/index.min.js.map +1 -0
  56. package/dist/pulse-store/index.mjs +122 -0
  57. package/dist/pulse-store/index.mjs.map +7 -0
  58. package/dist/request/index.d.ts +11 -11
  59. package/dist/request/index.d.ts.map +1 -1
  60. package/dist/request/index.js +63 -84
  61. package/dist/request/index.js.map +2 -2
  62. package/dist/request/index.min.js +1 -0
  63. package/dist/request/index.min.js.map +1 -0
  64. package/dist/request/index.mjs +63 -84
  65. package/dist/request/index.mjs.map +2 -2
  66. package/dist/router/index.d.ts +36 -33
  67. package/dist/router/index.d.ts.map +1 -1
  68. package/dist/router/index.js +247 -96
  69. package/dist/router/index.js.map +3 -3
  70. package/dist/router/index.min.js +1 -0
  71. package/dist/router/index.min.js.map +1 -0
  72. package/dist/router/index.mjs +247 -96
  73. package/dist/router/index.mjs.map +3 -3
  74. package/dist/signals/index.d.ts +6 -0
  75. package/dist/signals/index.d.ts.map +1 -0
  76. package/dist/signals/index.js +92 -0
  77. package/dist/signals/index.js.map +7 -0
  78. package/dist/signals/index.min.js +1 -0
  79. package/dist/signals/index.min.js.map +1 -0
  80. package/dist/signals/index.mjs +71 -0
  81. package/dist/signals/index.mjs.map +7 -0
  82. package/dist/suspense/index.d.ts +6 -0
  83. package/dist/suspense/index.d.ts.map +1 -0
  84. package/dist/suspense/index.js +67 -0
  85. package/dist/suspense/index.js.map +7 -0
  86. package/dist/suspense/index.min.js +1 -0
  87. package/dist/suspense/index.min.js.map +1 -0
  88. package/dist/suspense/index.mjs +46 -0
  89. package/dist/suspense/index.mjs.map +7 -0
  90. package/dist/sw/index.min.js +1 -0
  91. package/dist/sw/index.min.js.map +1 -0
  92. package/dist/translate/index.d.ts +19 -0
  93. package/dist/translate/index.d.ts.map +1 -0
  94. package/dist/translate/index.js +150 -0
  95. package/dist/translate/index.js.map +7 -0
  96. package/dist/translate/index.min.js +1 -0
  97. package/dist/translate/index.min.js.map +1 -0
  98. package/dist/translate/index.mjs +129 -0
  99. package/dist/translate/index.mjs.map +7 -0
  100. package/dist/tsconfig.tsbuildinfo +1 -1
  101. package/dist/utils/deep-freeze.d.ts +3 -0
  102. package/dist/utils/deep-freeze.d.ts.map +1 -0
  103. package/dist/utils/getter-setter.d.ts +3 -0
  104. package/dist/utils/getter-setter.d.ts.map +1 -0
  105. package/dist/utils/has-changed.d.ts +2 -0
  106. package/dist/utils/has-changed.d.ts.map +1 -0
  107. package/dist/utils/index.d.ts +4 -0
  108. package/dist/utils/index.d.ts.map +1 -0
  109. package/dist/utils/index.js +138 -0
  110. package/dist/utils/index.js.map +7 -0
  111. package/dist/utils/index.min.js +1 -0
  112. package/dist/utils/index.min.js.map +1 -0
  113. package/dist/utils/index.mjs +115 -0
  114. package/dist/utils/index.mjs.map +7 -0
  115. package/lib/flux-store/index.ts +312 -0
  116. package/lib/hooks/index.ts +39 -57
  117. package/lib/index.ts +135 -118
  118. package/lib/native-store/index.ts +106 -0
  119. package/lib/node/index.ts +3 -1
  120. package/lib/node/utils/icons.ts +4 -4
  121. package/lib/node/utils/inline.ts +2 -0
  122. package/lib/node/utils/node.sw.js +152 -0
  123. package/lib/node/utils/session-storage.ts +117 -0
  124. package/lib/node/utils/sw.ts +34 -10
  125. package/lib/node/utils/tree-adapter.ts +19 -1
  126. package/lib/pulse-store/index.ts +188 -0
  127. package/lib/request/index.ts +92 -122
  128. package/lib/router/index.ts +353 -164
  129. package/lib/signals/index.ts +98 -0
  130. package/lib/suspense/index.ts +57 -0
  131. package/lib/translate/index.ts +156 -0
  132. package/lib/utils/deep-freeze.ts +54 -0
  133. package/lib/utils/getter-setter.ts +40 -0
  134. package/lib/utils/has-changed.ts +43 -0
  135. package/lib/utils/index.ts +3 -0
  136. package/package.json +40 -57
  137. package/tsconfig.json +5 -4
  138. package/dist/dataset/index.d.ts +0 -24
  139. package/dist/dataset/index.d.ts.map +0 -1
  140. package/dist/dataset/index.js +0 -178
  141. package/dist/dataset/index.js.map +0 -7
  142. package/dist/dataset/index.mjs +0 -157
  143. package/dist/dataset/index.mjs.map +0 -7
  144. package/dist/node/node.sw.tpl +0 -133
  145. package/dist/node/utils/node.sw.tpl +0 -133
  146. package/dist/proxy-signal/index.d.ts +0 -23
  147. package/dist/proxy-signal/index.d.ts.map +0 -1
  148. package/dist/proxy-signal/index.js +0 -138
  149. package/dist/proxy-signal/index.js.map +0 -7
  150. package/dist/proxy-signal/index.mjs +0 -117
  151. package/dist/proxy-signal/index.mjs.map +0 -7
  152. package/dist/signal/index.d.ts +0 -9
  153. package/dist/signal/index.d.ts.map +0 -1
  154. package/dist/signal/index.js +0 -76
  155. package/dist/signal/index.js.map +0 -7
  156. package/dist/signal/index.mjs +0 -55
  157. package/dist/signal/index.mjs.map +0 -7
  158. package/dist/store/index.d.ts +0 -16
  159. package/dist/store/index.d.ts.map +0 -1
  160. package/dist/store/index.js +0 -93
  161. package/dist/store/index.js.map +0 -7
  162. package/dist/store/index.mjs +0 -72
  163. package/dist/store/index.mjs.map +0 -7
  164. package/lib/dataset/index.ts +0 -193
  165. package/lib/node/utils/node.sw.tpl +0 -133
  166. package/lib/proxy-signal/index.ts +0 -187
  167. package/lib/signal/index.ts +0 -86
  168. package/lib/store/index.ts +0 -101
@@ -0,0 +1,98 @@
1
+ import { current, updateVnode, Vnode, VnodeWithDom } from "valyrian.js";
2
+ import { get, set, hasChanged } from "valyrian.js/utils";
3
+
4
+ const effectStack: Function[] = [];
5
+
6
+ // eslint-disable-next-line no-unused-vars
7
+ export type Signal<T> = [() => T, (newValue: T | ((current: T) => T)) => void, () => void];
8
+
9
+ export function createSignal<T>(initialValue: T): Signal<T> {
10
+ let value = initialValue;
11
+ const subscribers = new Set<Function>();
12
+ const vnodesToUpdate = new WeakSet<Vnode>();
13
+
14
+ const runSubscribers = () => subscribers.forEach((subscriber) => subscriber());
15
+
16
+ const read = () => {
17
+ const currentEffect = effectStack[effectStack.length - 1];
18
+ if (currentEffect && !subscribers.has(currentEffect)) {
19
+ subscribers.add(currentEffect);
20
+ }
21
+
22
+ const currentVnode = current.vnode as VnodeWithDom;
23
+ if (currentVnode && !vnodesToUpdate.has(currentVnode)) {
24
+ const subscription = () => {
25
+ if (!currentVnode.dom) {
26
+ subscribers.delete(subscription);
27
+ vnodesToUpdate.delete(currentVnode);
28
+ return;
29
+ }
30
+ updateVnode(currentVnode);
31
+ };
32
+
33
+ subscribers.add(subscription);
34
+ vnodesToUpdate.add(currentVnode);
35
+ }
36
+
37
+ return value;
38
+ };
39
+
40
+ // eslint-disable-next-line no-unused-vars
41
+ const write = (newValue: T | ((current: T) => T)) => {
42
+ // eslint-disable-next-line no-unused-vars
43
+ const resolvedValue = typeof newValue === "function" ? (newValue as (current: T) => T)(value) : newValue;
44
+
45
+ if (current.event && !current.event.defaultPrevented) {
46
+ current.event.preventDefault();
47
+ }
48
+
49
+ if (!hasChanged(value, resolvedValue)) {
50
+ return;
51
+ }
52
+
53
+ value = resolvedValue;
54
+
55
+ runSubscribers();
56
+ };
57
+
58
+ return [read, write, runSubscribers];
59
+ }
60
+
61
+ export function createEffect(effect: Function) {
62
+ const runEffect = () => {
63
+ try {
64
+ effectStack.push(runEffect);
65
+ effect();
66
+ } finally {
67
+ effectStack.pop();
68
+ }
69
+ };
70
+
71
+ runEffect();
72
+ }
73
+
74
+ // Path is a string with dot notation, e.g:
75
+ // 'a.b.c' === obj.a.b.c
76
+ // 'a.0.c' === obj.a[0].c
77
+ // eslint-disable-next-line no-unused-vars
78
+ export type SignalStore<T> = [() => T, (path: string, newValue: T | ((current: T) => T) | any) => void];
79
+
80
+ export function createSignalStore<T>(initialState: T): SignalStore<T> {
81
+ const [state, , runSubscribers] = createSignal(initialState);
82
+
83
+ // eslint-disable-next-line no-unused-vars
84
+ const setter = (path: string, newValue: T | ((current: T) => T)) => {
85
+ const current = get(initialState, path);
86
+ // eslint-disable-next-line no-unused-vars
87
+ const resolvedValue = typeof newValue === "function" ? (newValue as (current: T) => T)(current) : newValue;
88
+
89
+ if (!hasChanged(current, resolvedValue)) {
90
+ return;
91
+ }
92
+
93
+ set(initialState, path, resolvedValue);
94
+ runSubscribers();
95
+ };
96
+
97
+ return [state, setter];
98
+ }
@@ -0,0 +1,57 @@
1
+ import { ValyrianComponent, Vnode, isVnodeComponent, isPOJOComponent, isComponent, v, Children } from "valyrian.js";
2
+ import { useState } from "valyrian.js/hooks";
3
+
4
+ export function Suspense(
5
+ {
6
+ fallback,
7
+ error
8
+ }: // eslint-disable-next-line no-unused-vars
9
+ { fallback: any | Vnode | ValyrianComponent; error?: (e: Error) => any | Vnode | ValyrianComponent },
10
+ children: Children
11
+ ) {
12
+ const [loadedChildren, setLoadedChildren] = useState(null);
13
+ const [err, setErr] = useState(null);
14
+
15
+ return v(() => {
16
+ if (err()) {
17
+ if (error) {
18
+ return error(err());
19
+ }
20
+ return err().message;
21
+ }
22
+
23
+ if (loadedChildren()) {
24
+ return loadedChildren();
25
+ }
26
+
27
+ Promise.all(
28
+ children.map((child) => {
29
+ if (isVnodeComponent(child)) {
30
+ if (isPOJOComponent(child.tag)) {
31
+ return child.tag.view.bind(child.tag)(child.props || {}, child.children);
32
+ }
33
+
34
+ return child.tag(child.props || {}, child.children);
35
+ }
36
+
37
+ if (isPOJOComponent(child)) {
38
+ return child.view.bind(child)({}, []);
39
+ }
40
+
41
+ if (isComponent(child)) {
42
+ return child({}, []);
43
+ }
44
+
45
+ return child;
46
+ })
47
+ )
48
+ .then((newChildren) => {
49
+ setLoadedChildren(newChildren);
50
+ })
51
+ .catch((e) => {
52
+ setErr(e);
53
+ });
54
+
55
+ return fallback;
56
+ }, {});
57
+ }
@@ -0,0 +1,156 @@
1
+ import { directive, setPropNameReserved, update, VnodeWithDom } from "valyrian.js";
2
+ import { get } from "valyrian.js/utils";
3
+
4
+ const translations: Record<string, Record<string, any>> = {};
5
+ let lang = "en";
6
+
7
+ export function t(path: string, params?: Record<string, string>): string {
8
+ const langDef = translations[lang];
9
+ const translation = get(langDef, path);
10
+
11
+ if (typeof translation !== "string") {
12
+ // eslint-disable-next-line no-console
13
+ console.warn(`Translation not found for ${path}`);
14
+ return path;
15
+ }
16
+
17
+ if (!params) {
18
+ return translation;
19
+ }
20
+
21
+ return translation.replace(/{(\w+)}/g, (_, key) => {
22
+ if (key in params) {
23
+ return params[key];
24
+ }
25
+ return `{${key}}`;
26
+ });
27
+ }
28
+
29
+ export function setTranslations(
30
+ defaultTranslation: Record<string, any>,
31
+ newTranslations: Record<string, Record<string, any>> = {}
32
+ ) {
33
+ for (const lang in translations) {
34
+ Reflect.deleteProperty(translations, lang);
35
+ }
36
+
37
+ translations.en = { ...defaultTranslation };
38
+
39
+ for (const lang in newTranslations) {
40
+ translations[lang] = {
41
+ ...defaultTranslation,
42
+ ...newTranslations[lang]
43
+ };
44
+ }
45
+ update();
46
+ }
47
+
48
+ export function getTranslations(): Record<string, Record<string, any>> {
49
+ return translations;
50
+ }
51
+
52
+ export function setLang(newLang: string): void {
53
+ if (typeof newLang !== "string") {
54
+ throw new Error(`Language ${newLang} not found`);
55
+ }
56
+
57
+ const parsedLang = newLang.toLowerCase().split("-").shift()?.split("_").shift();
58
+
59
+ if (typeof parsedLang !== "string") {
60
+ throw new Error(`Language ${newLang} not found`);
61
+ }
62
+
63
+ if (!translations[parsedLang]) {
64
+ throw new Error(`Language ${newLang} not found`);
65
+ }
66
+
67
+ lang = parsedLang;
68
+ update();
69
+ }
70
+
71
+ export function getLang(): string {
72
+ return lang;
73
+ }
74
+
75
+ export class NumberFormatter {
76
+ #value: number = 0;
77
+
78
+ get value(): number {
79
+ return this.#value;
80
+ }
81
+
82
+ private constructor() {}
83
+
84
+ public set(newValue: number | string, shiftDecimal = false) {
85
+ this.#value = this.clean(newValue, shiftDecimal);
86
+ return this;
87
+ }
88
+
89
+ private clean(value: string | number, shiftDecimal = false): number {
90
+ let stringNumber = String(value).replace(/[^0-9.-]+/g, "");
91
+
92
+ if (shiftDecimal) {
93
+ stringNumber = stringNumber.replace(/\./g, "");
94
+ }
95
+
96
+ const number = Number(stringNumber);
97
+
98
+ return isNaN(number) ? 0 : number;
99
+ }
100
+
101
+ format(digits = 2, options: Intl.NumberFormatOptions = {}, customLocale?: Intl.LocalesArgument): string {
102
+ const lang = customLocale || getLang();
103
+ const formatter = new Intl.NumberFormat(lang as string, {
104
+ style: "currency",
105
+ currency: "USD",
106
+ minimumFractionDigits: digits,
107
+ maximumFractionDigits: digits,
108
+ ...options
109
+ });
110
+
111
+ return formatter.format(this.#value);
112
+ }
113
+
114
+ fromDecimalPlaces(decimalPlaces: number) {
115
+ const currentDecimalPlaces = this.getDecimalPlaces();
116
+ const factor = Math.pow(10, decimalPlaces - currentDecimalPlaces);
117
+ this.#value = Number((this.#value / factor).toFixed(decimalPlaces));
118
+ return this;
119
+ }
120
+
121
+ // Ex toDecimalPlaces(1) = 123.456 -> 12345.6
122
+ toDecimalPlaces(decimalPlaces: number) {
123
+ const currentDecimalPlaces = this.getDecimalPlaces();
124
+ const factor = Math.pow(10, currentDecimalPlaces - decimalPlaces);
125
+ this.#value = Number((this.#value * factor).toFixed(decimalPlaces));
126
+ return this;
127
+ }
128
+
129
+ getDecimalPlaces(): number {
130
+ if (Math.floor(this.#value) === this.#value) {
131
+ return 0;
132
+ }
133
+
134
+ const stringValue = String(this.#value);
135
+ const decimalIndex = stringValue.indexOf(".");
136
+ return decimalIndex === -1 ? 0 : stringValue.length - decimalIndex - 1;
137
+ }
138
+
139
+ shiftDecimalPlaces() {
140
+ return this.toDecimalPlaces(0);
141
+ }
142
+
143
+ static create(value: number | string = 0, shiftDecimal = false): NumberFormatter {
144
+ const formatter = new NumberFormatter();
145
+ return formatter.set(value, shiftDecimal);
146
+ }
147
+ }
148
+
149
+ directive("t", (value: string | null, vnode: VnodeWithDom): void => {
150
+ const keys = typeof value === "string" ? [value] : vnode.children;
151
+ const params = vnode.props["v-t-params"] || {};
152
+ const children = keys.map((key) => (typeof key === "string" && key.trim().length > 1 ? t(key.trim(), params) : key));
153
+ vnode.children = children;
154
+ });
155
+
156
+ setPropNameReserved("v-t-params");
@@ -0,0 +1,54 @@
1
+ export function deepFreeze(obj: any): any {
2
+ if (typeof obj === "object" && obj !== null && !Object.isFrozen(obj)) {
3
+ if (Array.isArray(obj)) {
4
+ for (let i = 0, l = obj.length; i < l; i++) {
5
+ deepFreeze(obj[i]);
6
+ }
7
+ } else {
8
+ const props = Reflect.ownKeys(obj);
9
+ for (let i = 0, l = props.length; i < l; i++) {
10
+ deepFreeze(obj[props[i]]);
11
+ }
12
+
13
+ // If the object is an instance of a class (not a plain object or array) we need to freeze the prototype
14
+ const proto = Object.getPrototypeOf(obj);
15
+ if (proto && proto !== Object.prototype) {
16
+ deepFreeze(proto);
17
+ }
18
+ }
19
+ Object.freeze(obj);
20
+ }
21
+
22
+ return obj;
23
+ }
24
+
25
+ export function deepCloneUnfreeze<T>(obj: T): T {
26
+ if (typeof obj === "undefined" || obj === null || typeof obj !== "object") {
27
+ return obj;
28
+ }
29
+
30
+ // If the object is an instance of a class (not a plain object or array) we need to clone it
31
+ // This could not work with classes that have required parameters in the constructor
32
+ if (obj.constructor && obj.constructor !== Object && obj.constructor !== Array) {
33
+ const clone = Reflect.construct(obj.constructor, []);
34
+
35
+ for (const key of Reflect.ownKeys(obj)) {
36
+ const value = (obj as Record<string | symbol, any>)[key];
37
+ (clone as Record<string | symbol, any>)[key] = deepCloneUnfreeze(value);
38
+ }
39
+
40
+ return clone;
41
+ }
42
+
43
+ if (Array.isArray(obj)) {
44
+ return obj.map((item) => deepCloneUnfreeze(item)) as unknown as T;
45
+ }
46
+
47
+ const clone = {} as T;
48
+ for (const key of Reflect.ownKeys(obj)) {
49
+ const value = (obj as Record<string | symbol, any>)[key];
50
+ (clone as Record<string | symbol, any>)[key] = deepCloneUnfreeze(value);
51
+ }
52
+
53
+ return clone;
54
+ }
@@ -0,0 +1,40 @@
1
+ // Dot notation: get(obj, 'a.b.c' ) === obj.a.b.c
2
+ // get(obj, 'a.0.c') === obj.a[0].c
3
+ export function get(obj: unknown, path: string, defaultValue?: unknown) {
4
+ if (!path || typeof path !== "string" || !obj || typeof obj !== "object") {
5
+ return defaultValue;
6
+ }
7
+
8
+ const result = path.split(".").reduce((acc: any, part) => acc && acc?.[part], obj);
9
+
10
+ if (typeof result === "undefined") {
11
+ return defaultValue || null;
12
+ }
13
+
14
+ return result;
15
+ }
16
+
17
+ // Dot notation: set(obj, 'a.b.c', value) === obj.a.b.c = value
18
+ // set(obj, 'a.0.c', value) === obj.a[0].c = value
19
+ export function set(obj: any, path: string, value: any) {
20
+ if (!path || typeof path !== "string" || !obj || typeof obj !== "object") {
21
+ return;
22
+ }
23
+
24
+ const parts = path.split(".");
25
+ const last = parts.pop();
26
+
27
+ if (!last) {
28
+ return;
29
+ }
30
+
31
+ let target = obj;
32
+ for (const part of parts) {
33
+ if (!target[part]) {
34
+ target[part] = {};
35
+ }
36
+ target = target[part];
37
+ }
38
+
39
+ target[last] = value;
40
+ }
@@ -0,0 +1,43 @@
1
+ // Utility function to check if dependencies have changed recursively
2
+ // eslint-disable-next-line sonarjs/cognitive-complexity
3
+ export function hasChanged(prev: any, current: any) {
4
+ if (Array.isArray(prev)) {
5
+ if (Array.isArray(current) === false) {
6
+ return true;
7
+ }
8
+
9
+ if (prev.length !== current.length) {
10
+ return true;
11
+ }
12
+
13
+ for (let i = 0; i < current.length; i++) {
14
+ if (hasChanged(prev[i], current[i])) {
15
+ return true;
16
+ }
17
+ }
18
+
19
+ return false;
20
+ }
21
+
22
+ if (typeof prev === "object" && prev !== null) {
23
+ if (typeof current !== "object" || current === null) {
24
+ return true;
25
+ }
26
+
27
+ for (const key in current) {
28
+ if (hasChanged(prev[key], current[key])) {
29
+ return true;
30
+ }
31
+ }
32
+
33
+ for (const key in prev) {
34
+ if (hasChanged(prev[key], current[key])) {
35
+ return true;
36
+ }
37
+ }
38
+
39
+ return false;
40
+ }
41
+
42
+ return Object.is(prev, current) === false;
43
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./getter-setter";
2
+ export * from "./has-changed";
3
+ export * from "./deep-freeze";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "valyrian.js",
3
- "version": "7.2.12",
3
+ "version": "8.0.1",
4
4
  "description": "Lightweight steel to forge PWAs. (Minimal Frontend Framework with server side rendering and other capabilities)",
5
5
  "repository": "git@github.com:Masquerade-Circus/valyrian.js.git",
6
6
  "author": "Masquerade <christian@masquerade-circus.net>",
@@ -16,22 +16,12 @@
16
16
  "types": "dist/**/*.d.ts",
17
17
  "exports": {
18
18
  ".": {
19
- "types": "./dist/index.d.ts",
19
+ "types": "./lib/index.ts",
20
20
  "import": "./dist/index.mjs",
21
21
  "require": "./dist/index.js"
22
22
  },
23
- "./lib": {
24
- "types": "./lib/index.ts",
25
- "import": "./lib/index.ts",
26
- "require": "./lib/index.ts"
27
- },
28
- "./lib/*": {
29
- "types": "./lib/*/index.ts",
30
- "import": "./lib/*/index.ts",
31
- "require": "./lib/*/index.ts"
32
- },
33
23
  "./*": {
34
- "types": "./dist/*.d.ts",
24
+ "types": "./lib/*/index.ts",
35
25
  "import": "./dist/*/index.mjs",
36
26
  "require": "./dist/*/index.js"
37
27
  }
@@ -66,70 +56,62 @@
66
56
  "node": ">=18.0.0"
67
57
  },
68
58
  "scripts": {
69
- "dev:source": "NODE_ENV=development nodemon --enable-source-maps -e tsx,ts,json,css -w ./lib -w ./www source.js",
70
- "dev:test": "nodemon --enable-source-maps -e mjs,js,ts,json,css,tsx,jsx -w ./lib -w ./test -w ./dist --exec 'mocha --bail --timeout 15000 --slow 0 --require ./register --enable-source-maps --reporter ./test/reporter.js \"test/**/*_test.js\"'",
71
- "dev:test:nyc": "nodemon --enable-source-maps -w ./test -w ./lib -w ./plugins --exec 'nyc --reporter=text --reporter=lcov mocha --timeout 15000 --slow 0 --require ./register \"test/**/*_test.js\"'",
59
+ "dev:source": "NODE_ENV=development chokidar './lib/**/*.ts' -c 'bun run source.js'",
60
+ "dev:test": "bun test --watch",
72
61
  "dev:web": "browser-sync start --config 'www/bs-config.js'",
73
- "build": "npm run build:source && npm run remark",
74
- "build:source": "cross-env NODE_ENV=production node source.js",
75
- "test": "cross-env NODE_ENV=development nyc mocha --forbid-only --timeout 15000 --slow 0 --require ./register --enable-source-maps --exit \"test/**/*_test.js\"",
76
- "coverage": "nyc report --reporter=lcov",
62
+ "build": "bun run build:source && bun run remark",
63
+ "build:source": "cross-env NODE_ENV=production bun run source.js",
64
+ "test": "cross-env NODE_ENV=development bun test --bail --coverage --coverage-reporter=lcov --coverage-reporter=text",
77
65
  "remark": "remark . -o",
78
- "commit": "git add . && git-cz",
66
+ "commit": "git add . && git-cz && git push",
79
67
  "release": "release-it --verbose",
80
68
  "release-test": "release-it --dry-run --verbose",
81
- "bench": "nodemon -e js,ts,json,css,tsx -w ./bench -w ./lib -w ./plugins --exec 'NODE_OPTIONS=--enable-source-maps buffalo-test --require ./register'"
69
+ "update": "ncu -u && bun install"
82
70
  },
83
71
  "dependencies": {
84
- "clean-css": "^5.3.2",
85
- "esbuild": "^0.19.3",
86
- "favicons": "^7.1.4",
87
- "form-data": "^4.0.0",
88
- "purgecss": "^5.0.0",
72
+ "clean-css": "^5.3.3",
73
+ "esbuild": "^0.24.0",
74
+ "favicons": "^7.2.0",
75
+ "form-data": "^4.0.1",
76
+ "purgecss": "^7.0.2",
89
77
  "remark": "^15.0.1",
90
- "terser": "^5.20.0",
91
- "ts-node": "^10.9.1",
78
+ "terser": "^5.37.0",
79
+ "ts-node": "^10.9.2",
92
80
  "tsc-prog": "^2.3.0",
93
- "tslib": "^2.6.2",
94
- "typescript": "^5.2.2"
81
+ "tslib": "^2.8.1",
82
+ "typescript": "^5.7.2"
95
83
  },
96
84
  "devDependencies": {
97
- "@release-it/conventional-changelog": "^7.0.2",
98
- "@types/clean-css": "^4.2.7",
99
- "@types/node": "^20.7.0",
100
- "@types/node-fetch": "^2.6.6",
85
+ "@release-it/conventional-changelog": "^9.0.3",
86
+ "@types/bun": "^1.1.14",
87
+ "@types/clean-css": "^4.2.11",
88
+ "@types/node": "^22.10.1",
89
+ "@types/node-fetch": "^2.6.12",
101
90
  "@types/sharp": "^0.32.0",
102
91
  "@types/source-map": "^0.5.7",
103
- "@typescript-eslint/eslint-plugin": "^6.7.3",
104
- "@typescript-eslint/parser": "^6.7.3",
92
+ "@typescript-eslint/eslint-plugin": "^8.18.0",
93
+ "@typescript-eslint/parser": "^8.18.0",
105
94
  "buffalo-test": "^2.0.0",
106
- "compression": "^1.7.4",
95
+ "chokidar-cli": "^3.0.0",
96
+ "compression": "^1.7.5",
107
97
  "cross-env": "^7.0.3",
108
98
  "cz-conventional-changelog": "^3.3.0",
109
- "dayjs": "^1.11.10",
110
- "eslint": "^8.50.0",
111
- "eslint-plugin-sonarjs": "^0.21.0",
99
+ "dayjs": "^1.11.13",
100
+ "eslint": "^9.16.0",
101
+ "eslint-plugin-sonarjs": "^3.0.1",
112
102
  "expect": "^29.7.0",
113
- "fastify": "^4.23.2",
103
+ "fastify": "^5.1.0",
114
104
  "gzip-size": "^7.0.0",
115
- "mocha": "^10.2.0",
116
- "nodemon": "^3.0.1",
117
- "nyc": "^15.1.0",
105
+ "npm-check-updates": "^17.1.11",
118
106
  "pirates": "^4.0.6",
119
- "release-it": "^16.2.1",
120
- "remark-cli": "^11.0.0",
107
+ "release-it": "^17.10.0",
108
+ "remark-cli": "^12.0.1",
121
109
  "remark-toc": "^9.0.0"
122
110
  },
123
111
  "overrides": {
124
112
  "minimist": "^1.2.8",
125
113
  "source-map-support": "^0.5.21"
126
114
  },
127
- "nyc": {
128
- "exclude": [
129
- "test",
130
- "register.js"
131
- ]
132
- },
133
115
  "remarkConfig": {
134
116
  "plugins": [
135
117
  "toc"
@@ -210,14 +192,15 @@
210
192
  },
211
193
  "hooks": {
212
194
  "before:init": [
213
- "npm run build",
214
- "npm run test"
195
+ "bun run build",
196
+ "bun link",
197
+ "bun run test"
215
198
  ],
216
199
  "after:bump": [
217
- "npm run remark"
200
+ "bun run remark"
218
201
  ],
219
202
  "after:@release-it/conventional-changelog": [
220
- "npm run remark"
203
+ "bun run remark"
221
204
  ]
222
205
  }
223
206
  }
package/tsconfig.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "target": "ESNext",
7
7
 
8
8
  "moduleResolution": "NodeNext",
9
- "noEmit": false,
9
+ "noEmit": true,
10
10
  "moduleDetection": "force",
11
11
 
12
12
  "jsx": "react", // support JSX
@@ -22,13 +22,14 @@
22
22
  "composite": true,
23
23
  "downlevelIteration": true,
24
24
  "allowSyntheticDefaultImports": true,
25
+ "allowImportingTsExtensions": true,
25
26
  "resolveJsonModule": true,
26
27
 
27
- "rootDir": "lib",
28
+ "rootDir": "./lib",
28
29
  "paths": {
29
30
  "node_modules/*": ["./node_modules/*"]
30
31
  }
31
32
  },
32
- "include": ["./lib"],
33
- "exclude": ["./dist"]
33
+ "include": ["./lib", "./test", "./package.json"],
34
+ "exclude": ["./lib/node/utils/node.sw.js"]
34
35
  }
@@ -1,24 +0,0 @@
1
- import { VnodeWithDom } from "valyrian.js";
2
- interface DataSetInterface<T> {
3
- data: T[];
4
- reset: (data: T[]) => void;
5
- add: (...data: T[]) => void;
6
- update: (index: number, data: T) => void;
7
- delete: (index: number) => void;
8
- }
9
- interface DataSetHandler<T> {
10
- (data: T, index: number): VnodeWithDom;
11
- }
12
- export declare class DataSet<T> implements DataSetInterface<T> {
13
- #private;
14
- get data(): T[];
15
- set data(data: T[]);
16
- constructor(data?: T[], shouldFreeze?: boolean);
17
- setVnodeAndHandler(vnode: VnodeWithDom, handler: DataSetHandler<T>): void;
18
- reset(data: T[]): void;
19
- add(...data: T[]): void;
20
- delete(index: number): void;
21
- update(index: number, item: Partial<T>): void;
22
- }
23
- export {};
24
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/dataset/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAqD,MAAM,aAAa,CAAC;AAE9F,UAAU,gBAAgB,CAAC,CAAC;IAC1B,IAAI,EAAE,CAAC,EAAE,CAAC;IAEV,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC;IAE3B,GAAG,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC;IAE5B,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;IAEzC,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC;AACD,UAAU,cAAc,CAAC,CAAC;IAExB,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,YAAY,CAAC;CACxC;AAoBD,qBAAa,OAAO,CAAC,CAAC,CAAE,YAAW,gBAAgB,CAAC,CAAC,CAAC;;IAQpD,IAAI,IAAI,IAQO,CAAC,EAAE,CAFjB;IAED,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,EAEjB;gBAqBW,IAAI,GAAE,CAAC,EAAO,EAAE,YAAY,UAAO;IAK/C,kBAAkB,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC;IAMlE,KAAK,CAAC,IAAI,EAAE,CAAC,EAAE;IA2Cf,GAAG,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE;IA4BhB,MAAM,CAAC,KAAK,EAAE,MAAM;IAcpB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;CAgBvC"}