@defold-typescript/types 0.55.0 → 0.57.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.
@@ -1963,6 +1963,15 @@ function weldStrandedListMarkers(text) {
1963
1963
  return out.join(`
1964
1964
  `).trim();
1965
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
+ }
1966
1975
  function preToMarkdown(inner) {
1967
1976
  const lines = htmlToCodeText(inner).split(`
1968
1977
  `);
@@ -1999,8 +2008,8 @@ ${LIST_INDENT.repeat(Math.max(0, listDepth - 1))}- `;
1999
2008
  }).replace(/<br\s*\/?>/gi, `
2000
2009
  `).replace(/<\/p>/gi, `
2001
2010
 
2002
- `).replace(/<[^>]+>/g, "");
2003
- text = decodeEntities(text);
2011
+ `);
2012
+ text = decodeEntities(stripMarkup(text));
2004
2013
  text = text.replace(/[ \t]+/g, " ").replace(/ *\n */g, `
2005
2014
  `).replace(/\n{3,}/g, `
2006
2015
 
@@ -2012,9 +2021,9 @@ ${LIST_INDENT.repeat(Math.max(0, listDepth - 1))}- `;
2012
2021
  return text.split("*/").join("*\\/");
2013
2022
  }
2014
2023
  function htmlToCodeText(html) {
2015
- let text = html.replace(/<br\s*\/?>/gi, `
2016
- `).replace(/<[^>]+>/g, "");
2017
- text = decodeEntities(text);
2024
+ const stripped = stripMarkup(html.replace(/<br\s*\/?>/gi, `
2025
+ `));
2026
+ const text = decodeEntities(stripped);
2018
2027
  const lines = text.split(`
2019
2028
  `).map((line) => line.replace(/[ \t]+$/g, ""));
2020
2029
  while (lines.length > 0 && lines[0] === "")
@@ -2191,7 +2200,7 @@ function renderDocComment(parts) {
2191
2200
  }
2192
2201
  return [...lines.map((line) => line.replaceAll("*/", "*\\/")), " */"];
2193
2202
  }
