@gameslate/sdk 0.3.32 → 0.3.33

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 CHANGED
@@ -90,6 +90,9 @@ the input `downloads/<id>`; the player sees it among the plugin's permissions.
90
90
 
91
91
  `0.3.x` speaks plugin contract (`sdkApi`) 3: new 0.3 versions add tools, never change the contract. The core refuses a plugin built for another contract.
92
92
 
93
+ - **0.3.33**: the Limitations check nests as Markdown does: an item indented as far as its
94
+ parent's text (2 spaces under `- `, as Prettier writes it) is nested, not a top-level bullet
95
+ (0.3.32 read 1-3 spaces as top level and refused 2-space nesting).
93
96
  - **0.3.32**: the per-game README's `## Known Gaps` section is now `## Limitations`, and the
94
97
  support check refuses one with no bullets, a top-level bullet that doesn't start with
95
98
  `**Not tracked:**`, `**Not shown:**`, `**Can be wrong:**` or `**Not supported:**`, or those
@@ -10,20 +10,20 @@ const LIMITATION_LABELS = [
10
10
  '**Can be wrong:**',
11
11
  '**Not supported:**',
12
12
  ];
13
- /* Markdown's top level: up to 3 spaces before the marker; numbered items count too */
14
- const TOP_LEVEL_BULLET = /^ {0,3}(?:[-*+]|\d+[.)])\s+(.*)$/;
13
+ /* a list item: its indent, marker and the spaces before its text (numbered items count too) */
14
+ const LIST_ITEM = /^( {0,3})([-*+]|\d+[.)])( +)(.*)$/;
15
15
  /* `* * *`, `---`: a divider, not a bullet */
16
16
  const THEMATIC_BREAK = /^ {0,3}([-*_])( *\1){2,} *$/;
17
17
  const FENCE = /^ {0,3}(```|~~~)/;
18
18
  const SECTION_END = /^ {0,3}#{1,2}\s/;
19
- /* the top-level bullets between `## Limitations` and the next heading of level 1 or 2, outside
20
- * code fences; undefined when there is no such section */
21
- function findLimitationsBullets(body) {
19
+ /* the section's lines up to the next heading of level 1 or 2, fenced code left out; undefined
20
+ * when there is no `## Limitations` */
21
+ function findSectionLines(body) {
22
22
  const lines = body.split(/\r?\n/);
23
23
  const start = lines.findIndex(l => l.trimEnd() === LIMITATIONS_HEADING);
24
24
  if (start < 0)
25
25
  return undefined;
26
- const bullets = [];
26
+ const kept = [];
27
27
  let inFence = false;
28
28
  for (const line of lines.slice(start + 1)) {
29
29
  if (FENCE.test(line))
@@ -32,19 +32,44 @@ function findLimitationsBullets(body) {
32
32
  continue;
33
33
  else if (SECTION_END.test(line))
34
34
  break;
35
- else if (!THEMATIC_BREAK.test(line)) {
36
- const text = TOP_LEVEL_BULLET.exec(line)?.[1];
37
- if (text !== undefined)
38
- bullets.push(text);
35
+ else
36
+ kept.push(line);
37
+ }
38
+ return kept;
39
+ }
40
+ /* The top-level items' text. As in CommonMark, an item is nested when it is indented as far as
41
+ * the text of the top-level item above it (2 spaces under `- `, 3 under `1. `), and top level
42
+ * when indented less. A paragraph after a blank line ends the list. */
43
+ function topLevelItems(lines) {
44
+ const items = [];
45
+ /* where the text of the last top-level item starts; undefined outside a list */
46
+ let textColumn;
47
+ let afterBlank = false;
48
+ for (const line of lines) {
49
+ if (line.trim() === '') {
50
+ afterBlank = true;
51
+ continue;
52
+ }
53
+ const indent = line.length - line.trimStart().length;
54
+ const item = THEMATIC_BREAK.test(line) ? null : LIST_ITEM.exec(line);
55
+ const topLevel = textColumn === undefined || indent < textColumn;
56
+ if (item && topLevel) {
57
+ const [, lead = '', marker = '', gap = '', text = ''] = item;
58
+ items.push(text);
59
+ textColumn = lead.length + marker.length + gap.length;
39
60
  }
61
+ else if (!item && afterBlank && topLevel)
62
+ textColumn = undefined;
63
+ afterBlank = false;
40
64
  }
41
- return bullets;
65
+ return items;
42
66
  }
43
67
  /** Checks the Limitations section's shape: labelled top-level bullets, labels in order. */
44
68
  export function checkLimitationsSection(body, problems) {
45
- const bullets = findLimitationsBullets(body);
46
- if (bullets === undefined)
69
+ const lines = findSectionLines(body);
70
+ if (lines === undefined)
47
71
  return;
72
+ const bullets = topLevelItems(lines);
48
73
  const labelList = LIMITATION_LABELS.join(', ');
49
74
  if (bullets.length === 0) {
50
75
  problems.push(`section "${LIMITATIONS_HEADING}" has no bullets: start each with ${labelList}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gameslate/sdk",
3
- "version": "0.3.32",
3
+ "version": "0.3.33",
4
4
  "description": "Build plugins for GameSlate, the second-screen companion for PC games: the plugin contract, game-state and catalogue schemas, and the plugin builder.",
5
5
  "license": "MIT",
6
6
  "type": "module",