valyrian.js 7.2.8 → 7.2.10

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 (64) hide show
  1. package/dist/dataset/index.d.ts +2 -2
  2. package/dist/dataset/index.d.ts.map +1 -1
  3. package/dist/dataset/index.js +11 -4
  4. package/dist/dataset/index.js.map +7 -0
  5. package/dist/dataset/index.mjs +10 -4
  6. package/dist/dataset/index.mjs.map +7 -0
  7. package/dist/hooks/index.js +1 -0
  8. package/dist/hooks/index.js.map +7 -0
  9. package/dist/hooks/index.mjs.map +7 -0
  10. package/dist/index.d.ts +17 -21
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +4 -1
  13. package/dist/index.js.map +7 -0
  14. package/dist/index.min.js +1 -1
  15. package/dist/index.min.js.map +1 -1
  16. package/dist/index.mjs +3 -1
  17. package/dist/index.mjs.map +7 -0
  18. package/dist/node/index.js +7 -0
  19. package/dist/node/index.js.map +7 -0
  20. package/dist/node/index.mjs +6 -0
  21. package/dist/node/index.mjs.map +7 -0
  22. package/dist/node/utils/inline.d.ts +2 -2
  23. package/dist/node/utils/inline.d.ts.map +1 -1
  24. package/dist/node/utils/tree-adapter.d.ts +3 -3
  25. package/dist/node/utils/tree-adapter.d.ts.map +1 -1
  26. package/dist/proxy-signal/index.js +1 -0
  27. package/dist/proxy-signal/index.js.map +7 -0
  28. package/dist/proxy-signal/index.mjs.map +7 -0
  29. package/dist/request/index.js +1 -0
  30. package/dist/request/index.js.map +7 -0
  31. package/dist/request/index.mjs.map +7 -0
  32. package/dist/router/index.d.ts +2 -2
  33. package/dist/router/index.d.ts.map +1 -1
  34. package/dist/router/index.js +5 -3
  35. package/dist/router/index.js.map +7 -0
  36. package/dist/router/index.mjs +4 -3
  37. package/dist/router/index.mjs.map +7 -0
  38. package/dist/signal/index.d.ts.map +1 -1
  39. package/dist/signal/index.js +3 -2
  40. package/dist/signal/index.js.map +7 -0
  41. package/dist/signal/index.mjs +2 -2
  42. package/dist/signal/index.mjs.map +7 -0
  43. package/dist/store/index.js +1 -0
  44. package/dist/store/index.js.map +7 -0
  45. package/dist/store/index.mjs.map +7 -0
  46. package/dist/sw/index.d.ts +1 -1
  47. package/dist/sw/index.d.ts.map +1 -1
  48. package/dist/sw/index.js +1 -0
  49. package/dist/sw/index.js.map +7 -0
  50. package/dist/sw/index.mjs.map +7 -0
  51. package/dist/tsconfig.tsbuildinfo +1 -0
  52. package/lib/dataset/index.ts +15 -7
  53. package/lib/hooks/index.ts +2 -2
  54. package/lib/index.d.ts +0 -0
  55. package/lib/index.ts +22 -31
  56. package/lib/interfaces.ts.bak +141 -0
  57. package/lib/node/utils/inline.ts +17 -2
  58. package/lib/router/index.ts +16 -4
  59. package/lib/signal/index.ts +5 -5
  60. package/package.json +1 -1
  61. package/tsconfig.json +22 -8
  62. package/dist/interfaces.d.ts +0 -96
  63. package/dist/interfaces.d.ts.map +0 -1
  64. package/lib/interfaces.ts +0 -98
@@ -6,7 +6,11 @@ import esbuild from "esbuild";
6
6
  /* eslint-disable sonarjs/cognitive-complexity */
7
7
  import fs from "fs";
8
8
 
