funicular 0.0.1 → 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.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +56 -1
  3. data/README.md +58 -20
  4. data/Rakefile +74 -2
  5. data/demo/keymap_editor.html +582 -0
  6. data/demo/test_cable.html +179 -0
  7. data/demo/test_chartjs.html +235 -0
  8. data/demo/test_component.html +201 -0
  9. data/demo/test_diff_patch.html +146 -0
  10. data/demo/test_error_boundary.html +284 -0
  11. data/demo/test_router.html +257 -0
  12. data/demo/test_vdom.html +100 -0
  13. data/demo/tic-tac-toe.html +201 -0
  14. data/docs/README.md +419 -0
  15. data/docs/advanced-features.md +632 -0
  16. data/docs/architecture.md +409 -0
  17. data/docs/components-and-state.md +539 -0
  18. data/docs/data-fetching.md +528 -0
  19. data/docs/forms.md +446 -0
  20. data/docs/rails-integration.md +426 -0
  21. data/docs/realtime.md +543 -0
  22. data/docs/routing-and-navigation.md +427 -0
  23. data/docs/styling.md +285 -0
  24. data/exe/funicular +32 -0
  25. data/lib/funicular/assets/funicular.rb +21 -0
  26. data/lib/funicular/assets/funicular_debug.css +73 -0
  27. data/lib/funicular/assets/funicular_debug.js +183 -0
  28. data/lib/funicular/commands/routes.rb +69 -0
  29. data/lib/funicular/compiler.rb +135 -0
  30. data/lib/funicular/configuration.rb +76 -0
  31. data/lib/funicular/helpers/picoruby_helper.rb +50 -0
  32. data/lib/funicular/middleware.rb +98 -0
  33. data/lib/funicular/railtie.rb +26 -0
  34. data/lib/funicular/route_parser.rb +137 -0
  35. data/lib/funicular/vendor/picorbc/VERSION +1 -0
  36. data/lib/funicular/vendor/picorbc/picorbc.js +5283 -0
  37. data/lib/funicular/vendor/picorbc/picorbc.wasm +0 -0
  38. data/lib/funicular/vendor/picoruby/VERSION +1 -0
  39. data/lib/funicular/vendor/picoruby/debug/init.iife.js +130 -0
  40. data/lib/funicular/vendor/picoruby/debug/picoruby.js +6404 -0
  41. data/lib/funicular/vendor/picoruby/debug/picoruby.wasm +0 -0
  42. data/lib/funicular/vendor/picoruby/dist/init.iife.js +130 -0
  43. data/lib/funicular/vendor/picoruby/dist/picoruby.js +2 -0
  44. data/lib/funicular/vendor/picoruby/dist/picoruby.wasm +0 -0
  45. data/lib/funicular/version.rb +1 -1
  46. data/lib/funicular.rb +29 -1
  47. data/lib/tasks/funicular.rake +135 -0
  48. data/minitest/funicular_test.rb +13 -0
  49. data/minitest/test_helper.rb +7 -0
  50. data/mrbgem.rake +15 -0
  51. data/mrblib/cable.rb +417 -0
  52. data/mrblib/component.rb +911 -0
  53. data/mrblib/debug.rb +205 -0
  54. data/mrblib/differ.rb +244 -0
  55. data/mrblib/environment_inquirer.rb +34 -0
  56. data/mrblib/error_boundary.rb +125 -0
  57. data/mrblib/file_upload.rb +184 -0
  58. data/mrblib/form_builder.rb +284 -0
  59. data/mrblib/funicular.rb +156 -0
  60. data/mrblib/http.rb +89 -0
  61. data/mrblib/model.rb +146 -0
  62. data/mrblib/patcher.rb +203 -0
  63. data/mrblib/router.rb +229 -0
  64. data/mrblib/styles.rb +83 -0
  65. data/mrblib/vdom.rb +273 -0
  66. data/sig/cable.rbs +65 -0
  67. data/sig/component.rbs +141 -0
  68. data/sig/debug.rbs +28 -0
  69. data/sig/differ.rbs +18 -0
  70. data/sig/environment_iquirer.rbs +10 -0
  71. data/sig/error_boundary.rbs +14 -0
  72. data/sig/file_upload.rbs +18 -0
  73. data/sig/form_builder.rbs +29 -0
  74. data/sig/funicular.rbs +11 -1
  75. data/sig/http.rbs +22 -0
  76. data/sig/model.rbs +23 -0
  77. data/sig/patcher.rbs +15 -0
  78. data/sig/router.rbs +43 -0
  79. data/sig/styles.rbs +25 -0
  80. data/sig/vdom.rbs +59 -0
  81. metadata +119 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d778a4d72fce90ad8e8403f40a32293431da06b47908e927a587ad725afa192
