@xstd/constructor-types 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.
@@ -0,0 +1,89 @@
1
+ # Contributing
2
+
3
+ This projet is open to everyone. Feel free to test the library, share it, improve it, and create merge requests.
4
+
5
+ ## Getting started
6
+
7
+ ### Tools
8
+
9
+ #### [nvm](https://github.com/nvm-sh/nvm)
10
+
11
+ We recommend using [nvm](https://github.com/nvm-sh/nvm) to manage your Node.js versions.
12
+
13
+ ```shell
14
+ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
15
+ ```
16
+
17
+ #### [Node](https://nodejs.org)
18
+
19
+ ```shell
20
+ nvm use
21
+
22
+ # Verify the Node.js version:
23
+ node -v
24
+ ```
25
+
26
+ #### [Yarn](https://yarnpkg.com)
27
+
28
+ ```shell
29
+ corepack enable yarn
30
+
31
+ # Verify Yarn version:
32
+ yarn -v
33
+
34
+ # Install the dependencies:
35
+ yarn install
36
+ ```
37
+
38
+ ### Environment variables
39
+
40
+ ```shell
41
+ # Copy the example file into .env:
42
+ cp .env.example .env
43
+ ```
44
+
45
+ And replace the corresponding variables:
46
+
47
+ - [NPM_TOKEN](https://docs.npmjs.com/creating-and-viewing-access-tokens)
48
+
49
+ ### Code
50
+
51
+ - The source code is located in the `src` directory.
52
+ - The projet uses [prettier](https://prettier.io/) to format the code. You'll want to enable and configure it in your IDE.
53
+ - The tests run with [vitest](https://vitest.dev)
54
+
55
+ ### Commands
56
+
57
+ - `fb:build`: builds the library.
58
+ - converts the typescript files into javascript files, copies the scss files, and assembles all the assets to create a package ready to be published.
59
+ - some files are handled differently:
60
+ - `*.protected.{ts,scss}` or `**/*.protected/**`: these files are exported under `package-name/protected`
61
+ - this is indented to expose parts of the code that should be restricted to advanced users only, or shared to other libraries requiring _internal_ control.
62
+ - `*.private.{ts,scss}` or `/*.private/**`: these files are **not** exported.
63
+ - this is indented to consume parts of the code internally, and not expose them publicly.
64
+ - `fb:format`: formats the code using `prettier`.
65
+ - `fb:test`: runs the tests using `vitest`.
66
+ - `fb:test:coverage`: runs the tests with coverage.
67
+ - by default, 100% code coverage is required, to enforce good quality.
68
+ - `fb:bench`: runs the bench tests.
69
+ - `fb:typedoc`: generates the documentation.
70
+ - if the library exposes publicly only a few and/or simple parts, the documentation may be defined in the `README.md` instead.
71
+ - `fb:prod`: builds the lib in `prod` mode.
72
+ - builds and publishes the lib on npm as a _prod_ version.
73
+ - `fb:dev`: builds the lib in `dev` mode.
74
+ - builds and publishes the lib on a local `verdaccio` with a `dev` tag.
75
+ - a local `verdaccio` is used to debug/test your library in another project:
76
+ - it is better than `npm link`, as it enforce a specific version, and allows some dependencies to be `dev` too.
77
+ - `fb:rc`: builds the lib in `rc` mode.
78
+ - builds and publishes the lib on npm with a `rc` tag.
79
+ - to test before production and final release
80
+
81
+ ### To create an MR
82
+
83
+ 1. fork the repository
84
+ 1. add the feature/fix by modifying the code in the `src/` directory
85
+ 1. add/write some tests until 100% code coverage is reached (run the tests with `yarn fb:test:coverage`)
86
+ 1. format the code, using the command `yarn fb:format`
87
+ 1. commit and push your work following the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) convention
88
+ 1. create an MR from your repository to the upstream repository, explaining clearly what was added/fixed.
89
+
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2026 Valentin Richard
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,20 @@
1
+ [![npm (scoped)](https://img.shields.io/npm/v/@xstd/constructor-types.svg)](https://www.npmjs.com/package/@xstd/constructor-types)
2
+ ![npm](https://img.shields.io/npm/dm/@xstd/constructor-types.svg)
3
+ ![NPM](https://img.shields.io/npm/l/@xstd/constructor-types.svg)
4
+ ![npm type definitions](https://img.shields.io/npm/types/@xstd/constructor-types.svg)
5
+
6
+ ## @xstd/constructor-types
7
+
8
+ Typescript class constructor types
9
+
10
+ ## 📦 Installation
11
+
12
+ ```shell
13
+ yarn add @xstd/constructor-types
14
+ # or
15
+ npm install @xstd/constructor-types --save
16
+ ```
17
+
18
+ ## 📜 Documentation
19
+
20
+ TODO
@@ -0,0 +1,2 @@
1
+ export type AbstractConstructor<GArguments extends readonly any[], GInstance> = abstract new (...args: GArguments) => GInstance;
2
+ export type GenericAbstractConstructor = AbstractConstructor<any, any>;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=abstract-constructor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abstract-constructor.js","sourceRoot":"","sources":["../src/abstract-constructor.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export type Constructor<GArguments extends readonly any[], GInstance> = abstract new (...args: GArguments) => GInstance;
2
+ export type GenericConstructor = Constructor<any, any>;
package/constructor.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=constructor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constructor.js","sourceRoot":"","sources":["../src/constructor.ts"],"names":[],"mappings":""}
package/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './abstract-constructor.ts';
2
+ export * from './constructor.ts';
package/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from "./abstract-constructor.js";
2
+ export * from "./constructor.js";
3
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@xstd/constructor-types",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "main": "./index.js",
6
+ "scripts": {
7
+ "fb:build": "node fabrique/actions/cli/build.cli.js",
8
+ "fb:format": "prettier --write --ignore-unknown --config ./.prettierrc \"src/**/*.{js,jsx,ts,tsx,html,css,scss}\"",
9
+ "fb:test": "vitest",
10
+ "fb:test:coverage": "vitest run --coverage",
11
+ "fb:bench": "vitest bench",
12
+ "fb:typedoc": "typedoc --options typedoc.json --tsconfig tsconfig.json",
13
+ "fb:prod": "node --env-file='.env' fabrique/actions/cli/build-and-publish.cli.js --mode prod",
14
+ "fb:dev": "node fabrique/actions/cli/build-and-publish.cli.js --mode dev",
15
+ "fb:rc": "node --env-file='.env' fabrique/actions/cli/build-and-publish.cli.js --mode rc",
16
+ "fb:node:dev": "node --experimental-strip-types --watch src/main.ts",
17
+ "fb:node:dev:inspect": "node --experimental-strip-types --watch --inspect src/main.ts"
18
+ },
19
+ "description": "Typescript class constructor types",
20
+ "keywords": [],
21
+ "author": "Valentin Richard",
22
+ "license": "MIT",
23
+ "access": "public",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/xstd-js/constructor-types.git"
27
+ },
28
+ "devDependencies": {
29
+ "@types/node": "^25.5.0",
30
+ "@vitest/coverage-istanbul": "^4.1.0",
31
+ "prettier": "^3.8.1",
32
+ "prettier-plugin-organize-imports": "^4.3.0",
33
+ "typedoc": "^0.28.17",
34
+ "typescript": "^5.9.3",
35
+ "vitest": "^4.1.0"
36
+ },
37
+ "packageManager": "yarn@4.13.0",
38
+ "fabrique": {
39
+ "version": "1.2.3",
40
+ "type": "lib"
41
+ },
42
+ "exports": {
43
+ ".": {
44
+ "types": "./index.d.ts",
45
+ "default": "./index.js"
46
+ }
47
+ },
48
+ "typings": "./index.d.ts",
49
+ "types": "./index.d.ts"
50
+ }