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

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.
@@ -1,3 +1,4 @@
1
+ import '../globals';
1
2
  declare class MergedState<TState extends object> {
2
3
  static useRefresh<TState extends object>(this: MergedState<TState>): void;
3
4
  reservedKeys: string[];
@@ -12,6 +12,7 @@ var __assign = (this && this.__assign) || function () {
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.useMergedState = void 0;
15
+ require("../globals");
15
16
  var react_1 = require("react");
16
17
  var MergedState = /** @class */ (function () {
17
18
  function MergedState(initialState) {
@@ -1,3 +1,4 @@
1
+ import '../globals';
1
2
  /**
2
3
  * Returns a value that is false before the component has been mounted,
3
4
  * then true during all subsequent rerenders.
@@ -12,6 +12,7 @@ var __assign = (this && this.__assign) || function () {
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.useCleanState = exports.useMountState = void 0;
15
+ require("../globals");
15
16
  var react_1 = require("react");
16
17
  /**
17
18
  * Returns a value that is false before the component has been mounted,
@@ -4,7 +4,7 @@ type AsyncAllowedEffectCallback = () => Awaitable<IVoidFunction>;
4
4
  type UseMountCallbacks = <TInstance extends ComponentInstance<any, any, any>>(instance: TInstance) => void;
5
5
  export declare const useMountCallbacks: UseMountCallbacks;
6
6
  export declare const noOp: () => void;
7
- export declare class ComponentInstance<TProps extends o = WeakEmptyObject, TState extends TStateData = WeakEmptyObject, THooks extends o = WeakEmptyObject> extends ComponentLogic<TProps, TState, THooks> {
7
+ export declare class ComponentInstance<TProps extends o = {}, TState extends TStateData = WeakEmptyObject, THooks extends o = WeakEmptyObject> extends ComponentLogic<TProps, TState, THooks> {
8
8
  /**
9
9
  * Runs only _before_ first render, i.e before the component instance is mounted.
10
10
  * Useful for logic that is involved in determining what to render.
@@ -54,7 +54,7 @@ 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>;
57
+ <Class extends typeof ComponentInstance<HardEmptyObject, o, o>>(Methods: Class & IComponentInstanceClass<InstanceType<Class>>): InstanceType<Class>;
58
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;
@@ -117,7 +117,7 @@ var useInstance = function () {
117
117
  }
118
118
  var Component = args[0], _b = args[1], props = _b === void 0 ? {} : _b;
119
119
  // useHooks.
120
- var instance = (0, logic_1.useLogic)(Component, props); // Must spread rest parameter, rather than passing a single `props` argument directly.
120
+ var instance = (0, logic_1.useLogic)(Component, props);
121
121
  /**
122
122
  * Argument of type '
123
123
  * [
@@ -154,8 +154,16 @@ testing: {
154
154
  var A = /** @class */ (function (_super) {
155
155
  __extends(A, _super);
156
156
  function A() {
157
- return _super !== null && _super.apply(this, arguments) || this;
157
+ var _this = _super !== null && _super.apply(this, arguments) || this;
158
+ // k = this.props.o
159
+ _this.a = _this.state['_initialValues_'];
160
+ return _this;
161
+ // hard empty has every key
162
+ // weak empty has no key
163
+ // weak empty is not assignable to hard empty
158
164
  }
159
165
  return A;
160
166
  }(ComponentInstance));
167
+ var p = { k: '' };
168
+ var a = (0, exports.useInstance)(A, { o: '' });
161
169
  }
@@ -2,7 +2,7 @@ import type { TCleanState, ExtractCleanStateData, TStateData } from '../base/sta
2
2
  export type HardEmpty = HardEmptyObject;
3
3
  export type WeakEmpty = WeakEmptyObject;
4
4
  type o = object;
5
- export declare class ComponentLogic<TProps extends o = WeakEmpty, TState extends TStateData = WeakEmpty, // WeakEmpty,
5
+ export declare class ComponentLogic<TProps extends o = {}, TState extends TStateData = WeakEmpty, // WeakEmpty,
6
6
  THooks extends o = WeakEmpty> {
7
7
  state: TCleanState<TState>;
8
8
  props: TProps;
@@ -15,7 +15,7 @@ export interface IComponentLogicClass<Instance extends ComponentLogic<o, o, o> =
15
15
  getInitialState: (props?: Instance['props']) => ExtractCleanStateData<Instance['state']>;
16
16
  }
17
17
  type UseLogic = {
18
- <Class extends typeof ComponentLogic<HardEmptyObject, o, o>>(Methods: Class & IComponentLogicClass<InstanceType<Class>>, props?: HardEmptyObject): InstanceType<Class>;
18
+ <Class extends typeof ComponentLogic<HardEmptyObject, o, o>>(Methods: Class & IComponentLogicClass<InstanceType<Class>>): InstanceType<Class>;
19
19
  <Class extends typeof ComponentLogic<o, o, o>>(Methods: Class & IComponentLogicClass<InstanceType<Class>>, props: InstanceType<Class>['props']): InstanceType<Class>;
20
20
  };
21
21
  declare const useLogic: UseLogic;
package/build/index.d.ts CHANGED
@@ -1 +1 @@
1
- export * from "./classy";
1
+ export * from './classy';
package/build/index.js CHANGED
@@ -16,7 +16,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./classy"), exports);
18
18
  // PS: Document component inheritance pattern with lifecycle callback arrays and namespaces.
19
- // Due to react's remounting behaviour, components must externally track when some logic has run, if it really really must only ever run once per mounted instance. Tricky to get right for components that may have multiple instance rendered simultaneously at different parts of a page.
19
+ // Due to react's remounting behaviour, components must externally track when some logic has run,
20
+ // if it really really must only ever run once per mounted instance. Tricky to get right for components that may have multiple instance rendered simultaneously at different parts of a page.
20
21
  // useCleanState => useState, separate call for each key
21
22
  // useMergedState => useState, same call for all keys
22
23
  // useMethods => useCallback
@@ -35,10 +35,12 @@
35
35
  "exactOptionalPropertyTypes": true,
36
36
  },
37
37
  "include": [
38
+ // "**/[!globals].ts",
38
39
  "**/*.ts",
39
40
  "**/*.tsx"
40
41
  ],
41
42
  "exclude": [
43
+ "**/globals.ts",
42
44
  "node_modules/**/**.*",
43
45
  "build/**/**.*",
44
46
  "mirror-pkg/**/**.*"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cleanweb/react",
3
- "version": "1.1.1-beta.11",
3
+ "version": "1.1.1-beta.13",
4
4
  "description": "A suite of helpers for writing cleaner React function components.",
5
5
  "engines": {
6
6
  "node": ">=18"
@@ -30,7 +30,7 @@
30
30
  "scripts": {
31
31
  "prebuild": "rimraf ./build",
32
32
  "build": "tsc && tsc-alias",
33
- "postbuild": "copyfiles globals.d.ts tsconfig.json build",
33
+ "postbuild": "copyfiles tsconfig.json build",
34
34
  "_": "",
35
35
  "prepublishOnly": "npm run build",
36
36
  "publish:patch": "npm version patch && npm publish",