kopytko-formatter 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Błażej Chełkowski
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,141 @@
1
+ # kopytko-formatter
2
+
3
+ BrightScript formatter and code style checker for the [Kopytko ecosystem](https://github.com/bchelkowski/vscode-kopytko).
4
+
5
+ Use it as a **CLI tool** in CI pipelines, or import it as a **library** in your own tools.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install --save-dev kopytko-formatter
11
+ ```
12
+
13
+ ## CLI Usage
14
+
15
+ ```bash
16
+ # Check mode — exit 1 if any file needs formatting (use in CI)
17
+ npx kopytko-format --check "src/**/*.brs"
18
+
19
+ # Write mode — format files in place
20
+ npx kopytko-format --write "src/**/*.brs"
21
+
22
+ # With explicit config
23
+ npx kopytko-format --check --config .kopytkorc "components/**/*.brs"
24
+ ```
25
+
26
+ ### Options
27
+
28
+ | Flag | Description |
29
+ |---|---|
30
+ | `--check` | Check mode — exit 1 if any file needs formatting |
31
+ | `--write` | Write formatted output back to files |
32
+ | `--config <path>` | Path to config file (JSON) |
33
+ | `--ignore <glob>` | Glob pattern of files to skip (repeatable) |
34
+ | `--help`, `-h` | Show help |
35
+ | `--version`, `-v` | Show version |
36
+
37
+ ## Configuration
38
+
39
+ The formatter reads config from (in priority order):
40
+
41
+ 1. `--config <file>` CLI flag
42
+ 2. `kopytko-formatter.json` in the current directory
43
+ 3. `.vscode/settings.json` — reads `kopytko.format.*` keys automatically
44
+
45
+ Config keys match the VS Code extension settings without the `kopytko.format.` prefix.
46
+
47
+ ### Example `kopytko-formatter.json`
48
+
49
+ ```json
50
+ {
51
+ "indentSize": 2,
52
+ "endKeywordStyle": "spaced",
53
+ "trimTrailingWhitespace": true,
54
+ "insertFinalNewline": true,
55
+ "spaceAroundOperators": true,
56
+ "spaceAroundAssignment": true,
57
+ "sortImports": true,
58
+ "emptyLineAfterImports": true,
59
+ "maxEmptyLines": 1,
60
+ "emptyLinesBetweenFunctions": 1,
61
+ "keywordCasing": "LowerCase",
62
+ "builtinCasing": "PascalCase",
63
+ "typeCasing": "PascalCase",
64
+ "literalCasing": "LowerCase",
65
+ "logicOperatorCasing": "UpperCase",
66
+ "ignore": [
67
+ "**/node_modules/**",
68
+ "**/dist/**",
69
+ "**/_tests/**"
70
+ ]
71
+ }
72
+ ```
73
+
74
+ If your project already has formatting settings in `.vscode/settings.json`, no extra config file is needed — the CLI reads them directly.
75
+
76
+ ### Ignoring files
77
+
78
+ Exclude paths from formatting via the `ignore` array in your config file or the `--ignore` CLI flag:
79
+
80
+ ```bash
81
+ # CLI flag (repeatable)
82
+ npx kopytko-format --check --ignore "**/_tests/**" --ignore "**/dist/**" app
83
+
84
+ # Or in kopytko-formatter.json / .vscode/settings.json
85
+ # "ignore": ["**/_tests/**", "**/dist/**"]
86
+ ```
87
+
88
+ Patterns use glob syntax: `*` matches within a path segment, `**` matches any depth.
89
+
90
+ ## Library Usage
91
+
92
+ ```typescript
93
+ import { formatText, checkFormatting, DEFAULT_FORMATTING_CONFIG } from 'kopytko-formatter';
94
+
95
+ // Format a BrightScript source string
96
+ const formatted = formatText(source, {
97
+ ...DEFAULT_FORMATTING_CONFIG,
98
+ indentSize: 2,
99
+ endKeywordStyle: 'spaced',
100
+ });
101
+
102
+ // Check if source is already formatted (returns boolean)
103
+ const isClean = checkFormatting(source, DEFAULT_FORMATTING_CONFIG);
104
+ ```
105
+
106
+ ### API
107
+
108
+ #### `formatText(source, config, casing?, userFunctions?): string`
109
+
110
+ Formats BrightScript source code using an 11-pass engine.
111
+
112
+ - `source` — raw BrightScript source text
113
+ - `config` — `FormattingConfig` object
114
+ - `casing` — optional `CasingConfig` for identifier casing rules
115
+ - `userFunctions` — optional array of known function definitions for casing normalization
116
+
117
+ #### `checkFormatting(source, config, casing?, userFunctions?): boolean`
118
+
119
+ Returns `true` if the source text is already formatted (no changes needed).
120
+
121
+ ## GitHub Actions
122
+
123
+ ```yaml
124
+ # .github/workflows/format-check.yml
125
+ name: Format Check
126
+ on: [push, pull_request]
127
+ jobs:
128
+ format:
129
+ runs-on: ubuntu-latest
130
+ steps:
131
+ - uses: actions/checkout@v4
132
+ - uses: actions/setup-node@v4
133
+ with:
134
+ node-version: 24
135
+ - run: npm ci
136
+ - run: npx kopytko-format --check "src/**/*.brs"
137
+ ```
138
+
139
+ ## License
140
+
141
+ MIT
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=kopytko-format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kopytko-format.d.ts","sourceRoot":"","sources":["../../bin/kopytko-format.ts"],"names":[],"mappings":""}
@@ -0,0 +1,356 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ const fs = __importStar(require("fs"));
38
+ const path = __importStar(require("path"));
39
+ const formatter_1 = require("../src/formatter");
40
+ const config_1 = require("../src/config");
41
+ const casing_1 = require("../src/casing");
42
+ const VERSION = require('../../package.json').version;
43
+ function printUsage() {
44
+ console.log(`
45
+ kopytko-format v${VERSION}
46
+ BrightScript formatter for the Kopytko ecosystem.
47
+
48
+ USAGE
49
+ kopytko-format [options] <glob ...>
50
+
51
+ OPTIONS
52
+ --check Check mode — exit 1 if any file needs formatting.
53
+ --write Write formatted output back to files (default: print diff).
54
+ --config <path> Path to config file (JSON). Default: auto-detect.
55
+ --ignore <glob> Glob pattern of files to skip (repeatable).
56
+ --help, -h Show this help message.
57
+ --version, -v Show version.
58
+
59
+ EXAMPLES
60
+ kopytko-format --check "src/**/*.brs"
61
+ kopytko-format --write "src/**/*.brs"
62
+ kopytko-format --check --config kopytko-formatter.json "components/**/*.brs"
63
+
64
+ CONFIG
65
+ The formatter reads config from (in priority order):
66
+ 1. --config <file> explicit path
67
+ 2. kopytko-formatter.json in the current directory
68
+ 3. .vscode/settings.json "kopytko.format.*" keys
69
+
70
+ Config keys match VS Code settings without the "kopytko.format." prefix.
71
+ Example kopytko-formatter.json:
72
+ {
73
+ "indentSize": 2,
74
+ "endKeywordStyle": "spaced",
75
+ "trimTrailingWhitespace": true,
76
+ "insertFinalNewline": true,
77
+ "keywordCasing": "LowerCase",
78
+ "builtinCasing": "PascalCase",
79
+ "ignore": [
80
+ "**/node_modules/**",
81
+ "**/dist/**",
82
+ "**/_tests/**"
83
+ ]
84
+ }
85
+ `);
86
+ }
87
+ function parseArgs(argv) {
88
+ const opts = { check: false, write: false, config: null, ignore: [], patterns: [] };
89
+ for (let i = 0; i < argv.length; i++) {
90
+ const arg = argv[i];
91
+ if (arg === '--check') {
92
+ opts.check = true;
93
+ }
94
+ else if (arg === '--write') {
95
+ opts.write = true;
96
+ }
97
+ else if (arg === '--config' && i + 1 < argv.length) {
98
+ opts.config = argv[++i];
99
+ }
100
+ else if (arg === '--ignore' && i + 1 < argv.length) {
101
+ opts.ignore.push(argv[++i]);
102
+ }
103
+ else if (arg === '--help' || arg === '-h') {
104
+ printUsage();
105
+ process.exit(0);
106
+ }
107
+ else if (arg === '--version' || arg === '-v') {
108
+ console.log(VERSION);
109
+ process.exit(0);
110
+ }
111
+ else if (arg.startsWith('-')) {
112
+ console.error(`Unknown option: ${arg}`);
113
+ process.exit(1);
114
+ }
115
+ else {
116
+ opts.patterns.push(arg);
117
+ }
118
+ }
119
+ return opts;
120
+ }
121
+ /**
122
+ * Finds the raw config object from the first available source.
123
+ * Priority: --config flag > kopytko-formatter.json > .vscode/settings.json
124
+ */
125
+ function findRawConfig(configPath) {
126
+ // 1. Explicit config file
127
+ if (configPath) {
128
+ if (!fs.existsSync(configPath)) {
129
+ console.error(`Config file not found: ${configPath}`);
130
+ process.exit(1);
131
+ }
132
+ const raw = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
133
+ return { settings: raw, source: configPath };
134
+ }
135
+ // 2. kopytko-formatter.json in cwd
136
+ const formatterConfigPath = path.join(process.cwd(), 'kopytko-formatter.json');
137
+ if (fs.existsSync(formatterConfigPath)) {
138
+ const raw = JSON.parse(fs.readFileSync(formatterConfigPath, 'utf-8'));
139
+ return { settings: raw, source: formatterConfigPath };
140
+ }
141
+ // 3. .vscode/settings.json with "kopytko.format.*" keys
142
+ const vscodeSettingsPath = path.join(process.cwd(), '.vscode', 'settings.json');
143
+ if (fs.existsSync(vscodeSettingsPath)) {
144
+ const content = fs.readFileSync(vscodeSettingsPath, 'utf-8');
145
+ // Strip single-line comments (// ...) that VS Code allows in JSONC
146
+ const stripped = content.replace(/^\s*\/\/.*$/gm, '');
147
+ const raw = JSON.parse(stripped);
148
+ const extracted = extractVscodeSettings(raw);
149
+ if (extracted) {
150
+ return { settings: extracted, source: vscodeSettingsPath };
151
+ }
152
+ }
153
+ return null;
154
+ }
155
+ /**
156
+ * Extracts kopytko.format.* keys from a VS Code settings.json object.
157
+ * Strips the "kopytko.format." prefix from each key.
158
+ * Returns null if no kopytko.format keys are found.
159
+ */
160
+ function extractVscodeSettings(raw) {
161
+ const PREFIX = 'kopytko.format.';
162
+ const result = {};
163
+ let found = false;
164
+ for (const [key, value] of Object.entries(raw)) {
165
+ if (key.startsWith(PREFIX)) {
166
+ result[key.slice(PREFIX.length)] = value;
167
+ found = true;
168
+ }
169
+ }
170
+ return found ? result : null;
171
+ }
172
+ /** Maps VS Code casing key names to CasingConfig field names. */
173
+ const CASING_KEY_MAP = {
174
+ 'keywordCasing': 'keywords',
175
+ 'builtinCasing': 'builtins',
176
+ 'methodCasing': 'methods',
177
+ 'typeCasing': 'types',
178
+ 'literalCasing': 'literals',
179
+ 'logicOperatorCasing': 'logicOperators',
180
+ 'mathOperatorCasing': 'mathOperators',
181
+ 'userFunctionCasing': 'userFunctions',
182
+ 'userMethodCasing': 'userMethods',
183
+ 'exactCasing': 'exactCasing',
184
+ };
185
+ function loadConfig(configPath) {
186
+ const raw = findRawConfig(configPath);
187
+ if (!raw)
188
+ return { ...config_1.DEFAULT_FORMATTING_CONFIG };
189
+ console.log(` Config: ${raw.source}`);
190
+ return (0, config_1.parseFormattingConfig)(raw.settings);
191
+ }
192
+ /** Loads ignore patterns from the config file. */
193
+ function loadIgnorePatterns(configPath) {
194
+ const raw = findRawConfig(configPath);
195
+ if (!raw)
196
+ return [];
197
+ const ignore = raw.settings['ignore'];
198
+ if (Array.isArray(ignore))
199
+ return ignore.filter((p) => typeof p === 'string');
200
+ return [];
201
+ }
202
+ /**
203
+ * Matches a file path against a glob-like ignore pattern.
204
+ * Supports: `*` (single segment), `**` (any depth), `?` (single char).
205
+ */
206
+ function matchesIgnorePattern(filePath, pattern) {
207
+ const normalized = filePath.replace(/\\/g, '/');
208
+ const regex = pattern
209
+ .replace(/\\/g, '/')
210
+ .replace(/[.+^${}()|[\]]/g, '\\$&')
211
+ .replace(/\*\*/g, '\u0000')
212
+ .replace(/\*/g, '[^/]*')
213
+ .replace(/\u0000/g, '.*')
214
+ .replace(/\?/g, '[^/]');
215
+ return new RegExp(`(?:^|/)${regex}(?:$|/)`).test(normalized) ||
216
+ new RegExp(`^${regex}$`).test(normalized);
217
+ }
218
+ function isIgnored(filePath, ignorePatterns) {
219
+ return ignorePatterns.some((pattern) => matchesIgnorePattern(filePath, pattern));
220
+ }
221
+ function loadCasingConfig(configPath) {
222
+ const raw = findRawConfig(configPath);
223
+ if (!raw)
224
+ return { ...casing_1.DEFAULT_CASING_CONFIG };
225
+ const s = raw.settings;
226
+ const result = {};
227
+ for (const [srcKey, destKey] of Object.entries(CASING_KEY_MAP)) {
228
+ // Support both VS Code key names (keywordCasing) and direct names (keywords)
229
+ if (s[srcKey] !== undefined)
230
+ result[destKey] = s[srcKey];
231
+ else if (s[destKey] !== undefined)
232
+ result[destKey] = s[destKey];
233
+ }
234
+ return {
235
+ builtins: result.builtins ?? 'NoChange',
236
+ keywords: result.keywords ?? 'NoChange',
237
+ methods: result.methods ?? 'NoChange',
238
+ types: result.types,
239
+ literals: result.literals,
240
+ logicOperators: result.logicOperators,
241
+ mathOperators: result.mathOperators,
242
+ userFunctions: result.userFunctions,
243
+ userMethods: result.userMethods,
244
+ exactCasing: result.exactCasing,
245
+ };
246
+ }
247
+ function collectFiles(patterns) {
248
+ const files = [];
249
+ for (const pattern of patterns) {
250
+ // Simple glob: if it's a direct file path, use it
251
+ if (fs.existsSync(pattern) && fs.statSync(pattern).isFile()) {
252
+ files.push(pattern);
253
+ continue;
254
+ }
255
+ // Walk directories for .brs files
256
+ if (fs.existsSync(pattern) && fs.statSync(pattern).isDirectory()) {
257
+ walkDir(pattern, files);
258
+ continue;
259
+ }
260
+ // Basic glob support: **/*.brs patterns
261
+ // For proper glob support, users should pipe from find or use shell expansion
262
+ const resolved = resolveGlob(pattern);
263
+ files.push(...resolved);
264
+ }
265
+ return [...new Set(files)];
266
+ }
267
+ function walkDir(dir, out) {
268
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
269
+ const full = path.join(dir, entry.name);
270
+ if (entry.isDirectory()) {
271
+ if (entry.name === 'node_modules' || entry.name === '.git')
272
+ continue;
273
+ walkDir(full, out);
274
+ }
275
+ else if (entry.name.endsWith('.brs')) {
276
+ out.push(full);
277
+ }
278
+ }
279
+ }
280
+ function resolveGlob(pattern) {
281
+ // Handle simple **/*.brs patterns
282
+ if (pattern.includes('*')) {
283
+ const parts = pattern.split(path.sep === '\\' ? /[\\/]/ : '/');
284
+ const baseIdx = parts.findIndex(p => p.includes('*'));
285
+ const baseDir = baseIdx > 0 ? parts.slice(0, baseIdx).join(path.sep) : '.';
286
+ const ext = path.extname(pattern) || '.brs';
287
+ if (!fs.existsSync(baseDir))
288
+ return [];
289
+ const files = [];
290
+ walkDir(baseDir, files);
291
+ return files.filter(f => f.endsWith(ext));
292
+ }
293
+ return [];
294
+ }
295
+ function main() {
296
+ const opts = parseArgs(process.argv.slice(2));
297
+ if (opts.patterns.length === 0) {
298
+ console.error('Error: No file patterns provided.\n');
299
+ printUsage();
300
+ process.exit(1);
301
+ }
302
+ const config = loadConfig(opts.config);
303
+ const casing = loadCasingConfig(opts.config);
304
+ const ignorePatterns = [...loadIgnorePatterns(opts.config), ...opts.ignore];
305
+ const allFiles = collectFiles(opts.patterns);
306
+ const files = ignorePatterns.length > 0
307
+ ? allFiles.filter((f) => !isIgnored(f, ignorePatterns))
308
+ : allFiles;
309
+ if (files.length === 0) {
310
+ console.error('No .brs files found matching the given patterns.');
311
+ process.exit(1);
312
+ }
313
+ let unformatted = 0;
314
+ let formatted = 0;
315
+ let errors = 0;
316
+ for (const file of files) {
317
+ try {
318
+ const source = fs.readFileSync(file, 'utf-8');
319
+ const isClean = (0, formatter_1.checkFormatting)(source, config, casing);
320
+ if (isClean) {
321
+ formatted++;
322
+ continue;
323
+ }
324
+ unformatted++;
325
+ if (opts.write) {
326
+ const result = (0, formatter_1.formatText)(source, config, casing);
327
+ fs.writeFileSync(file, result, 'utf-8');
328
+ console.log(` ✓ ${file}`);
329
+ }
330
+ else if (opts.check) {
331
+ console.log(` ✗ ${file}`);
332
+ }
333
+ else {
334
+ // Default: print to stdout
335
+ const result = (0, formatter_1.formatText)(source, config, casing);
336
+ console.log(`--- ${file} ---`);
337
+ console.log(result);
338
+ }
339
+ }
340
+ catch (err) {
341
+ errors++;
342
+ console.error(` ✗ Error processing ${file}: ${err.message}`);
343
+ }
344
+ }
345
+ // Summary
346
+ const total = files.length;
347
+ console.log(`\n${total} file(s) checked: ${formatted} clean, ${unformatted} need formatting${errors > 0 ? `, ${errors} error(s)` : ''}.`);
348
+ if (opts.check && unformatted > 0) {
349
+ process.exit(1);
350
+ }
351
+ if (errors > 0) {
352
+ process.exit(2);
353
+ }
354
+ }
355
+ main();
356
+ //# sourceMappingURL=kopytko-format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kopytko-format.js","sourceRoot":"","sources":["../../bin/kopytko-format.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,uCAAyB;AACzB,2CAA6B;AAC7B,gDAA+D;AAC/D,0CAAmG;AACnG,0CAAoE;AAEpE,MAAM,OAAO,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC,OAAO,CAAC;AAUtD,SAAS,UAAU;IACjB,OAAO,CAAC,GAAG,CAAC;kBACI,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwCxB,CAAC,CAAC;AACH,CAAC;AAED,SAAS,SAAS,CAAC,IAAc;IAC/B,MAAM,IAAI,GAAe,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IAEhG,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAAC,CAAC;aACxC,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAAC,CAAC;aAC7C,IAAI,GAAG,KAAK,UAAU,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;YAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CA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CAAC,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;YAC7B,CAAC;iBAAM,CAAC;gBACN,2BAA2B;gBAC3B,MAAM,MAAM,GAAG,IAAA,sBAAU,EAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;gBAClD,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,MAAM,CAAC,CAAC;gBAC/B,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACtB,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,EAAE,CAAC;YACT,OAAO,CAAC,KAAK,CAAC,wBAAwB,IAAI,KAAM,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;QAC3E,CAAC;IACH,CAAC;IAED,UAAU;IACV,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC;IAC3B,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK,qBAAqB,SAAS,WAAW,WAAW,mBAAmB,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,MAAM,WAAW,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAE1I,IAAI,IAAI,CAAC,KAAK,IAAI,WAAW,GAAG,CAAC,EAAE,CAAC;QAClC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * BrightScript built-in functions and global objects.
3
+ * Covers the standard BrightScript runtime as documented at:
4
+ * https://developer.roku.com/docs/references/brightscript/language/global-functions.md
5
+ */
6
+ export interface BrightScriptBuiltin {
7
+ name: string;
8
+ signature: string;
9
+ returnType: string;
10
+ description: string;
11
+ category: 'math' | 'string' | 'type' | 'utility' | 'io' | 'filesystem' | 'object';
12
+ }
13
+ export declare const BRIGHTSCRIPT_BUILTINS: BrightScriptBuiltin[];
14
+ export declare function findBuiltin(name: string): BrightScriptBuiltin | undefined;
15
+ export declare const BRIGHTSCRIPT_KEYWORDS: string[];
16
+ /** Keyword sub-categories for granular casing control. */
17
+ export type KeywordCategory = 'keyword' | 'type' | 'literal' | 'logicOperator' | 'mathOperator';
18
+ /** Returns the category of a keyword (lowercase). */
19
+ export declare function getKeywordCategory(keyword: string): KeywordCategory;
20
+ //# sourceMappingURL=builtins.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builtins.d.ts","sourceRoot":"","sources":["../../src/builtins.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,YAAY,GAAG,QAAQ,CAAC;CACnF;AAED,eAAO,MAAM,qBAAqB,EAAE,mBAAmB,EAsGtD,CAAC;AAMF,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,mBAAmB,GAAG,SAAS,CAEzE;AAED,eAAO,MAAM,qBAAqB,UAQjC,CAAC;AAEF,0DAA0D;AAC1D,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,eAAe,GAAG,cAAc,CAAC;AAmBhG,qDAAqD;AACrD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe,CAEnE"}