iets-dev 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.
Files changed (66) hide show
  1. package/.claude/settings.local.json +59 -0
  2. package/.github/workflows/build.yml +33 -0
  3. package/.github/workflows/npm-publish.yml +24 -0
  4. package/CLAUDE.md +68 -0
  5. package/README.md +21 -0
  6. package/eslint.config.js +34 -0
  7. package/package.json +28 -0
  8. package/pnpm-workspace.yaml +5 -0
  9. package/scripts/barrel-generator.test.ts +155 -0
  10. package/scripts/barrel-generator.ts +207 -0
  11. package/scripts/ensure-iesdp.sh +20 -0
  12. package/scripts/ts-update.sh +15 -0
  13. package/scripts/ts-update.test.ts +136 -0
  14. package/scripts/ts-update.ts +457 -0
  15. package/scripts/utils.ts +32 -0
  16. package/src/CHANGELOG.md +45 -0
  17. package/src/README.md +23 -0
  18. package/src/ambient.d.ts +23 -0
  19. package/src/bg1/index.d.ts +6 -0
  20. package/src/bg2/actions.d.ts +3512 -0
  21. package/src/bg2/align.ids.d.ts +4 -0
  22. package/src/bg2/animate.ids.d.ts +326 -0
  23. package/src/bg2/areaflag.ids.d.ts +4 -0
  24. package/src/bg2/areatype.ids.d.ts +4 -0
  25. package/src/bg2/astyles.ids.d.ts +11 -0
  26. package/src/bg2/class.ids.d.ts +135 -0
  27. package/src/bg2/damages.ids.d.ts +4 -0
  28. package/src/bg2/difflev.ids.d.ts +4 -0
  29. package/src/bg2/dir.ids.ts +23 -0
  30. package/src/bg2/dmgtype.ids.d.ts +4 -0
  31. package/src/bg2/ea.ids.d.ts +5 -0
  32. package/src/bg2/gender.ids.d.ts +4 -0
  33. package/src/bg2/general.ids.d.ts +4 -0
  34. package/src/bg2/gtimes.ids.d.ts +4 -0
  35. package/src/bg2/happy.ids.d.ts +4 -0
  36. package/src/bg2/help.d.ts +42 -0
  37. package/src/bg2/hotkey.ids.d.ts +4 -0
  38. package/src/bg2/index.ts +1809 -0
  39. package/src/bg2/jourtype.ids.d.ts +4 -0
  40. package/src/bg2/kit.ids.d.ts +4 -0
  41. package/src/bg2/mflags.ids.d.ts +4 -0
  42. package/src/bg2/modal.ids.d.ts +14 -0
  43. package/src/bg2/npc.ids.d.ts +4 -0
  44. package/src/bg2/object.d.ts +366 -0
  45. package/src/bg2/object.ts +69 -0
  46. package/src/bg2/race.ids.d.ts +85 -0
  47. package/src/bg2/reaction.ids.d.ts +4 -0
  48. package/src/bg2/scrlev.ids.d.ts +4 -0
  49. package/src/bg2/scroll.ids.d.ts +4 -0
  50. package/src/bg2/seq.ids.d.ts +4 -0
  51. package/src/bg2/shoutids.ids.d.ts +15 -0
  52. package/src/bg2/slots.ids.d.ts +88 -0
  53. package/src/bg2/sndslot.ids.d.ts +4 -0
  54. package/src/bg2/soundoff.ids.d.ts +4 -0
  55. package/src/bg2/specific.ids.d.ts +4 -0
  56. package/src/bg2/spell.ids.d.ts +2008 -0
  57. package/src/bg2/state.ids.d.ts +124 -0
  58. package/src/bg2/stats.ids.d.ts +4 -0
  59. package/src/bg2/time.ids.d.ts +4 -0
  60. package/src/bg2/timeoday.ids.d.ts +4 -0
  61. package/src/bg2/triggers.d.ts +1082 -0
  62. package/src/bg2/weather.ids.d.ts +4 -0
  63. package/src/index.ts +107 -0
  64. package/src/package.json +21 -0
  65. package/src/tsconfig.json +11 -0
  66. package/tsconfig.json +19 -0
