@thigasdevelopment/luam 0.10.1 → 0.10.2
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/luam.mjs +44 -9
- package/package.json +1 -1
package/luam.mjs
CHANGED
|
@@ -4836,6 +4836,19 @@ function createObjectType(members) {
|
|
|
4836
4836
|
);
|
|
4837
4837
|
return createRecord(keys.length === 0 ? "{}" : `{ ${keys.join(", ")} }`, members);
|
|
4838
4838
|
}
|
|
4839
|
+
function createLiteralRecord(members) {
|
|
4840
|
+
const literal = createObjectType(members);
|
|
4841
|
+
return literal.kind === "record" ? { ...literal, isLiteral: true } : literal;
|
|
4842
|
+
}
|
|
4843
|
+
function isEmptyLiteral(type) {
|
|
4844
|
+
return type.kind === "record" && type.isLiteral === true && type.members.size === 0;
|
|
4845
|
+
}
|
|
4846
|
+
function widenInferred(type) {
|
|
4847
|
+
if (type.kind !== "record" || type.isLiteral !== true) {
|
|
4848
|
+
return widenLiteral(type);
|
|
4849
|
+
}
|
|
4850
|
+
return type.members.size === 0 ? TABLE_TYPE : createRecord(type.name, type.members, type.origin);
|
|
4851
|
+
}
|
|
4839
4852
|
function createFunction(parameters, returnType, minimumArguments2, isVariadic = false) {
|
|
4840
4853
|
return { kind: "function", parameters, returnType, minimumArguments: minimumArguments2 ?? parameters.length, isVariadic };
|
|
4841
4854
|
}
|
|
@@ -5034,7 +5047,7 @@ function isAssignable(source, target, options = { allowNil: false }) {
|
|
|
5034
5047
|
return source.kind === "record" ? isRecordAssignable(source, target, options) : source.kind === "table";
|
|
5035
5048
|
}
|
|
5036
5049
|
if (target.kind === "array") {
|
|
5037
|
-
return source.kind === "table" || source.kind === "array" && isAssignable(source.element, target.element, options);
|
|
5050
|
+
return source.kind === "table" || isEmptyLiteral(source) || source.kind === "array" && isAssignable(source.element, target.element, options);
|
|
5038
5051
|
}
|
|
5039
5052
|
if (target.kind === "map") {
|
|
5040
5053
|
return isMapAssignable(source, target, options);
|
|
@@ -6037,7 +6050,7 @@ import { tmpdir } from "node:os";
|
|
|
6037
6050
|
import { join as join2 } from "node:path";
|
|
6038
6051
|
|
|
6039
6052
|
// src/cli/version.ts
|
|
6040
|
-
var VERSION = true ? "0.10.
|
|
6053
|
+
var VERSION = true ? "0.10.2" : "0.0.0-dev";
|
|
6041
6054
|
var PROGRAM_NAME = "luam";
|
|
6042
6055
|
var PROGRAM_DESCRIPTION = "luam \u2014 the Luam compiler for Multi Theft Auto resources.";
|
|
6043
6056
|
|
|
@@ -8338,11 +8351,11 @@ var MTA_SETTINGS_SERVER = {
|
|
|
8338
8351
|
|
|
8339
8352
|
// ../mta-types/src/generated/api/mta-sql-server.ts
|
|
8340
8353
|
var MTA_SQL_SERVER = {
|
|
8341
|
-
dbConnect: fn([STRING, STRING, STRING, STRING, STRING], named("
|
|
8342
|
-
dbExec: fn([named("
|
|
8354
|
+
dbConnect: fn([STRING, STRING, STRING, STRING, STRING], named("Connection"), 2),
|
|
8355
|
+
dbExec: fn([named("Connection"), STRING, ANY], BOOLEAN, 2, true),
|
|
8343
8356
|
dbFree: fn([ANY], BOOLEAN, 1),
|
|
8344
8357
|
dbPoll: fn([ANY, NUMBER, BOOLEAN], TABLE, 2),
|
|
8345
|
-
dbPrepareString: fn([named("
|
|
8358
|
+
dbPrepareString: fn([named("Connection"), STRING, ANY], STRING, 2, true),
|
|
8346
8359
|
dbQuery: fn([ANY, ANY, ANY, ANY, ANY], ANY, 2, true),
|
|
8347
8360
|
executeSQLQuery: fn([STRING, ANY], TABLE, 1, true)
|
|
8348
8361
|
};
|
|
@@ -9410,6 +9423,17 @@ var MTA_OOP_1 = [
|
|
|
9410
9423
|
],
|
|
9411
9424
|
null
|
|
9412
9425
|
),
|
|
9426
|
+
oopClass(
|
|
9427
|
+
"Connection",
|
|
9428
|
+
"Element",
|
|
9429
|
+
[
|
|
9430
|
+
oopMethod("exec", "server", "dbExec", fn([STRING, ANY], BOOLEAN, 1, true)),
|
|
9431
|
+
oopMethod("prepareString", "server", "dbPrepareString", fn([STRING, ANY], STRING, 1, true)),
|
|
9432
|
+
oopMethod("query", "server", "dbQuery", fn([ANY, ANY, ANY, ANY, ANY], ANY, 2, true))
|
|
9433
|
+
],
|
|
9434
|
+
[],
|
|
9435
|
+
oopConstructor("server", fn([STRING, STRING, STRING, STRING, STRING], named("Connection"), 2))
|
|
9436
|
+
),
|
|
9413
9437
|
oopClass(
|
|
9414
9438
|
"DxFont",
|
|
9415
9439
|
null,
|
|
@@ -10090,7 +10114,7 @@ var MTA_OOP_4 = [
|
|
|
10090
10114
|
oopMethod("toggleRespawn", "client", "toggleObjectRespawn", fn([BOOLEAN], BOOLEAN, 1))
|
|
10091
10115
|
],
|
|
10092
10116
|
[],
|
|
10093
|
-
oopConstructor("shared", fn([NUMBER, NUMBER, NUMBER, NUMBER, NUMBER, NUMBER, NUMBER, BOOLEAN], named("
|
|
10117
|
+
oopConstructor("shared", fn([NUMBER, NUMBER, NUMBER, NUMBER, NUMBER, NUMBER, NUMBER, BOOLEAN], named("Object"), 4))
|
|
10094
10118
|
),
|
|
10095
10119
|
oopClass("Ped", "Element", [
|
|
10096
10120
|
oopMethod("addClothes", "shared", "addPedClothes", fn([STRING, STRING, NUMBER], BOOLEAN, 3)),
|
|
@@ -11297,7 +11321,7 @@ var CheckContext = class {
|
|
|
11297
11321
|
return this.returnStack[this.returnStack.length - 1]?.expected ?? null;
|
|
11298
11322
|
}
|
|
11299
11323
|
inferReturnType(type) {
|
|
11300
|
-
this.returnStack[this.returnStack.length - 1]?.inferred.push(
|
|
11324
|
+
this.returnStack[this.returnStack.length - 1]?.inferred.push(widenInferred(type));
|
|
11301
11325
|
}
|
|
11302
11326
|
pushClassMethod(frame) {
|
|
11303
11327
|
this.methodStack.push(frame);
|
|
@@ -12096,6 +12120,7 @@ var ELEMENT_TYPES = [
|
|
|
12096
12120
|
{ name: "Browser", parent: "Element" },
|
|
12097
12121
|
{ name: "Camera", parent: "Element" },
|
|
12098
12122
|
{ name: "ColShape", parent: "Element" },
|
|
12123
|
+
{ name: "Connection", parent: "Element" },
|
|
12099
12124
|
{ name: "DxFont", parent: null },
|
|
12100
12125
|
{ name: "DxRenderTarget", parent: null },
|
|
12101
12126
|
{ name: "DxScreenSource", parent: null },
|
|
@@ -12600,8 +12625,18 @@ function checkTable(context, expression) {
|
|
|
12600
12625
|
}
|
|
12601
12626
|
return checkExpression(context, field2.value);
|
|
12602
12627
|
});
|
|
12628
|
+
const isRecord = expression.fields.every((field2) => field2.name !== null);
|
|
12629
|
+
if (isRecord) {
|
|
12630
|
+
const members = /* @__PURE__ */ new Map();
|
|
12631
|
+
expression.fields.forEach((field2, index) => {
|
|
12632
|
+
if (field2.name !== null) {
|
|
12633
|
+
members.set(field2.name, valueTypes[index] ?? ANY_TYPE);
|
|
12634
|
+
}
|
|
12635
|
+
});
|
|
12636
|
+
return context.record(expression, createLiteralRecord(members));
|
|
12637
|
+
}
|
|
12603
12638
|
const isArray = expression.fields.every((field2) => field2.key === null && field2.name === null);
|
|
12604
|
-
if (!isArray
|
|
12639
|
+
if (!isArray) {
|
|
12605
12640
|
return context.record(expression, TABLE_TYPE);
|
|
12606
12641
|
}
|
|
12607
12642
|
return context.record(expression, createArray(createUnion(valueTypes)));
|
|
@@ -13173,7 +13208,7 @@ function checkLocal(context, statement) {
|
|
|
13173
13208
|
const valueType = valueTypes[index] ?? NIL_TYPE;
|
|
13174
13209
|
context.forgetNarrowing(declaration.name);
|
|
13175
13210
|
if (declaration.annotation === null) {
|
|
13176
|
-
const inferred = context.allowNil || value === void 0 ? ANY_TYPE :
|
|
13211
|
+
const inferred = context.allowNil || value === void 0 ? ANY_TYPE : widenInferred(valueType);
|
|
13177
13212
|
context.binder.declare({ name: declaration.name, type: inferred, isLocal: true, position: declaration.position });
|
|
13178
13213
|
return;
|
|
13179
13214
|
}
|