4
- data.tar.gz: 1ded05e84560d65c99119e6e8603c04a8f130e40949ca476d6ec1419ba19cc82
3
+ metadata.gz: c20fca7e6590276dff1b8d10dcec31cc33a7c89070f2d515b28a39123358a7bb
4
+ data.tar.gz: f96247a21b413702c3e999a0588b4366e7cb356535eca53d472ca36abd331c62
5
5
  SHA512:
6
- metadata.gz: 843a50c979823f2a307107958dab03e4414ebf37978bb968857336c6ba4436f48ab47322f3bf7b37ce27f2bd8030696d668c20c3adc52df7b01eb7c443c01d6d
7
- data.tar.gz: 51f945d515798ee9804b4e11359f7ff7579024a8db8e392ef96c4bfa36867a0a6a52cedb8da8542abc7161be1fe256b3076ba345e39803407683e3523fbeef6f
6
+ metadata.gz: f592cbc26f7266a421846e0cb7f9445dcbc34458025d33d3da0ba140a5c3a3b5ee1c7b646ae56d7d5097162ed587ec92bcb402cc5da113d905deaae8bdb18a6c
7
+ data.tar.gz: 9967e115be234ee8c29e3a605192a398cef6f6de7413d833beaf08b23829752f049e9ced1590761a8b7b1f1cbaccc515efdc9ec5ff0fa431879c83e06c37c88f
data/CHANGELOG.md CHANGED
@@ -1,4 +1,59 @@
1
- ## [Unreleased]
1
+ ## [0.1.0] - 2026-04-20
2
+
3
+ ### Added
4
+
5
+ - Consolidated with picoruby-funicular: merged the full PicoRuby frontend
6
+ framework into this gem, including Component, Cable, VDOM, Router,
7
+ FormBuilder, Model, HTTP, FileUpload, ErrorBoundary, Styles, Differ,
8
+ Patcher, Debug, and EnvironmentInquirer, along with RBS signatures and
9
+ comprehensive test suite
10
+ - Bundle PicoRuby.wasm and picorbc WASM artifacts into the gem via a
11
+ `rake copy_wasm` task; artifacts are vendored at build time so no
12
+ runtime npm lookup is required
13
+ - `Funicular::Configuration` with per-environment PicoRuby.wasm source
14
+ selection (`:local_debug`, `:local_dist`, `:cdn`) and optional
15
+ `cdn_version` override
16
+ - `picoruby_include_tag` view helper (auto-registered via Railtie) that
17
+ serves the appropriate PicoRuby.wasm build per environment
18
+ - `funicular:install:wasm` rake sub-task to copy dist/debug WASM builds
19
+ into `public/picoruby/`
20
+ - Rails Asset Pipeline integration: Rack middleware, compiler, and
21
+ `funicular:compile` / `funicular:install` rake tasks
22
+ - `funicular routes` CLI command and `Funicular::RouteParser` to inspect
23
+ Rails routes from the command line
24
+ - Component Debug Highlighter: CSS/JS assets (`funicular_debug.css`,
25
+ `funicular_debug.js`) that highlight the selected component in the
26
+ browser
27
+ - `ENV['FUNICULAR_ENV']` is now set from `Rails.env` in generated
28
+ `application.rb`
29
+
30
+ ### Changed
31
+
32
+ - picorbc is now resolved from a vendored WASM artifact; removed
33
+ npm-based picorbc lookup and all `PICORBC_VERSION` environment variable
34
+ logic
35
+ - Upgraded picorbc to the latest version
36
+ - Switched test framework from test/unit to minitest
37
+
38
+ ### Fixed
39
+
40
+ - Asset pipeline: middleware now detects whether `app.mrb` has actually
41
+ changed before recompiling, preventing unnecessary rebuilds
42
+ - XSS vulnerabilities in VDOM attribute handling: expanded
43
+ `URL_ATTRIBUTES` constant, applied case-insensitive `javascript:` URI
44
+ blocking, and added the same URL validation to `Patcher#update_props`
45
+ and `Patcher#create_element`
46
+ - XSS vulnerability in Debug module: replaced manual JSON string
47
+ concatenation with `JSON.generate` to eliminate escaping gaps
48
+ - `funicular:compile` rake task
49
+ - `funicular:install` rake task
50
+ - Rack middleware
51
+ - RBS type signatures
52
+
53
+ ### Removed
54
+
55
+ - Debugger Chrome extension (`debugger/` directory)
56
+ - `.ruby-version` file
2
57
 