9
- export async function inline(file: string | { raw: string; map?: string | null; file: string }, options: Record<string, any> = {}) {
9
+ // eslint-disable-next-line complexity
10
+ export async function inline(
11
+ file: string | { raw: string; map?: string | null; file: string },
12
+ options: Record<string, any> = {}
13
+ ) {
10
14
  if (typeof file === "string") {
11
15
  let ext = file.split(".").pop();
12
16
  if (ext && /(js|cjs|jsx|mjs|ts|tsx)/.test(ext)) {
@@ -69,6 +73,9 @@ export async function inline(file: string | { raw: string; map?: string | null;
69
73
  };
70
74
 
71
75
  let result = await esbuild.build(esbuildOptions);
76
+ if (result.outputFiles?.length !== 2) {
77
+ throw new Error(result.errors.join("\n"));
78
+ }
72
79
 
73
80
  if (options.compact) {
74
81
  const terser = await import("terser");
@@ -86,6 +93,10 @@ export async function inline(file: string | { raw: string; map?: string | null;
86
93
  ...(options.terser || {})
87
94
  });
88
95
 
96
+ if (!result2.code || !result2.map) {
97
+ throw new Error("Unknown error");
98
+ }
99
+
89
100
  let mapBase64 = Buffer.from(result2.map.toString()).toString("base64");
90
101
  let suffix = `//# sourceMappingURL=data:application/json;charset=utf-8;base64,${mapBase64}`;
91
102
  return { raw: result2.code, map: suffix, file };
@@ -117,7 +128,11 @@ export async function inline(file: string | { raw: string; map?: string | null;
117
128
  }
118
129
  }
119
130
 
120
- inline.uncss = async function (renderedHtml: (string | Promise<string>)[], css: string, options: Record<string, any> = {}) {
131
+ inline.uncss = async function (
132
+ renderedHtml: (string | Promise<string>)[],
133
+ css: string,
134
+ options: Record<string, any> = {}
135
+ ) {
121
136
  let html = await Promise.all(renderedHtml);
122
137
 
123
138
  let contents = html.map((item) => {
@@ -65,7 +65,11 @@ interface RouterInterface {
65
65
 
66
66
  interface RedirectFunction {
67
67
  // eslint-disable-next-line no-unused-vars
68
- (url: string, parentComponent?: Component, preventPushState?: boolean): string | void;
68
+ (
69
+ path: string,
70
+ parentComponent?: Component | POJOComponent | VnodeComponentInterface,
71
+ preventPushState?: boolean
72
+ ): Promise<string | void>;
69
73
  }
70
74
 
71
75
  function flat(array: any) {
@@ -181,7 +185,7 @@ async function searchComponent(
181
185
  url: router.url,
182
186
  path: router.path,
183
187
  matches: router.matches,
184
- redirect: (path: string, parentComponent?: Component) => {
188
+ redirect: (path: string, parentComponent?: Component | POJOComponent | VnodeComponentInterface) => {
185
189
  router.go(path, parentComponent);
186
190
  // Return false to stop the middleware chain
187
191
  return false;
@@ -260,7 +264,11 @@ export class Router implements RouterInterface {
260
264
  return this.paths.filter((path) => path.method === "add").map((path) => path.path);
261
265
  }
262
266
 
263
- async go(path: string, parentComponent?: Component, preventPushState = false): Promise<string | void> {
267
+ async go(
268
+ path: string,
269
+ parentComponent?: Component | POJOComponent | VnodeComponentInterface,
270
+ preventPushState = false
271
+ ): Promise<string | void> {
264
272
  if (!path) {
265
273
  throw new Error("router.url.required");
266
274
  }
@@ -312,7 +320,11 @@ export class Router implements RouterInterface {
312
320
 
313
321
  let localRedirect: RedirectFunction;
314
322
 
315
- export function redirect(url: string, parentComponent?: Component, preventPushState = false): string | void {
323
+ export function redirect(
324
+ url: string,
325
+ parentComponent?: Component | POJOComponent | VnodeComponentInterface,
326
+ preventPushState = false
327
+ ): Promise<string | void> {
316
328
  if (!localRedirect) {
317
329
  throw new Error("router.redirect.not.found");
318
330
  }
@@ -22,12 +22,12 @@ export interface SignalInterface extends Array<any> {
22
22
  }
23
23
 
24
24
  // eslint-disable-next-line sonarjs/cognitive-complexity
25
- export function Signal(initialValue): SignalInterface {
25
+ export function Signal(initialValue: any): SignalInterface {
26
26
  // Create a copy of the current context object
27
27
  const { vnode, component } = { ...current };
28
28
 
29
29
  // Check if the context object has a vnode property
30
- if (vnode) {
30
+ if (vnode && component) {
31
31
  // Is first call
32
32
  if (!vnode.components) {
33
33
  // Set the components property to an empty array
@@ -70,7 +70,7 @@ export function Signal(initialValue): SignalInterface {
70
70
  const subscriptions: SubscriptionsInterface = [];
71
71
 
72
72
  // Define a function that allows other parts of the code to subscribe to changes to the Signal's value
73
- const subscribe = (callback) => {
73
+ const subscribe = (callback: Function) => {
74
74
  // Add the callback function to the subscriptions array if it is not already in the array
75
75
  if (subscriptions.indexOf(callback) === -1) {
76
76
  subscriptions.push(callback);
@@ -127,7 +127,7 @@ export function Signal(initialValue): SignalInterface {
127
127
  }
128
128
 
129
129
  // Define a function that allows the value of the Signal to be updated and notifies any subscribed functions of the change
130
- const set = (newValue) => {
130
+ const set = (newValue: any) => {
131
131
  // If we have a current event on going, prevent the default action
132
132
  if (current.event) {
133
133
  current.event.preventDefault();
@@ -152,7 +152,7 @@ export function Signal(initialValue): SignalInterface {
152
152
 
153
153
  // If the context object has a vnode property, add the signal to the vnode's signals array
154
154
  // and add the subscriptions array to the vnode's subscriptions array
155
- if (vnode) {
155
+ if (vnode && component) {
156
156
  component.signals.push(signal);
157
157
  }
158
158
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "valyrian.js",
3
- "version": "7.2.8",
3
+ "version": "7.2.10",
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>",
package/tsconfig.json CHANGED
@@ -1,20 +1,34 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "jsx": "react",
4
- "target": "ES2022",
5
- "module": "ES2022",
3
+ // enable latest features
4
+ "lib": ["esnext", "dom"],
5
+ "module": "NodeNext",
6
+ "target": "ESNext",
7
+
6
8
  "moduleResolution": "NodeNext",
7
- "resolveJsonModule": true,
8
- "allowSyntheticDefaultImports": true,
9
- "allowJs": false,
10
- "esModuleInterop": true,
9
+ "noEmit": false,
10
+ "moduleDetection": "force",
11
+
12
+ "jsx": "react", // support JSX
11
13
  "jsxFactory": "v",
12
14
  "jsxFragmentFactory": "v.fragment",
15
+ "allowJs": true, // allow importing `.js` from `.ts`
16
+ "esModuleInterop": true, // allow default imports for CommonJS modules
17
+
18
+ // best practices
19
+ "strict": true,
20
+ "forceConsistentCasingInFileNames": true,
21
+ "skipLibCheck": true,
22
+ "composite": true,
23
+ "downlevelIteration": true,
24
+ "allowSyntheticDefaultImports": true,
25
+ "resolveJsonModule": true,
26
+
13
27
  "rootDir": "lib",
14
28
  "paths": {
15
29
  "node_modules/*": ["./node_modules/*"]
16
30
  }
17
31
  },
18
32
  "include": ["./lib"],
19
- "exclude": ["./dist/**"]
33
+ "exclude": ["./dist"]
20
34
  }
@@ -1,96 +0,0 @@
1
- declare module "valyrian.js" {
2
- interface Props {
3
- key?: string | number;
4
- state?: any;
5
- oncreate?: {
6
- (vnode: VnodeInterface): never;
7
- };
8
- onupdate?: {
9
- (vnode: VnodeInterface, oldVnode: VnodeInterface): never;
10
- };
11
- onremove?: {
12
- (oldVnode: VnodeInterface): never;
13
- };
14
- shouldupdate?: {
15
- (vnode: VnodeInterface, oldVnode: VnodeInterface): undefined | boolean;
16
- };
17
- [key: string | number | symbol]: any;
18
- }
19
- interface DomElement extends Element {
20
- [key: string]: any;
21
- }
22
- interface VnodeInterface {
23
- new (tag: string | Component | POJOComponent, props: Props, children: Children): VnodeInterface;
24
- tag: string | Component | POJOComponent;
25
- props: Props;
26
- children: Children;
27
- isSVG?: boolean;
28
- dom?: DomElement;
29
- processed?: boolean;
30
- [key: string | number | symbol]: any;
31
- }
32
- interface VnodeWithDom extends VnodeInterface {
33
- dom: DomElement;
34
- }
35
- interface Component {
36
- (props?: Props | null, ...children: any[]): VnodeInterface | Children | any;
37
- [key: string]: any;
38
- }
39
- interface POJOComponent {
40
- view: Component;
41
- props?: Props | null;
42
- children?: any[];
43
- [key: string]: any;
44
- }
45
- interface VnodeComponentInterface extends VnodeInterface {
46
- tag: Component | POJOComponent;
47
- props: Props;
48
- children: Children;
49
- }
50
- interface Children extends Array<VnodeInterface | VnodeComponentInterface | any> {
51
- }
52
- interface Directive {
53
- (value: any, vnode: VnodeWithDom, oldVnode?: VnodeWithDom): void | boolean;
54
- }
55
- interface Directives {
56
- [key: string]: Directive;
57
- }
58
- interface ReservedProps {
59
- [key: string]: true;
60
- }
61
- interface Current {
62
- component: Component | POJOComponent | null;
63
- vnode: VnodeWithDom | null;
64
- oldVnode?: VnodeWithDom | null;
65
- event: Event | null;
66
- }
67
- interface V {
68
- (tagOrComponent: string | Component | POJOComponent, props: Props | null, ...children: Children): VnodeInterface | VnodeComponentInterface;
69
- fragment(_: any, ...children: Children): Children;
70
- }
71
- let isNodeJs: boolean;
72
- function createDomElement(tag: string, isSVG?: boolean): DomElement;
73
- const Vnode: VnodeInterface;
74
- function isComponent(component: any): component is Component;
75
- const isVnode: (object?: unknown | VnodeInterface) => object is VnodeInterface;
76
- const isVnodeComponent: (object?: unknown | VnodeComponentInterface) => object is VnodeComponentInterface;
77
- function domToVnode(dom: any): VnodeWithDom;
78
- function trust(htmlString: string): any;
79
- const current: Current;
80
- const reservedProps: Record<string, true>;
81
- function onMount(callback: any): void;
82
- function onUpdate(callback: any): void;
83
- function onCleanup(callback: any): void;
84
- function onUnmount(callback: any): void;
85
- const directives: Directives;
86
- function directive(name: string, directive: Directive): void;
87
- function setAttribute(name: string, value: any, newVnode: VnodeWithDom, oldVnode?: VnodeWithDom): void;
88
- function updateAttributes(newVnode: VnodeWithDom, oldVnode?: VnodeWithDom): void;
89
- function patch(newVnode: VnodeWithDom, oldVnode?: VnodeWithDom): void;
90
- function update(): void | string;
91
- function updateVnode(vnode: VnodeWithDom, oldVnode: VnodeWithDom): string | void;
92
- function unmount(): string | void;
93
- function mount(dom: any, component: any): string | void;
94
- const v: V;
95
- }
96
- //# sourceMappingURL=interfaces.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../lib/interfaces.ts"],"names":[],"mappings":"AAEA,OAAO,QAAQ,aAAa,CAAC;IAC3B,UAAiB,KAAK;QACpB,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QACtB,KAAK,CAAC,EAAE,GAAG,CAAC;QACZ,QAAQ,CAAC,EAAE;YACT,CAAC,KAAK,EAAE,cAAc,GAAG,KAAK,CAAC;SAChC,CAAC;QACF,QAAQ,CAAC,EAAE;YACT,CAAC,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,cAAc,GAAG,KAAK,CAAC;SAC1D,CAAC;QACF,QAAQ,CAAC,EAAE;YACT,CAAC,QAAQ,EAAE,cAAc,GAAG,KAAK,CAAC;SACnC,CAAC;QACF,YAAY,CAAC,EAAE;YACb,CAAC,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,cAAc,GAAG,SAAS,GAAG,OAAO,CAAC;SACxE,CAAC;QACF,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC;KACtC;IACD,UAAiB,UAAW,SAAQ,OAAO;QACzC,CAAC,GAAG,EAAE,MAAM,GAAG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int-disable no-use-before-define */
2
- /* eslint-disable no-unused-vars */
3
- declare module "valyrian.js" {
4
- export interface Props {
5
- key?: string | number;
6
- state?: any;
7
- oncreate?: {
8
- (vnode: VnodeInterface): never;
9
- };
10
- onupdate?: {
11
- (vnode: VnodeInterface, oldVnode: VnodeInterface): never;
12
- };
13
- onremove?: {
14
- (oldVnode: VnodeInterface): never;
15
- };
16
- shouldupdate?: {
17
- (vnode: VnodeInterface, oldVnode: VnodeInterface): undefined | boolean;
18
- };
19
- [key: string | number | symbol]: any;
20
- }
21
- export interface DomElement extends Element {
22
- [key: string]: any;
23
- }
24
- export interface VnodeInterface {
25
- new (tag: string | Component | POJOComponent, props: Props, children: Children): VnodeInterface;
26
- tag: string | Component | POJOComponent;
27
- props: Props;
28
- children: Children;
29
- isSVG?: boolean;
30
- dom?: DomElement;
31
- processed?: boolean;
32
- [key: string | number | symbol]: any;
33
- }
34
- export interface VnodeWithDom extends VnodeInterface {
35
- dom: DomElement;
36
- }
37
- export interface Component {
38
- (props?: Props | null, ...children: any[]): VnodeInterface | Children | any;
39
- [key: string]: any;
40
- }
41
- export interface POJOComponent {
42
- view: Component;
43
- props?: Props | null;
44
- children?: any[];
45
- [key: string]: any;
46
- }
47
- export interface VnodeComponentInterface extends VnodeInterface {
48
- tag: Component | POJOComponent;
49
- props: Props;
50
- children: Children;
51
- }
52
- export interface Children extends Array<VnodeInterface | VnodeComponentInterface | any> {}
53
- export interface Directive {
54
- (value: any, vnode: VnodeWithDom, oldVnode?: VnodeWithDom): void | boolean;
55
- }
56
- export interface Directives {
57
- [key: string]: Directive;
58
- }
59
- export interface ReservedProps {
60
- [key: string]: true;
61
- }
62
- export interface Current {
63
- component: Component | POJOComponent | null;
64
- vnode: VnodeWithDom | null;
65
- oldVnode?: VnodeWithDom | null;
66
- event: Event | null;
67
- }
68
- export interface V {
69
- (tagOrComponent: string | Component | POJOComponent, props: Props | null, ...children: Children):
70
- | VnodeInterface
71
- | VnodeComponentInterface;
72
- fragment(_: any, ...children: Children): Children;
73
- }
74
- export let isNodeJs: boolean;
75
- export function createDomElement(tag: string, isSVG?: boolean): DomElement;
76
- export const Vnode: VnodeInterface;
77
- export function isComponent(component: any): component is Component;
78
- export const isVnode: (object?: unknown | VnodeInterface) => object is VnodeInterface;
79
- export const isVnodeComponent: (object?: unknown | VnodeComponentInterface) => object is VnodeComponentInterface;
80
- export function domToVnode(dom: any): VnodeWithDom;
81
- export function trust(htmlString: string): any;
82
- export const current: Current;
83
- export const reservedProps: Record<string, true>;
84
- export function onMount(callback: any): void;
85
- export function onUpdate(callback: any): void;
86
- export function onCleanup(callback: any): void;
87
- export function onUnmount(callback: any): void;
88
- export const directives: Directives;
89
- export function directive(name: string, directive: Directive): void;
90
- export function setAttribute(name: string, value: any, newVnode: VnodeWithDom, oldVnode?: VnodeWithDom): void;
91
- export function updateAttributes(newVnode: VnodeWithDom, oldVnode?: VnodeWithDom): void;
92
- export function patch(newVnode: VnodeWithDom, oldVnode?: VnodeWithDom): void;
93
- export function update(): void | string;
94
- export function updateVnode(vnode: VnodeWithDom, oldVnode: VnodeWithDom): string | void;
95
- export function unmount(): string | void;
96
- export function mount(dom: any, component: any): string | void;
97
- export const v: V;
98
- }