2194
- 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;
2195
2204
  var init_doc_comment = __esm(() => {
2196
2205
  NAMED_ENTITIES = {
2197
2206
  amp: "&",
@@ -2220,6 +2229,12 @@ var init_doc_comment = __esm(() => {
2220
2229
  };
2221
2230
  STRANDED_MARKER = /^(*)-$/;
2222
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");
2223
2238
  MISREAD_MARKDOWN_LINE = /^\s*`[^`]+`/;
2224
2239
  MANGLED_FENCE = /<code>([A-Za-z0-9_+-]+)\n([\s\S]*?)<\/code>/g;
2225
2240
  FENCE_OPENER = /^```([A-Za-z0-9_+-]+)$/;
@@ -55,6 +55,15 @@ function weldStrandedListMarkers(text) {
55
55
  return out.join(`
56
56
  `).trim();
57
57
  }
58
+ function stripMarkup(html) {
59
+ let text = html;
60
+ let previous;
61
+ do {
62
+ previous = text;
63
+ text = text.replace(MARKUP_TAG, "");
64
+ } while (text !== previous);
65
+ return text;
66
+ }
58
67
  function preToMarkdown(inner) {
59
68
  const lines = htmlToCodeText(inner).split(`
60
69
  `);
@@ -91,8 +100,8 @@ ${LIST_INDENT.repeat(Math.max(0, listDepth - 1))}- `;
91
100
  }).replace(/<br\s*\/?>/gi, `
92
101
  `).replace(/<\/p>/gi, `
93
102
 
94
- `).replace(/<[^>]+>/g, "");
95
- text = decodeEntities(text);
103
+ `);
104
+ text = decodeEntities(stripMarkup(text));
96
105
  text = text.replace(/[ \t]+/g, " ").replace(/ *\n */g, `
97
106
  `).replace(/\n{3,}/g, `
98
107
 
@@ -104,9 +113,9 @@ ${LIST_INDENT.repeat(Math.max(0, listDepth - 1))}- `;
104
113
  return text.split("*/").join("*\\/");
105
114
  }
106
115
  function htmlToCodeText(html) {
107
- let text = html.replace(/<br\s*\/?>/gi, `
108
- `).replace(/<[^>]+>/g, "");
109
- text = decodeEntities(text);
116
+ const stripped = stripMarkup(html.replace(/<br\s*\/?>/gi, `
117
+ `));
118
+ const text = decodeEntities(stripped);
110
119
  const lines = text.split(`
111
120
  `).map((line) => line.replace(/[ \t]+$/g, ""));
112
121
  while (lines.length > 0 && lines[0] === "")
@@ -283,7 +292,7 @@ function renderDocComment(parts) {
283
292
  }
284
293
  return [...lines.map((line) => line.replaceAll("*/", "*\\/")), " */"];
285
294
  }
286
- var NAMED_ENTITIES, LIST_INDENT = "", STRANDED_MARKER, LIST_ITEM, MISREAD_MARKDOWN_LINE, MANGLED_FENCE, FENCE_OPENER;
295
+ var NAMED_ENTITIES, LIST_INDENT = "", STRANDED_MARKER, LIST_ITEM, MARKUP_TAG, MISREAD_MARKDOWN_LINE, MANGLED_FENCE, FENCE_OPENER;
287
296
  var init_doc_comment = __esm(() => {
288
297
  NAMED_ENTITIES = {
289
298
  amp: "&",
@@ -312,6 +321,12 @@ var init_doc_comment = __esm(() => {
312
321
  };
313
322
  STRANDED_MARKER = /^(*)-$/;
314
323
  LIST_ITEM = /^*- /;
324
+ MARKUP_TAG = new RegExp([
325
+ "</?(?: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*/?>",
326
+ "</?(?:script|style|iframe)\\b[^<>]*>",
327
+ `</?[a-z][^<>=]*=(?:[^<>"']|"[^"]*"|'[^']*')*>`,
328
+ "</?[a-z][^<>=]*=[^<>]*>"
329
+ ].join("|"), "gi");
315
330
  MISREAD_MARKDOWN_LINE = /^\s*`[^`]+`/;
316
331
  MANGLED_FENCE = /<code>([A-Za-z0-9_+-]+)\n([\s\S]*?)<\/code>/g;
317
332
  FENCE_OPENER = /^```([A-Za-z0-9_+-]+)$/;
@@ -795,8 +795,8 @@
795
795
  ],
796
796
  "gui.play_particlefx": [
797
797
  {
798
- "sourceHash": "19a26b6e14ad0997",
799
- "ts": "// How to play a particle fx when a gui node is created.\n// The callback receives the gui node, the hash of the id\n// of the emitter, and the new state of the emitter as particlefx.EMITTER_STATE_.\nexport default defineGuiScript({\n init(self) {\n gui.play_particlefx(gui.get_node(\"particlefx\"), (self, node, emitter, state) => {\n if (emitter === hash(\"exhaust\") && state === particlefx.EMITTER_STATE_POSTSPAWN) {\n // exhaust is done spawning particles...\n }\n });\n },\n});"
798
+ "sourceHash": "3a4e5cb8e98bf1a0",
799
+ "ts": "// How to play a particle fx when a gui node is created.\n// The callback receives the gui node, the hash of the id\n// of the emitter, and the new state of the emitter as particlefx.EMITTER_STATE_<STATE>.\nexport default defineGuiScript({\n init(self) {\n gui.play_particlefx(gui.get_node(\"particlefx\"), (self, node, emitter, state) => {\n if (emitter === hash(\"exhaust\") && state === particlefx.EMITTER_STATE_POSTSPAWN) {\n // exhaust is done spawning particles...\n }\n });\n },\n});"
800
800
  }
801
801
  ],
802
802
  "gui.reset_material": [
@@ -1107,8 +1107,8 @@
1107
1107
  ],
1108
1108
  "particlefx.play": [
1109
1109
  {
1110
- "sourceHash": "01a21997b47ac4fc",
1111
- "ts": "// How to play a particle fx when a game object is created.\n// The callback receives the hash of the path to the particlefx, the hash of the id\n// of the emitter, and the new state of the emitter as particlefx.EMITTER_STATE_.\nexport default defineScript({\n init(self) {\n particlefx.play(\"#particlefx\", (self, id, emitter, state) => {\n if (emitter === hash(\"exhaust\") && state === particlefx.EMITTER_STATE_POSTSPAWN) {\n // exhaust is done spawning particles...\n }\n });\n },\n});"
1110
+ "sourceHash": "ad5d0aba2677b291",
1111
+ "ts": "// How to play a particle fx when a game object is created.\n// The callback receives the hash of the path to the particlefx, the hash of the id\n// of the emitter, and the new state of the emitter as particlefx.EMITTER_STATE_<STATE>.\nexport default defineScript({\n init(self) {\n particlefx.play(\"#particlefx\", (self, id, emitter, state) => {\n if (emitter === hash(\"exhaust\") && state === particlefx.EMITTER_STATE_POSTSPAWN) {\n // exhaust is done spawning particles...\n }\n });\n },\n});"
1112
1112
  }
1113
1113
  ],
1114
1114
  "particlefx.reset_constant": [
@@ -1355,7 +1355,7 @@ declare global {
1355
1355
  * ```ts
1356
1356
  * // How to play a particle fx when a gui node is created.
1357
1357
  * // The callback receives the gui node, the hash of the id
1358
- * // of the emitter, and the new state of the emitter as particlefx.EMITTER_STATE_.
1358
+ * // of the emitter, and the new state of the emitter as particlefx.EMITTER_STATE_<STATE>.
1359
1359
  * export default defineGuiScript({
1360
1360
  * init(self) {
1361
1361
  * gui.play_particlefx(gui.get_node("particlefx"), (self, node, emitter, state) => {
@@ -45,7 +45,7 @@ declare global {
45
45
  * ```ts
46
46
  * // How to play a particle fx when a game object is created.
47
47
  * // The callback receives the hash of the path to the particlefx, the hash of the id
48
- * // of the emitter, and the new state of the emitter as particlefx.EMITTER_STATE_.
48
+ * // of the emitter, and the new state of the emitter as particlefx.EMITTER_STATE_<STATE>.
49
49
  * export default defineScript({
50
50
  * init(self) {
51
51
  * particlefx.play("#particlefx", (self, id, emitter, state) => {
@@ -1324,7 +1324,7 @@ declare global {
1324
1324
  * ```ts
1325
1325
  * // How to play a particle fx when a gui node is created.
1326
1326
  * // The callback receives the gui node, the hash of the id
1327
- * // of the emitter, and the new state of the emitter as particlefx.EMITTER_STATE_.
1327
+ * // of the emitter, and the new state of the emitter as particlefx.EMITTER_STATE_<STATE>.
1328
1328
  * export default defineGuiScript({
1329
1329
  * init(self) {
1330
1330
  * gui.play_particlefx(gui.get_node("particlefx"), (self, node, emitter, state) => {
@@ -53,7 +53,7 @@ declare global {
53
53
  * AABB information return as a table with `min` and `max` fields, where `min` and `max` has type `vmath.vector3`.
54
54
  *
55
55
  * @param url - the model
56
- * @returns A table containing info about all AABB in the format
56
+ * @returns A table containing info about all AABB in the format <hash(mesh_id), aabb_info>
57
57
  * @example
58
58
  * ```ts
59
59
  * model.get_mesh_aabb("#model"); // => { hash("Sword") = { min = vmath.vector3(-0.5, -0.5, 0), max = vmath.vector3(0.5, 0.5, 0) }, hash("Shield") = { min = vmath.vector3(-0.5, -0.5, -0.5), max = vmath.vector3(0.5, 0.5, 0.5) } }
@@ -49,7 +49,7 @@ declare global {
49
49
  * ```ts
50
50
  * // How to play a particle fx when a game object is created.
51
51
  * // The callback receives the hash of the path to the particlefx, the hash of the id
52
- * // of the emitter, and the new state of the emitter as particlefx.EMITTER_STATE_.
52
+ * // of the emitter, and the new state of the emitter as particlefx.EMITTER_STATE_<STATE>.
53
53
  * export default defineScript({
54
54
  * init(self) {
55
55
  * particlefx.play("#particlefx", (self, id, emitter, state) => {
@@ -102,10 +102,10 @@ declare global {
102
102
  * number the height of the animation
103
103
  *
104
104
  * - `frame_start`
105
- * number index to the first geometry of the animation. Indices are lua based and must be in the range of 1 .. in atlas.
105
+ * number index to the first geometry of the animation. Indices are lua based and must be in the range of 1 .. <number-of-geometries> in atlas.
106
106
  *
107
107
  * - `frame_end`
108
- * number index to the last geometry of the animation (non-inclusive). Indices are lua based and must be in the range of 1 .. in atlas.
108
+ * number index to the last geometry of the animation (non-inclusive). Indices are lua based and must be in the range of 1 .. <number-of-geometries> in atlas.
109
109
  *
110
110
  * - `playback`
111
111
  * constant optional playback mode of the animation, the default value is go.PLAYBACK_ONCE_FORWARD
@@ -1096,10 +1096,10 @@ declare global {
1096
1096
  * number the height of the animation
1097
1097
  *
1098
1098
  * - `frame_start`
1099
- * number index to the first geometry of the animation. Indices are lua based and must be in the range of 1 .. in atlas.
1099
+ * number index to the first geometry of the animation. Indices are lua based and must be in the range of 1 .. <number-of-geometries> in atlas.
1100
1100
  *
1101
1101
  * - `frame_end`
1102
- * number index to the last geometry of the animation (non-inclusive). Indices are lua based and must be in the range of 1 .. in atlas.
1102
+ * number index to the last geometry of the animation (non-inclusive). Indices are lua based and must be in the range of 1 .. <number-of-geometries> in atlas.
1103
1103
  *
1104
1104
  * - `playback`
1105
1105
  * constant optional playback mode of the animation, the default value is go.PLAYBACK_ONCE_FORWARD
@@ -1322,7 +1322,7 @@ declare global {
1322
1322
  * ```ts
1323
1323
  * // How to play a particle fx when a gui node is created.
1324
1324
  * // The callback receives the gui node, the hash of the id
1325
- * // of the emitter, and the new state of the emitter as particlefx.EMITTER_STATE_.
1325
+ * // of the emitter, and the new state of the emitter as particlefx.EMITTER_STATE_<STATE>.
1326
1326
  * export default defineGuiScript({
1327
1327
  * init(self) {
1328
1328
  * gui.play_particlefx(gui.get_node("particlefx"), (self, node, emitter, state) => {
@@ -72,7 +72,7 @@ declare global {
72
72
  * AABB information return as a table with `min` and `max` fields, where `min` and `max` has type `vmath.vector3`.
73
73
  *
74
74
  * @param url - the model
75
- * @returns A table containing info about all AABB in the format
75
+ * @returns A table containing info about all AABB in the format <hash(mesh_id), aabb_info>
76
76
  * @example
77
77
  * ```ts
78
78
  * model.get_mesh_aabb("#model"); // => { hash("Sword") = { min = vmath.vector3(-0.5, -0.5, 0), max = vmath.vector3(0.5, 0.5, 0) }, hash("Shield") = { min = vmath.vector3(-0.5, -0.5, -0.5), max = vmath.vector3(0.5, 0.5, 0.5) } }
@@ -49,7 +49,7 @@ declare global {
49
49
  * ```ts
50
50
  * // How to play a particle fx when a game object is created.
51
51
  * // The callback receives the hash of the path to the particlefx, the hash of the id
52
- * // of the emitter, and the new state of the emitter as particlefx.EMITTER_STATE_.
52
+ * // of the emitter, and the new state of the emitter as particlefx.EMITTER_STATE_<STATE>.
53
53
  * export default defineScript({
54
54
  * init(self) {
55
55
  * particlefx.play("#particlefx", (self, id, emitter, state) => {
@@ -102,10 +102,10 @@ declare global {
102
102
  * number the height of the animation
103
103
  *
104
104
  * - `frame_start`
105
- * number index to the first geometry of the animation. Indices are lua based and must be in the range of 1 .. in atlas.
105
+ * number index to the first geometry of the animation. Indices are lua based and must be in the range of 1 .. <number-of-geometries> in atlas.
106
106
  *
107
107
  * - `frame_end`
108
- * number index to the last geometry of the animation (non-inclusive). Indices are lua based and must be in the range of 1 .. in atlas.
108
+ * number index to the last geometry of the animation (non-inclusive). Indices are lua based and must be in the range of 1 .. <number-of-geometries> in atlas.
109
109
  *
110
110
  * - `playback`
111
111
  * constant optional playback mode of the animation, the default value is go.PLAYBACK_ONCE_FORWARD
@@ -1100,10 +1100,10 @@ declare global {
1100
1100
  * number the height of the animation
1101
1101
  *
1102
1102
  * - `frame_start`
1103
- * number index to the first geometry of the animation. Indices are lua based and must be in the range of 1 .. in atlas.
1103
+ * number index to the first geometry of the animation. Indices are lua based and must be in the range of 1 .. <number-of-geometries> in atlas.
1104
1104
  *
1105
1105
  * - `frame_end`
1106
- * number index to the last geometry of the animation (non-inclusive). Indices are lua based and must be in the range of 1 .. in atlas.
1106
+ * number index to the last geometry of the animation (non-inclusive). Indices are lua based and must be in the range of 1 .. <number-of-geometries> in atlas.
1107
1107
  *
1108
1108
  * - `playback`
1109
1109
  * constant optional playback mode of the animation, the default value is go.PLAYBACK_ONCE_FORWARD
@@ -1322,7 +1322,7 @@ declare global {
1322
1322
  * ```ts
1323
1323
  * // How to play a particle fx when a gui node is created.
1324
1324
  * // The callback receives the gui node, the hash of the id
1325
- * // of the emitter, and the new state of the emitter as particlefx.EMITTER_STATE_.
1325
+ * // of the emitter, and the new state of the emitter as particlefx.EMITTER_STATE_<STATE>.
1326
1326
  * export default defineGuiScript({
1327
1327
  * init(self) {
1328
1328
  * gui.play_particlefx(gui.get_node("particlefx"), (self, node, emitter, state) => {
@@ -72,7 +72,7 @@ declare global {
72
72
  * AABB information return as a table with `min` and `max` fields, where `min` and `max` has type `vmath.vector3`.
73
73
  *
74
74
  * @param url - the model
75
- * @returns A table containing info about all AABB in the format
75
+ * @returns A table containing info about all AABB in the format <hash(mesh_id), aabb_info>
76
76
  * @example
77
77
  * ```ts
78
78
  * model.get_mesh_aabb("#model"); // => { hash("Sword") = { min = vmath.vector3(-0.5, -0.5, 0), max = vmath.vector3(0.5, 0.5, 0) }, hash("Shield") = { min = vmath.vector3(-0.5, -0.5, -0.5), max = vmath.vector3(0.5, 0.5, 0.5) } }
@@ -49,7 +49,7 @@ declare global {
49
49
  * ```ts
50
50
  * // How to play a particle fx when a game object is created.
51
51
  * // The callback receives the hash of the path to the particlefx, the hash of the id
52
- * // of the emitter, and the new state of the emitter as particlefx.EMITTER_STATE_.
52
+ * // of the emitter, and the new state of the emitter as particlefx.EMITTER_STATE_<STATE>.
53
53
  * export default defineScript({
54
54
  * init(self) {
55
55
  * particlefx.play("#particlefx", (self, id, emitter, state) => {
@@ -102,10 +102,10 @@ declare global {
102
102
  * number the height of the animation
103
103
  *
104
104
  * - `frame_start`
105
- * number index to the first geometry of the animation. Indices are lua based and must be in the range of 1 .. in atlas.
105
+ * number index to the first geometry of the animation. Indices are lua based and must be in the range of 1 .. <number-of-geometries> in atlas.
106
106
  *
107
107
  * - `frame_end`
108
- * number index to the last geometry of the animation (non-inclusive). Indices are lua based and must be in the range of 1 .. in atlas.
108
+ * number index to the last geometry of the animation (non-inclusive). Indices are lua based and must be in the range of 1 .. <number-of-geometries> in atlas.
109
109
  *
110
110
  * - `playback`
111
111
  * constant optional playback mode of the animation, the default value is go.PLAYBACK_ONCE_FORWARD
@@ -1100,10 +1100,10 @@ declare global {
1100
1100
  * number the height of the animation
1101
1101
  *
1102
1102
  * - `frame_start`
1103
- * number index to the first geometry of the animation. Indices are lua based and must be in the range of 1 .. in atlas.
1103
+ * number index to the first geometry of the animation. Indices are lua based and must be in the range of 1 .. <number-of-geometries> in atlas.
1104
1104
  *
1105
1105
  * - `frame_end`
1106
- * number index to the last geometry of the animation (non-inclusive). Indices are lua based and must be in the range of 1 .. in atlas.
1106
+ * number index to the last geometry of the animation (non-inclusive). Indices are lua based and must be in the range of 1 .. <number-of-geometries> in atlas.
1107
1107
  *
1108
1108
  * - `playback`
1109
1109
  * constant optional playback mode of the animation, the default value is go.PLAYBACK_ONCE_FORWARD
@@ -1355,7 +1355,7 @@ declare global {
1355
1355
  * ```ts
1356
1356
  * // How to play a particle fx when a gui node is created.
1357
1357
  * // The callback receives the gui node, the hash of the id
1358
- * // of the emitter, and the new state of the emitter as particlefx.EMITTER_STATE_.
1358
+ * // of the emitter, and the new state of the emitter as particlefx.EMITTER_STATE_<STATE>.
1359
1359
  * export default defineGuiScript({
1360
1360
  * init(self) {
1361
1361
  * gui.play_particlefx(gui.get_node("particlefx"), (self, node, emitter, state) => {
@@ -45,7 +45,7 @@ declare global {
45
45
  * ```ts
46
46
  * // How to play a particle fx when a game object is created.
47
47
  * // The callback receives the hash of the path to the particlefx, the hash of the id
48
- * // of the emitter, and the new state of the emitter as particlefx.EMITTER_STATE_.
48
+ * // of the emitter, and the new state of the emitter as particlefx.EMITTER_STATE_<STATE>.
49
49
  * export default defineScript({
50
50
  * init(self) {
51
51
  * particlefx.play("#particlefx", (self, id, emitter, state) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defold-typescript/types",
3
- "version": "0.55.0",
3
+ "version": "0.57.0",
4
4
  "description": "TypeScript types for the Defold engine's Lua APIs.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -13,11 +13,11 @@ export const EXTENSION_GOLDENS_DIR = "extension-goldens";
13
13
  const PACKAGE_ROOT = resolve(import.meta.dirname, "..");
14
14
  const EXTENSION_GOLDEN_NAMESPACES = ["iac", "iap", "push", "webview"] as const;
15
15
 
16
- // Each golden's doc is the conversion of the extension's `.script_api` at its
17
- // `packages/library-types/defold-extensions.json` pin, the same JSON the
18
- // Libraries pages render, so a golden carries the namespace's constants, optional
19
- // slots and callback arguments exactly as `resolve` would emit them for a project.
20
- const EXTENSION_DOCS_DIR = resolve(PACKAGE_ROOT, "../library-types/defold-extensions/api-doc");
16
+ // Each golden's doc is a copy of the conversion of the extension's `.script_api`
17
+ // at its `defold-extensions.json` pin, the same JSON the Libraries pages render,
18
+ // so a golden carries the namespace's constants, optional slots and callback
19
+ // arguments exactly as `resolve` would emit them for a project.
20
+ const EXTENSION_DOCS_DIR = resolve(PACKAGE_ROOT, "fixtures/extension-docs");
21
21
 
22
22
  export const EXTENSION_GOLDEN_MANIFEST: readonly ModuleManifestEntry[] =
23
23
  EXTENSION_GOLDEN_NAMESPACES.map((namespace) => ({
@@ -23,7 +23,7 @@ export interface SignaturesArtifact {
23
23
  readonly versions: Record<string, Record<string, string>>;
24
24
  // The same axis and keys, carrying each documented slot's rendered type. Kept
25
25
  // parallel rather than folded into `versions` because three consumers
26
- // (`api-surface-loader`, `combined-surface`, `version-window`) type that map's
26
+ // (`toolchain-surface-loader`, `combined-surface`, `version-window`) type that map's
27
27
  // value as a string; a symbol documenting no slot is absent here.
28
28
  readonly slotTypes: Record<string, Record<string, SlotTypes>>;
29
29
  }
@@ -87,6 +87,37 @@ function weldStrandedListMarkers(text: string): string {
87
87
  return out.join("\n").trim();
88
88
  }
89
89
 
90
+ // What counts as markup in upstream prose: the tags the docs use, plus any tag
91
+ // assigning an attribute. Every other `<` is text, as in `Values <= 0` or
92
+ // `<logger_name>.log`. A listed name must close straight away, because a
93
+ // comparison such as `a <b and c> d` reads the same as a tag with bare
94
+ // attributes. `object` stays off the list: `wrap` documents `<object>` as text.
95
+ // `lia` and `super` are upstream typos. The toolchain docs site renders this
96
+ // output with `html: true`, so script-bearing elements go whatever follows their
97
+ // name, and a quoted attribute value may hold a `<` a browser reads as part of
98
+ // the tag.
99
+ const MARKUP_TAG = new RegExp(
100
+ [
101
+ "</?(?: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*/?>",
102
+ "</?(?:script|style|iframe)\\b[^<>]*>",
103
+ "</?[a-z][^<>=]*=(?:[^<>\"']|\"[^\"]*\"|'[^']*')*>",
104
+ "</?[a-z][^<>=]*=[^<>]*>",
105
+ ].join("|"),
106
+ "gi",
107
+ );
108
+
109
+ // Removing a tag can join the text around it into a new one (`<scr<b>ipt>`), so
110
+ // this repeats until nothing changes.
111
+ function stripMarkup(html: string): string {
112
+ let text = html;
113
+ let previous: string;
114
+ do {
115
+ previous = text;
116
+ text = text.replace(MARKUP_TAG, "");
117
+ } while (text !== previous);
118
+ return text;
119
+ }
120
+
90
121
  // Upstream Markdown indented one level too deep is highlighted as code while
91
122
  // still reading as Markdown: every line opens on a backtick-quoted name, as in
92
123
  // the field table `graphics.get_adapter_info` documents under `limits`. That
@@ -156,10 +187,9 @@ export function htmlToDocText(html: string): string {
156
187
  return close ? "" : `\n${LIST_INDENT.repeat(Math.max(0, listDepth - 1))}- `;
157
188
  })
158
189
  .replace(/<br\s*\/?>/gi, "\n")
159
- .replace(/<\/p>/gi, "\n\n")
160
- .replace(/<[^>]+>/g, "");
190
+ .replace(/<\/p>/gi, "\n\n");
161
191
 
162
- text = decodeEntities(text);
192
+ text = decodeEntities(stripMarkup(text));
163
193
 
164
194
  // Collapse horizontal whitespace runs, trim around newlines, fold runaway
165
195
  // blank runs to one blank line, then trim the whole string — preserving
@@ -195,8 +225,8 @@ export function htmlToDocText(html: string): string {
195
225
  * runs of blank lines to one. Returns `""` for empty / whitespace-only input.
196
226
  */
197
227
  export function htmlToCodeText(html: string): string {
198
- let text = html.replace(/<br\s*\/?>/gi, "\n").replace(/<[^>]+>/g, "");
199
- text = decodeEntities(text);
228
+ const stripped = stripMarkup(html.replace(/<br\s*\/?>/gi, "\n"));
229
+ const text = decodeEntities(stripped);
200
230
 
201
231
  const lines = text.split("\n").map((line) => line.replace(/[ \t]+$/g, ""));
202
232
  while (lines.length > 0 && lines[0] === "") lines.shift();
@@ -568,7 +568,7 @@ function isPlainObject(value: unknown): value is Record<string, unknown> {
568
568
  // multi-value return as a field of that return (`cast:return::tile_x`). A
569
569
  // typedef method is keyed by its bare name, so one key covers every class of the
570
570
  // page that declares that method.
571
- // `docs-site/app/lib/library-index-slot-gate.test.ts` reds on a scanned slot
571
+ // The library docs site's `site/app/lib/library-index-slot-gate.test.ts` reds on a scanned slot
572
572
  // missing from the library data folder's `index-slot-classifications.json` and on an entry
573
573
  // no library page declares.
574
574
  export function parseLibraryIndexSlotClassifications(