3
58
  ## [0.0.1] - 2025-11-27
4
59
 
data/README.md CHANGED
@@ -1,43 +1,81 @@
1
1
  # Funicular
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
3
+ > 🎵Funicu-lì, Funicu-là!🚊🚊🚊
4
+ >
5
+ > 🎵Funicu-lì, Funicu-là!🚞🚞🚞
4
6
 
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/funicular`. To experiment with that code, run `bin/console` for an interactive prompt.
7
+ **Funicular** is a single-page application (SPA) framework powered by PicoRuby.wasm.
6
8
 
7
- ## Installation
9
+ ## Features
8
10
 
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
11
+ - Write client-side code in Ruby instead of JavaScript
12
+ - Seamless Rails integration
10
13
 
11
- Install the gem and add to the application's Gemfile by executing:
14
+ ## Combined Gem
12
15
 
13
- ```bash
14
- bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
16
+ This repository consists of three relevant projects:
17
+
18
+ - PicoGem "picoruby-funicular" ... Core implementation
19
+ - CRubyGem "funicular" ... Rails integration
20
+ - Chrome extension "PicoRuby Debugger"
21
+
22
+ ### PicoGem "picoruby-funicular"
23
+
24
+ ```console
25
+ .
26
+ ├── mrbgem.rake
27
+ ├── mrblib/
28
+ └── test/
15
29
  ```
16
30
 
17
- If bundler is not being used to manage dependencies, install the gem by executing:
31
+ ### CRubyGem "funicular"
32
+
33
+ ```console
34
+ .
35
+ ├── bin/
36
+ ├── exe/
37
+ ├── funicular.gemspec
38
+ ├── Gemfile
39
+ ├── Gemfile.lock
40
+ ├── lib/
41
+ ├── minitest/
42
+ └── Rakefile
43
+ ```
44
+
45
+ ### Chrome extention "PicoRuby.wasm debugger"
18
46
 
