@defold-typescript/types 0.54.0 → 0.56.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.
- package/dist/cli-runtime.js +93 -31
- package/dist/library-runtime.js +7176 -0
- package/examples/translations.json +4 -4
- package/generated/gui.d.ts +1 -1
- package/generated/particlefx.d.ts +1 -1
- package/generated/versions/defold-1.12.4/gui.d.ts +1 -1
- package/generated/versions/defold-1.12.4/model.d.ts +1 -1
- package/generated/versions/defold-1.12.4/particlefx.d.ts +1 -1
- package/generated/versions/defold-1.12.4/resource.d.ts +4 -4
- package/generated/versions/defold-1.13.0/gui.d.ts +1 -1
- package/generated/versions/defold-1.13.0/model.d.ts +1 -1
- package/generated/versions/defold-1.13.0/particlefx.d.ts +1 -1
- package/generated/versions/defold-1.13.0/resource.d.ts +4 -4
- package/generated/versions/defold-1.13.1/gui.d.ts +1 -1
- package/generated/versions/defold-1.13.1/model.d.ts +1 -1
- package/generated/versions/defold-1.13.1/particlefx.d.ts +1 -1
- package/generated/versions/defold-1.13.1/resource.d.ts +4 -4
- package/generated/versions/defold-1.13.2/gui.d.ts +1 -1
- package/generated/versions/defold-1.13.2/particlefx.d.ts +1 -1
- package/package.json +8 -2
- package/scripts/cli-runtime.ts +6 -1
- package/scripts/doc-source.ts +1 -1
- package/scripts/extension-goldens.ts +5 -5
- package/scripts/generate-api-signatures.ts +1 -1
- package/scripts/library-runtime.ts +22 -0
- package/scripts/regen.ts +2 -2
- package/scripts/sync-api-docs.ts +47 -26
- package/src/doc-comment.ts +38 -7
- package/src/index-slot-classifications.ts +2 -2
- package/src/library-signature.ts +2 -2
- package/src/luals-type-expr.ts +1 -1
package/dist/cli-runtime.js
CHANGED
|
@@ -1888,6 +1888,15 @@ function mapLualsExpression(token, resolveLeaf, position = "output") {
|
|
|
1888
1888
|
function isLualsFunctionToken(token) {
|
|
1889
1889
|
return /^fun\s*\(/.test(token.trim());
|
|
1890
1890
|
}
|
|
1891
|
+
function mapLualsCallSignatureExpression(token, resolveLeaf, position = "output") {
|
|
1892
|
+
const trimmed = token.trim();
|
|
1893
|
+
if (!isLualsFunctionToken(trimmed)) {
|
|
1894
|
+
throw new Error(`mapLualsCallSignature: expected a "fun(...)" token, got "${token}".`);
|
|
1895
|
+
}
|
|
1896
|
+
const walk = { resolveLeaf, unknowns: [], position };
|
|
1897
|
+
const { paramList, ret } = functionParts(trimmed, walk);
|
|
1898
|
+
return { ts: `(${paramList}): ${ret}`, unknowns: walk.unknowns };
|
|
1899
|
+
}
|
|
1891
1900
|
var LUALS_THROWAWAY_PARAM = "_", LUALS_VARARG_TOKEN = "...", NUMERIC_LITERAL, TUPLE_KEY, INDEX_KEY;
|
|
1892
1901
|
var init_luals_type_expr = __esm(() => {
|
|
1893
1902
|
NUMERIC_LITERAL = /^-?\d+(\.\d+)?$/;
|
|
@@ -1954,6 +1963,15 @@ function weldStrandedListMarkers(text) {
|
|
|
1954
1963
|
return out.join(`
|
|
1955
1964
|
`).trim();
|
|
1956
1965
|
}
|
|
1966
|
+
function stripMarkup(html) {
|
|
1967
|
+
let text = html;
|
|
1968
|
+
let previous;
|
|
1969
|
+
do {
|
|
1970
|
+
previous = text;
|
|
1971
|
+
text = text.replace(MARKUP_TAG, "");
|
|
1972
|
+
} while (text !== previous);
|
|
1973
|
+
return text;
|
|
1974
|
+
}
|
|
1957
1975
|
function preToMarkdown(inner) {
|
|
1958
1976
|
const lines = htmlToCodeText(inner).split(`
|
|
1959
1977
|
`);
|
|
@@ -1990,8 +2008,8 @@ ${LIST_INDENT.repeat(Math.max(0, listDepth - 1))}- `;
|
|
|
1990
2008
|
}).replace(/<br\s*\/?>/gi, `
|
|
1991
2009
|
`).replace(/<\/p>/gi, `
|
|
1992
2010
|
|
|
1993
|
-
`)
|
|
1994
|
-
text = decodeEntities(text);
|
|
2011
|
+
`);
|
|
2012
|
+
text = decodeEntities(stripMarkup(text));
|
|
1995
2013
|
text = text.replace(/[ \t]+/g, " ").replace(/ *\n */g, `
|
|
1996
2014
|
`).replace(/\n{3,}/g, `
|
|
1997
2015
|
|
|
@@ -2003,9 +2021,9 @@ ${LIST_INDENT.repeat(Math.max(0, listDepth - 1))}- `;
|
|
|
2003
2021
|
return text.split("*/").join("*\\/");
|
|
2004
2022
|
}
|
|
2005
2023
|
function htmlToCodeText(html) {
|
|
2006
|
-
|
|
2007
|
-
`)
|
|
2008
|
-
text = decodeEntities(
|
|
2024
|
+
const stripped = stripMarkup(html.replace(/<br\s*\/?>/gi, `
|
|
2025
|
+
`));
|
|
2026
|
+
const text = decodeEntities(stripped);
|
|
2009
2027
|
const lines = text.split(`
|
|
2010
2028
|
`).map((line) => line.replace(/[ \t]+$/g, ""));
|
|
2011
2029
|
while (lines.length > 0 && lines[0] === "")
|
|
@@ -2180,10 +2198,9 @@ function renderDocComment(parts) {
|
|
|
2180
2198
|
}
|
|
2181
2199
|
lines.push(" * ```");
|
|
2182
2200
|
}
|
|
2183
|
-
lines.
|
|
2184
|
-
return lines;
|
|
2201
|
+
return [...lines.map((line) => line.replaceAll("*/", "*\\/")), " */"];
|
|
2185
2202
|
}
|
|
2186
|
-
var NAMED_ENTITIES, LIST_INDENT = "", STRANDED_MARKER, LIST_ITEM, MISREAD_MARKDOWN_LINE, MANGLED_FENCE, FENCE_OPENER;
|
|
2203
|
+
var NAMED_ENTITIES, LIST_INDENT = "", STRANDED_MARKER, LIST_ITEM, MARKUP_TAG, MISREAD_MARKDOWN_LINE, MANGLED_FENCE, FENCE_OPENER;
|
|
2187
2204
|
var init_doc_comment = __esm(() => {
|
|
2188
2205
|
NAMED_ENTITIES = {
|
|
2189
2206
|
amp: "&",
|
|
@@ -2212,6 +2229,12 @@ var init_doc_comment = __esm(() => {
|
|
|
2212
2229
|
};
|
|
2213
2230
|
STRANDED_MARKER = /^(*)-$/;
|
|
2214
2231
|
LIST_ITEM = /^*- /;
|
|
2232
|
+
MARKUP_TAG = new RegExp([
|
|
2233
|
+
"</?(?:a|b|blockquote|br|code|dd|div|dl|dt|em|h[1-6]|hr|i|iframe|img|kbd|li|lia|ol|p|pre|s|script|small|span|strong|style|sub|sup|super|table|tbody|td|tfoot|th|thead|tr|u|ul)\\s*/?>",
|
|
2234
|
+
"</?(?:script|style|iframe)\\b[^<>]*>",
|
|
2235
|
+
`</?[a-z][^<>=]*=(?:[^<>"']|"[^"]*"|'[^']*')*>`,
|
|
2236
|
+
"</?[a-z][^<>=]*=[^<>]*>"
|
|
2237
|
+
].join("|"), "gi");
|
|
2215
2238
|
MISREAD_MARKDOWN_LINE = /^\s*`[^`]+`/;
|
|
2216
2239
|
MANGLED_FENCE = /<code>([A-Za-z0-9_+-]+)\n([\s\S]*?)<\/code>/g;
|
|
2217
2240
|
FENCE_OPENER = /^```([A-Za-z0-9_+-]+)$/;
|
|
@@ -2748,6 +2771,29 @@ ${sentence}`;
|
|
|
2748
2771
|
function indexBaseNotes(elementName, kind, slotName) {
|
|
2749
2772
|
return slotBaseNotes(INDEX_SLOT_CLASSIFICATIONS, "Defold", `${elementName}:${kind}:${slotName}`);
|
|
2750
2773
|
}
|
|
2774
|
+
function isPlainObject(value) {
|
|
2775
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2776
|
+
}
|
|
2777
|
+
function parseLibraryIndexSlotClassifications(json) {
|
|
2778
|
+
if (!isPlainObject(json)) {
|
|
2779
|
+
throw new Error("library index-slot classifications must be a JSON object");
|
|
2780
|
+
}
|
|
2781
|
+
const map = new Map;
|
|
2782
|
+
for (const [key, value] of Object.entries(json)) {
|
|
2783
|
+
if (!isPlainObject(value)) {
|
|
2784
|
+
throw new Error(`library index-slot classification ${key} must be an object`);
|
|
2785
|
+
}
|
|
2786
|
+
const { class: slotClass, evidence } = value;
|
|
2787
|
+
if (typeof slotClass !== "string" || !INDEX_SLOT_CLASSES.has(slotClass)) {
|
|
2788
|
+
throw new Error(`library index-slot classification ${key} has class ${JSON.stringify(slotClass)}, not one of ${[...INDEX_SLOT_CLASSES].join(", ")}`);
|
|
2789
|
+
}
|
|
2790
|
+
if (typeof evidence !== "string" || evidence.trim() === "") {
|
|
2791
|
+
throw new Error(`library index-slot classification ${key} needs a non-blank evidence string`);
|
|
2792
|
+
}
|
|
2793
|
+
map.set(key, { class: slotClass, evidence });
|
|
2794
|
+
}
|
|
2795
|
+
return map;
|
|
2796
|
+
}
|
|
2751
2797
|
function libraryIndexBaseNotes(classifications, page, elementName, kind, slotName) {
|
|
2752
2798
|
return slotBaseNotes(classifications, `\`${page}\``, `${page}/${elementName}:${kind}:${slotName}`);
|
|
2753
2799
|
}
|
|
@@ -4939,6 +4985,16 @@ function wholeTokenMapping(token) {
|
|
|
4939
4985
|
}
|
|
4940
4986
|
return recoverCallbackSignature(token) ?? undefined;
|
|
4941
4987
|
}
|
|
4988
|
+
function unknownDefoldTypeLeaves(token) {
|
|
4989
|
+
if (token === "nil" || wholeTokenMapping(token) !== undefined)
|
|
4990
|
+
return [];
|
|
4991
|
+
if (token.trim() === "")
|
|
4992
|
+
return [token];
|
|
4993
|
+
return mapLualsExpression(token, resolveDefoldLeaf).unknowns;
|
|
4994
|
+
}
|
|
4995
|
+
function isKnownDefoldTypeToken(token) {
|
|
4996
|
+
return unknownDefoldTypeLeaves(token).length === 0;
|
|
4997
|
+
}
|
|
4942
4998
|
function defaultMapType(token, position) {
|
|
4943
4999
|
return wholeTokenMapping(token) ?? mapLualsExpression(token, resolveDefoldLeaf, position).ts;
|
|
4944
5000
|
}
|
|
@@ -7829,7 +7885,10 @@ function readZipDirectory(bytes, path) {
|
|
|
7829
7885
|
if (bytes.readUInt32LE(at) === ZIP_END_RECORD_SIGNATURE && at + ZIP_END_RECORD_SIZE + bytes.readUInt16LE(at + 20) === bytes.length) {
|
|
7830
7886
|
const directory = readCentralDirectory(bytes, at, path);
|
|
7831
7887
|
if (!(directory instanceof Error)) {
|
|
7832
|
-
return
|
|
7888
|
+
return {
|
|
7889
|
+
entries: directory,
|
|
7890
|
+
comment: bytes.toString("utf8", at + ZIP_END_RECORD_SIZE, bytes.length)
|
|
7891
|
+
};
|
|
7833
7892
|
}
|
|
7834
7893
|
nearestDefect ??= directory;
|
|
7835
7894
|
}
|
|
@@ -7841,31 +7900,34 @@ function readZipDirectory(bytes, path) {
|
|
|
7841
7900
|
}
|
|
7842
7901
|
function readZip(path) {
|
|
7843
7902
|
const bytes = readFileSync(path);
|
|
7844
|
-
const entries = readZipDirectory(bytes, path);
|
|
7903
|
+
const { entries, comment } = readZipDirectory(bytes, path);
|
|
7904
|
+
const entryBytes = (name) => {
|
|
7905
|
+
const entry = entries.get(name);
|
|
7906
|
+
if (entry === undefined) {
|
|
7907
|
+
throw new Error(`no entry ${name} in ${path}`);
|
|
7908
|
+
}
|
|
7909
|
+
const { localHeaderOffset, compressedSize, method } = entry;
|
|
7910
|
+
if (bytes.readUInt32LE(localHeaderOffset) !== ZIP_LOCAL_HEADER_SIGNATURE) {
|
|
7911
|
+
throw new Error(`${path}: local header of ${name} has no signature`);
|
|
7912
|
+
}
|
|
7913
|
+
const nameLength = bytes.readUInt16LE(localHeaderOffset + 26);
|
|
7914
|
+
const extraLength = bytes.readUInt16LE(localHeaderOffset + 28);
|
|
7915
|
+
const start = localHeaderOffset + 30 + nameLength + extraLength;
|
|
7916
|
+
const data = bytes.subarray(start, start + compressedSize);
|
|
7917
|
+
if (method === ZIP_METHOD_STORED) {
|
|
7918
|
+
return data;
|
|
7919
|
+
}
|
|
7920
|
+
if (method === ZIP_METHOD_DEFLATE) {
|
|
7921
|
+
return inflateRawSync(data);
|
|
7922
|
+
}
|
|
7923
|
+
throw new Error(`${path}: entry ${name} uses unsupported compression method ${method}`);
|
|
7924
|
+
};
|
|
7845
7925
|
return {
|
|
7846
7926
|
has: (name) => entries.has(name),
|
|
7847
7927
|
entries: () => [...entries.keys()],
|
|
7848
|
-
read: (name) =>
|
|
7849
|
-
|
|
7850
|
-
|
|
7851
|
-
throw new Error(`no entry ${name} in ${path}`);
|
|
7852
|
-
}
|
|
7853
|
-
const { localHeaderOffset, compressedSize, method } = entry;
|
|
7854
|
-
if (bytes.readUInt32LE(localHeaderOffset) !== ZIP_LOCAL_HEADER_SIGNATURE) {
|
|
7855
|
-
throw new Error(`${path}: local header of ${name} has no signature`);
|
|
7856
|
-
}
|
|
7857
|
-
const nameLength = bytes.readUInt16LE(localHeaderOffset + 26);
|
|
7858
|
-
const extraLength = bytes.readUInt16LE(localHeaderOffset + 28);
|
|
7859
|
-
const start = localHeaderOffset + 30 + nameLength + extraLength;
|
|
7860
|
-
const data = bytes.subarray(start, start + compressedSize);
|
|
7861
|
-
if (method === ZIP_METHOD_STORED) {
|
|
7862
|
-
return data.toString("utf8");
|
|
7863
|
-
}
|
|
7864
|
-
if (method === ZIP_METHOD_DEFLATE) {
|
|
7865
|
-
return inflateRawSync(data).toString("utf8");
|
|
7866
|
-
}
|
|
7867
|
-
throw new Error(`${path}: entry ${name} uses unsupported compression method ${method}`);
|
|
7868
|
-
}
|
|
7928
|
+
read: (name) => entryBytes(name).toString("utf8"),
|
|
7929
|
+
bytes: (name) => new Uint8Array(entryBytes(name)),
|
|
7930
|
+
comment: () => comment
|
|
7869
7931
|
};
|
|
7870
7932
|
}
|
|
7871
7933
|
function isRecord4(value) {
|