@cleanweb/react 1.1.1-beta.10 → 1.1.1-beta.11

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.
@@ -2,6 +2,7 @@ import type { VoidFunctionComponent } from 'react';
2
2
  import type { IComponentInstanceClass } from './instance';
3
3
  import type { TStateData } from '../base';
4
4
  import { ComponentInstance } from './instance';
5
+ export declare const useRerender: () => () => void;
5
6
  type ComponentClassParams = ConstructorParameters<typeof ClassComponent>;
6
7
  type o = object;
7
8
  export interface IComponentClass<Instance extends ClassComponent<o, o, o> = ClassComponent, Params extends ComponentClassParams = ComponentClassParams> extends IComponentInstanceClass<Instance, Params> {
@@ -15,7 +15,7 @@ var __extends = (this && this.__extends) || (function () {
15
15
  };
16
16
  })();
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.Use = exports.ClassComponent = void 0;
18
+ exports.Use = exports.ClassComponent = exports.useRerender = void 0;
19
19
  var jsx_runtime_1 = require("react/jsx-runtime");
20
20
  var react_1 = require("react");
21
21
  var instance_1 = require("./instance");
@@ -41,6 +41,7 @@ var useRerender = function () {
41
41
  var rerender = function () { return _forceRerender(Date.now()); };
42
42
  return rerender;
43
43
  };
44
+ exports.useRerender = useRerender;
44
45
  ;
45
46
  var ClassComponent = /** @class */ (function (_super) {
46
47
  __extends(ClassComponent, _super);
@@ -57,7 +58,7 @@ var ClassComponent = /** @class */ (function (_super) {
57
58
  var Render = instance.Render, template = instance.template;
58
59
  var _forceUpdate;
59
60
  // @ts-expect-error (Cannot assign to 'forceUpdate' because it is a read-only property.ts(2540))
60
- instance.forceUpdate = (_forceUpdate = useRerender() // Moved this to separate line to allow TS errors. Use proxy local variable to regain some type checking for the assignment.
61
+ instance.forceUpdate = (_forceUpdate = (0, exports.useRerender)() // Moved this to separate line to allow TS errors. Use proxy local variable to regain some type checking for the assignment to `instance.forceUpdate`.
61
62
  );
62
63
  // Add calling component name to Render function name in stack traces.
63
64
  (0, react_1.useMemo)(function () {
@@ -76,13 +77,17 @@ var ClassComponent = /** @class */ (function (_super) {
76
77
  * state in the "before-render" stage of `Render`, since it will be attempting to update it's parent's
77
78
  * state (i.e `Wrapper` component) rather than it's own state.
78
79
  *
79
- * Consider using this as a function call instead of JSX to avoid that. This way, we avoid
80
+ * Users should favor using the `template()` method instead. This way, we avoid
80
81
  * establishing a component boundary between `Wrapper` and `Render`.
81
82
  *
82
83
  * Although, since beforeRender() is called earlier from a hook, this is probably
83
84
  * a non-issue. It will only force users to move their logic into `beforeRender` instead
84
- * of doing it directly in `Render`. This might mean cleaner Render functions,
85
- * so there's probably no real value lost if we keep the component boundary.
85
+ * of doing it directly in `Render`. Even if `template` is being used, the `beforeRender` method
86
+ * is the preferred location for such logic to maintain a high level of separation of concerns,
87
+ * which is what this library exists to provide.
88
+ *
89
+ * So there's probably no real value lost with the component boundary. Users should just use
90
+ * `beforeRender` + `template`.
86
91
  **/
87
92
  switch (typeof template) {
88
93
  case 'undefined':
@@ -54,8 +54,8 @@ type InstanceClassParams = ConstructorParameters<typeof ComponentInstance<o, o,
54
54
  export interface IComponentInstanceClass<Instance extends ComponentInstance<o, o, o> = ComponentInstance, Params extends InstanceClassParams = InstanceClassParams> extends IComponentLogicClass<Instance, Params> {
55
55
  }
56
56
  type UseInstance = {
57
- <Class extends typeof ComponentInstance<HardEmptyObject, o, o>>(Methods: Class & IComponentInstanceClass<InstanceType<Class>>, ...props: ([] | [HardEmptyObject])): InstanceType<Class>;
58
- <Class extends typeof ComponentInstance<o, o, o>>(Methods: Class & IComponentInstanceClass<InstanceType<Class>>, ...props: [InstanceType<Class>['props']]): InstanceType<Class>;
57
+ <Class extends typeof ComponentInstance<HardEmptyObject, o, o>>(Methods: Class & IComponentInstanceClass<InstanceType<Class>>, props?: HardEmptyObject): InstanceType<Class>;
58
+ <Class extends typeof ComponentInstance<o, o, o>>(Methods: Class & IComponentInstanceClass<InstanceType<Class>>, props: InstanceType<Class>['props']): InstanceType<Class>;
59
59
  };
60
60
  export declare const useInstance: UseInstance;
61
61
  export {};
@@ -56,7 +56,7 @@ testing: {
56
56
  }(ComponentLogic));
57
57
  ;
58
58
  MyComponentLogic.getInitialState;
59
- var self_1 = useLogic(MyComponentLogic, {});
59
+ // const self = useLogic(MyComponentLogic);
60
60
  }
61
61
  testing: {
62
62
  var A = /** @class */ (function (_super) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cleanweb/react",
3
- "version": "1.1.1-beta.10",
3
+ "version": "1.1.1-beta.11",
4
4
  "description": "A suite of helpers for writing cleaner React function components.",
5
5
  "engines": {
6
6
  "node": ">=18"