oxc 0.1.0-arm-linux-gnu

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 (56) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +21 -0
  3. data/README.md +437 -0
  4. data/ext/oxc/extconf.rb +123 -0
  5. data/ext/oxc/include/oxc.h +40 -0
  6. data/ext/oxc/oxc.c +136 -0
  7. data/lib/oxc/3.2/oxc.so +0 -0
  8. data/lib/oxc/3.3/oxc.so +0 -0
  9. data/lib/oxc/3.4/oxc.so +0 -0
  10. data/lib/oxc/4.0/oxc.so +0 -0
  11. data/lib/oxc/backend.rb +41 -0
  12. data/lib/oxc/diagnosed.rb +33 -0
  13. data/lib/oxc/diagnostic.rb +86 -0
  14. data/lib/oxc/errors.rb +26 -0
  15. data/lib/oxc/minifier.rb +31 -0
  16. data/lib/oxc/minify_result.rb +25 -0
  17. data/lib/oxc/options.rb +113 -0
  18. data/lib/oxc/parse_result.rb +106 -0
  19. data/lib/oxc/result.rb +51 -0
  20. data/lib/oxc/transform_result.rb +47 -0
  21. data/lib/oxc/transformer.rb +31 -0
  22. data/lib/oxc/version.rb +5 -0
  23. data/lib/oxc.rb +52 -0
  24. data/licenses/README.md +12 -0
  25. data/licenses/oxc-MIT.txt +22 -0
  26. data/licenses/oxc-THIRD-PARTY.txt +763 -0
  27. data/oxc.gemspec +43 -0
  28. data/rust/Cargo.lock +1436 -0
  29. data/rust/Cargo.toml +32 -0
  30. data/rust/build.rs +52 -0
  31. data/rust/cbindgen.toml +24 -0
  32. data/rust/rustfmt.toml +3 -0
  33. data/rust/src/diagnostic.rs +75 -0
  34. data/rust/src/lib.rs +288 -0
  35. data/rust/src/module_record.rs +262 -0
  36. data/rust/src/options.rs +744 -0
  37. data/rust/src/parse.rs +93 -0
  38. data/rust/src/result.rs +55 -0
  39. data/rust/src/source_type.rs +26 -0
  40. data/rust/src/symbols.rs +101 -0
  41. data/rust/src/transform.rs +116 -0
  42. data/sig/oxc/backend.rbs +29 -0
  43. data/sig/oxc/diagnosed.rbs +23 -0
  44. data/sig/oxc/diagnostic.rbs +57 -0
  45. data/sig/oxc/errors.rbs +31 -0
  46. data/sig/oxc/minifier.rbs +21 -0
  47. data/sig/oxc/minify_result.rbs +11 -0
  48. data/sig/oxc/options.rbs +42 -0
  49. data/sig/oxc/parse_result.rbs +61 -0
  50. data/sig/oxc/result.rbs +32 -0
  51. data/sig/oxc/transform_result.rbs +22 -0
  52. data/sig/oxc/transformer.rbs +21 -0
  53. data/sig/oxc/types.rbs +96 -0
  54. data/sig/oxc/version.rbs +5 -0
  55. data/sig/oxc.rbs +15 -0
  56. metadata +107 -0
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Oxc
4
+ class TransformResult < Result
5
+ attr_reader :declaration #: String?
6
+ attr_reader :declaration_map #: String?
7
+ attr_reader :helpers_used #: Hash[String, String]
8
+
9
+ #: (String) -> Oxc::TransformResult
10
+ def self.from_json(payload)
11
+ parsed = JSON.parse(payload)
12
+
13
+ new(
14
+ code: parsed.fetch("code"),
15
+ map: parsed["map"],
16
+ declaration: parsed["declaration"],
17
+ declaration_map: parsed["declaration_map"],
18
+ legal_comments: parsed.fetch("legal_comments"),
19
+ helpers_used: parsed.fetch("helpers_used"),
20
+ diagnostics: parsed.fetch("errors").map { |diagnostic| Diagnostic.from_hash(diagnostic) },
21
+ panicked: parsed.fetch("panicked")
22
+ )
23
+ end
24
+
25
+ #: (code: String, diagnostics: Array[Oxc::Diagnostic], ?map: String?, ?declaration: String?, ?declaration_map: String?, ?legal_comments: Array[String], ?helpers_used: Hash[String, String], ?panicked: bool) -> void
26
+ def initialize(declaration: nil, declaration_map: nil, helpers_used: {}, **)
27
+ super(**)
28
+
29
+ @declaration = declaration
30
+ @declaration_map = declaration_map
31
+ @helpers_used = helpers_used.freeze
32
+
33
+ freeze
34
+ end
35
+
36
+ private
37
+
38
+ #: () -> Array[String]
39
+ def parts
40
+ parts = super
41
+ parts << "declaration=#{declaration.length} bytes" if declaration
42
+ parts << "helpers_used=#{helpers_used.length}" unless helpers_used.empty?
43
+
44
+ parts
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Oxc
4
+ class Transformer
5
+ attr_reader :options #: Hash[Symbol, untyped]
6
+
7
+ #: (?filename: String?, ?lang: String?, ?source_type: String?, ?cwd: String?, ?target: targets?, ?jsx: jsx?, ?typescript: typescript?, ?assumptions: assumptions?, ?decorator: decorator?, ?helpers: helpers?, ?define: Hash[String, String]?, ?inject: inject?, ?minify: minify?, ?codegen: codegen?, ?sourcemap: bool, ?strict: bool) -> void
8
+ def initialize(**options)
9
+ @options = options.transform_keys(&:to_sym).freeze
10
+
11
+ freeze
12
+ end
13
+
14
+ #: (String, ?filename: String?, ?lang: String?, ?source_type: String?, ?cwd: String?, ?target: targets?, ?jsx: jsx?, ?typescript: typescript?, ?assumptions: assumptions?, ?decorator: decorator?, ?helpers: helpers?, ?define: Hash[String, String]?, ?inject: inject?, ?minify: minify?, ?codegen: codegen?, ?sourcemap: bool, ?strict: bool) -> Oxc::TransformResult
15
+ def transform(source, **overrides)
16
+ Oxc.transform(source, **options, **overrides)
17
+ end
18
+
19
+ alias call transform
20
+
21
+ #: (?filename: String?, ?lang: String?, ?source_type: String?, ?cwd: String?, ?target: targets?, ?jsx: jsx?, ?typescript: typescript?, ?assumptions: assumptions?, ?decorator: decorator?, ?helpers: helpers?, ?define: Hash[String, String]?, ?inject: inject?, ?minify: minify?, ?codegen: codegen?, ?sourcemap: bool, ?strict: bool) -> Oxc::Transformer
22
+ def with(**overrides)
23
+ self.class.new(**options, **overrides)
24
+ end
25
+
26
+ #: () -> String
27
+ def inspect
28
+ "#<#{self.class.name} #{options.inspect}>"
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Oxc
4
+ VERSION = "0.1.0"
5
+ end
data/lib/oxc.rb ADDED
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+
5
+ require_relative "oxc/version"
6
+ require_relative "oxc/errors"
7
+ require_relative "oxc/backend"
8
+
9
+ begin
10
+ major, minor, = RUBY_VERSION.split(".")
11
+ require_relative "oxc/#{major}.#{minor}/oxc"
12
+ rescue LoadError
13
+ require_relative "oxc/oxc"
14
+ end
15
+
16
+ require_relative "oxc/options"
17
+ require_relative "oxc/diagnostic"
18
+ require_relative "oxc/diagnosed"
19
+ require_relative "oxc/result"
20
+ require_relative "oxc/minify_result"
21
+ require_relative "oxc/transform_result"
22
+ require_relative "oxc/parse_result"
23
+ require_relative "oxc/transformer"
24
+ require_relative "oxc/minifier"
25
+
26
+ module Oxc
27
+ #: (String, ?filename: String?, ?lang: String?, ?source_type: String?, ?compress: compress?, ?mangle: mangle?, ?codegen: codegen?, ?sourcemap: bool, ?strict: bool) -> Oxc::MinifyResult
28
+ def self.minify(source, **options)
29
+ serialized = Options.serialize(options, Options::MINIFY, "minify")
30
+
31
+ MinifyResult.from_json(Backend.minify(source.to_s, serialized)).validate!(strict: options[:strict])
32
+ end
33
+
34
+ #: (String, ?filename: String?, ?lang: String?, ?source_type: String?, ?cwd: String?, ?target: targets?, ?jsx: jsx?, ?typescript: typescript?, ?assumptions: assumptions?, ?decorator: decorator?, ?helpers: helpers?, ?define: Hash[String, String]?, ?inject: inject?, ?minify: minify?, ?codegen: codegen?, ?sourcemap: bool, ?strict: bool) -> Oxc::TransformResult
35
+ def self.transform(source, **options)
36
+ serialized = Options.serialize(options, Options::TRANSFORM, "transform")
37
+
38
+ TransformResult.from_json(Backend.transform(source.to_s, serialized)).validate!(strict: options[:strict])
39
+ end
40
+
41
+ #: (String, ?filename: String?, ?lang: String?, ?source_type: String?, ?ast_type: String?, ?ast: bool, ?ranges: bool, ?preserve_parens: bool, ?comments: bool, ?module_record: bool, ?symbols: bool, ?semantic_errors: bool) -> Oxc::ParseResult
42
+ def self.parse(source, **options)
43
+ serialized = Options.serialize(options, Options::PARSE, "parse")
44
+
45
+ ParseResult.from_json(Backend.parse(source.to_s, serialized))
46
+ end
47
+
48
+ #: () -> String
49
+ def self.oxc_version
50
+ Backend.oxc_version
51
+ end
52
+ end
@@ -0,0 +1,12 @@
1
+ # Licenses of what this gem builds against
2
+
3
+ A precompiled gem ships a native extension with [Oxc](https://github.com/oxc-project/oxc) compiled into it, so the terms that cover Oxc cover part of what is being distributed.
4
+
5
+ They are carried here so that whoever received the gem has them in hand.
6
+
7
+ | File | Covers | License |
8
+ |-----------------------|---------------------------------------------------------|------------|
9
+ | `oxc-MIT.txt` | Oxc itself | MIT |
10
+ | `oxc-THIRD-PARTY.txt` | the code Oxc carries from TypeScript and from `miette` | Apache-2.0 |
11
+
12
+ The gem's own Ruby, C, and Rust code is MIT, in `LICENSE.txt` at the root.
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-present VoidZero Inc. & Contributors
4
+ Copyright (c) 2023 Boshen
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.