@cleanweb/react 1.1.1-beta.0 → 1.1.1-beta.2
Sign up to get free protection for your applications and to get access to all the features.
package/build/base/methods.d.ts
CHANGED
@@ -3,6 +3,6 @@ export declare class ComponentMethods<TState extends object, TProps extends obje
|
|
3
3
|
state: TCleanState<TState>;
|
4
4
|
props: TProps;
|
5
5
|
}
|
6
|
-
type UseMethods = <TMethods extends ComponentMethods<any, any>>(Methods: Constructor<TMethods
|
6
|
+
type UseMethods = <TMethods extends typeof ComponentMethods<any, any>, Instance extends InstanceType<TMethods> = InstanceType<TMethods>>(Methods: TMethods & Constructor<InstanceType<TMethods>>, state: InstanceType<TMethods>['state'], props: InstanceType<TMethods>['props']) => InstanceType<TMethods>;
|
7
7
|
export declare const useMethods: UseMethods;
|
8
8
|
export {};
|
package/build/base/methods.js
CHANGED
@@ -1,4 +1,55 @@
|
|
1
1
|
"use strict";
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
3
|
+
var extendStatics = function (d, b) {
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
7
|
+
return extendStatics(d, b);
|
8
|
+
};
|
9
|
+
return function (d, b) {
|
10
|
+
if (typeof b !== "function" && b !== null)
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
12
|
+
extendStatics(d, b);
|
13
|
+
function __() { this.constructor = d; }
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
15
|
+
};
|
16
|
+
})();
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
24
|
+
});
|
25
|
+
};
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
28
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
30
|
+
function step(op) {
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
32
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
33
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
35
|
+
switch (op[0]) {
|
36
|
+
case 0: case 1: t = op; break;
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
40
|
+
default:
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
45
|
+
if (t[2]) _.ops.pop();
|
46
|
+
_.trys.pop(); continue;
|
47
|
+
}
|
48
|
+
op = body.call(thisArg, _);
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
51
|
+
}
|
52
|
+
};
|
2
53
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
54
|
exports.useMethods = exports.ComponentMethods = void 0;
|
4
55
|
var react_1 = require("react");
|
@@ -23,3 +74,27 @@ var useMethods = function (Methods, state, props) {
|
|
23
74
|
return methods;
|
24
75
|
};
|
25
76
|
exports.useMethods = useMethods;
|
77
|
+
testing: {
|
78
|
+
var a = function () { return __awaiter(void 0, void 0, void 0, function () {
|
79
|
+
var a, MyMethods, useCleanState, self;
|
80
|
+
return __generator(this, function (_a) {
|
81
|
+
switch (_a.label) {
|
82
|
+
case 0:
|
83
|
+
a = { b: '' };
|
84
|
+
MyMethods = /** @class */ (function (_super) {
|
85
|
+
__extends(MyMethods, _super);
|
86
|
+
function MyMethods() {
|
87
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
88
|
+
}
|
89
|
+
return MyMethods;
|
90
|
+
}(ComponentMethods));
|
91
|
+
;
|
92
|
+
return [4 /*yield*/, import('./state.js')];
|
93
|
+
case 1:
|
94
|
+
useCleanState = (_a.sent()).useCleanState;
|
95
|
+
self = (0, exports.useMethods)(MyMethods, useCleanState({}), {});
|
96
|
+
return [2 /*return*/];
|
97
|
+
}
|
98
|
+
});
|
99
|
+
}); };
|
100
|
+
}
|
package/build/classy/class.d.ts
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
import type { VoidFunctionComponent } from 'react';
|
2
|
-
import type { TComponentClass } from './logic';
|
3
2
|
import { ComponentInstance } from './instance';
|
4
|
-
type Extractor = <TComponent extends ClassComponent<object, object, object>>(this:
|
3
|
+
type Extractor = <TComponent extends typeof ClassComponent<object, object, object>>(this: TComponent & Constructor<InstanceType<TComponent>>, _Component?: TComponent & Constructor<InstanceType<TComponent>>) => VoidFunctionComponent<InstanceType<TComponent>['props']>;
|
5
4
|
export declare class ClassComponent<TState extends object = EmptyObject, TProps extends object = EmptyObject, THooks extends object = EmptyObject> extends ComponentInstance<TState, TProps, THooks> {
|
6
5
|
Render: VoidFunctionComponent<{}>;
|
7
6
|
static renderAs: 'component' | 'template';
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import type { TComponentClass } from './logic';
|
2
1
|
import { ComponentLogic } from './logic';
|
3
2
|
type AsyncAllowedEffectCallback = () => Awaitable<IVoidFunction>;
|
4
3
|
export declare const noOp: () => void;
|
@@ -47,7 +46,7 @@ export declare class ComponentInstance<TState extends object = EmptyObject, TPro
|
|
47
46
|
*/
|
48
47
|
cleanUp: IVoidFunction;
|
49
48
|
}
|
50
|
-
type UseInstance = <TClass extends ComponentInstance<object, object, object>>(Class:
|
49
|
+
type UseInstance = <TClass extends typeof ComponentInstance<object, object, object>>(Class: TClass & Constructor<InstanceType<TClass>>, ...props: valueof<InstanceType<TClass>['props']> extends never ? ([] | [EmptyObject] | [InstanceType<TClass>['props']]) : [InstanceType<TClass>['props']]) => InstanceType<TClass>;
|
51
50
|
/**
|
52
51
|
* To ensure successful type checking, the second parameter must be written with spread syntax.
|
53
52
|
* Likely because of the `exactOptionalPropertyTypes` config option turned on,
|
package/build/classy/logic.d.ts
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
import type { TCleanState, TState } from '../base/state';
|
2
|
-
|
3
|
-
|
2
|
+
type o = object;
|
3
|
+
export declare class ComponentLogic<TState_ extends object = EmptyObject, TProps extends object = EmptyObject, THooks extends object = EmptyObject> {
|
4
|
+
state: TCleanState<TState_>;
|
4
5
|
props: TProps;
|
5
6
|
hooks: THooks;
|
6
|
-
static getInitialState:
|
7
|
+
static getInitialState: <ThisT extends typeof ComponentLogic<o, o, o>>(this: ThisT, props?: InstanceType<ThisT>['props']) => TState<InstanceType<ThisT>['state']> & any;
|
7
8
|
useHooks?: () => THooks;
|
8
9
|
}
|
9
10
|
type CnstPrm = ConstructorParameters<typeof ComponentLogic>;
|
@@ -17,6 +18,6 @@ export type ComponentClassStatics<Instance extends ComponentLogic<object, object
|
|
17
18
|
export type TComponentClass<Instance extends ComponentLogic<object, object, object>, Statics extends ComponentClassStatics<Instance> = ComponentClassStatics<Instance>, Params extends CnstPrm = CnstPrm> = Statics & Constructor<Instance, Params>;
|
18
19
|
export interface IEmpty extends EmptyObject {
|
19
20
|
}
|
20
|
-
type UseLogic = <
|
21
|
+
type UseLogic = <Class extends typeof ComponentLogic<object, object, object>, Instance extends InstanceType<Class> = InstanceType<Class>>(Methods: Class & Constructor<Instance>, ...props: valueof<Instance['props']> extends never ? ([] | [EmptyObject] | [Instance['props']]) : [Instance['props']]) => Instance;
|
21
22
|
export declare const useLogic: UseLogic;
|
22
23
|
export {};
|
package/build/classy/logic.js
CHANGED