js-routes 1.4.13 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/lib/routes.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes.js","sourceRoot":"","sources":["routes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA0DH,aAAa,CAAC,OAAO,CACnB,CAAC,IAAa,EAAwB,EAAE;IACtC,MAAM,OAAO,GAAG,CAAC,KAAc,EAAE,GAAW,EAAE,EAAE,CAC9C,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACnD,IAAK,SASJ;IATD,WAAK,SAAS;QACZ,2CAAS,CAAA;QACT,uCAAO,CAAA;QACP,6CAAU,CAAA;QACV,qCAAM,CAAA;QACN,yCAAQ,CAAA;QACR,+CAAW,CAAA;QACX,2CAAS,CAAA;QACT,uCAAO,CAAA;IACT,CAAC,EATI,SAAS,KAAT,SAAS,QASb;IAmBD,MAAM,IAAI,GAAG,IAAI,CAAC;IAKlB,MAAM,gBAAgB,GAAyC;QAC7D,GAAG,EAAE;YACH,oEAAoE;YACpE,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAO,CAAC,OAAO,GAAG,MAAM,CAAC;YAC9C,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,MAAM,KAAK,QAAQ;SAC1C;QACD,GAAG,EAAE;YACH,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE;YACjB,oEAAoE;YACpE,MAAO,CAAC,EAAE,EAAE;gBACV,OAAO,MAAM,CAAC;YAChB,CAAC,CAAC;YACJ,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,MAAM,KAAK,UAAU,IAAI,CAAC,CAAC,MAAM,CAAC,GAAG;SAC5D;QACD,GAAG,EAAE;YACH,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE;gBACjB,IAAI,gBAAgB,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE;oBAClC,gBAAgB,CAAC,GAAG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.ts ADDED
@@ -0,0 +1,687 @@
1
+ /**
2
+ * File generated by js-routes RubyVariables.GEM_VERSION
3
+ * Based on Rails RubyVariables.RAILS_VERSION routes of RubyVariables.APP_CLASS
4
+ */
5
+
6
+ type RouteParameter = unknown;
7
+ type RouteParameters = Record<string, RouteParameter>;
8
+ type Serializer = (value: unknown) => string;
9
+ type RouteHelper = {
10
+ (...args: RouteParameter[]): string;
11
+ requiredParams(): string[];
12
+ toString(): string;
13
+ };
14
+
15
+ type RouteHelpers = Record<string, RouteHelper>;
16
+
17
+ type Configuration = {
18
+ prefix: string;
19
+ default_url_options: RouteParameters;
20
+ special_options_key: string;
21
+ serializer: Serializer;
22
+ };
23
+
24
+ type Optional<T> = { [P in keyof T]?: T[P] | null };
25
+ interface RouterExposedMethods {
26
+ config(): Configuration;
27
+ configure(arg: Partial<Configuration>): Configuration;
28
+ serialize: Serializer;
29
+ }
30
+
31
+ type KeywordUrlOptions = Optional<{
32
+ host: string;
33
+ protocol: string;
34
+ subdomain: string;
35
+ port: string;
36
+ anchor: string;
37
+ trailing_slash: boolean;
38
+ }>;
39
+
40
+ type PartsTable = Record<string, { r?: boolean; d?: unknown }>;
41
+
42
+ type ModuleType = "CJS" | "AMD" | "UMD" | "ESM";
43
+
44
+ declare const RubyVariables: {
45
+ PREFIX: string;
46
+ DEPRECATED_GLOBBING_BEHAVIOR: boolean;
47
+ SPECIAL_OPTIONS_KEY: string;
48
+ DEFAULT_URL_OPTIONS: RouteParameters;
49
+ SERIALIZER: Serializer;
50
+ NAMESPACE: string;
51
+ ROUTES_OBJECT: RouteHelpers;
52
+ MODULE_TYPE: ModuleType | null;
53
+ WRAPPER: <T>(callback: T) => T;
54
+ };
55
+
56
+ declare const define:
57
+ | undefined
58
+ | (((arg: unknown[], callback: () => unknown) => void) & { amd?: unknown });
59
+
60
+ declare const module: { exports: any } | undefined;
61
+
62
+ RubyVariables.WRAPPER(
63
+ (that: unknown): RouterExposedMethods => {
64
+ const hasProp = (value: unknown, key: string) =>
65
+ Object.prototype.hasOwnProperty.call(value, key);
66
+ enum NodeTypes {
67
+ GROUP = 1,
68
+ CAT = 2,
69
+ SYMBOL = 3,
70
+ OR = 4,
71
+ STAR = 5,
72
+ LITERAL = 6,
73
+ SLASH = 7,
74
+ DOT = 8,
75
+ }
76
+ type RouteNodes = {
77
+ [NodeTypes.GROUP]: { left: RouteTree; right: never };
78
+ [NodeTypes.STAR]: { left: RouteTree; right: never };
79
+ [NodeTypes.LITERAL]: { left: string; right: never };
80
+ [NodeTypes.SLASH]: { left: "/"; right: never };
81
+ [NodeTypes.DOT]: { left: "."; right: never };
82
+ [NodeTypes.CAT]: { left: RouteTree; right: RouteTree };
83
+ [NodeTypes.SYMBOL]: { left: string; right: never };
84
+ };
85
+ type RouteNode<T extends keyof RouteNodes> = [
86
+ T,
87
+ RouteNodes[T]["left"],
88
+ RouteNodes[T]["right"]
89
+ ];
90
+ type RouteTree = {
91
+ [T in keyof RouteNodes]: RouteNode<T>;
92
+ }[keyof RouteNodes];
93
+
94
+ const Root = that;
95
+ type ModuleDefinition = {
96
+ define: (routes: unknown) => void;
97
+ support: () => boolean;
98
+ };
99
+ const ModuleReferences: Record<ModuleType, ModuleDefinition> = {
100
+ CJS: {
101
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
102
+ define: (routes) => (module!.exports = routes),
103
+ support: () => typeof module === "object",
104
+ },
105
+ AMD: {
106
+ define: (routes) =>
107
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
108
+ define!([], function () {
109
+ return routes;
110
+ }),
111
+ support: () => typeof define === "function" && !!define.amd,
112
+ },
113
+ UMD: {
114
+ define: (routes) => {
115
+ if (ModuleReferences.AMD.support()) {
116
+ ModuleReferences.AMD.define(routes);
117
+ } else {
118
+ if (ModuleReferences.CJS.support()) {
119
+ try {
120
+ ModuleReferences.CJS.define(routes);
121
+ } catch (error) {
122
+ if (error.name !== "TypeError") throw error;
123
+ }
124
+ }
125
+ }
126
+ },
127
+ support: () =>
128
+ ModuleReferences.AMD.support() || ModuleReferences.CJS.support(),
129
+ },
130
+ ESM: {
131
+ define: () => null,
132
+ support: () => true,
133
+ },
134
+ };
135
+
136
+ class ParametersMissing extends Error {
137
+ readonly keys: string[];
138
+ constructor(...keys: string[]) {
139
+ super(`Route missing required keys: ${keys.join(", ")}`);
140
+ this.keys = keys;
141
+ Object.setPrototypeOf(this, Object.getPrototypeOf(this));
142
+ this.name = ParametersMissing.name;
143
+ }
144
+ }
145
+
146
+ const DeprecatedGlobbingBehavior =
147
+ RubyVariables.DEPRECATED_GLOBBING_BEHAVIOR;
148
+
149
+ const UriEncoderSegmentRegex = /[^a-zA-Z0-9\-._~!$&'()*+,;=:@]/g;
150
+
151
+ const ReservedOptions = [
152
+ "anchor",
153
+ "trailing_slash",
154
+ "subdomain",
155
+ "host",
156
+ "port",
157
+ "protocol",
158
+ ] as const;
159
+ type ReservedOption = typeof ReservedOptions[any];
160
+
161
+ class UtilsClass {
162
+ configuration: Configuration = {
163
+ prefix: RubyVariables.PREFIX,
164
+ default_url_options: RubyVariables.DEFAULT_URL_OPTIONS,
165
+ special_options_key: RubyVariables.SPECIAL_OPTIONS_KEY,
166
+ serializer:
167
+ RubyVariables.SERIALIZER || this.default_serializer.bind(this),
168
+ };
169
+
170
+ default_serializer(value: any, prefix?: string | null): string {
171
+ if (this.is_nullable(value)) {
172
+ return "";
173
+ }
174
+ if (!prefix && !this.is_object(value)) {
175
+ throw new Error("Url parameters should be a javascript hash");
176
+ }
177
+ prefix = prefix || "";
178
+ const result: string[] = [];
179
+ if (this.is_array(value)) {
180
+ for (const element of value) {
181
+ result.push(this.default_serializer(element, prefix + "[]"));
182
+ }
183
+ } else if (this.is_object(value)) {
184
+ for (let key in value) {
185
+ if (!hasProp(value, key)) continue;
186
+ let prop = value[key];
187
+ if (this.is_nullable(prop) && prefix) {
188
+ prop = "";
189
+ }
190
+ if (this.is_not_nullable(prop)) {
191
+ if (prefix) {
192
+ key = prefix + "[" + key + "]";
193
+ }
194
+ result.push(this.default_serializer(prop, key));
195
+ }
196
+ }
197
+ } else {
198
+ if (this.is_not_nullable(value)) {
199
+ result.push(
200
+ encodeURIComponent(prefix) + "=" + encodeURIComponent("" + value)
201
+ );
202
+ }
203
+ }
204
+ return result.join("&");
205
+ }
206
+
207
+ serialize(object: unknown): string {
208
+ return this.configuration.serializer(object);
209
+ }
210
+
211
+ extract_options(
212
+ number_of_params: number,
213
+ args: RouteParameter[]
214
+ ): {
215
+ args: RouteParameter[];
216
+ options: KeywordUrlOptions & RouteParameters;
217
+ } {
218
+ const last_el = args[args.length - 1];
219
+ if (
220
+ (args.length > number_of_params && last_el === 0) ||
221
+ (this.is_object(last_el) &&
222
+ !this.looks_like_serialized_model(last_el))
223
+ ) {
224
+ if (this.is_object(last_el)) {
225
+ delete last_el[this.configuration.special_options_key];
226
+ }
227
+ return {
228
+ args: args.slice(0, args.length - 1),
229
+ options: last_el as KeywordUrlOptions & RouteParameters,
230
+ };
231
+ } else {
232
+ return { args, options: {} };
233
+ }
234
+ }
235
+
236
+ looks_like_serialized_model(
237
+ object: any
238
+ ): object is
239
+ | { id: unknown }
240
+ | { to_param: unknown }
241
+ | { toParam: unknown } {
242
+ return (
243
+ this.is_object(object) &&
244
+ !object[this.configuration.special_options_key] &&
245
+ ("id" in object || "to_param" in object || "toParam" in object)
246
+ );
247
+ }
248
+
249
+ path_identifier(object: unknown): string {
250
+ const result = this.unwrap_path_identifier(object);
251
+ return this.is_nullable(result) || result === false ? "" : "" + result;
252
+ }
253
+
254
+ unwrap_path_identifier(object: any): unknown {
255
+ let result: any = object;
256
+ if (!this.is_object(object)) {
257
+ return object;
258
+ }
259
+ if ("to_param" in object) {
260
+ result = object.to_param;
261
+ } else if ("toParam" in object) {
262
+ result = object.toParam;
263
+ } else if ("id" in object) {
264
+ result = object.id;
265
+ } else {
266
+ result = object;
267
+ }
268
+ return this.is_callable(result) ? result.call(object) : result;
269
+ }
270
+
271
+ partition_parameters(
272
+ parts: string[],
273
+ required_params: string[],
274
+ default_options: RouteParameters,
275
+ call_arguments: RouteParameter[]
276
+ ): {
277
+ keyword_parameters: KeywordUrlOptions;
278
+ query_parameters: RouteParameters;
279
+ } {
280
+ // eslint-disable-next-line prefer-const
281
+ let { args, options } = this.extract_options(
282
+ parts.length,
283
+ call_arguments
284
+ );
285
+ if (args.length > parts.length) {
286
+ throw new Error("Too many parameters provided for path");
287
+ }
288
+ let use_all_parts = args.length > required_params.length;
289
+ const parts_options: RouteParameters = {};
290
+ for (const key in options) {
291
+ const value = options[key];
292
+ if (!hasProp(options, key)) continue;
293
+ use_all_parts = true;
294
+ if (parts.includes(key)) {
295
+ parts_options[key] = value;
296
+ }
297
+ }
298
+ options = {
299
+ ...this.configuration.default_url_options,
300
+ ...default_options,
301
+ ...options,
302
+ };
303
+
304
+ const keyword_parameters: KeywordUrlOptions = {};
305
+ const query_parameters: RouteParameters = {};
306
+ for (const key in options) {
307
+ if (!hasProp(options, key)) continue;
308
+ const value = options[key];
309
+ if (this.is_reserved_option(key)) {
310
+ keyword_parameters[key] = value as any;
311
+ } else {
312
+ if (
313
+ !this.is_nullable(value) &&
314
+ (value !== default_options[key] || required_params.includes(key))
315
+ ) {
316
+ query_parameters[key] = value;
317
+ }
318
+ }
319
+ }
320
+ const route_parts = use_all_parts ? parts : required_params;
321
+ let i = 0;
322
+ for (const part of route_parts) {
323
+ if (i < args.length) {
324
+ const value = args[i];
325
+ if (!hasProp(parts_options, part)) {
326
+ query_parameters[part] = value;
327
+ ++i;
328
+ }
329
+ }
330
+ }
331
+ return { keyword_parameters, query_parameters };
332
+ }
333
+ build_route(
334
+ parts: string[],
335
+ required_params: string[],
336
+ default_options: RouteParameters,
337
+ route: RouteTree,
338
+ absolute: boolean,
339
+ args: RouteParameter[]
340
+ ): string {
341
+ const {
342
+ keyword_parameters,
343
+ query_parameters,
344
+ } = this.partition_parameters(
345
+ parts,
346
+ required_params,
347
+ default_options,
348
+ args
349
+ );
350
+ const missing_params = required_params.filter(
351
+ (param) =>
352
+ !hasProp(query_parameters, param) ||
353
+ this.is_nullable(query_parameters[param])
354
+ );
355
+ if (missing_params.length) {
356
+ throw new ParametersMissing(...missing_params);
357
+ }
358
+ let result = this.get_prefix() + this.visit(route, query_parameters);
359
+ if (keyword_parameters.trailing_slash) {
360
+ result = result.replace(/(.*?)[/]?$/, "$1/");
361
+ }
362
+ const url_params = this.serialize(query_parameters);
363
+ if (url_params.length) {
364
+ result += "?" + url_params;
365
+ }
366
+ result += keyword_parameters.anchor
367
+ ? "#" + keyword_parameters.anchor
368
+ : "";
369
+ if (absolute) {
370
+ result = this.route_url(keyword_parameters) + result;
371
+ }
372
+ return result;
373
+ }
374
+
375
+ visit(
376
+ route: RouteTree,
377
+ parameters: RouteParameters,
378
+ optional = false
379
+ ): string {
380
+ switch (route[0]) {
381
+ case NodeTypes.GROUP:
382
+ return this.visit(route[1], parameters, true);
383
+ case NodeTypes.CAT:
384
+ return this.visit_cat(route, parameters, optional);
385
+ case NodeTypes.SYMBOL:
386
+ return this.visit_symbol(route, parameters, optional);
387
+ case NodeTypes.STAR:
388
+ return this.visit_globbing(route[1], parameters, true);
389
+ case NodeTypes.LITERAL:
390
+ case NodeTypes.SLASH:
391
+ case NodeTypes.DOT:
392
+ return route[1];
393
+ default:
394
+ throw new Error("Unknown Rails node type");
395
+ }
396
+ }
397
+
398
+ is_not_nullable<T>(object: T): object is NonNullable<T> {
399
+ return !this.is_nullable(object);
400
+ }
401
+
402
+ is_nullable(object: unknown): object is null | undefined {
403
+ return object === undefined || object === null;
404
+ }
405
+
406
+ visit_cat(
407
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
408
+ [_type, left, right]: RouteNode<NodeTypes.CAT>,
409
+ parameters: RouteParameters,
410
+ optional: boolean
411
+ ): string {
412
+ const left_part = this.visit(left, parameters, optional);
413
+ const right_part = this.visit(right, parameters, optional);
414
+ if (
415
+ optional &&
416
+ ((this.is_optional_node(left[0]) && !left_part) ||
417
+ (this.is_optional_node(right[0]) && !right_part))
418
+ ) {
419
+ return "";
420
+ }
421
+ return left_part + right_part;
422
+ }
423
+
424
+ visit_symbol(
425
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
426
+ [_type, key]: RouteNode<NodeTypes.SYMBOL>,
427
+ parameters: RouteParameters,
428
+ optional: boolean
429
+ ): string {
430
+ const value = this.path_identifier(parameters[key]);
431
+ delete parameters[key];
432
+ if (value.length) {
433
+ return this.encode_segment(value);
434
+ }
435
+ if (optional) {
436
+ return "";
437
+ } else {
438
+ throw new ParametersMissing(key);
439
+ }
440
+ }
441
+
442
+ encode_segment(segment: string): string {
443
+ return segment.replace(UriEncoderSegmentRegex, function (str) {
444
+ return encodeURIComponent(str);
445
+ });
446
+ }
447
+
448
+ is_optional_node(node: NodeTypes): boolean {
449
+ return [NodeTypes.STAR, NodeTypes.SYMBOL, NodeTypes.CAT].includes(node);
450
+ }
451
+
452
+ build_path_spec(route: RouteTree, wildcard = false): string {
453
+ let key: string;
454
+ switch (route[0]) {
455
+ case NodeTypes.GROUP:
456
+ return "(" + this.build_path_spec(route[1]) + ")";
457
+ case NodeTypes.CAT:
458
+ return (
459
+ this.build_path_spec(route[1]) + this.build_path_spec(route[2])
460
+ );
461
+ case NodeTypes.STAR:
462
+ return this.build_path_spec(route[1], true);
463
+ case NodeTypes.SYMBOL:
464
+ key = route[1];
465
+ if (wildcard) {
466
+ return (key.startsWith("*") ? "" : "*") + key;
467
+ } else {
468
+ return ":" + key;
469
+ }
470
+ break;
471
+ case NodeTypes.SLASH:
472
+ case NodeTypes.DOT:
473
+ case NodeTypes.LITERAL:
474
+ return route[1];
475
+ default:
476
+ throw new Error("Unknown Rails node type");
477
+ }
478
+ }
479
+
480
+ visit_globbing(
481
+ route: RouteTree,
482
+ parameters: RouteParameters,
483
+ optional: boolean
484
+ ): string {
485
+ const key = route[1] as string;
486
+ let value = parameters[key];
487
+ delete parameters[key];
488
+ if (this.is_nullable(value)) {
489
+ return this.visit(route, parameters, optional);
490
+ }
491
+ if (this.is_array(value)) {
492
+ value = value.join("/");
493
+ }
494
+ const result = this.path_identifier(value as any);
495
+ return DeprecatedGlobbingBehavior ? result : encodeURI(result);
496
+ }
497
+
498
+ get_prefix(): string {
499
+ const prefix = this.configuration.prefix;
500
+ return prefix.match("/$")
501
+ ? prefix.substring(0, prefix.length - 1)
502
+ : prefix;
503
+ }
504
+
505
+ route(
506
+ parts_table: PartsTable,
507
+ route_spec: RouteTree,
508
+ absolute = false
509
+ ): RouteHelper {
510
+ const required_params: string[] = [];
511
+ const parts: string[] = [];
512
+ const default_options: RouteParameters = {};
513
+ for (const [part, { r: required, d: value }] of Object.entries(
514
+ parts_table
515
+ )) {
516
+ parts.push(part);
517
+ if (required) {
518
+ required_params.push(part);
519
+ }
520
+ if (this.is_not_nullable(value)) {
521
+ default_options[part] = value;
522
+ }
523
+ }
524
+ const result = (...args: RouteParameter[]): string => {
525
+ return this.build_route(
526
+ parts,
527
+ required_params,
528
+ default_options,
529
+ route_spec,
530
+ absolute,
531
+ args
532
+ );
533
+ };
534
+ result.requiredParams = () => required_params;
535
+ result.toString = () => {
536
+ return this.build_path_spec(route_spec);
537
+ };
538
+ return result;
539
+ }
540
+
541
+ route_url(route_defaults: KeywordUrlOptions): string {
542
+ const hostname = route_defaults.host || this.current_host();
543
+ if (!hostname) {
544
+ return "";
545
+ }
546
+ const subdomain = route_defaults.subdomain
547
+ ? route_defaults.subdomain + "."
548
+ : "";
549
+ const protocol = route_defaults.protocol || this.current_protocol();
550
+ let port =
551
+ route_defaults.port ||
552
+ (!route_defaults.host ? this.current_port() : undefined);
553
+ port = port ? ":" + port : "";
554
+ return protocol + "://" + subdomain + hostname + port;
555
+ }
556
+
557
+ has_location(): boolean {
558
+ return this.is_not_nullable(window) && !!window.location;
559
+ }
560
+
561
+ current_host(): string | null {
562
+ if (this.has_location()) {
563
+ return window.location.hostname;
564
+ } else {
565
+ return null;
566
+ }
567
+ }
568
+
569
+ current_protocol(): string {
570
+ if (this.has_location() && window.location.protocol !== "") {
571
+ return window.location.protocol.replace(/:$/, "");
572
+ } else {
573
+ return "http";
574
+ }
575
+ }
576
+ current_port(): string {
577
+ if (this.has_location() && window.location.port !== "") {
578
+ return window.location.port;
579
+ } else {
580
+ return "";
581
+ }
582
+ }
583
+
584
+ is_object(value: unknown): value is Record<string, unknown> {
585
+ return (
586
+ typeof value === "object" &&
587
+ Object.prototype.toString.call(value) === "[object Object]"
588
+ );
589
+ }
590
+
591
+ is_array<T>(object: unknown | T[]): object is T[] {
592
+ return object instanceof Array;
593
+ }
594
+
595
+ is_callable(object: unknown): object is Function {
596
+ return typeof object === "function" && !!object.call;
597
+ }
598
+
599
+ is_reserved_option(key: unknown): key is ReservedOption {
600
+ return ReservedOptions.includes(key as any);
601
+ }
602
+
603
+ namespace(
604
+ object: any,
605
+ namespace: string | null | undefined,
606
+ routes: unknown
607
+ ): unknown {
608
+ const parts = namespace?.split(".") || [];
609
+ if (parts.length === 0) {
610
+ return routes;
611
+ }
612
+ for (let index = 0; index < parts.length; index++) {
613
+ const part = parts[index];
614
+ if (index < parts.length - 1) {
615
+ object = object[part] || (object[part] = {});
616
+ } else {
617
+ return (object[part] = routes);
618
+ }
619
+ }
620
+ }
621
+
622
+ configure(new_config: Partial<Configuration>): Configuration {
623
+ this.configuration = { ...this.configuration, ...new_config };
624
+ return this.configuration;
625
+ }
626
+
627
+ config(): Configuration {
628
+ return { ...this.configuration };
629
+ }
630
+
631
+ is_module_supported(name: ModuleType): boolean {
632
+ return ModuleReferences[name].support();
633
+ }
634
+
635
+ ensure_module_supported(name: ModuleType): void {
636
+ if (!this.is_module_supported(name)) {
637
+ throw new Error(`${name} is not supported by runtime`);
638
+ }
639
+ }
640
+
641
+ define_module(
642
+ name: ModuleType | null,
643
+ module: RouterExposedMethods
644
+ ): void {
645
+ if (!name) {
646
+ return;
647
+ }
648
+ this.ensure_module_supported(name);
649
+ ModuleReferences[name].define(module);
650
+ }
651
+ }
652
+
653
+ const Utils = new UtilsClass();
654
+
655
+ // We want this helper name to be short
656
+ const __jsr = {
657
+ r(
658
+ parts_table: PartsTable,
659
+ route_spec: RouteTree,
660
+ absolute?: boolean
661
+ ): RouteHelper {
662
+ return Utils.route(parts_table, route_spec, absolute);
663
+ },
664
+ };
665
+
666
+ const result = {
667
+ ...__jsr,
668
+ configure: (config: Partial<Configuration>) => {
669
+ return Utils.configure(config);
670
+ },
671
+ config: (): Configuration => {
672
+ return Utils.config();
673
+ },
674
+ serialize: (object: unknown): string => {
675
+ return Utils.serialize(object);
676
+ },
677
+ ...RubyVariables.ROUTES_OBJECT,
678
+ };
679
+
680
+ Utils.namespace(Root, RubyVariables.NAMESPACE, result);
681
+
682
+ if (RubyVariables.MODULE_TYPE) {
683
+ Utils.define_module(RubyVariables.MODULE_TYPE, result);
684
+ }
685
+ return result;
686
+ }
687
+ )(this);