@gwigz/slua-tstl-plugin 0.1.1 → 0.1.3

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.
Files changed (3) hide show
  1. package/README.md +0 -1
  2. package/dist/index.js +10 -12
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -7,7 +7,6 @@
7
7
  - Translates TypeScript patterns to native Luau/LSL equivalents (see below)
8
8
  - Handles adjusting `Vector`, `Quaternion`, and `UUID` casing
9
9
  - Validates `luaTarget` is set to `Luau`
10
- - Warns if `luaLibImport` is not `none` or `inline` (for now)
11
10
 
12
11
  ## Transforms
13
12
 
package/dist/index.js CHANGED
@@ -308,6 +308,16 @@ const CALL_TRANSFORMS = [
308
308
  return createNamespacedCall("string", "sub", args, node);
309
309
  },
310
310
  },
311
+ // str.replaceAll(search, replacement) -> ll.ReplaceSubString(str, search, replacement, 0)
312
+ {
313
+ match: (node, checker) => isMethodCall(node, checker, isStringType, "replaceAll", 2),
314
+ emit: (node, context) => {
315
+ const str = context.transformExpression(node.expression.expression);
316
+ const search = context.transformExpression(node.arguments[0]);
317
+ const replacement = context.transformExpression(node.arguments[1]);
318
+ return createNamespacedCall("ll", "ReplaceSubString", [str, search, replacement, tstl.createNumericLiteral(0)], node);
319
+ },
320
+ },
311
321
  // arr.includes(val) -> table.find(arr, val) ~= nil
312
322
  {
313
323
  match: (node, checker) => isMethodCall(node, checker, isArrayType, "includes", 1),
@@ -432,18 +442,6 @@ const plugin = {
432
442
  source: "@gwigz/slua-tstl-plugin",
433
443
  });
434
444
  }
435
- if (options.luaLibImport !== undefined &&
436
- ![tstl.LuaLibImportKind.None, tstl.LuaLibImportKind.Inline].includes(options.luaLibImport)) {
437
- diagnostics.push({
438
- file: undefined,
439
- start: undefined,
440
- length: undefined,
441
- messageText: '@gwigz/slua-tstl-plugin requires luaLibImport to be "none" or "inline"',
442
- category: ts.DiagnosticCategory.Warning,
443
- code: 90002,
444
- source: "@gwigz/slua-tstl-plugin",
445
- });
446
- }
447
445
  return diagnostics;
448
446
  },
449
447
  beforeEmit(program, _options, _emitHost, result) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gwigz/slua-tstl-plugin",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "TypeScriptToLua plugin for targeting Second Life's SLua runtime",
5
5
  "license": "MIT",
6
6
  "repository": {