@@ -0,0 +1,4 @@
1
+ import type { IE } from "../index";
2
+
3
+ /** Weather.ids */
4
+ export declare type WeatherID = IE<number, "WeatherID">;
package/src/index.ts ADDED
@@ -0,0 +1,107 @@
1
+ /**
2
+ * IElib TypeScript bindings -- core types.
3
+ *
4
+ * Type branding strategy:
5
+ * - Numeric IDS types use IE<number, "..."> for nominal safety. Custom values: `42 as SpellID`.
6
+ * - String resref types use `string & {}` (unbranded) -- resrefs are raw string literals
7
+ * and branding would force a cast on every usage with no practical benefit.
8
+ * - Action uses a branded interface so ActionOverride can enforce real action calls.
9
+ * - IDS type names use a *ID suffix when a same-named trigger/action function exists
10
+ * (e.g. ClassID vs Class() trigger). Otherwise bare names are used.
11
+ */
12
+
13
+ /**
14
+ * Type branding
15
+ */
16
+ type Brand<B> = { __brand: B };
17
+ export type IE<T, B> = T & Brand<B>;
18
+
19
+ /**
20
+ * Object specifier, e.g. [ENEMY.0.0.MAGE].
21
+ *
22
+ * No validation for now.
23
+ */
24
+ export class ObjectSpec {
25
+ id: string;
26
+ constructor(id: string) {
27
+ this.id = id;
28
+ }
29
+ }
30
+ /**
31
+ * Wrapper for object specifiers.
32
+ *
33
+ * Allows using object specifier strings like `[ENEMY.0.0.MAGE]` in Typescript.
34
+ *
35
+ * Also allows to use death variables (strings up to 17 characters - limited by SPRITE_IS_DEAD vars).
36
+ *
37
+ * No validation for now.
38
+ * @param spec Object specifier string
39
+ * @returns object specifier, compatible with `ObjectPtr` type
40
+ */
41
+ export function obj(spec: string) {
42
+ return new ObjectSpec(spec);
43
+ }
44
+
45
+ // --- MLS sync surface start ---
46
+ // These types must be structurally compatible with BGforge MLS.
47
+ // Both projects define them independently; keep shapes and brand strings identical.
48
+
49
+ /**
50
+ * String reference (TLK index).
51
+ *
52
+ * Branded to prevent accidentally passing a plain number where a text
53
+ * reference is expected.
54
+ */
55
+ export type StrRef = number & { __brand: "StrRef" };
56
+
57
+ /** Branded type for engine actions. Engine action functions must return this type. */
58
+ export interface Action {
59
+ readonly __brand: "Action";
60
+ }
61
+
62
+ // --- MLS sync surface end ---
63
+
64
+ export { tra, tlk } from "./ambient";
65
+
66
+ /**
67
+ * Game Object
68
+ */
69
+ export type ObjectPtr = IE<string, "ObjectPtr"> | ObjectSpec;
70
+
71
+ /**
72
+ * Area point/location.
73
+ */
74
+ export type Point = `[${number}.${number}]`;
75
+
76
+ /** Spell.ids */
77
+ export type SpellID = IE<number, "SpellID">;
78
+
79
+ /**
80
+ * Resource reference, up to 8 characters.
81
+ *
82
+ * Not branded with IE<T,B> intentionally: resrefs are almost always raw string literals,
83
+ * and branding would require a cast on every usage (e.g. "SWORD01" as ItmRef).
84
+ * Unlike numeric IDS types which have pre-typed constants, there is no finite set of valid resrefs.
85
+ */
86
+ export type ResRef = string & {};
87
+ /** SPL resource reference, up to 8 characters. */
88
+ export type SplRef = string & {};
89
+ /** ITM resource reference, up to 8 characters. */
90
+ export type ItmRef = string & {};
91
+ /** ARE resource reference, up to 8 characters. */
92
+ export type AreRef = string & {};
93
+ /** CRE resource reference, up to 8 characters. */
94
+ export type CreRef = string & {};
95
+
96
+ export { Direction } from "./bg2/dir.ids";
97
+
98
+ /**
99
+ * Variable and timers scope: GLOBAL, LOCALS, MYAREA, or area resref.
100
+ *
101
+ * Not narrowed to a union: scope accepts any area resref as a string,
102
+ * so the set of valid values is open-ended.
103
+ */
104
+ export type Scope = string & {};
105
+ export const GLOBAL: Scope = "GLOBAL";
106
+ export const LOCALS: Scope = "LOCALS";
107
+ export const MYAREA: Scope = "MYAREA";
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@bgforge/iets",
3
+ "version": "0.3.1",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": "./index.ts",
7
+ "./bg2": "./bg2/index.ts"
8
+ },
9
+ "scripts": {},
10
+ "dependencies": {},
11
+ "devDependencies": {},
12
+ "keywords": [
13
+ "Infinity Engine",
14
+ "Baldur's Gate",
15
+ "WeiDU"
16
+ ],
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "https://github.com/BGforgeNet/iets"
20
+ }
21
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ES2022",
5
+ "moduleResolution": "bundler",
6
+ "strict": true,
7
+ "noEmit": true,
8
+ "skipLibCheck": false
9
+ },
10
+ "include": ["./**/*.ts", "./**/*.d.ts"]
11
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ES2022",
5
+ "moduleResolution": "bundler",
6
+ "strict": true,
7
+ "esModuleInterop": true,
8
+ "skipLibCheck": true,
9
+ "noEmit": true,
10
+ "noUncheckedIndexedAccess": true,
11
+ "noImplicitReturns": true,
12
+ "resolveJsonModule": true,
13
+ "declaration": false,
14
+ "declarationMap": false,
15
+ "sourceMap": false
16
+ },
17
+ "include": ["scripts/**/*.ts"],
18
+ "exclude": ["node_modules", "external"]
19
+ }