brighterscript 0.65.17 → 0.65.19
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/CHANGELOG.md +14 -0
- package/README.md +13 -421
- package/dist/BsConfig.d.ts +3 -0
- package/dist/PluginInterface.d.ts +4 -2
- package/dist/PluginInterface.js.map +1 -1
- package/dist/Program.d.ts +5 -7
- package/dist/Program.js +14 -7
- package/dist/Program.js.map +1 -1
- package/dist/ProgramBuilder.d.ts +3 -3
- package/dist/ProgramBuilder.js +11 -1
- package/dist/ProgramBuilder.js.map +1 -1
- package/dist/Scope.d.ts +1 -1
- package/dist/Scope.js +6 -2
- package/dist/Scope.js.map +1 -1
- package/dist/XmlScope.js +6 -6
- package/dist/XmlScope.js.map +1 -1
- package/dist/astUtils/reflection.d.ts +2 -1
- package/dist/astUtils/reflection.js +5 -1
- package/dist/astUtils/reflection.js.map +1 -1
- package/dist/bscPlugin/validation/BrsFileValidator.js +3 -0
- package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -1
- package/dist/files/BrsFile.spec.js +200 -0
- package/dist/files/BrsFile.spec.js.map +1 -1
- package/dist/files/XmlFile.d.ts +1 -1
- package/dist/files/XmlFile.js.map +1 -1
- package/dist/parser/Expression.d.ts +10 -1
- package/dist/parser/Expression.js +22 -1
- package/dist/parser/Expression.js.map +1 -1
- package/dist/parser/Parser.d.ts +1 -0
- package/dist/parser/Parser.js +64 -18
- package/dist/parser/Parser.js.map +1 -1
- package/dist/util.d.ts +7 -6
- package/dist/util.js +50 -33
- package/dist/util.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
+
## [0.65.19](https://github.com/rokucommunity/brighterscript/compare/v0.65.18...v0.65.19) - 2024-01-30
|
|
10
|
+
### Changed
|
|
11
|
+
- Backport v1 syntax changes ([#1034](https://github.com/rokucommunity/brighterscript/pull/1034))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## [0.65.18](https://github.com/rokucommunity/brighterscript/compare/v0.65.17...v0.65.18) - 2024-01-25
|
|
16
|
+
### Changed
|
|
17
|
+
- Refactor bsconfig documentation ([#1024](https://github.com/rokucommunity/brighterscript/pull/1024))
|
|
18
|
+
- Prevent overwriting `Program._manifest` if already set on startup ([#1027](https://github.com/rokucommunity/brighterscript/pull/1027))
|
|
19
|
+
- Improving null safety: Add FinalizedBsConfig and tweak plugin events ([#1000](https://github.com/rokucommunity/brighterscript/pull/1000))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
9
23
|
## [0.65.17](https://github.com/rokucommunity/brighterscript/compare/v0.65.16...0.65.17) - 2024-01-16
|
|
10
24
|
### Changed
|
|
11
25
|
- add documentation on pruneEmptyCodeFiles to the README ([#1012](https://github.com/rokucommunity/brighterscript/pull/1012))
|
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ A superset of Roku's BrightScript language. Compiles to standard BrightScript.
|
|
|
14
14
|
The BrighterScript language provides new features and syntax enhancements to Roku's BrightScript language. Because the language is a superset of BrightScript, the parser and associated tools (VSCode integration, cli, etc...) work with standard BrightScript (.brs) files. This means you will get benefits (as described in the following section) from using the BrighterScript compiler, whether your project contains BrighterScript (.bs) files or not. The BrighterScript language transpiles to standard BrightScript, so your code is fully compatible with all roku devices.
|
|
15
15
|
|
|
16
16
|
## Features
|
|
17
|
-
BrighterScript adds several new features to the BrightScript language such as
|
|
17
|
+
BrighterScript adds several new features to the BrightScript language such as namespaces, classes, import statements, and more. Take a look at the language specification docs for more information.
|
|
18
18
|
|
|
19
19
|
[BrighterScript Language Specification](https://github.com/rokucommunity/BrighterScript/blob/master/docs/readme.md)
|
|
20
20
|
|
|
@@ -91,7 +91,6 @@ BrighterScript adds several new features to the BrightScript language such as Na
|
|
|
91
91
|
</p>
|
|
92
92
|
<br/>
|
|
93
93
|
|
|
94
|
-
|
|
95
94
|
The BrighterScript project is used to power the popular [Brightscript Language](https://marketplace.visualstudio.com/items?itemName=rokucommunity.brightscript) VSCode extension, the [maestro framework](https://github.com/georgejecook/maestro/blob/master/docs/index.md), and more.
|
|
96
95
|
|
|
97
96
|
[Contact us](https://github.com/rokucommunity/brighterscript/issues/new) if you use BrighterScript in your project and would like your logo listed above. More projects are adopting BrighterScript all the time, from using the new BrighterScript language features to simply using the compiler in their build pipeline.
|
|
@@ -163,434 +162,27 @@ If you need to configure `bsc`, you can do so in two ways:
|
|
|
163
162
|
## bsconfig.json
|
|
164
163
|
|
|
165
164
|
### Overview
|
|
166
|
-
The presence of a `bsconfig.json` file in a directory indicates that the directory is the root of a BrightScript project. The `bsconfig.json` file specifies the root files and the compiler options required to compile the project.
|
|
167
|
-
|
|
168
|
-
### Configuration inheritance with `extends`
|
|
169
|
-
|
|
170
|
-
A `bsconfig.json` file can inherit configurations from another file using the `extends` property.
|
|
171
|
-
|
|
172
|
-
The extends is a top-level property in `bsconfig.json`. `extends`’ value is a string containing a path to another configuration file to inherit from.
|
|
173
|
-
|
|
174
|
-
The configuration from the base file are loaded first, then overridden by those in the inheriting config file. If a circularity is encountered, we report an error.
|
|
175
|
-
|
|
176
|
-
The `files` property from the inheriting config file overwrite those from the base config file.
|
|
177
|
-
|
|
178
|
-
All relative paths found in the configuration file will be resolved relative to the configuration file they originated in.
|
|
179
|
-
|
|
180
|
-
### Optional `extends` and `project`
|
|
181
|
-
There are situations where you want to store some compiler settings in a config file, but not fail if that config file doesn't exist. To do this, you can denote that your `extends` or `project` path is optional by prefixing it with a question mark (`?`). For example:
|
|
182
|
-
|
|
183
|
-
- **bsconfig.json** `extends`
|
|
184
|
-
```json
|
|
185
|
-
{
|
|
186
|
-
"extends": "?path/to/optional/bsconfig.json"
|
|
187
|
-
}
|
|
188
|
-
```
|
|
189
|
-
- CLI "extends"
|
|
190
|
-
```
|
|
191
|
-
bsc --extends "?path/to/optional/bsconfig.json"
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
- CLI `project` argument
|
|
195
|
-
```
|
|
196
|
-
bsc --project "?path/to/optional/bsconfig.json"
|
|
197
|
-
```
|
|
198
|
-
- Node.js API `extends`
|
|
199
|
-
```
|
|
200
|
-
var programBuilder = new ProgramBuilder({
|
|
201
|
-
"extends": "?path/to/optional/bsconfig.json"
|
|
202
|
-
});
|
|
203
|
-
```
|
|
204
|
-
- Node.js API `project`
|
|
205
|
-
```
|
|
206
|
-
var programBuilder = new ProgramBuilder({
|
|
207
|
-
"project": "?path/to/optional/bsconfig.json"
|
|
208
|
-
});
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
### `bsconfig.json` options
|
|
212
|
-
|
|
213
|
-
These are the options available in the `bsconfig.json` file.
|
|
214
|
-
|
|
215
|
-
#### `project`
|
|
216
|
-
|
|
217
|
-
Type: `string`
|
|
218
|
-
|
|
219
|
-
A path to a project file. This is really only passed in from the command line or the NodeJS API, and should not be present in `bsconfig.json` files. Prefix with a question mark (?) to prevent throwing an exception when the file does not exist.
|
|
220
|
-
|
|
221
|
-
#### `extends`
|
|
222
|
-
|
|
223
|
-
Type: `string`
|
|
224
|
-
|
|
225
|
-
Relative or absolute path to another `bsconfig.json` file that this `bsconfig.json` file should import and then override. Prefix with a question mark (?) to prevent throwing an exception when the file does not exist. Defaults to `undefined`.
|
|
226
|
-
|
|
227
|
-
Note: child config properties completely replace parent config properties. For example: if a parent and child bsconfigs both specify an array for `plugins`, or `files`, or `diagnosticFilters`, etc., then the parent's setting will be completely ignored and the child's setting will be used instead.
|
|
228
|
-
|
|
229
|
-
#### `cwd`
|
|
230
|
-
|
|
231
|
-
Type: `string`
|
|
232
|
-
|
|
233
|
-
If present, overrides the current working directory when invoking `bsc`. Defaults to `process.cwd()`.
|
|
234
|
-
|
|
235
|
-
#### `rootDir`
|
|
236
|
-
|
|
237
|
-
Type: `string`
|
|
238
|
-
|
|
239
|
-
The root directory of your roku project. Defaults to `process.cwd()`.
|
|
240
|
-
|
|
241
|
-
#### `stagingDir`
|
|
242
|
-
|
|
243
|
-
Type: `string`
|
|
244
|
-
|
|
245
|
-
The folder where the transpiled files are placed. This folder will be created automatically if it does not exist, and will be deleted after transpilation completes unless `retainStagingDir` is set to `true`. Defaults to `./out/.roku-deploy-staging`.
|
|
246
|
-
|
|
247
|
-
#### `retainStagingDir`
|
|
248
|
-
|
|
249
|
-
Type: `boolean`
|
|
250
|
-
|
|
251
|
-
Prevent the staging folder from being deleted after creating the package. Defaults to `false`, meaning that the folder is deleted every time.
|
|
252
|
-
|
|
253
|
-
#### `removeParameterTypes`
|
|
254
|
-
|
|
255
|
-
Type: `boolean`
|
|
256
|
-
|
|
257
|
-
If true, removes the explicit type to function's parameters and return (i.e. the `as type` syntax); otherwise keep this information.
|
|
258
|
-
|
|
259
|
-
#### `files`
|
|
260
|
-
|
|
261
|
-
Type:
|
|
262
|
-
```typescript
|
|
263
|
-
Array<
|
|
264
|
-
string |
|
|
265
|
-
string[] |
|
|
266
|
-
{
|
|
267
|
-
src: string | string[],
|
|
268
|
-
dest: string
|
|
269
|
-
}>
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
The files array is how you specify what files are included in your project. Any strings found in the files array must be relative to rootDir, and are used as include filters, meaning that if a file matches the pattern, it is included.
|
|
273
|
-
|
|
274
|
-
For most standard projects, the default files array should work just fine:
|
|
275
|
-
|
|
276
|
-
```jsonc
|
|
277
|
-
{
|
|
278
|
-
"files": [
|
|
279
|
-
"source/**/*",
|
|
280
|
-
"components/**/*",
|
|
281
|
-
"images/**/*",
|
|
282
|
-
"manifest"
|
|
283
|
-
]
|
|
284
|
-
}
|
|
285
|
-
```
|
|
286
|
-
|
|
287
|
-
This will copy all files from the standard roku folders directly into the package while maintaining each file's relative file path within rootDir.
|
|
288
|
-
|
|
289
|
-
If you want to include additional files, you will need to provide the entire array. For example, if you have a folder with other assets, you could do the following:
|
|
290
|
-
|
|
291
|
-
```jsonc
|
|
292
|
-
{
|
|
293
|
-
"files": [
|
|
294
|
-
"source/**/*",
|
|
295
|
-
"components/**/*",
|
|
296
|
-
"images/**/*",
|
|
297
|
-
"manifest"
|
|
298
|
-
//your folder with other assets
|
|
299
|
-
"assets/**/*",
|
|
300
|
-
]
|
|
301
|
-
}
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
If a `bsconfig.json` file specifies a parent config using the `extends` field, and the child specifies a `files` field, then the parent's `files` field will be completely overridden by the child.
|
|
305
|
-
|
|
306
|
-
##### Excluding files
|
|
307
|
-
|
|
308
|
-
You can exclude files from the output by prefixing your file patterns with "!". This is useful in cases where you want everything in a folder EXCEPT certain files.
|
|
309
|
-
|
|
310
|
-
```jsonc
|
|
311
|
-
{
|
|
312
|
-
"files": [
|
|
313
|
-
"source/**/*",
|
|
314
|
-
"!source/some/unwanted/file.brs"
|
|
315
|
-
]
|
|
316
|
-
}
|
|
317
|
-
```
|
|
318
|
-
|
|
319
|
-
The files array is processed from top to bottom, with later patterns overriding previous ones. This means that in order to exclude a file which is included by another pattern, the negative pattern using `!` must occur **after** the positive pattern.
|
|
320
|
-
|
|
321
|
-
##### File pattern resolution
|
|
322
|
-
|
|
323
|
-
All patterns will be resolved relative to rootDir, with their relative positions within rootDir maintained.
|
|
324
|
-
|
|
325
|
-
Patterns may not reference files outside of `rootDir` unless the `{ src, dest }` form is used (see below). For example:
|
|
326
|
-
|
|
327
|
-
```jsonc
|
|
328
|
-
{
|
|
329
|
-
"rootDir": "C:/projects/CatVideoPlayer",
|
|
330
|
-
"files": [
|
|
331
|
-
"source/main.brs",
|
|
332
|
-
|
|
333
|
-
//NOT allowed because it navigates outside the rootDir
|
|
334
|
-
"../common/promise.brs"
|
|
335
|
-
]
|
|
336
|
-
}
|
|
337
|
-
```
|
|
338
|
-
|
|
339
|
-
Any valid glob pattern is supported. For more information, see the documentation on the underlying [fast-glob](https://github.com/mrmlnc/fast-glob) library.
|
|
340
|
-
|
|
341
|
-
Empty folders are not copied.
|
|
342
|
-
|
|
343
|
-
Paths to folders will be ignored. If you want to copy a folder and its contents, use the glob syntax (i.e. `some_folder/**/*`).
|
|
344
|
-
|
|
345
|
-
##### Specifying file destinations
|
|
346
|
-
|
|
347
|
-
For more advanced use cases, you may provide an object which contains the source pattern and output path. This allows you to be very specific about what files to copy, and where they are placed in the output folder. This option also supports copying files from outside the `rootDir`.
|
|
348
|
-
|
|
349
|
-
The object structure is as follows:
|
|
350
|
-
|
|
351
|
-
```typescript
|
|
352
|
-
{
|
|
353
|
-
/**
|
|
354
|
-
* A glob pattern string or file path, or an array of glob pattern strings and/or file paths.
|
|
355
|
-
* These can be relative paths or absolute paths.
|
|
356
|
-
* All non-absolute paths are resolved relative to the rootDir
|
|
357
|
-
*/
|
|
358
|
-
src: Array<string | string[]>;
|
|
359
|
-
/**
|
|
360
|
-
* The relative path to the location in the output folder where the files should be placed,
|
|
361
|
-
* relative to the root of the output folder
|
|
362
|
-
*/
|
|
363
|
-
dest: string | undefined
|
|
364
|
-
}
|
|
365
|
-
```
|
|
366
|
-
|
|
367
|
-
If `src` is a non-glob path to a single file, then `dest` should include the filename and extension. For example:
|
|
368
|
-
|
|
369
|
-
```jsonc
|
|
370
|
-
{ "src": "lib/Promise/promise.brs", "dest": "source/promise.brs" }
|
|
371
|
-
```
|
|
372
|
-
|
|
373
|
-
If `src` is a glob pattern, then dest should be a path to the folder in the output directory. For example:
|
|
374
|
-
|
|
375
|
-
```jsonc
|
|
376
|
-
{ "src": "lib/*.brs", "dest": "source/lib" }
|
|
377
|
-
```
|
|
378
|
-
|
|
379
|
-
If `src` is a path to a folder, it will be ignored. If you want to copy a folder and its contents, use the glob syntax. The following example will copy all files from the lib/vendor folder recursively:
|
|
380
|
-
|
|
381
|
-
```jsonc
|
|
382
|
-
{ "src": "lib/vendor/**/*", "dest": "vendor" }
|
|
383
|
-
```
|
|
384
|
-
|
|
385
|
-
If `dest` is not specified it will default to the root of the output folder.
|
|
386
|
-
|
|
387
|
-
An example of combining regular and advanced file patterns:
|
|
388
|
-
|
|
389
|
-
```jsonc
|
|
390
|
-
{
|
|
391
|
-
"rootDir": "C:/projects/CatVideoPlayer",
|
|
392
|
-
"files": [
|
|
393
|
-
"source/main.brs",
|
|
394
|
-
{
|
|
395
|
-
"src": "../common/promise.brs",
|
|
396
|
-
"dest": "source/common"
|
|
397
|
-
}
|
|
398
|
-
]
|
|
399
|
-
}
|
|
400
|
-
```
|
|
401
|
-
|
|
402
|
-
##### File collision handling
|
|
403
|
-
|
|
404
|
-
Because file entries are processed in order you can override a file by specifying an alternative later in the files array.
|
|
405
|
-
|
|
406
|
-
For example, if you have a base project and a child project that wants to override specific files, you could do the following:
|
|
165
|
+
The presence of a `bsconfig.json` file in a directory indicates that the directory is the root of a BrightScript project. The `bsconfig.json` file specifies the root files and the compiler options required to compile the project. Here is a minimal example, which is recommended for new projects:
|
|
407
166
|
|
|
408
167
|
```jsonc
|
|
409
168
|
{
|
|
169
|
+
"rootDir": "src",
|
|
410
170
|
"files": [
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
]
|
|
171
|
+
"**/*"
|
|
172
|
+
],
|
|
173
|
+
"stagingFolderPath": "dist",
|
|
174
|
+
"retainStagingFolder": true,
|
|
175
|
+
//this flag tells BrighterScript that for every xml file, try to import a .bs file with the same name and location
|
|
176
|
+
"autoImportComponentScript": true,
|
|
177
|
+
"sourceMap": true
|
|
419
178
|
}
|
|
420
179
|
```
|
|
421
180
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
Type: `string`
|
|
425
|
-
|
|
426
|
-
The path (including filename) where the output file should be placed. Defaults to `"./out/${WORKSPACE_FOLDER_NAME}.zip"`.
|
|
427
|
-
|
|
428
|
-
#### `createPackage`
|
|
429
|
-
|
|
430
|
-
Type: `boolean`
|
|
431
|
-
|
|
432
|
-
Causes the build to create a zip package. Defaults to `true`. This setting is ignored when `deploy` is enabled.
|
|
433
|
-
|
|
434
|
-
#### `watch`
|
|
435
|
-
|
|
436
|
-
Type: `boolean`
|
|
437
|
-
|
|
438
|
-
If `true`, the server will keep running and will watch and recompile on every file change. Defaults to `false`.
|
|
439
|
-
|
|
440
|
-
#### `deploy`
|
|
441
|
-
|
|
442
|
-
Type: `boolean`
|
|
443
|
-
|
|
444
|
-
If `true`, after a successful build, the project will be deployed to the Roku specified in host. Defaults to `false`. If this field is set to `true`, then the `host` and `password` fields must be set as well.
|
|
445
|
-
|
|
446
|
-
#### `host`
|
|
447
|
-
|
|
448
|
-
Type: `string`
|
|
449
|
-
|
|
450
|
-
The host of the Roku that this project will deploy to when the `deploy` field is set to `true`. Defaults to `undefined`.
|
|
451
|
-
|
|
452
|
-
#### `username`
|
|
453
|
-
|
|
454
|
-
Type: `string`
|
|
455
|
-
|
|
456
|
-
The username that will be used to deploy to the Roku device when the `deploy` field is set to `true`. Defaults to `undefined`.
|
|
457
|
-
|
|
458
|
-
#### `password`
|
|
459
|
-
|
|
460
|
-
Type: `string`
|
|
461
|
-
|
|
462
|
-
The password that will be used to deploy to the Roku device when the `deploy` field is set to `true`. Defaults to `undefined`.
|
|
463
|
-
|
|
464
|
-
#### `emitFullPaths`
|
|
465
|
-
|
|
466
|
-
Type: `boolean`
|
|
467
|
-
|
|
468
|
-
Emit full paths to files when printing diagnostics to the console. Defaults to `false`.
|
|
469
|
-
|
|
470
|
-
#### `emitDefinitions`
|
|
471
|
-
|
|
472
|
-
Type: `boolean`
|
|
473
|
-
|
|
474
|
-
Emit type definition files (`d.bs`) during transpile. Defaults to `false`.
|
|
475
|
-
|
|
476
|
-
#### `diagnosticFilters`
|
|
477
|
-
|
|
478
|
-
Type: `Array<string | number | {src: string; codes: number[]}`
|
|
479
|
-
|
|
480
|
-
A list of filters used to hide diagnostics.
|
|
481
|
-
- A `string` value should be a relative-to-root-dir or absolute file path or glob pattern of the files that should be excluded. Any file matching this pattern will have all diagnostics supressed.
|
|
482
|
-
- A `number` value should be a diagnostic code. This will supress all diagnostics with that code for the whole project.
|
|
483
|
-
- An object can also be provided to filter specific diagnostic codes for a file pattern. For example,
|
|
484
|
-
|
|
485
|
-
```jsonc
|
|
486
|
-
"diagnosticFilters": [{
|
|
487
|
-
"src": "vendor/**/*",
|
|
488
|
-
"codes": [1000, 1011] //ignore these specific codes from vendor libraries
|
|
489
|
-
}]
|
|
490
|
-
```
|
|
491
|
-
|
|
492
|
-
Defaults to `undefined`.
|
|
493
|
-
|
|
494
|
-
If a child bsconfig extends from a parent bsconfig, and both bsconfigs specify `diagnosticFilters`, the parent bsconfig's `diagnosticFilters` field will be completely overwritten.
|
|
495
|
-
|
|
496
|
-
#### `diagnosticSeverityOverrides`
|
|
497
|
-
|
|
498
|
-
Type: `Record<string | number, 'hint' | 'info' | 'warn' | 'error'>`
|
|
499
|
-
|
|
500
|
-
A map of error codes and severity levels that will override diagnostics' severity. When a diagnostic generator doesn't offer enough control on an error's severity, this is a tool to work around blocking errors, or raise the level of other errors.
|
|
501
|
-
|
|
502
|
-
```jsonc
|
|
503
|
-
"diagnosticSeverityOverrides": {
|
|
504
|
-
"1011": "error", //raise a warning to an error
|
|
505
|
-
"LINT1001": "warn" //oops we have lots of those to fix... later
|
|
506
|
-
}
|
|
507
|
-
```
|
|
508
|
-
|
|
509
|
-
#### `diagnosticLevel`
|
|
510
|
-
|
|
511
|
-
Type: `"hint" | "info" | "warn" | "error"`
|
|
512
|
-
|
|
513
|
-
Specify what diagnostic levels are printed to the console. This has no effect on what diagnostics are reported in the LanguageServer. Defaults to `"warn"`.
|
|
514
|
-
|
|
515
|
-
#### `autoImportComponentScript`
|
|
516
|
-
|
|
517
|
-
Type: `bool`
|
|
518
|
-
|
|
519
|
-
BrighterScript only: will automatically import a script at transpile-time for a component with the same name if it exists. Defaults to `false`.
|
|
520
|
-
|
|
521
|
-
#### `sourceRoot`
|
|
522
|
-
|
|
523
|
-
Type: `string`
|
|
524
|
-
|
|
525
|
-
Override the root directory path where debugger should locate the source files. The location will be embedded in the source map to help debuggers locate the original source files. This only applies to files found within `rootDir`. This is useful when you want to preprocess files before passing them to BrighterScript, and want a debugger to open the original files. This option also affects the `SOURCE_FILE_PATH` and `SOURCE_LOCATION` source literals.
|
|
526
|
-
|
|
527
|
-
#### `plugins`
|
|
528
|
-
|
|
529
|
-
Type: `Array<string>`
|
|
530
|
-
|
|
531
|
-
List of node scripts or npm modules to load as plugins to the BrighterScript compiler. Defaults to `undefined`.
|
|
532
|
-
|
|
533
|
-
If a child bsconfig extends from a parent bsconfig, and both bsconfigs specify a `plugins` field, the child's `plugins` field will completely overwrite the parent's `plugins` field.
|
|
534
|
-
|
|
535
|
-
#### `require`
|
|
536
|
-
|
|
537
|
-
Type: `Array<string>`
|
|
538
|
-
|
|
539
|
-
List of node scripts or npm modules to load during the startup sequence. Useful for running things like `ts-node/require`. Defaults to `undefined`.
|
|
540
|
-
|
|
541
|
-
If a child bsconfig extends from a parent bsconfig, and both bsconfigs specify a `require` field, the child's `require` field will completely overwrite the parent's `require` field.
|
|
542
|
-
|
|
543
|
-
#### `allowBrighterScriptInBrightScript`
|
|
544
|
-
|
|
545
|
-
Type: `boolean`
|
|
546
|
-
|
|
547
|
-
Allow BrighterScript features (classes, interfaces, etc...) to be included in BrightScript (`.brs`) files, and force those files to be transpiled.
|
|
548
|
-
|
|
549
|
-
#### `bslibDestinationDir`
|
|
550
|
-
|
|
551
|
-
Type: `string`
|
|
552
|
-
|
|
553
|
-
Override the destination directory for the bslib.brs file. Use this if you want
|
|
554
|
-
to customize where the bslib.brs file is located in the staging directory. Note
|
|
555
|
-
that using a location outside of `source` will break scripts inside `source`
|
|
556
|
-
that depend on bslib.brs. Defaults to `source`.
|
|
557
|
-
|
|
558
|
-
#### `pruneEmptyCodeFiles`
|
|
559
|
-
|
|
560
|
-
Type: `boolean`
|
|
561
|
-
|
|
562
|
-
Remove files from the final package which would be empty or consist entirely of comments after compilation. Also removes imports of any such empty scripts from XML files. This can speed up sideloading packages during development. Defaults to `false`.
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
## Ignore errors and warnings on a per-line basis
|
|
566
|
-
In addition to disabling an entire class of errors in `bsconfig.json` by using `ignoreErrorCodes`, you may also disable errors for a subset of the complier rules within a file with the following comment flags:
|
|
567
|
-
- `bs:disable-next-line`
|
|
568
|
-
- `bs:disable-next-line: code1 code2 code3`
|
|
569
|
-
- `bs:disable-line`
|
|
570
|
-
- `bs:disable-line: code1 code2 code3`
|
|
571
|
-
|
|
572
|
-
Here are some examples:
|
|
573
|
-
|
|
574
|
-
```BrightScript
|
|
575
|
-
sub Main()
|
|
576
|
-
'disable errors about invalid syntax here
|
|
577
|
-
'bs:disable-next-line
|
|
578
|
-
DoSomething(
|
|
579
|
-
|
|
580
|
-
DoSomething( 'bs:disable-line
|
|
581
|
-
|
|
582
|
-
'disable errors about wrong parameter count
|
|
583
|
-
DoSomething(1,2,3) 'bs:disable-line
|
|
584
|
-
|
|
585
|
-
DoSomething(1,2,3) 'bs:disable-line:1002
|
|
586
|
-
end sub
|
|
587
|
-
|
|
588
|
-
sub DoSomething()
|
|
589
|
-
end sub
|
|
590
|
-
```
|
|
181
|
+
More information on the config file format may be found in the [bsconfig.json documentation](https://github.com/rokucommunity/BrighterScript/blob/master/docs/bsconfig.md).
|
|
591
182
|
|
|
592
|
-
|
|
183
|
+
## Suppressing compiler messages
|
|
593
184
|
|
|
185
|
+
The BrighterScript compiler emits errors and warnings when it encounters potentially invalid code. Errors and warnings may also be emitted by compiler plugins, such as by [the BrighterScript linter](https://github.com/rokucommunity/bslint). These messages can be suppressed if needed; see [the documentation](https://github.com/rokucommunity/BrighterScript/blob/master/docs/suppressing-compiler-messages.md).
|
|
594
186
|
|
|
595
187
|
## ropm support
|
|
596
188
|
In order for BrighterScript-transpiled projects to work as ropm modules, they need a reference to [bslib](https://github.com/rokucommunity/bslib/blob/master/source/bslib.brs) (the BrightScript runtime library for BrighterScript features) in their package. As `ropm` and `brighterscript` become more popular, this could result in many duplicate copies of `bslib.brs`.
|
package/dist/BsConfig.d.ts
CHANGED
|
@@ -187,3 +187,6 @@ export interface BsConfig {
|
|
|
187
187
|
*/
|
|
188
188
|
bslibDestinationDir?: string;
|
|
189
189
|
}
|
|
190
|
+
declare type OptionalBsConfigFields = '_ancestors' | 'sourceRoot' | 'project' | 'manifest' | 'noProject' | 'extends' | 'host' | 'password' | 'require' | 'stagingFolderPath' | 'diagnosticLevel' | 'rootDir' | 'stagingDir';
|
|
191
|
+
export declare type FinalizedBsConfig = Omit<Required<BsConfig>, OptionalBsConfigFields> & Pick<BsConfig, OptionalBsConfigFields>;
|
|
192
|
+
export {};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { CompilerPlugin } from './interfaces';
|
|
2
2
|
import type { Logger } from './Logger';
|
|
3
|
-
export declare type
|
|
3
|
+
export declare type PluginEventArgs<T> = {
|
|
4
|
+
[K in keyof Required<T> as Required<T>[K] extends (...args: any[]) => any ? K : never]: Required<T>[K] extends (...args: any[]) => any ? Parameters<Required<T>[K]> : never;
|
|
5
|
+
};
|
|
4
6
|
export default class PluginInterface<T extends CompilerPlugin = CompilerPlugin> {
|
|
5
7
|
private plugins;
|
|
6
8
|
/**
|
|
@@ -19,7 +21,7 @@ export default class PluginInterface<T extends CompilerPlugin = CompilerPlugin>
|
|
|
19
21
|
/**
|
|
20
22
|
* Call `event` on plugins
|
|
21
23
|
*/
|
|
22
|
-
emit<K extends keyof T & string>(event: K, ...args:
|
|
24
|
+
emit<K extends keyof PluginEventArgs<T> & string>(event: K, ...args: PluginEventArgs<T>[K]): void;
|
|
23
25
|
/**
|
|
24
26
|
* Add a plugin to the beginning of the list of plugins
|
|
25
27
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PluginInterface.js","sourceRoot":"","sources":["../src/PluginInterface.ts"],"names":[],"mappings":";;AAEA,qCAAoC;
|
|
1
|
+
{"version":3,"file":"PluginInterface.js","sourceRoot":"","sources":["../src/PluginInterface.ts"],"names":[],"mappings":";;AAEA,qCAAoC;AAuBpC,MAAqB,eAAe;IAgBhC,YACY,OAAyB,EACjC,OAGU;QAJF,YAAO,GAAP,OAAO,CAAkB;QAMjC,IAAI,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,CAAC,IAAI,MAAK,QAAQ,EAAE;YACxC,IAAI,CAAC,MAAM,GAAG,OAA4B,CAAC;SAC9C;aAAM;YACH,IAAI,CAAC,MAAM,GAAI,OAAe,aAAf,OAAO,uBAAP,OAAO,CAAU,MAAM,CAAC;YACvC,IAAI,CAAC,cAAc,GAAG,CAAC,OAAe,aAAf,OAAO,uBAAP,OAAO,CAAU,cAAc,MAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;SACnF;IACL,CAAC;IASD;;OAEG;IACI,IAAI,CAA8C,KAAQ,EAAE,GAAG,IAA2B;QAC7F,KAAK,IAAI,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE;YAC7B,IAAK,MAAc,CAAC,KAAK,CAAC,EAAE;gBACxB,IAAI;oBACA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAQ,CAAC,KAAK,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,GAAG,EAAE;wBACvD,MAAc,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;oBACpC,CAAC,CAAC,CAAC;iBACN;gBAAC,OAAO,GAAG,EAAE;oBACV,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,6BAA6B,MAAM,CAAC,IAAI,IAAI,KAAK,GAAG,EAAE,GAAG,CAAC,CAAC;oBAC7E,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE;wBACtB,MAAM,GAAG,CAAC;qBACb;iBACJ;aACJ;SACJ;IACL,CAAC;IAED;;OAEG;IACI,QAAQ,CAA4C,MAAS;QAChE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;YACnB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;SAChC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;IAED;;OAEG;IACI,GAAG,CAA4C,MAAS;QAC3D,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;YACnB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SAC7B;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;IAEM,GAAG,CAAC,MAAsB;QAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC;IAEM,MAAM,CAA4C,MAAS;QAC9D,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;YAClB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;SACrD;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;IAED;;OAEG;IACI,KAAK;QACR,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;IACtB,CAAC;CACJ;AA/FD,kCA+FC"}
|
package/dist/Program.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CodeAction, CompletionItem, Position, Range, SignatureInformation, Location } from 'vscode-languageserver';
|
|
2
|
-
import type { BsConfig } from './BsConfig';
|
|
2
|
+
import type { BsConfig, FinalizedBsConfig } from './BsConfig';
|
|
3
3
|
import { Scope } from './Scope';
|
|
4
4
|
import { BrsFile } from './files/BrsFile';
|
|
5
5
|
import { XmlFile } from './files/XmlFile';
|
|
@@ -29,15 +29,12 @@ export interface SignatureInfoObj {
|
|
|
29
29
|
signature: SignatureInformation;
|
|
30
30
|
}
|
|
31
31
|
export declare class Program {
|
|
32
|
-
/**
|
|
33
|
-
* The root directory for this program
|
|
34
|
-
*/
|
|
35
|
-
options: BsConfig;
|
|
36
32
|
constructor(
|
|
37
33
|
/**
|
|
38
34
|
* The root directory for this program
|
|
39
35
|
*/
|
|
40
36
|
options: BsConfig, logger?: Logger, plugins?: PluginInterface);
|
|
37
|
+
options: FinalizedBsConfig;
|
|
41
38
|
logger: Logger;
|
|
42
39
|
private createGlobalScope;
|
|
43
40
|
/**
|
|
@@ -124,7 +121,7 @@ export declare class Program {
|
|
|
124
121
|
/**
|
|
125
122
|
* roku filesystem is case INsensitive, so find the scope by key case insensitive
|
|
126
123
|
*/
|
|
127
|
-
getScopeByName(scopeName: string): Scope;
|
|
124
|
+
getScopeByName(scopeName: string): Scope | undefined;
|
|
128
125
|
/**
|
|
129
126
|
* Return all scopes
|
|
130
127
|
*/
|
|
@@ -317,8 +314,9 @@ export declare class Program {
|
|
|
317
314
|
/**
|
|
318
315
|
* Try to find and load the manifest into memory
|
|
319
316
|
* @param manifestFileObj A pointer to a potential manifest file object found during loading
|
|
317
|
+
* @param replaceIfAlreadyLoaded should we overwrite the internal `_manifest` if it already exists
|
|
320
318
|
*/
|
|
321
|
-
loadManifest(manifestFileObj?: FileObj): void;
|
|
319
|
+
loadManifest(manifestFileObj?: FileObj, replaceIfAlreadyLoaded?: boolean): void;
|
|
322
320
|
/**
|
|
323
321
|
* Get a map of the manifest information
|
|
324
322
|
*/
|
package/dist/Program.js
CHANGED
|
@@ -35,7 +35,6 @@ class Program {
|
|
|
35
35
|
* The root directory for this program
|
|
36
36
|
*/
|
|
37
37
|
options, logger, plugins) {
|
|
38
|
-
this.options = options;
|
|
39
38
|
/**
|
|
40
39
|
* A graph of all files and their dependencies.
|
|
41
40
|
* For example:
|
|
@@ -45,6 +44,11 @@ class Program {
|
|
|
45
44
|
this.dependencyGraph = new DependencyGraph_1.DependencyGraph();
|
|
46
45
|
this.diagnosticFilterer = new DiagnosticFilterer_1.DiagnosticFilterer();
|
|
47
46
|
this.diagnosticAdjuster = new DiagnosticSeverityAdjuster_1.DiagnosticSeverityAdjuster();
|
|
47
|
+
/**
|
|
48
|
+
* A scope that contains all built-in global functions.
|
|
49
|
+
* All scopes should directly or indirectly inherit from this scope
|
|
50
|
+
*/
|
|
51
|
+
this.globalScope = undefined;
|
|
48
52
|
/**
|
|
49
53
|
* A set of diagnostics. This does not include any of the scope diagnostics.
|
|
50
54
|
* Should only be set from `this.validate()`
|
|
@@ -614,14 +618,12 @@ class Program {
|
|
|
614
618
|
* @param file the file
|
|
615
619
|
*/
|
|
616
620
|
getScopesForFile(file) {
|
|
617
|
-
|
|
618
|
-
file = this.getFile(file);
|
|
619
|
-
}
|
|
621
|
+
const resolvedFile = typeof file === 'string' ? this.getFile(file) : file;
|
|
620
622
|
let result = [];
|
|
621
|
-
if (
|
|
623
|
+
if (resolvedFile) {
|
|
622
624
|
for (let key in this.scopes) {
|
|
623
625
|
let scope = this.scopes[key];
|
|
624
|
-
if (scope.hasFile(
|
|
626
|
+
if (scope.hasFile(resolvedFile)) {
|
|
625
627
|
result.push(scope);
|
|
626
628
|
}
|
|
627
629
|
}
|
|
@@ -1149,8 +1151,13 @@ class Program {
|
|
|
1149
1151
|
/**
|
|
1150
1152
|
* Try to find and load the manifest into memory
|
|
1151
1153
|
* @param manifestFileObj A pointer to a potential manifest file object found during loading
|
|
1154
|
+
* @param replaceIfAlreadyLoaded should we overwrite the internal `_manifest` if it already exists
|
|
1152
1155
|
*/
|
|
1153
|
-
loadManifest(manifestFileObj) {
|
|
1156
|
+
loadManifest(manifestFileObj, replaceIfAlreadyLoaded = true) {
|
|
1157
|
+
//if we already have a manifest instance, and should not replace...then don't replace
|
|
1158
|
+
if (!replaceIfAlreadyLoaded && this._manifest) {
|
|
1159
|
+
return;
|
|
1160
|
+
}
|
|
1154
1161
|
let manifestPath = manifestFileObj
|
|
1155
1162
|
? manifestFileObj.src
|
|
1156
1163
|
: path.join(this.options.rootDir, 'manifest');
|