@scml-dol-maplebirch/types 4.3.1
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/README.md +79 -0
- package/index.d.ts +29 -0
- package/maplebirch.d.ts +3250 -0
- package/package.json +44 -0
package/README.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# @scml-dol-maplebirch/types
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@scml-dol-maplebirch/types)
|
|
4
|
+
[](https://github.com/MaplebirchLeaf/SCML-DOL-maplebirchFramework/blob/main/LICENSE)
|
|
5
|
+
|
|
6
|
+
TypeScript declarations for the public APIs and globals exposed by
|
|
7
|
+
[maplebirchFramework](https://github.com/MaplebirchLeaf/SCML-DOL-maplebirchFramework).
|
|
8
|
+
|
|
9
|
+
This package contains declarations only. It improves editor completion and type checking for DoL mods,
|
|
10
|
+
but does not install or load maplebirchFramework at runtime.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install --save-dev @scml-dol-maplebirch/types
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Configuration
|
|
19
|
+
|
|
20
|
+
Add the package to the `types` list in your mod project's `tsconfig.json`:
|
|
21
|
+
|
|
22
|
+
```json
|
|
23
|
+
{
|
|
24
|
+
"compilerOptions": {
|
|
25
|
+
"types": ["@types/twine-sugarcube", "@scml-dol-maplebirch/types"],
|
|
26
|
+
"skipLibCheck": true
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
`skipLibCheck` is currently recommended because declarations supplied by the wider ModLoader ecosystem
|
|
32
|
+
are not yet fully compatible with TypeScript 7's stricter declaration checks. Your own source files are
|
|
33
|
+
still checked normally.
|
|
34
|
+
|
|
35
|
+
If your project does not restrict `compilerOptions.types`, installing the package and importing it from
|
|
36
|
+
one source file is sufficient:
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import type {} from '@scml-dol-maplebirch/types';
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Global API
|
|
43
|
+
|
|
44
|
+
The package declares the global `maplebirch` instance and the framework's public utility globals:
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
maplebirch.log('module loaded', 'INFO');
|
|
48
|
+
maplebirch.tool.addTo('Options', 'MyModOptions');
|
|
49
|
+
|
|
50
|
+
maplebirch.on(':passagestart', passage => {
|
|
51
|
+
maplebirch.log(`entered passage: ${passage.title}`, 'DEBUG');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const copy = clone({ enabled: true });
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Importing the API type
|
|
58
|
+
|
|
59
|
+
Use a type-only import when a named type is more convenient than the global declaration:
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
import type maplebirch from '@scml-dol-maplebirch/types';
|
|
63
|
+
|
|
64
|
+
type Maplebirch = typeof maplebirch;
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Version compatibility
|
|
68
|
+
|
|
69
|
+
Package versions follow maplebirchFramework versions. For the most accurate declarations, use the same
|
|
70
|
+
version as the framework loaded by your mod rather than relying on an unpinned latest version.
|
|
71
|
+
|
|
72
|
+
## Related dependencies
|
|
73
|
+
|
|
74
|
+
Declarations from SugarCube, ModLoader, and SC2 are installed transitively. You normally do not need to
|
|
75
|
+
install them separately unless your project imports those packages directly.
|
|
76
|
+
|
|
77
|
+
## License
|
|
78
|
+
|
|
79
|
+
[MIT](https://github.com/MaplebirchLeaf/SCML-DOL-maplebirchFramework/blob/main/LICENSE)
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import instance, * as types from './maplebirch';
|
|
2
|
+
|
|
3
|
+
type Utils = typeof types.utils.publicUtils;
|
|
4
|
+
|
|
5
|
+
declare global {
|
|
6
|
+
const maplebirch: typeof instance;
|
|
7
|
+
function clone(...args: Parameters<Utils['clone']>): ReturnType<Utils['clone']>;
|
|
8
|
+
const equal: Utils['equal'];
|
|
9
|
+
const merge: Utils['merge'];
|
|
10
|
+
const append: Utils['append'];
|
|
11
|
+
const cover: Utils['cover'];
|
|
12
|
+
const mergefn: Utils['mergefn'];
|
|
13
|
+
const appendfn: Utils['appendfn'];
|
|
14
|
+
const coverfn: Utils['coverfn'];
|
|
15
|
+
const contains: Utils['contains'];
|
|
16
|
+
function random(...args: Parameters<Utils['random']>): ReturnType<Utils['random']>;
|
|
17
|
+
function either(...args: Parameters<Utils['either']>): ReturnType<Utils['either']>;
|
|
18
|
+
const SelectCase: Utils['SelectCase'];
|
|
19
|
+
const convert: Utils['convert'];
|
|
20
|
+
const clamp: Utils['clamp'];
|
|
21
|
+
const loadImage: Utils['loadImage'];
|
|
22
|
+
|
|
23
|
+
interface Window extends Readonly<Utils> {
|
|
24
|
+
readonly maplebirch: typeof instance;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default instance;
|
|
29
|
+
export * from './maplebirch';
|