From 93afd0249430fd42e94acee84b55230815577159 Mon Sep 17 00:00:00 2001 From: keyasuda Date: Tue, 3 Jan 2023 00:01:41 +0900 Subject: [PATCH] v0.1.14: avoid TypeError with old app.js --- CHANGELOG.md | 4 ++++ gem/Gemfile.lock | 2 +- gem/lib/bormashino/version.rb | 2 +- npm/package-lock.json | 4 ++-- npm/package.json | 2 +- npm/src/ruby.js | 3 +++ test-app/Gemfile.lock | 2 +- test-app/js/app.js | 6 +++--- test-app/package-lock.json | 2 +- test-app/spec/test_app_spec.rb | 5 ++++- 10 files changed, 21 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 35bff03..389ed65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [0.1.14] - 2022-01-03 + +- avoid TypeError with old app.js + ## [0.1.13] - 2022-01-02 - enable JS::Object#await diff --git a/gem/Gemfile.lock b/gem/Gemfile.lock index 15d598a..95421ce 100644 --- a/gem/Gemfile.lock +++ b/gem/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - bormashino (0.1.13) + bormashino (0.1.14) json_pure (~> 2.6, >= 2.6.1) os (~> 1.1, >= 1.1.4) ruby2_keywords (= 0.0.4) diff --git a/gem/lib/bormashino/version.rb b/gem/lib/bormashino/version.rb index 54a698b..48ba6d7 100644 --- a/gem/lib/bormashino/version.rb +++ b/gem/lib/bormashino/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Bormashino - VERSION = '0.1.13' + VERSION = '0.1.14' end diff --git a/npm/package-lock.json b/npm/package-lock.json index 9eea06d..9619a80 100644 --- a/npm/package-lock.json +++ b/npm/package-lock.json @@ -1,12 +1,12 @@ { "name": "bormashino", - "version": "0.1.13", + "version": "0.1.14", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "bormashino", - "version": "0.1.13", + "version": "0.1.14", "license": "MIT", "dependencies": { "@wasmer/wasi": "0.12.0", diff --git a/npm/package.json b/npm/package.json index 3e774f1..783efec 100644 --- a/npm/package.json +++ b/npm/package.json @@ -2,7 +2,7 @@ "name": "bormashino", "description": "The package to build SPAs with Ruby", "homepage": "https://github.com/keyasuda/bormashino", - "version": "0.1.13", + "version": "0.1.14", "main": "src/index.js", "scripts": { "test": "jest --notify src/", diff --git a/npm/src/ruby.js b/npm/src/ruby.js index 4e61cf4..4d71184 100644 --- a/npm/src/ruby.js +++ b/npm/src/ruby.js @@ -88,6 +88,9 @@ export const initVmFromRubyModule = async ( } const requestToServer = async (method, path, payload, referer) => { + if (typeof window.bormashino == 'undefined') { + window.bormashino = {} + } window.bormashino.requestSrc = JSON.stringify({ method, path, diff --git a/test-app/Gemfile.lock b/test-app/Gemfile.lock index ce88f17..2b604ed 100644 --- a/test-app/Gemfile.lock +++ b/test-app/Gemfile.lock @@ -11,7 +11,7 @@ GIT PATH remote: ../gem specs: - bormashino (0.1.13) + bormashino (0.1.14) json_pure (~> 2.6, >= 2.6.1) os (~> 1.1, >= 1.1.4) ruby2_keywords (= 0.0.4) diff --git a/test-app/js/app.js b/test-app/js/app.js index f9069ea..09045ee 100644 --- a/test-app/js/app.js +++ b/test-app/js/app.js @@ -20,12 +20,12 @@ const main = async () => { 'dispatched: ' + Number(new Date()) }) - window.bormashino = RubyApplication - window.rubyVM = vm - const currentPath = () => location.href.replace(location.origin, '') RubyApplication.request('get', currentPath()) RubyApplication.mount() + + window.bormashino = RubyApplication + window.rubyVM = vm } main() diff --git a/test-app/package-lock.json b/test-app/package-lock.json index 13710f2..6cb8036 100644 --- a/test-app/package-lock.json +++ b/test-app/package-lock.json @@ -15,7 +15,7 @@ }, "../npm": { "name": "bormashino", - "version": "0.1.13", + "version": "0.1.14", "license": "MIT", "dependencies": { "@wasmer/wasi": "0.12.0", diff --git a/test-app/spec/test_app_spec.rb b/test-app/spec/test_app_spec.rb index 98bb45b..6eab862 100644 --- a/test-app/spec/test_app_spec.rb +++ b/test-app/spec/test_app_spec.rb @@ -5,7 +5,10 @@ visit 'http://localhost:5000' loop do sleep 1 - break if page.find(:css, 'h1') + begin + break if page.find(:css, 'h1') + rescue StandardError + end end end