lilac-wasm-bin 0.2.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.
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lilac
4
+ module Wasm
5
+ module Bin
6
+ VERSION = "0.2.0"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,101 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "bin/version"
4
+
5
+ module Lilac
6
+ module Wasm
7
+ # Path resolution for the bundled wasm runtimes + JS bridge.
8
+ #
9
+ # Released gem layout:
10
+ # lilac-wasm-bin-X.Y.Z/
11
+ # ├── lib/lilac/wasm/bin.rb ← this file
12
+ # └── data/
13
+ # ├── lilac-full.wasm
14
+ # ├── lilac-compiled.wasm
15
+ # ├── mrbc-host.wasm (compiler-only wasm, driven via wasmtime-rb)
16
+ # └── mruby-wasm-js/
17
+ # ├── index.js
18
+ # ├── wasi-preview1.js
19
+ # └── ...
20
+ #
21
+ # Monorepo dev layout (via `gem "lilac-wasm-bin", path: "../wasm-bin"`):
22
+ # `data/` may be empty or partially populated. As a fallback the
23
+ # resolver walks up to the lilac monorepo root and reads from
24
+ # `build/` (lilac-{full,compiled}.wasm) / `mrbgem/mruby-wasm-js/`
25
+ # (bridge), so contributors don't have to `rake build:assets`
26
+ # before every tweak. The fallback prefers the RELEASE wasm
27
+ # (`build/<name>.release.wasm`, what the released gem ships) over the
28
+ # dev build, so a `path:` checkout vendors the same small artifact as
29
+ # production; the dev build is the last resort (debugging).
30
+ module Bin
31
+ # Absolute path to this gem's `data/` directory — the canonical
32
+ # location for the bundled wasm + bridge in a released gem.
33
+ DATA_DIR = File.expand_path("../../../data", __dir__).freeze
34
+
35
+ class << self
36
+ # Path to lilac-full.wasm. Prefers the gem's data/; falls back
37
+ # to `<monorepo>/build/lilac-full.wasm` for in-repo development.
38
+ # Returns nil if neither exists.
39
+ def lilac_full_wasm
40
+ first_existing(*monorepo_candidates("lilac-full"))
41
+ end
42
+
43
+ # Path to lilac-compiled.wasm. Same discovery pattern.
44
+ def lilac_compiled_wasm
45
+ first_existing(*monorepo_candidates("lilac-compiled"))
46
+ end
47
+
48
+ # Path to mrbc-host.wasm — a compiler-only wasm reactor that
49
+ # `lilac-cli`'s WasmMrbcDriver drives via wasmtime-rb to replace
50
+ # the external `mrbc` binary for `lilac build --target compiled`.
51
+ # Same gem-vs-monorepo discovery as the other variants.
52
+ def mrbc_host_wasm
53
+ first_existing(*monorepo_candidates("mrbc-host"))
54
+ end
55
+
56
+ # Path to the JS bridge directory (`@takahashim/mruby-wasm-js`
57
+ # source). The runtime wasms can't load without `index.js` +
58
+ # `wasi-preview1.js` etc. siblings — the lilac-cli builder
59
+ # auto-vendors the whole directory into `dist/vendor/.../`.
60
+ def mruby_wasm_js_dir
61
+ first_directory(
62
+ File.join(DATA_DIR, "mruby-wasm-js"),
63
+ File.join(monorepo_root, "mrbgem", "mruby-wasm-js", "js"),
64
+ )
65
+ end
66
+
67
+ private
68
+
69
+ # Discovery candidates for a wasm `<base>` (`lilac-full` etc.),
70
+ # in priority order: the gem's `data/` (what a released gem ships,
71
+ # always the release build), then the monorepo RELEASE build,
72
+ # then the monorepo dev build (debugging last resort).
73
+ def monorepo_candidates(base)
74
+ [
75
+ File.join(DATA_DIR, "#{base}.wasm"),
76
+ File.join(monorepo_root, "build", "#{base}.release.wasm"),
77
+ File.join(monorepo_root, "build", "#{base}.wasm"),
78
+ ]
79
+ end
80
+
81
+ # `lilac/` repo root one level above the wasm-bin gem. Only
82
+ # meaningful in the monorepo dev layout (`gem ... path: ...`);
83
+ # in a released gem this resolves to an arbitrary path under
84
+ # ~/.gem and the file checks above simply produce no hits.
85
+ # Kept as a method (not constant) so it's not exposed on the
86
+ # public Bin namespace.
87
+ def monorepo_root
88
+ File.expand_path("../../../..", __dir__)
89
+ end
90
+
91
+ def first_existing(*paths)
92
+ paths.find { |p| File.file?(p) }
93
+ end
94
+
95
+ def first_directory(*paths)
96
+ paths.find { |p| File.directory?(p) }
97
+ end
98
+ end
99
+ end
100
+ end
101
+ end
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lilac-wasm-bin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - takahashim
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: wasmtime
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '45.0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '45.0'
26
+ description: Ships the lilac-full.wasm, lilac-compiled.wasm and the mruby-wasm-js
27
+ JS bridge as a single Ruby gem so that `bundle install` is enough to make `lilac
28
+ dev` and `lilac build` work — no npm install, no manual cp.
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - README.md
34
+ - data/lilac-compiled.wasm
35
+ - data/lilac-full.wasm
36
+ - data/mrbc-host.wasm
37
+ - data/mruby-wasm-js/_memory.js
38
+ - data/mruby-wasm-js/_smoke.ts
39
+ - data/mruby-wasm-js/debug.js
40
+ - data/mruby-wasm-js/index.d.ts
41
+ - data/mruby-wasm-js/index.js
42
+ - data/mruby-wasm-js/wasi-preview1.js
43
+ - lib/lilac/wasm/bin.rb
44
+ - lib/lilac/wasm/bin/version.rb
45
+ licenses:
46
+ - MIT
47
+ metadata:
48
+ source_code_uri: https://github.com/takahashim/lilac
49
+ rubygems_mfa_required: 'true'
50
+ rdoc_options: []
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: 3.2.0
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ requirements: []
64
+ rubygems_version: 3.6.9
65
+ specification_version: 4
66
+ summary: Lilac wasm runtimes (full + compiled) + JS bridge, packaged for rubygems
67
+ test_files: []