@j2inn/resolvable-ui-elements 0.0.3 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { type FunctionResult } from './resolvableElements/elements/function/FunctionElement';
2
+ export { type ResolvableValueElementMeta } from './resolvableElements/elements/ResolvableValueElement';
2
3
  export { isSectionData, type ParametersOfSection, type ResolvedSection, } from './resolvableElements/elements/section/SectionElementMeta';
3
4
  export { type UiElementData } from './resolvableElements/elements/UiElement';
4
5
  export * from './resolvableElements/react/SectionChecker';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;AAMH,+FAIiE;AAHhE,mHAAA,aAAa,OAAA;AAKd,0EAA0E;AAC1E,QAAQ;AACR,0EAA0E;AAC1E,4EAAyD;AACzD,gFAA6D;AAC7D,+EAA4D;AAC5D,0EAA0E;AAC1E,QAAQ;AACR,0EAA0E;AAC1E,mDAAgC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;AAOH,+FAIiE;AAHhE,mHAAA,aAAa,OAAA;AAKd,0EAA0E;AAC1E,QAAQ;AACR,0EAA0E;AAC1E,4EAAyD;AACzD,gFAA6D;AAC7D,+EAA4D;AAC5D,0EAA0E;AAC1E,QAAQ;AACR,0EAA0E;AAC1E,mDAAgC"}
@@ -7,6 +7,6 @@ export declare class FunctionElement<T extends UiElementData> extends UiElement<
7
7
  #private;
8
8
  constructor(data: UiElementConstructorData<T>);
9
9
  }
10
- export declare type FunctionResult = (parameters: Parameters) => Promise<HGrid>;
11
- export declare type Parameters = Record<string, OptionalHVal | HaysonVal | undefined> | OptionalHVal | DictStore | undefined;
10
+ export type FunctionResult = (parameters: Parameters) => Promise<HGrid>;
11
+ export type Parameters = Record<string, OptionalHVal | HaysonVal | undefined> | OptionalHVal | DictStore | undefined;
12
12
  export declare const makeParametersDict: (parameters: Record<string, OptionalHVal | HaysonVal | undefined> | OptionalHVal | DictStore | undefined) => HDict;
@@ -21,7 +21,12 @@ class FunctionElement extends UiElement_1.UiElement {
21
21
  const { expr } = this._meta;
22
22
  return async (parameters) => {
23
23
  const resolvedExpression = (0, resolveTemplatedExpression_1.resolveTemplateExpression)(expr, (0, exports.makeParametersDict)(parameters));
24
- return await this.resolver.eval(resolvedExpression);
24
+ const result = await this.resolver.eval(resolvedExpression);
25
+ // Update watch records
26
+ if (!result.isError()) {
27
+ this.resolver.client.ops.watch.update(result.filter('id and mod'));
28
+ }
29
+ return result;
25
30
  };
26
31
  };
27
32
  }
