js-routes 2.4.0 → 2.4.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 40c089f66c3042418a4b05690dd145fa20d0c61094d5242eb818b54cf8908e0a
4
- data.tar.gz: 228996f6fe1b66fd475aecc4372da6d03ff25d06e23c426fdd44b3c608ef16ea
3
+ metadata.gz: 80c67cfe21ee9772f3912537cec0994797a76128083d495d9963381888e7833c
4
+ data.tar.gz: b2d63fcf45117749fa00be661b94fcd8a606ac711bdbcfd1bc2699be87d7c407
5
5
  SHA512:
6
- metadata.gz: 72aaae2f2221a6db8e96d10f3bc410f82f6c9f5f9ff9c03c193bdac42bb332113acf972a9331afde0800dde6cb11128aa94adecee8e365af29cf647fff4c5b06
7
- data.tar.gz: 87a8a03ff9d7929d9fc46c8c46fc913c43a6efa1a55b04b3b52476c75533349a6b538eff3fe2a1e306ce4cf198652578b33c0ca2382679f0dbaf5b39b8d25660
6
+ metadata.gz: abebd07a033d7046989e71b1fc00aad559c1973f9eadaf0f93df25057bd01d1c3cd9bca2447d272c2c56ccef10a9803d6ae81479999be7ed315eefeb7c0211e1
7
+ data.tar.gz: c000eb635b4b77167cb04df8b3b691528cebe78ce557d8bcab75e95c420e033b79d066e3f8135a7b04f5b899c964512e741b5c0fc0a30c99692d1b2ebb76b883
data/CHANGELOG.md CHANGED
@@ -2,6 +2,23 @@
2
2
 
3
3
  ## Pending
4
4
 
5
+ ## [2.4.1]
6
+
7
+ ### Fix camelCase TypeScript definitions for optional parameters
8
+
9
+ Fix a bug introduced in 2.4.0 where `camel_case: true` caused TypeScript type definitions to advertise camelCase keys for optional route parameters while the JavaScript runtime still required snake_case. Fixes [#351](https://github.com/railsware/js-routes/issues/351).
10
+
11
+ Optional parameter names in `.d.ts` output now match what the runtime actually accepts:
12
+
13
+ ```typescript
14
+ // Before (broken): type advertised perPage but runtime required per_page
15
+ itemsPath({ perPage: 20 }) // → "/items?perPage=20" ✗ (silently wrong)
16
+ itemsPath({ per_page: 20 }) // → "/items/20" ✓ (worked but type was misleading)
17
+
18
+ // After (fixed): type and runtime agree on snake_case
19
+ itemsPath({ per_page: 20 }) // → "/items/20" ✓
20
+ ```
21
+
5
22
  ## [2.4.0]
6
23
 
7
24
  ### Package mode
@@ -37,10 +37,9 @@ module JsRoutes
37
37
  end
38
38
 
39
39
  unless @configuration.module_type == "NIL"
40
- banner + jsr + routes_export
40
+ banner + routes_js + routes_export
41
41
  else
42
- # Strip the empty IMPORT_ROUTER statement (comment + semicolon) left after substitution
43
- jsr.sub(/\A(\/\/[^\n]+\n)*;\n/, "")
42
+ routes_js
44
43
  end
45
44
 
46
45
  end
@@ -49,7 +48,7 @@ module JsRoutes
49
48
  def package
50
49
  raise "Package generation requires module_type: 'PKG'" unless @configuration.pkg?
51
50
 
52
- jsr
51
+ routes_js
53
52
  end
54
53
 
55
54
  sig { returns(String) }
@@ -116,7 +115,7 @@ module JsRoutes
116
115
  end
117
116
 
118
117
  sig { returns(String) }
119
- def jsr
118
+ def routes_js
120
119
  return pkg_jsr if @configuration.pkg?
121
120
 
122
121
  if @configuration.dts?
@@ -153,7 +152,6 @@ module JsRoutes
153
152
  'SERIALIZER' => @configuration.serializer || json(nil),
154
153
  'MODULE_TYPE' => json(@configuration.module_type),
155
154
  'WRAPPER' => wrapper_variable,
156
- "IMPORT_ROUTER" => import_router_variable,
157
155
  "EMBED_ROUTER" => embed_router_variable,
158
156
  }
159
157
  end
@@ -180,9 +178,9 @@ module JsRoutes
180
178
  end
181
179
 
182
180
  sig { returns(String) }
183
- def import_router_variable
181
+ def router_js
184
182
  if @configuration.use_package?