19
- ```bash
20
- gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
47
+ ```console
48
+ .
49
+ └── debugger/
21
50
  ```
22
51
 
23
- ## Usage
52
+ ----
53
+
54
+ The others are common resources.
24
55
 
25
- TODO: Write usage instructions here
56
+ ## Documentation
57
+
58
+ You may want to see Tic-Tac-Toe tutorial first: [https://picoruby.org/funicular](https://picoruby.org/funicular)
59
+
60
+ Then, dig [docs/](docs/).
26
61
 
27
62
  ## Development
28
63
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
64
+ This repository is a submodule of [picoruby/picoruby](https://github.com/picoruby/picoruby).
65
+ Do not check it out standalone. Instead, clone the parent repository and work from there:
66
+
67
+ ```console
68
+ git clone --recurse-submodules https://github.com/picoruby/picoruby.git
69
+ cd picoruby/mrbgems/picoruby-funicular
70
+ ```
30
71
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
72
+ The CRubyGem side (`lib/`, `funicular.gemspec`, etc.) can be developed and tested independently inside that directory, but `rake copy_wasm` which vendorsthe PicoRuby.wasm and picorbc wasm artifacts into the gem relies on sibling directories within the picoruby repository (`mrbgems/picoruby-wasm/npm/`).
73
+ Running it from a standalone checkout will fail.
32
74
 
33
75
  ## Contributing
34
76
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/funicular. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/funicular/blob/master/CODE_OF_CONDUCT.md).
77
+ Bug reports and pull requests are welcome on GitHub at https://github.com/picoruby/funicular.
36
78
 
37
79
  ## License
38
80
 
39
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
-
41
- ## Code of Conduct
42
-
43
- Everyone interacting in the Funicular project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/funicular/blob/master/CODE_OF_CONDUCT.md).
81
+ Copyright © 2025- HASUMI Hitoshi. See MIT-LICENSE for further details.
data/Rakefile CHANGED
@@ -4,9 +4,81 @@ require "bundler/gem_tasks"
4
4
  require "rake/testtask"
5
5
 
6
6
  Rake::TestTask.new(:test) do |t|
7
- t.libs << "test"
7
+ t.libs << "minitest"
8
8
  t.libs << "lib"
9
- t.test_files = FileList["test/**/*_test.rb"]
9
+ t.test_files = FileList["minitest/**/*_test.rb"]
10
10
  end
11
11
 
12
12
  task default: :test
13
+
14
+ desc "Copy picoruby and picorbc wasm artifacts from picoruby-wasm into the gem"
15
+ task :copy_wasm do
16
+ require "fileutils"
17
+ require "json"
18
+
19
+ vendor_root = File.expand_path("lib/funicular/vendor", __dir__)
20
+
21
+ # PICORUBY_WASM_NPM_DIR overrides the default search path.
22
+ # Default: picoruby-wasm is a sibling of picoruby-funicular under mrbgems/.
23
+ npm_root = ENV["PICORUBY_WASM_NPM_DIR"] ||
24
+ File.expand_path("../picoruby-wasm/npm", __dir__)
25
+
26
+ unless Dir.exist?(npm_root)
27
+ abort "picoruby-wasm npm directory not found: #{npm_root}\n" \
28
+ "Set PICORUBY_WASM_NPM_DIR to override, and ensure picoruby-wasm has been built."
29
+ end
30
+
31
+ # ------------------------------------------------------------------
32
+ # 1) PicoRuby runtime (browser): dist + debug
33
+ # ------------------------------------------------------------------
34
+ picoruby_src = File.join(npm_root, "picoruby")
35
+ picoruby_dest = File.join(vendor_root, "picoruby")
36
+ abort "Missing #{picoruby_src}" unless Dir.exist?(picoruby_src)
37
+
38
+ picoruby_version = JSON.parse(File.read(File.join(picoruby_src, "package.json"))).fetch("version")
39
+ picoruby_files = %w[picoruby.wasm picoruby.js init.iife.js]
40
+
41
+ %w[dist debug].each do |variant|
42
+ src = File.join(picoruby_src, variant)
43
+ dst = File.join(picoruby_dest, variant)
44
+ abort "Missing source variant: #{src}" unless Dir.exist?(src)
45
+
46
+ FileUtils.rm_rf(dst)
47
+ FileUtils.mkdir_p(dst)
48
+ picoruby_files.each do |fname|
49
+ src_file = File.join(src, fname)
50
+ abort "Missing file: #{src_file}" unless File.exist?(src_file)
51
+ # FileUtils.copy_file follows symlinks, so debug/init.iife.js
52
+ # (a symlink to ../dist/init.iife.js) is materialized.
53
+ FileUtils.copy_file(src_file, File.join(dst, fname))
54
+ end
55
+ puts " copied picoruby/#{variant}"
56
+ end
57
+
58
+ File.write(File.join(picoruby_dest, "VERSION"), "#{picoruby_version}\n")
59
+ puts " wrote picoruby/VERSION (#{picoruby_version})"
60
+
61
+ # ------------------------------------------------------------------
62
+ # 2) picorbc compiler (node CLI, run by Funicular::Compiler)
63
+ # ------------------------------------------------------------------
64
+ picorbc_src = File.join(npm_root, "picorbc", "debug")
65
+ picorbc_dest = File.join(vendor_root, "picorbc")
66
+ abort "Missing #{picorbc_src}" unless Dir.exist?(picorbc_src)
67
+
68
+ picorbc_version = JSON.parse(File.read(File.join(npm_root, "picorbc", "package.json"))).fetch("version")
69
+ picorbc_files = %w[picorbc.js picorbc.wasm]
70
+
71
+ FileUtils.rm_rf(picorbc_dest)
72
+ FileUtils.mkdir_p(picorbc_dest)
73
+ picorbc_files.each do |fname|
74
+ src_file = File.join(picorbc_src, fname)
75
+ abort "Missing file: #{src_file}" unless File.exist?(src_file)
76
+ FileUtils.copy_file(src_file, File.join(picorbc_dest, fname))
77
+ end
78
+ File.chmod(0755, File.join(picorbc_dest, "picorbc.js"))
79
+ File.write(File.join(picorbc_dest, "VERSION"), "#{picorbc_version}\n")
80
+ puts " copied picorbc (#{picorbc_version})"
81
+ end
82
+
83
+ # Make sure the wasm artifacts are refreshed before the gem is packaged for release.
84
+ Rake::Task["build"].enhance([:copy_wasm])