Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package rubygem-js-routes for 
openSUSE:Factory checked in at 2022-04-30 22:52:28
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-js-routes (Old)
 and      /work/SRC/openSUSE:Factory/.rubygem-js-routes.new.1538 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "rubygem-js-routes"

Sat Apr 30 22:52:28 2022 rev:26 rq:974051 version:2.2.3

Changes:
--------
--- /work/SRC/openSUSE:Factory/rubygem-js-routes/rubygem-js-routes.changes      
2022-02-24 18:23:33.310656841 +0100
+++ 
/work/SRC/openSUSE:Factory/.rubygem-js-routes.new.1538/rubygem-js-routes.changes
    2022-04-30 22:52:36.880230490 +0200
@@ -1,0 +2,17 @@
+Thu Apr 28 05:34:07 UTC 2022 - Stephan Kulow <co...@suse.com>
+
+updated to version 2.2.3
+ see installed CHANGELOG.md
+
+  ## v2.2.4
+  
+  * Fix rails engine loading if sprockets is not in Gemfile. Fixes 
[#294](https://github.com/railsware/js-routes/issues/294)
+  
+  ## v2.2.3
+  
+  * Fixed NIL module type namespace defintion 
[#297](https://github.com/railsware/js-routes/issues/297).
+    * The patch may cause a problem with nested `namespace` option 
+    * Ex. Value like `MyProject.Routes` requires to define `window.MyProject` 
before importing the routes file
+  
+
+-------------------------------------------------------------------

Old:
----
  js-routes-2.2.2.gem

New:
----
  js-routes-2.2.3.gem

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ rubygem-js-routes.spec ++++++
--- /var/tmp/diff_new_pack.EAHyDT/_old  2022-04-30 22:52:37.828231773 +0200
+++ /var/tmp/diff_new_pack.EAHyDT/_new  2022-04-30 22:52:37.836231784 +0200
@@ -24,7 +24,7 @@
 #
 
 Name:           rubygem-js-routes
-Version:        2.2.2
+Version:        2.2.3
 Release:        0
 %define mod_name js-routes
 %define mod_full_name %{mod_name}-%{version}

++++++ js-routes-2.2.2.gem -> js-routes-2.2.3.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/CHANGELOG.md new/CHANGELOG.md
--- old/CHANGELOG.md    2022-02-01 15:34:29.000000000 +0100
+++ new/CHANGELOG.md    2022-03-07 13:07:43.000000000 +0100
@@ -1,5 +1,15 @@
 ## master
 
+## v2.2.4
+
+* Fix rails engine loading if sprockets is not in Gemfile. Fixes 
[#294](https://github.com/railsware/js-routes/issues/294)
+
+## v2.2.3
+
+* Fixed NIL module type namespace defintion 
[#297](https://github.com/railsware/js-routes/issues/297).
+  * The patch may cause a problem with nested `namespace` option 
+  * Ex. Value like `MyProject.Routes` requires to define `window.MyProject` 
before importing the routes file
+
 ## v2.2.2.
 
 * Fix custom file path 
[#295](https://github.com/railsware/js-routes/issues/295)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Readme.md new/Readme.md
--- old/Readme.md       2022-02-01 15:34:29.000000000 +0100
+++ new/Readme.md       2022-03-07 13:07:43.000000000 +0100
@@ -20,6 +20,7 @@
 
 * [Quick and easy](#quick-start)
   * Uses Rack Middleware to automatically update routes locally
+  * Automatically generates routes files on `assets:precompile` in production
   * Works great for a simple Rails application
 * [Webpacker ERB Loader](#webpacker)
   * Requires ESM module system (the default)
Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/js_routes/engine.rb new/lib/js_routes/engine.rb
--- old/lib/js_routes/engine.rb 2022-02-01 15:34:29.000000000 +0100
+++ new/lib/js_routes/engine.rb 2022-03-07 13:07:43.000000000 +0100
@@ -29,32 +29,34 @@
 
 
 class Engine < ::Rails::Engine
-  require 'sprockets/version'
-  v2                = Gem::Dependency.new('', ' ~> 2')
-  vgte3             = Gem::Dependency.new('', ' >= 3')
-  sprockets_version = Gem::Version.new(::Sprockets::VERSION).release
-  initializer_args  = case sprockets_version
-                        when -> (v) { v2.match?('', v) }
-                          { after: "sprockets.environment" }
-                        when -> (v) { vgte3.match?('', v) }
-                          { after: :engines_blank_point, before: 
:finisher_hook }
-                        else
-                          raise StandardError, "Sprockets version 
#{sprockets_version} is not supported"
-                      end
+  if defined?(::Sprockets::Railtie)
+    require 'sprockets/version'
+    v2                = Gem::Dependency.new('', ' ~> 2')
+    vgte3             = Gem::Dependency.new('', ' >= 3')
+    sprockets_version = Gem::Version.new(::Sprockets::VERSION).release
+    initializer_args  = case sprockets_version
+                          when -> (v) { v2.match?('', v) }
+                            { after: "sprockets.environment" }
+                          when -> (v) { vgte3.match?('', v) }
+                            { after: :engines_blank_point, before: 
:finisher_hook }
+                          else
+                            raise StandardError, "Sprockets version 
#{sprockets_version} is not supported"
+                        end
 
-  initializer 'js-routes.dependent_on_routes', initializer_args do
-    case sprockets_version
-      when  -> (v) { v2.match?('', v) },
-            -> (v) { vgte3.match?('', v) }
+    initializer 'js-routes.dependent_on_routes', initializer_args do
+      case sprockets_version
+        when  -> (v) { v2.match?('', v) },
+              -> (v) { vgte3.match?('', v) }
 
-      Rails.application.config.assets.configure do |config|
-        config.register_preprocessor(
-          "application/javascript",
-          SprocketsExtension,
-        )
+        Rails.application.config.assets.configure do |config|
+          config.register_preprocessor(
+            "application/javascript",
+            SprocketsExtension,
+          )
+        end
+      else
+        raise StandardError, "Sprockets version #{sprockets_version} is not 
supported"
       end
-    else
-      raise StandardError, "Sprockets version #{sprockets_version} is not 
supported"
     end
   end
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/js_routes/instance.rb 
new/lib/js_routes/instance.rb
--- old/lib/js_routes/instance.rb       2022-02-01 15:34:29.000000000 +0100
+++ new/lib/js_routes/instance.rb       2022-03-07 13:07:43.000000000 +0100
@@ -57,16 +57,35 @@
         'DEPRECATED_GLOBBING_BEHAVIOR' => ActionPack::VERSION::MAJOR == 4 && 
ActionPack::VERSION::MINOR == 0,
 
         'APP_CLASS'           => application.class.to_s,
-        'NAMESPACE'           => json(@configuration.namespace),
         'DEFAULT_URL_OPTIONS' => json(@configuration.default_url_options),
         'PREFIX'              => json(@configuration.prefix),
         'SPECIAL_OPTIONS_KEY' => json(@configuration.special_options_key),
         'SERIALIZER'          => @configuration.serializer || json(nil),
         'MODULE_TYPE'         => json(@configuration.module_type),
-        'WRAPPER'             => @configuration.esm? ? 'const __jsr = ' : '',
+        'WRAPPER'             => wrapper_variable,
       }
     end
 
+    def wrapper_variable
+      case @configuration.module_type
+      when 'ESM'
+        'const __jsr = '
+      when 'NIL'
+        namespace = @configuration.namespace
+        if namespace
+          if namespace.include?('.')
+            "#{namespace} = "
+          else
+            "(typeof window !== 'undefined' ? window : this).#{namespace} = "
+          end
+        else
+          ''
+        end
+      else
+        ''
+      end
+    end
+
     def application
       @configuration.application
     end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/js_routes/version.rb new/lib/js_routes/version.rb
--- old/lib/js_routes/version.rb        2022-02-01 15:34:29.000000000 +0100
+++ new/lib/js_routes/version.rb        2022-03-07 13:07:43.000000000 +0100
@@ -1,3 +1,3 @@
 module JsRoutes
-  VERSION = "2.2.2"
+  VERSION = "2.2.3"
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/js_routes.rb new/lib/js_routes.rb
--- old/lib/js_routes.rb        2022-02-01 15:34:29.000000000 +0100
+++ new/lib/js_routes.rb        2022-03-07 13:07:43.000000000 +0100
@@ -1,4 +1,4 @@
-if defined?(::Rails) && defined?(::Sprockets::Railtie)
+if defined?(::Rails)
   require 'js_routes/engine'
 end
 require 'js_routes/version'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/routes.d.ts new/lib/routes.d.ts
--- old/lib/routes.d.ts 2022-02-01 15:34:29.000000000 +0100
+++ new/lib/routes.d.ts 2022-03-07 13:07:43.000000000 +0100
@@ -66,7 +66,6 @@
     SPECIAL_OPTIONS_KEY: string;
     DEFAULT_URL_OPTIONS: RouteParameters;
     SERIALIZER: Serializer;
-    NAMESPACE: string;
     ROUTES_OBJECT: RouteHelpers;
     MODULE_TYPE: ModuleType;
     WRAPPER: <T>(callback: T) => T;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/routes.js new/lib/routes.js
--- old/lib/routes.js   2022-02-01 15:34:29.000000000 +0100
+++ new/lib/routes.js   2022-03-07 13:07:43.000000000 +0100
@@ -2,7 +2,7 @@
  * File generated by js-routes RubyVariables.GEM_VERSION
  * Based on Rails RubyVariables.RAILS_VERSION routes of RubyVariables.APP_CLASS
  */
-RubyVariables.WRAPPER((that) => {
+RubyVariables.WRAPPER(() => {
     const hasProp = (value, key) => 
Object.prototype.hasOwnProperty.call(value, key);
     let NodeTypes;
     (function (NodeTypes) {
@@ -15,8 +15,7 @@
         NodeTypes[NodeTypes["SLASH"] = 7] = "SLASH";
         NodeTypes[NodeTypes["DOT"] = 8] = "DOT";
     })(NodeTypes || (NodeTypes = {}));
-    const Root = that;
-    const isBroswer = typeof window !== "undefined";
+    const isBrowser = typeof window !== "undefined";
     const ModuleReferences = {
         CJS: {
             define(routes) {
@@ -70,11 +69,11 @@
             },
         },
         NIL: {
-            define(routes) {
-                Utils.namespace(Root, RubyVariables.NAMESPACE, routes);
+            define() {
+                // Defined using RubyVariables.WRAPPER
             },
             isSupported() {
-                return !RubyVariables.NAMESPACE || !!Root;
+                return true;
             },
         },
         DTS: {
@@ -422,15 +421,15 @@
         }
         current_host() {
             var _a;
-            return (isBroswer && ((_a = window === null || window === void 0 ? 
void 0 : window.location) === null || _a === void 0 ? void 0 : _a.hostname)) || 
"";
+            return (isBrowser && ((_a = window === null || window === void 0 ? 
void 0 : window.location) === null || _a === void 0 ? void 0 : _a.hostname)) || 
"";
         }
         current_protocol() {
             var _a, _b;
-            return ((isBroswer && ((_b = (_a = window === null || window === 
void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : 
_a.protocol) === null || _b === void 0 ? void 0 : _b.replace(/:$/, ""))) || 
"http");
+            return ((isBrowser && ((_b = (_a = window === null || window === 
void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : 
_a.protocol) === null || _b === void 0 ? void 0 : _b.replace(/:$/, ""))) || 
"http");
         }
         current_port() {
             var _a;
-            return (isBroswer && ((_a = window === null || window === void 0 ? 
void 0 : window.location) === null || _a === void 0 ? void 0 : _a.port)) || "";
+            return (isBrowser && ((_a = window === null || window === void 0 ? 
void 0 : window.location) === null || _a === void 0 ? void 0 : _a.port)) || "";
         }
         is_object(value) {
             return (typeof value === "object" &&
@@ -445,21 +444,6 @@
         is_reserved_option(key) {
             return ReservedOptions.includes(key);
         }
-        namespace(object, namespace, routes) {
-            const parts = (namespace === null || namespace === void 0 ? void 0 
: namespace.split(".")) || [];
-            if (parts.length === 0) {
-                return;
-            }
-            for (let index = 0; index < parts.length; index++) {
-                const part = parts[index];
-                if (index < parts.length - 1) {
-                    object = object[part] || (object[part] = {});
-                }
-                else {
-                    object[part] = routes;
-                }
-            }
-        }
         configure(new_config) {
             this.configuration = { ...this.configuration, ...new_config };
             return this.configuration;
@@ -502,4 +486,4 @@
     };
     Utils.define_module(RubyVariables.MODULE_TYPE, result);
     return result;
-})(this);
+})();
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/routes.ts new/lib/routes.ts
--- old/lib/routes.ts   2022-02-01 15:34:29.000000000 +0100
+++ new/lib/routes.ts   2022-03-07 13:07:43.000000000 +0100
@@ -84,7 +84,6 @@
   SPECIAL_OPTIONS_KEY: string;
   DEFAULT_URL_OPTIONS: RouteParameters;
   SERIALIZER: Serializer;
-  NAMESPACE: string;
   ROUTES_OBJECT: RouteHelpers;
   MODULE_TYPE: ModuleType;
   WRAPPER: <T>(callback: T) => T;
@@ -97,7 +96,7 @@
 declare const module: { exports: any } | undefined;
 
 RubyVariables.WRAPPER(
-  (that: unknown): RouterExposedMethods => {
+  (): RouterExposedMethods => {
     const hasProp = (value: unknown, key: string) =>
       Object.prototype.hasOwnProperty.call(value, key);
     enum NodeTypes {
@@ -128,8 +127,7 @@
       [T in keyof RouteNodes]: RouteNode<T>;
     }[keyof RouteNodes];
 
-    const Root = that;
-    const isBroswer = typeof window !== "undefined";
+    const isBrowser = typeof window !== "undefined";
     type ModuleDefinition = {
       define: (routes: RouterExposedMethods) => void;
       isSupported: () => boolean;
@@ -186,11 +184,11 @@
         },
       },
       NIL: {
-        define(routes) {
-          Utils.namespace(Root, RubyVariables.NAMESPACE, routes);
+        define() {
+          // Defined using RubyVariables.WRAPPER
         },
         isSupported() {
-          return !RubyVariables.NAMESPACE || !!Root;
+          return true;
         },
       },
       DTS: {
@@ -628,17 +626,17 @@
       }
 
       current_host(): string {
-        return (isBroswer && window?.location?.hostname) || "";
+        return (isBrowser && window?.location?.hostname) || "";
       }
 
       current_protocol(): string {
         return (
-          (isBroswer && window?.location?.protocol?.replace(/:$/, "")) || 
"http"
+          (isBrowser && window?.location?.protocol?.replace(/:$/, "")) || 
"http"
         );
       }
 
       current_port(): string {
-        return (isBroswer && window?.location?.port) || "";
+        return (isBrowser && window?.location?.port) || "";
       }
 
       is_object(value: unknown): value is Record<string, unknown> {
@@ -660,25 +658,6 @@
         return ReservedOptions.includes(key as any);
       }
 
-      namespace(
-        object: any,
-        namespace: string | null | undefined,
-        routes: unknown
-      ): void {
-        const parts = namespace?.split(".") || [];
-        if (parts.length === 0) {
-          return;
-        }
-        for (let index = 0; index < parts.length; index++) {
-          const part = parts[index];
-          if (index < parts.length - 1) {
-            object = object[part] || (object[part] = {});
-          } else {
-            object[part] = routes;
-          }
-        }
-      }
-
       configure(new_config: Partial<Configuration>): Configuration {
         this.configuration = { ...this.configuration, ...new_config };
         return this.configuration;
@@ -734,4 +713,4 @@
     Utils.define_module(RubyVariables.MODULE_TYPE, result);
     return result;
   }
-)(this);
+)();
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata        2022-02-01 15:34:29.000000000 +0100
+++ new/metadata        2022-03-07 13:07:43.000000000 +0100
@@ -1,14 +1,14 @@
 --- !ruby/object:Gem::Specification
 name: js-routes
 version: !ruby/object:Gem::Version
-  version: 2.2.2
+  version: 2.2.3
 platform: ruby
 authors:
 - Bogdan Gusiev
 autorequire:
 bindir: bin
 cert_chain: []
-date: 2022-02-01 00:00:00.000000000 Z
+date: 2022-03-07 00:00:00.000000000 Z
 dependencies:
 - !ruby/object:Gem::Dependency
   name: railties
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/spec/js_routes/module_types/dts/routes.spec.d.ts 
new/spec/js_routes/module_types/dts/routes.spec.d.ts
--- old/spec/js_routes/module_types/dts/routes.spec.d.ts        2022-02-01 
15:34:29.000000000 +0100
+++ new/spec/js_routes/module_types/dts/routes.spec.d.ts        2022-03-07 
13:07:43.000000000 +0100
@@ -66,7 +66,6 @@
     SPECIAL_OPTIONS_KEY: string;
     DEFAULT_URL_OPTIONS: RouteParameters;
     SERIALIZER: Serializer;
-    NAMESPACE: string;
     ROUTES_OBJECT: RouteHelpers;
     MODULE_TYPE: ModuleType;
     WRAPPER: <T>(callback: T) => T;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/spec/js_routes/module_types/nil_spec.rb 
new/spec/js_routes/module_types/nil_spec.rb
--- old/spec/js_routes/module_types/nil_spec.rb 2022-02-01 15:34:29.000000000 
+0100
+++ new/spec/js_routes/module_types/nil_spec.rb 2022-03-07 13:07:43.000000000 
+0100
@@ -45,6 +45,7 @@
     let(:_presetup) { "" }
     before do
       evaljs("var window = this;")
+      evaljs("window.PHM = {}")
       evaljs(_presetup)
       evaljs(generated_js)
     end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/spec/js_routes/options_spec.rb 
new/spec/js_routes/options_spec.rb
--- old/spec/js_routes/options_spec.rb  2022-02-01 15:34:29.000000000 +0100
+++ new/spec/js_routes/options_spec.rb  2022-03-07 13:07:43.000000000 +0100
@@ -399,13 +399,16 @@
       end
 
       let(:_presetup) do
-        window = {location: {
+        location =  {
           protocol: current_protocol,
           hostname: current_hostname,
           port: current_port,
           host: current_host,
-        }}
-        "const window = #{ActiveSupport::JSON.encode(window)}"
+        }
+        [
+          "const window = this;",
+          "window.location = #{ActiveSupport::JSON.encode(location)};",
+        ].join("\n")
       end
 
       context "without specifying a default host" do
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/spec/js_routes/rails_routes_compatibility_spec.rb 
new/spec/js_routes/rails_routes_compatibility_spec.rb
--- old/spec/js_routes/rails_routes_compatibility_spec.rb       2022-02-01 
15:34:29.000000000 +0100
+++ new/spec/js_routes/rails_routes_compatibility_spec.rb       2022-03-07 
13:07:43.000000000 +0100
@@ -2,8 +2,11 @@
 
 describe JsRoutes, "compatibility with Rails"  do
 
+  let(:generated_js) do
+    JsRoutes.generate({module_type: nil, namespace: 'Routes'})
+  end
   before(:each) do
-    evaljs(JsRoutes.generate({module_type: nil, namespace: 'Routes'}))
+    evaljs(generated_js)
   end
 
   it "should generate collection routing" do
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/spec/spec_helper.rb new/spec/spec_helper.rb
--- old/spec/spec_helper.rb     2022-02-01 15:34:29.000000000 +0100
+++ new/spec/spec_helper.rb     2022-03-07 13:07:43.000000000 +0100
@@ -42,10 +42,14 @@
 def evaljs(string, force: false, filename: 'context.js')
   jscontext(force).eval(string, filename: filename)
 rescue MiniRacer::ParseError => e
-  message = e.message
-  _, _, line, _ = message.split(':')
-  code = line && string.split("\n")[line.to_i-1]
-  raise "#{message}. Code: #{code.strip}";
+  trace = e.message
+  _, _, line, _ = trace.split(':')
+  if line
+    code = string.split("\n")[line.to_i-1]
+    raise "#{trace}. Code: #{code.strip}";
+  else
+    raise e
+  end
 rescue MiniRacer::RuntimeError => e
   raise e
 end
@@ -62,6 +66,10 @@
   Planner::Engine.routes.url_helpers
 end
 
+def log(string)
+  evaljs("console.log(#{string})")
+end
+
 ActiveSupport::Inflector.inflections do |inflect|
   inflect.irregular "budgie", "budgies"
 end

Reply via email to