185
- "import Router from '#{@configuration.package}'"
183
+ "import Router from '#{@configuration.package}';"
186
184
  elsif @configuration.modern?
187
185
  read_js(@configuration.router_source_file)
188
186
  else
@@ -194,20 +192,21 @@ module JsRoutes
194
192
  def wrapper_variable
195
193
  case @configuration.module_type
196
194
  when 'ESM', 'PKG'
197
- 'const __jsr = '
195
+ "#{router_js}const __jsr = "
198
196
  when 'NIL'
199
197
  namespace = @configuration.namespace
200
198
  if namespace
201
- if namespace.include?('.')
199
+ assignment = if namespace.include?('.')
202
200
  "#{namespace} = "
203
201
  else
204
202
  "(typeof window !== 'undefined' ? window : this).#{namespace} = "
205
203
  end
204
+ "#{router_js}#{assignment}"
206
205
  else
207
- ''
206
+ router_js
208
207
  end
209
208
  else
210
- ''
209
+ router_js
211
210
  end
212
211
  end
213
212
 
@@ -92,7 +92,7 @@ module JsRoutes
92
92
  def optional_parts_type
93
93
  return nil if optional_parts.empty?
94
94
  @optional_parts_type ||= T.let(
95
- "{" + optional_parts.map {|p| "#{format_param(p)}?: OptionalRouteParameter"}.join(', ') + "}",
95
+ "{" + optional_parts.map {|p| "#{p}?: OptionalRouteParameter"}.join(', ') + "}",
96
96
  T.nilable(String)
97
97
  )
98
98
  end
@@ -1,4 +1,4 @@
1
1
  # typed: strict
2
2
  module JsRoutes
3
- VERSION = "2.4.0"
3
+ VERSION = "2.4.1"
4
4
  end
data/lib/routes.js CHANGED
@@ -1,5 +1,3 @@
1
- // eslint-disable-next-line @typescript-eslint/no-unused-expressions
2
- RubyVariables.IMPORT_ROUTER;
3
1
  RubyVariables.WRAPPER(() => {
4
2
  var _a;
5
3
  // eslint-disable-next-line @typescript-eslint/no-unused-expressions
data/lib/routes.ts CHANGED
@@ -23,14 +23,10 @@ declare const RubyVariables: {
23
23
  SERIALIZER: Serializer | null;
24
24
  ROUTES_OBJECT: RouteHelpers;
25
25
  MODULE_TYPE: ModuleType;
26
- IMPORT_ROUTER: RouterConstructor;
27
26
  EMBED_ROUTER: RouterConstructor;
28
27
  WRAPPER: <T>(callback: T) => T;
29
28
  };
30
29
 
31
- // eslint-disable-next-line @typescript-eslint/no-unused-expressions
32
- RubyVariables.IMPORT_ROUTER;
33
-
34
30
  declare const define:
35
31
  | undefined
36
32
  | (((arg: unknown[], callback: () => unknown) => void) & { amd?: unknown });
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: js-routes
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bogdan Gusiev
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2026-06-11 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: railties
@@ -147,12 +146,11 @@ licenses:
147
146
  - MIT
148
147
  metadata:
149
148
  bug_tracker_uri: https://github.com/railsware/js-routes/issues
150
- changelog_uri: https://github.com/railsware/js-routes/blob/v2.4.0/CHANGELOG.md
149
+ changelog_uri: https://github.com/railsware/js-routes/blob/v2.4.1/CHANGELOG.md
151
150
  documentation_uri: https://github.com/railsware/js-routes
152
- source_code_uri: https://github.com/railsware/js-routes/tree/v2.4.0
151
+ source_code_uri: https://github.com/railsware/js-routes/tree/v2.4.1
153
152
  rubygems_mfa_required: 'true'
154
153
  github_repo: ssh://github.com/railsware/js-routes
155
- post_install_message:
156
154
  rdoc_options: []
157
155
  require_paths:
158
156
  - lib
@@ -160,15 +158,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
160
158
  requirements:
161
159
  - - ">="
162
160
  - !ruby/object:Gem::Version
163
- version: 2.4.0
161
+ version: '2.7'
164
162
  required_rubygems_version: !ruby/object:Gem::Requirement
165
163
  requirements:
166
164
  - - ">="
167
165
  - !ruby/object:Gem::Version
168
166
  version: '0'
169
167
  requirements: []
170
- rubygems_version: 3.5.11
171
- signing_key:
168
+ rubygems_version: 4.0.10
172
169
  specification_version: 4
173
170
  summary: Brings Rails named routes to javascript
174
171
  test_files: []