@@ -1 +1 @@
1
- {"version":3,"file":"FunctionElement.js","sourceRoot":"","sources":["../../../../src/resolvableElements/elements/function/FunctionElement.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,iDAAgF;AAChF,iFAA4E;AAE5E,4CAIqB;AAGrB;;GAEG;AACH,MAAa,eAAyC,SAAQ,qBAAY;IACzE,YAAY,IAAiC;QAC5C,KAAK,CAAC,IAAI,CAAC,CAAA;QACX,IAAI,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;YACrC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,cAAc,EAAE,CAAA;SAClC;IACF,CAAC;IAED,cAAc,GAAG,GAAmB,EAAE;QACrC,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,KAA4B,CAAA;QAElD,OAAO,KAAK,EAAE,UAAU,EAAE,EAAE;YAC3B,MAAM,kBAAkB,GAAG,IAAA,sDAAyB,EACnD,IAAI,EACJ,IAAA,0BAAkB,EAAC,UAAU,CAAC,CAC9B,CAAA;YAED,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;QACpD,CAAC,CAAA;IACF,CAAC,CAAA;CACD;AApBD,0CAoBC;AAUM,MAAM,kBAAkB,GAAG,CACjC,UAIY,EACJ,EAAE;IACV,IAAI,CAAC,UAAU,EAAE;QAChB,OAAO,qBAAK,CAAC,IAAI,EAAE,CAAA;KACnB;IACD,IAAI,UAAU,YAAY,qBAAK,EAAE;QAChC,OAAO,UAAU,CAAA;KACjB;IAED,OAAO,qBAAK,CAAC,IAAI,CAChB,MAAM,CAAC,WAAW,CACjB,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,CACvD,CACD,CAAA;AACF,CAAC,CAAA;AAnBY,QAAA,kBAAkB,sBAmB9B"}
1
+ {"version":3,"file":"FunctionElement.js","sourceRoot":"","sources":["../../../../src/resolvableElements/elements/function/FunctionElement.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,iDAAgF;AAChF,iFAA4E;AAE5E,4CAIqB;AAGrB;;GAEG;AACH,MAAa,eAAyC,SAAQ,qBAAY;IACzE,YAAY,IAAiC;QAC5C,KAAK,CAAC,IAAI,CAAC,CAAA;QACX,IAAI,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;YACrC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,cAAc,EAAE,CAAA;SAClC;IACF,CAAC;IAED,cAAc,GAAG,GAAmB,EAAE;QACrC,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,KAA4B,CAAA;QAElD,OAAO,KAAK,EAAE,UAAU,EAAE,EAAE;YAC3B,MAAM,kBAAkB,GAAG,IAAA,sDAAyB,EACnD,IAAI,EACJ,IAAA,0BAAkB,EAAC,UAAU,CAAC,CAC9B,CAAA;YAED,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;YAE3D,uBAAuB;YACvB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE;gBACtB,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CACpC,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAC3B,CAAA;aACD;YAED,OAAO,MAAM,CAAA;QACd,CAAC,CAAA;IACF,CAAC,CAAA;CACD;AA7BD,0CA6BC;AAUM,MAAM,kBAAkB,GAAG,CACjC,UAIY,EACJ,EAAE;IACV,IAAI,CAAC,UAAU,EAAE;QAChB,OAAO,qBAAK,CAAC,IAAI,EAAE,CAAA;KACnB;IACD,IAAI,UAAU,YAAY,qBAAK,EAAE;QAChC,OAAO,UAAU,CAAA;KACjB;IAED,OAAO,qBAAK,CAAC,IAAI,CAChB,MAAM,CAAC,WAAW,CACjB,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,CACvD,CACD,CAAA;AACF,CAAC,CAAA;AAnBY,QAAA,kBAAkB,sBAmB9B"}
@@ -18,7 +18,7 @@ export declare class ResolvableSectionElement<T extends UiElementData<UiElementS
18
18
  getParameterList: () => string[];
19
19
  }
20
20
  export declare const isChildUnresolvedSection: (value: unknown) => value is ChildUnresolvedSection;
21
- export declare type ChildUnresolvedSection = [
21
+ export type ChildUnresolvedSection = [
22
22
  string | undefined,
23
23
  UiElementData<UiElementSectionMeta>
24
24
  ];
@@ -3,13 +3,13 @@ import { UiElementData, UiElementMeta } from '../UiElement';
3
3
  export interface UiElementSectionMeta extends UiElementMeta {
4
4
  resolutionType?: never;
5
5
  }
6
- export declare type ResolvedSection<T extends UiElementData<UiElementSectionMeta>> = T extends {
6
+ export type ResolvedSection<T extends UiElementData<UiElementSectionMeta>> = T extends {
7
7
  _resolved?: Record<string, unknown>;
8
8
  } ? Required<T>['_resolved'] : Record<string, unknown>;
9
- export declare type ParametersOfSection<T extends UiElementData> = T extends {
9
+ export type ParametersOfSection<T extends UiElementData> = T extends {
10
10
  _parameters?: Record<string, HVal>;
11
11
  } ? PartialExplicitUndefined<T['_parameters']> : undefined;
12
- export declare type PartialExplicitUndefined<T> = {
12
+ export type PartialExplicitUndefined<T> = {
13
13
  [P in keyof T]: T[P] | null | undefined;
14
14
  };
15
15
  export declare const isSectionData: (element: UiElementData) => element is UiElementData<UiElementSectionMeta>;
@@ -3,7 +3,7 @@ import { UiElementData } from 'resolvableElements/elements/UiElement';
3
3
  /**
4
4
  * An utility type that allows a component to accept props with or without a 'section' property.
5
5
  */
6
- export declare type OptionalSection<P> = P | (Omit<P, 'section'> & {
6
+ export type OptionalSection<P> = P | (Omit<P, 'section'> & {
7
7
  section?: undefined;
8
8
  });
9
9
  /**
@@ -9,7 +9,7 @@ import { UiElementData } from '../elements/UiElement';
9
9
  * @returns the resolved result of the section that will be updated and force rendering when a subvalue changes.
10
10
  */
11
11
  export declare function useResolveSection<T extends UiElementData>(sectionData: T, parameters?: ParametersOfSection<T>): UseResolveSectionResult<T>;
12
- export declare type UseResolveSectionResult<T extends UiElementData> = [
12
+ export type UseResolveSectionResult<T extends UiElementData> = [
13
13
  ResolvedSection<T>,
14
14
  UseResolveSectionExtra<T>
15
15
  ];
@@ -1,4 +1,5 @@
1
1
  export { type FunctionResult } from './resolvableElements/elements/function/FunctionElement';
2
+ export { type ResolvableValueElementMeta } from './resolvableElements/elements/ResolvableValueElement';
2
3
  export { isSectionData, type ParametersOfSection, type ResolvedSection, } from './resolvableElements/elements/section/SectionElementMeta';
3
4
  export { type UiElementData } from './resolvableElements/elements/UiElement';
4
5
  export * from './resolvableElements/react/SectionChecker';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,EACN,aAAa,GAGb,MAAM,0DAA0D,CAAA;AAEjE,0EAA0E;AAC1E,QAAQ;AACR,0EAA0E;AAC1E,cAAc,2CAA2C,CAAA;AACzD,cAAc,+CAA+C,CAAA;AAC7D,cAAc,8CAA8C,CAAA;AAC5D,0EAA0E;AAC1E,QAAQ;AACR,0EAA0E;AAC1E,cAAc,kBAAkB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,OAAO,EACN,aAAa,GAGb,MAAM,0DAA0D,CAAA;AAEjE,0EAA0E;AAC1E,QAAQ;AACR,0EAA0E;AAC1E,cAAc,2CAA2C,CAAA;AACzD,cAAc,+CAA+C,CAAA;AAC7D,cAAc,8CAA8C,CAAA;AAC5D,0EAA0E;AAC1E,QAAQ;AACR,0EAA0E;AAC1E,cAAc,kBAAkB,CAAA"}
@@ -7,6 +7,6 @@ export declare class FunctionElement<T extends UiElementData> extends UiElement<
7
7
  #private;
8
8
  constructor(data: UiElementConstructorData<T>);
9
9
  }
10
- export declare type FunctionResult = (parameters: Parameters) => Promise<HGrid>;
11
- export declare type Parameters = Record<string, OptionalHVal | HaysonVal | undefined> | OptionalHVal | DictStore | undefined;
10
+ export type FunctionResult = (parameters: Parameters) => Promise<HGrid>;
11
+ export type Parameters = Record<string, OptionalHVal | HaysonVal | undefined> | OptionalHVal | DictStore | undefined;
12
12
  export declare const makeParametersDict: (parameters: Record<string, OptionalHVal | HaysonVal | undefined> | OptionalHVal | DictStore | undefined) => HDict;
@@ -18,7 +18,12 @@ export class FunctionElement extends UiElement {
18
18
  const { expr } = this._meta;
19
19
  return async (parameters) => {
20
20
  const resolvedExpression = resolveTemplateExpression(expr, makeParametersDict(parameters));
21
- return await this.resolver.eval(resolvedExpression);
21
+ const result = await this.resolver.eval(resolvedExpression);
22
+ // Update watch records
23
+ if (!result.isError()) {
24
+ this.resolver.client.ops.watch.update(result.filter('id and mod'));
25
+ }
26
+ return result;
22
27
  };
23
28
  };
24
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"FunctionElement.js","sourceRo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CAAA"}
1
+ {"version":3,"file":"FunctionElement.js","sourceRoot":"","sources":["../../../../src/resolvableElements/elements/function/FunctionElement.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAwB,KAAK,EAAuB,MAAM,eAAe,CAAA;AAChF,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAA;AAE5E,OAAO,EACN,SAAS,GAGT,MAAM,cAAc,CAAA;AAGrB;;GAEG;AACH,MAAM,OAAO,eAAyC,SAAQ,SAAY;IACzE,YAAY,IAAiC;QAC5C,KAAK,CAAC,IAAI,CAAC,CAAA;QACX,IAAI,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;YACrC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,cAAc,EAAE,CAAA;SAClC;IACF,CAAC;IAED,cAAc,GAAG,GAAmB,EAAE;QACrC,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,KAA4B,CAAA;QAElD,OAAO,KAAK,EAAE,UAAU,EAAE,EAAE;YAC3B,MAAM,kBAAkB,GAAG,yBAAyB,CACnD,IAAI,EACJ,kBAAkB,CAAC,UAAU,CAAC,CAC9B,CAAA;YAED,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;YAE3D,uBAAuB;YACvB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE;gBACtB,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CACpC,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAC3B,CAAA;aACD;YAED,OAAO,MAAM,CAAA;QACd,CAAC,CAAA;IACF,CAAC,CAAA;CACD;AAUD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CACjC,UAIY,EACJ,EAAE;IACV,IAAI,CAAC,UAAU,EAAE;QAChB,OAAO,KAAK,CAAC,IAAI,EAAE,CAAA;KACnB;IACD,IAAI,UAAU,YAAY,KAAK,EAAE;QAChC,OAAO,UAAU,CAAA;KACjB;IAED,OAAO,KAAK,CAAC,IAAI,CAChB,MAAM,CAAC,WAAW,CACjB,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,CACvD,CACD,CAAA;AACF,CAAC,CAAA"}
@@ -18,7 +18,7 @@ export declare class ResolvableSectionElement<T extends UiElementData<UiElementS
18
18
  getParameterList: () => string[];
19
19
  }
20
20
  export declare const isChildUnresolvedSection: (value: unknown) => value is ChildUnresolvedSection;
21
- export declare type ChildUnresolvedSection = [
21
+ export type ChildUnresolvedSection = [
22
22
  string | undefined,
23
23
  UiElementData<UiElementSectionMeta>
24
24
  ];
@@ -3,13 +3,13 @@ import { UiElementData, UiElementMeta } from '../UiElement';
3
3
  export interface UiElementSectionMeta extends UiElementMeta {
4
4
  resolutionType?: never;
5
5
  }
6
- export declare type ResolvedSection<T extends UiElementData<UiElementSectionMeta>> = T extends {
6
+ export type ResolvedSection<T extends UiElementData<UiElementSectionMeta>> = T extends {
7
7
  _resolved?: Record<string, unknown>;
8
8
  } ? Required<T>['_resolved'] : Record<string, unknown>;
9
- export declare type ParametersOfSection<T extends UiElementData> = T extends {
9
+ export type ParametersOfSection<T extends UiElementData> = T extends {
10
10
  _parameters?: Record<string, HVal>;
11
11
  } ? PartialExplicitUndefined<T['_parameters']> : undefined;
12
- export declare type PartialExplicitUndefined<T> = {
12
+ export type PartialExplicitUndefined<T> = {
13
13
  [P in keyof T]: T[P] | null | undefined;
14
14
  };
15
15
  export declare const isSectionData: (element: UiElementData) => element is UiElementData<UiElementSectionMeta>;
@@ -3,7 +3,7 @@ import { UiElementData } from 'resolvableElements/elements/UiElement';
3
3
  /**
4
4
  * An utility type that allows a component to accept props with or without a 'section' property.
5
5
  */
6
- export declare type OptionalSection<P> = P | (Omit<P, 'section'> & {
6
+ export type OptionalSection<P> = P | (Omit<P, 'section'> & {
7
7
  section?: undefined;
8
8
  });
9
9
  /**
@@ -9,7 +9,7 @@ import { UiElementData } from '../elements/UiElement';
9
9
  * @returns the resolved result of the section that will be updated and force rendering when a subvalue changes.
10
10
  */
11
11
  export declare function useResolveSection<T extends UiElementData>(sectionData: T, parameters?: ParametersOfSection<T>): UseResolveSectionResult<T>;
12
- export declare type UseResolveSectionResult<T extends UiElementData> = [
12
+ export type UseResolveSectionResult<T extends UiElementData> = [
13
13
  ResolvedSection<T>,
14
14
  UseResolveSectionExtra<T>
15
15
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@j2inn/resolvable-ui-elements",
3
- "version": "0.0.3",
3
+ "version": "1.0.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -23,10 +23,10 @@
23
23
  "dist_es/**/*"
24
24
  ],
25
25
  "peerDependencies": {
26
- "haystack-core": "^2.0.38",
27
- "haystack-nclient": "^3.0.28",
28
- "haystack-react": "^3.0.11",
29
- "haystack-units": "^1.0.20",
26
+ "haystack-core": "^2.0.45",
27
+ "haystack-nclient": "^3.0.32",
28
+ "haystack-react": "^3.0.17",
29
+ "haystack-units": "^1.0.22",
30
30
  "react": "^18.2.0",
31
31
  "react-dom": "^18.2.0"
32
32
  },
@@ -49,4 +49,4 @@
49
49
  "ts-jest": "^28.0.8",
50
50
  "typescript": "^4.8.2"
51
51
  }
52
- }
52
+ }