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 2021-08-24 10:54:25
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-js-routes (Old)
 and      /work/SRC/openSUSE:Factory/.rubygem-js-routes.new.1899 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "rubygem-js-routes"

Tue Aug 24 10:54:25 2021 rev:23 rq:912499 version:2.0.8

Changes:
--------
--- /work/SRC/openSUSE:Factory/rubygem-js-routes/rubygem-js-routes.changes      
2021-07-02 13:28:36.896226219 +0200
+++ 
/work/SRC/openSUSE:Factory/.rubygem-js-routes.new.1899/rubygem-js-routes.changes
    2021-08-24 10:55:17.304287924 +0200
@@ -1,0 +2,11 @@
+Mon Jul 26 05:59:53 UTC 2021 - Stephan Kulow <[email protected]>
+
+updated to version 2.0.8
+ see installed CHANGELOG.md
+
+  ## v2.0.8
+  
+  * Forbid usage of `namespace` option if `module_type` is not `nil`. 
[#281](https://github.com/railsware/js-routes/issues/281).
+  
+
+-------------------------------------------------------------------

Old:
----
  js-routes-2.0.7.gem

New:
----
  js-routes-2.0.8.gem

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

Other differences:
------------------
++++++ rubygem-js-routes.spec ++++++
--- /var/tmp/diff_new_pack.SfY68R/_old  2021-08-24 10:55:17.720287373 +0200
+++ /var/tmp/diff_new_pack.SfY68R/_new  2021-08-24 10:55:17.720287373 +0200
@@ -24,7 +24,7 @@
 #
 
 Name:           rubygem-js-routes
-Version:        2.0.7
+Version:        2.0.8
 Release:        0
 %define mod_name js-routes
 %define mod_full_name %{mod_name}-%{version}

++++++ js-routes-2.0.7.gem -> js-routes-2.0.8.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/CHANGELOG.md new/CHANGELOG.md
--- old/CHANGELOG.md    2021-06-09 17:31:03.000000000 +0200
+++ new/CHANGELOG.md    2021-07-21 15:28:09.000000000 +0200
@@ -1,5 +1,9 @@
 ## master
 
+## v2.0.8
+
+* Forbid usage of `namespace` option if `module_type` is not `nil`. 
[#281](https://github.com/railsware/js-routes/issues/281).
+
 ## v2.0.7
 
 * Remove source map annotation from JS file. Fixes 
[#277](https://github.com/railsware/js-routes/issues/277)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Readme.md new/Readme.md
--- old/Readme.md       2021-06-09 17:31:03.000000000 +0200
+++ new/Readme.md       2021-07-21 15:28:09.000000000 +0200
@@ -159,6 +159,7 @@
   * Default: `[]`
   * The regexp applies only to the name before the `_path` suffix, eg: you 
want to match exactly `settings_path`, the regexp should be `/^settings$/`
 * `namespace` - global object used to access routes.
+  * Only available if `module_type` option is set to `nil`.
   * Supports nested namespace like `MyProject.routes`
   * Default: `nil`
 * `camel_case` - specifies if route helpers should be generated in camel case 
instead of underscore case.
@@ -314,6 +315,9 @@
 } from 'routes.js.erb'
 ```
 
+Such import structure allows for moddern JS bundlers like 
[Webpack](https://webpack.js.org/) to only include explicitly imported routes 
into JS bundle file.
+See [Tree Shaking](https://webpack.js.org/guides/tree-shaking/) for more 
information.
+
 ### Exclude option
 
 Split your routes into multiple files related to each section of your website 
like:
@@ -325,18 +329,6 @@
 <%= JsRoutes.generate(exclude: /^admin_/)
 ```
 
-## JsRoutes and Heroku
-
-When using this setup on Heroku, it is impossible to use the asset pipeline. 
You should use the "Very Advanced Setup" schema in this case.
-
-For example create routes.js.erb in assets folder with needed content:
-
-``` erb
-<%= JsRoutes.generate(options) %>
-```
-
-This should just work.
-
 ## Advantages over alternatives
 
 There are some alternatives available. Most of them has only basic feature and 
don't reach the level of quality I accept.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/VERSION_2_UPGRADE.md new/VERSION_2_UPGRADE.md
--- old/VERSION_2_UPGRADE.md    2021-06-09 17:31:03.000000000 +0200
+++ new/VERSION_2_UPGRADE.md    2021-07-21 15:28:09.000000000 +0200
@@ -2,28 +2,40 @@
 
 ### Using ESM module by default
 
-The default setting are now changed:
+New version of JsRoutes doesn't try to guess your javascript environment 
module system because JS has generated a ton of legacy module systems in the 
past. 
+[ESM+Webpacker](/Readme.md#webpacker) upgrade is recommended. 
 
-Setting | Old | New 
---- | --- | ---
-module\_type | nil | ESM 
-namespace | Routes | nil
-documentation | false | true
+However, if you don't want to follow that pass, specify `module_type` 
configuration option instead based on module system available in your JS 
environment.
+Here are supported values:
 
-This is more optimized setup for WebPacker. 
-New version of js-routes generates function comment in the 
[JSDoc](https://jsdoc.app) format.
+* CJS
+* UMD
+* AMD
+* ESM
+* nil
+
+[Explaination 
Article](https://dev.to/iggredible/what-the-heck-are-cjs-amd-umd-and-esm-ikm)
 
-You can restore the old configuration like this:
+If you don't want to use any JS module system and make routes available via a 
**global variable**, specify `nil` as a `module_type` and use `namespace` 
option:
 
 ``` ruby
 JsRoutes.setup do |config|
   config.module_type = nil
-  config.namespace = 'Routes'
-  config.documentation = false
+  config.namespace = "Routes"
 end
 ```
 
-However, [ESM+Webpacker](/Readme.md#webpacker) upgrade is recommended. 
+### JSDoc comment
+
+New version of js-routes generates function comment in the 
[JSDoc](https://jsdoc.app) format.
+If you have any problems with that, you can disable it like this:
+
+
+``` ruby
+JsRoutes.setup do |config|
+  config.documentation = false
+end
+```
 
 ### `required_params` renamed
 
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/version.rb new/lib/js_routes/version.rb
--- old/lib/js_routes/version.rb        2021-06-09 17:31:03.000000000 +0200
+++ new/lib/js_routes/version.rb        2021-07-21 15:28:09.000000000 +0200
@@ -1,3 +1,3 @@
 class JsRoutes
-  VERSION = "2.0.7"
+  VERSION = "2.0.8"
 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        2021-06-09 17:31:03.000000000 +0200
+++ new/lib/js_routes.rb        2021-07-21 15:28:09.000000000 +0200
@@ -60,6 +60,7 @@
         value = value.call if value.is_a?(Proc)
         send(:"#{attribute}=", value)
       end
+      normalize_and_verify
       self
     end
 
@@ -76,7 +77,24 @@
     end
 
     def esm?
-      self.module_type === 'ESM'
+      module_type === 'ESM'
+    end
+
+    def normalize_and_verify
+      normalize
+      verify
+    end
+
+    protected
+
+    def normalize
+      self.module_type = module_type&.upcase || 'NIL'
+    end
+
+    def verify
+      if module_type != 'NIL' && namespace
+        raise "JsRoutes namespace option can only be used if module_type is 
nil"
+      end
     end
   end
 
@@ -87,6 +105,7 @@
   class << self
     def setup(&block)
       configuration.tap(&block) if block
+      configuration.normalize_and_verify
     end
 
     def configuration
@@ -248,12 +267,14 @@
       end
     end
 
+    protected
+
     def body(absolute)
-      "__jsr.r(#{arguments(absolute).join(', ')})"
+      "__jsr.r(#{arguments(absolute).map{|a| json(a)}.join(', ')})"
     end
 
     def arguments(absolute)
-      absolute ? base_arguments + [json(true)] : base_arguments
+      absolute ? base_arguments + [true] : base_arguments
     end
 
     def match_configuration?
@@ -298,10 +319,11 @@
       route.required_parts
     end
 
-    protected
-
     def base_arguments
-      return @base_arguments if defined?(@base_arguments)
+      @base_arguments ||= [parts_table, serialize(spec, parent_spec)]
+    end
+
+    def parts_table
       parts_table = {}
       route.parts.each do |part, hash|
         parts_table[part] ||= {}
@@ -318,11 +340,7 @@
           parts_table[part][:d] = value
         end
       end
-      @base_arguments = [
-        parts_table, serialize(spec, parent_spec)
-      ].map do |argument|
-        json(argument)
-      end
+      parts_table
     end
 
     def documentation_params
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 2021-06-09 17:31:03.000000000 +0200
+++ new/lib/routes.d.ts 2021-07-21 15:28:09.000000000 +0200
@@ -37,7 +37,7 @@
     r?: boolean;
     d?: unknown;
 }>;
-declare type ModuleType = "CJS" | "AMD" | "UMD" | "ESM";
+declare type ModuleType = "CJS" | "AMD" | "UMD" | "ESM" | "NIL";
 declare const RubyVariables: {
     PREFIX: string;
     DEPRECATED_GLOBBING_BEHAVIOR: boolean;
@@ -46,7 +46,7 @@
     SERIALIZER: Serializer;
     NAMESPACE: string;
     ROUTES_OBJECT: RouteHelpers;
-    MODULE_TYPE: ModuleType | null;
+    MODULE_TYPE: ModuleType;
     WRAPPER: <T>(callback: T) => T;
 };
 declare const define: undefined | (((arg: unknown[], callback: () => unknown) 
=> void) & {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/routes.js new/lib/routes.js
--- old/lib/routes.js   2021-06-09 17:31:03.000000000 +0200
+++ new/lib/routes.js   2021-07-21 15:28:09.000000000 +0200
@@ -18,25 +18,32 @@
     const Root = that;
     const ModuleReferences = {
         CJS: {
-            // eslint-disable-next-line 
@typescript-eslint/no-non-null-assertion
-            define: (routes) => (module.exports = routes),
-            support: () => typeof module === "object",
+            define(routes) {
+                // eslint-disable-next-line 
@typescript-eslint/no-non-null-assertion
+                module.exports = routes;
+            },
+            isSupported() {
+                return typeof module === "object";
+            },
         },
         AMD: {
-            define: (routes) => 
-            // eslint-disable-next-line 
@typescript-eslint/no-non-null-assertion
-            define([], function () {
-                return routes;
-            }),
-            support: () => typeof define === "function" && !!define.amd,
+            define(routes) {
+                // eslint-disable-next-line 
@typescript-eslint/no-non-null-assertion
+                define([], function () {
+                    return routes;
+                });
+            },
+            isSupported() {
+                return typeof define === "function" && !!define.amd;
+            },
         },
         UMD: {
-            define: (routes) => {
-                if (ModuleReferences.AMD.support()) {
+            define(routes) {
+                if (ModuleReferences.AMD.isSupported()) {
                     ModuleReferences.AMD.define(routes);
                 }
                 else {
-                    if (ModuleReferences.CJS.support()) {
+                    if (ModuleReferences.CJS.isSupported()) {
                         try {
                             ModuleReferences.CJS.define(routes);
                         }
@@ -47,11 +54,27 @@
                     }
                 }
             },
-            support: () => ModuleReferences.AMD.support() || 
ModuleReferences.CJS.support(),
+            isSupported() {
+                return (ModuleReferences.AMD.isSupported() ||
+                    ModuleReferences.CJS.isSupported());
+            },
         },
         ESM: {
-            define: () => null,
-            support: () => true,
+            define() {
+                // Module can only be defined using ruby code generation
+            },
+            isSupported() {
+                // Its impossible to check if "export" keyword is supported
+                return true;
+            },
+        },
+        NIL: {
+            define(routes) {
+                Utils.namespace(Root, RubyVariables.NAMESPACE, routes);
+            },
+            isSupported() {
+                return !!Root;
+            },
         },
     };
     class ParametersMissing extends Error {
@@ -62,7 +85,6 @@
             this.name = ParametersMissing.name;
         }
     }
-    const DeprecatedGlobbingBehavior = 
RubyVariables.DEPRECATED_GLOBBING_BEHAVIOR;
     const UriEncoderSegmentRegex = /[^a-zA-Z0-9\-._~!$&'()*+,;=:@]/g;
     const ReservedOptions = [
         "anchor",
@@ -342,7 +364,9 @@
                 value = value.join("/");
             }
             const result = this.path_identifier(value);
-            return DeprecatedGlobbingBehavior ? result : encodeURI(result);
+            return RubyVariables.DEPRECATED_GLOBBING_BEHAVIOR
+                ? result
+                : encodeURI(result);
         }
         get_prefix() {
             const prefix = this.configuration.prefix;
@@ -449,7 +473,7 @@
             return { ...this.configuration };
         }
         is_module_supported(name) {
-            return ModuleReferences[name].support();
+            return ModuleReferences[name].isSupported();
         }
         ensure_module_supported(name) {
             if (!this.is_module_supported(name)) {
@@ -457,9 +481,6 @@
             }
         }
         define_module(name, module) {
-            if (!name) {
-                return;
-            }
             this.ensure_module_supported(name);
             ModuleReferences[name].define(module);
         }
@@ -484,9 +505,6 @@
         },
         ...RubyVariables.ROUTES_OBJECT,
     };
-    Utils.namespace(Root, RubyVariables.NAMESPACE, result);
-    if (RubyVariables.MODULE_TYPE) {
-        Utils.define_module(RubyVariables.MODULE_TYPE, result);
-    }
+    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   2021-06-09 17:31:03.000000000 +0200
+++ new/lib/routes.ts   2021-07-21 15:28:09.000000000 +0200
@@ -39,7 +39,7 @@
 
 type PartsTable = Record<string, { r?: boolean; d?: unknown }>;
 
-type ModuleType = "CJS" | "AMD" | "UMD" | "ESM";
+type ModuleType = "CJS" | "AMD" | "UMD" | "ESM" | "NIL";
 
 declare const RubyVariables: {
   PREFIX: string;
@@ -49,7 +49,7 @@
   SERIALIZER: Serializer;
   NAMESPACE: string;
   ROUTES_OBJECT: RouteHelpers;
-  MODULE_TYPE: ModuleType | null;
+  MODULE_TYPE: ModuleType;
   WRAPPER: <T>(callback: T) => T;
 };
 
@@ -94,28 +94,35 @@
     const Root = that;
     type ModuleDefinition = {
       define: (routes: unknown) => void;
-      support: () => boolean;
+      isSupported: () => boolean;
     };
     const ModuleReferences: Record<ModuleType, ModuleDefinition> = {
       CJS: {
-        // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
-        define: (routes) => (module!.exports = routes),
-        support: () => typeof module === "object",
+        define(routes) {
+          // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+          module!.exports = routes;
+        },
+        isSupported() {
+          return typeof module === "object";
+        },
       },
       AMD: {
-        define: (routes) =>
+        define(routes) {
           // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
           define!([], function () {
             return routes;
-          }),
-        support: () => typeof define === "function" && !!define.amd,
+          });
+        },
+        isSupported() {
+          return typeof define === "function" && !!define.amd;
+        },
       },
       UMD: {
-        define: (routes) => {
-          if (ModuleReferences.AMD.support()) {
+        define(routes) {
+          if (ModuleReferences.AMD.isSupported()) {
             ModuleReferences.AMD.define(routes);
           } else {
-            if (ModuleReferences.CJS.support()) {
+            if (ModuleReferences.CJS.isSupported()) {
               try {
                 ModuleReferences.CJS.define(routes);
               } catch (error) {
@@ -124,12 +131,29 @@
             }
           }
         },
-        support: () =>
-          ModuleReferences.AMD.support() || ModuleReferences.CJS.support(),
+        isSupported() {
+          return (
+            ModuleReferences.AMD.isSupported() ||
+            ModuleReferences.CJS.isSupported()
+          );
+        },
       },
       ESM: {
-        define: () => null,
-        support: () => true,
+        define() {
+          // Module can only be defined using ruby code generation
+        },
+        isSupported() {
+          // Its impossible to check if "export" keyword is supported
+          return true;
+        },
+      },
+      NIL: {
+        define(routes) {
+          Utils.namespace(Root, RubyVariables.NAMESPACE, routes);
+        },
+        isSupported() {
+          return !!Root;
+        },
       },
     };
 
@@ -143,9 +167,6 @@
       }
     }
 
-    const DeprecatedGlobbingBehavior =
-      RubyVariables.DEPRECATED_GLOBBING_BEHAVIOR;
-
     const UriEncoderSegmentRegex = /[^a-zA-Z0-9\-._~!$&'()*+,;=:@]/g;
 
     const ReservedOptions = [
@@ -498,7 +519,9 @@
           value = value.join("/");
         }
         const result = this.path_identifier(value as any);
-        return DeprecatedGlobbingBehavior ? result : encodeURI(result);
+        return RubyVariables.DEPRECATED_GLOBBING_BEHAVIOR
+          ? result
+          : encodeURI(result);
       }
 
       get_prefix(): string {
@@ -635,7 +658,7 @@
       }
 
       is_module_supported(name: ModuleType): boolean {
-        return ModuleReferences[name].support();
+        return ModuleReferences[name].isSupported();
       }
 
       ensure_module_supported(name: ModuleType): void {
@@ -644,13 +667,7 @@
         }
       }
 
-      define_module(
-        name: ModuleType | null,
-        module: RouterExposedMethods
-      ): void {
-        if (!name) {
-          return;
-        }
+      define_module(name: ModuleType, module: RouterExposedMethods): void {
         this.ensure_module_supported(name);
         ModuleReferences[name].define(module);
       }
@@ -683,11 +700,7 @@
       ...RubyVariables.ROUTES_OBJECT,
     };
 
-    Utils.namespace(Root, RubyVariables.NAMESPACE, result);
-
-    if (RubyVariables.MODULE_TYPE) {
-      Utils.define_module(RubyVariables.MODULE_TYPE, result);
-    }
+    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        2021-06-09 17:31:03.000000000 +0200
+++ new/metadata        2021-07-21 15:28:09.000000000 +0200
@@ -1,14 +1,14 @@
 --- !ruby/object:Gem::Specification
 name: js-routes
 version: !ruby/object:Gem::Version
-  version: 2.0.7
+  version: 2.0.8
 platform: ruby
 authors:
 - Bogdan Gusiev
 autorequire:
 bindir: bin
 cert_chain: []
-date: 2021-06-09 00:00:00.000000000 Z
+date: 2021-07-21 00:00:00.000000000 Z
 dependencies:
 - !ruby/object:Gem::Dependency
   name: railties

Reply via email to