@mapl/router 0.0.20 → 0.0.22

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.
package/constants.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export declare const REQ = "__req";
2
+ export declare const PATH = "__req_p";
3
+ export declare const PATH_LEN = "__req_pl";
4
+ export declare const PARAMS = "__req_ps";
5
+ export declare const PREV_PARAM_IDX = "__req_ppi";
6
+ export declare const CURRENT_PARAM_IDX = "__req_cpi";
package/constants.js ADDED
@@ -0,0 +1 @@
1
+ export var REQ="__req";export var PATH="__req_p";export var PATH_LEN="__req_pl";export var PARAMS="__req_ps";export var PREV_PARAM_IDX="__req_ppi";export var CURRENT_PARAM_IDX="__req_cpi";
package/index.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import type { Builder } from '@mapl/compiler';
2
+ import { type Node } from './tree/node.js';
3
+ export type Router = [staticMap: Record<string, string> | null, root: Node | null];
4
+ export declare function createRouter(): Router;
5
+ export declare function insertItem(router: Router, path: string, item: string): void;
6
+ export declare function compileRouter(router: Router, contentBuilder: Builder<string>): void;
package/index.js ADDED
@@ -0,0 +1 @@
1
+ import{compileNode}from"./tree/compiler.js";import{createNode,insertItem as nodeInsertItem}from"./tree/node.js";export function createRouter(){return[null,null]}export function insertItem(router,path,item){if(path.includes("*"))nodeInsertItem(router[1]??=createNode("/"),path,item);else(router[0]??={})[path]=item}export function compileRouter(router,contentBuilder){let hasStatic=router[0]!==null;if(hasStatic){let staticMap=router[0];let hasMultiple=false;for(let key in staticMap){contentBuilder.push(`${hasMultiple?"else ":""}if(__req_p==="${key.slice(1).replace(/"/g,"\\\"")}"){${staticMap[key]}}`);hasMultiple=true}}if(router[1]!==null){if(hasStatic)contentBuilder.push("else{");contentBuilder.push("let __req_pl=__req_p.length;");compileNode(router[1],contentBuilder,false,false,-1,"");if(hasStatic)contentBuilder.push("}")}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mapl/router",
3
- "version": "0.0.20",
3
+ "version": "0.0.22",
4
4
  "main": "./index.js",
5
5
  "devDependencies": {
6
6
  "@stylistic/eslint-plugin": "latest",
@@ -0,0 +1,3 @@
1
+ import type { Builder } from '@mapl/compiler';
2
+ import type { Node } from './node.js';
3
+ export declare function compileNode(node: Node, builder: Builder<string>, hasParam: boolean, hasMultipleParams: boolean, startIndexValue: number, startIndexPrefix: string): void;
@@ -0,0 +1 @@
1
+ export function compileNode(node,builder,hasParam,hasMultipleParams,startIndexValue,startIndexPrefix){let part=node[0];let partLen=part.length;startIndexValue++;if(partLen!==1){builder.push(`if(__req_pl>${startIndexPrefix}${startIndexValue+partLen-2})`);for(let i=1;i<partLen;i++,startIndexValue++)builder.push(`if(__req_p.charCodeAt(${startIndexPrefix}${startIndexValue})===${part.charCodeAt(i)})`);builder.push("{")}if(node[1]!==null)builder.push(`if(__req_pl===${startIndexPrefix}${startIndexValue}){${node[1]}}`);if(node[2]!==null){let children=node[2];let childrenKeys=Object.keys(children);if(childrenKeys.length===1){builder.push(`if(__req_p.charCodeAt(${startIndexPrefix}${startIndexValue})===${childrenKeys[0]}){`);compileNode(children[childrenKeys[0]],builder,hasParam,hasMultipleParams,startIndexValue,startIndexPrefix);builder.push("}")}else{builder.push(`switch(__req_p.charCodeAt(${startIndexPrefix}${startIndexValue})){`);for(let i=0,l=childrenKeys.length;i<l;i++){builder.push(`case ${childrenKeys[i]}:`);compileNode(children[childrenKeys[i]],builder,hasParam,hasMultipleParams,startIndexValue,startIndexPrefix);builder.push("break;")}builder.push("}")}}if(node[3]!==null){let params=node[3];let hasStore=params[1]!==null;let hasChild=params[0]!==null;let requireAllocation=hasParam?hasMultipleParams:hasChild||!hasStore;if(requireAllocation)builder.push("{");if(hasParam)builder.push(`${hasMultipleParams?"":"let "}__req_ppi=${startIndexPrefix}${startIndexValue};`);let currentIndex=hasParam?"__req_ppi":startIndexPrefix+startIndexValue;let slashIndex=`__req_p.indexOf('/'${currentIndex==="0"?"":","+currentIndex})`;if(hasChild||!hasStore)builder.push(`${hasParam?"":"let "}__req_cpi=${slashIndex};`);if(hasStore){let paramsVal=currentIndex==="0"?"__req_p":`__req_p.slice(${currentIndex})`;builder.push(`if(${hasChild?"__req_cpi":slashIndex}===-1){${hasParam?`__req_ps.push(${paramsVal})`:`let __req_ps=[${paramsVal}]`};${params[1]}}`)}if(hasChild){let paramsVal=`__req_p.substring(${currentIndex},__req_cpi)`;builder.push(`if(${hasStore?"":"__req_cpi!==-1&&"}__req_cpi!==${currentIndex}){${hasParam?`__req_ps.push(${paramsVal})`:`let __req_ps=[${paramsVal}]`};`);compileNode(params[0],builder,true,hasParam,0,"__req_cpi+");if(!requireAllocation)builder.push("__req_ps.pop();");builder.push("}")}if(requireAllocation)builder.push("}")}if(node[4]!==null){let noStore=node[1]===null;let currentIndex=startIndexPrefix+startIndexValue;if(noStore)builder.push(`if(__req_pl!==${currentIndex}){`);let paramsVal=currentIndex==="0"?"__req_p":`__req_p.slice(${currentIndex})`;builder.push(`${hasParam?`__req_ps.push(${paramsVal})`:`let __req_ps=[${paramsVal}]`};${node[4]}`);if(noStore)builder.push("}")}if(partLen!==1)builder.push("}")}
package/tree/node.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ export type Node = [
2
+ part: string,
3
+ store: string | null,
4
+ children: Record<number, Node> | null,
5
+ params: ParamNode | null,
6
+ wildcardStore: string | null
7
+ ];
8
+ export type ParamNode = [
9
+ child: Node | null,
10
+ store: string | null
11
+ ];
12
+ export declare function createNode(part: string): Node;
13
+ export declare function createParamNode(nextNode: ParamNode[0]): ParamNode;
14
+ export declare function cloneNode(node: Node, part: string): Node;
15
+ export declare function resetNode(node: Node, part: string, children: Node[2]): void;
16
+ export declare function visitNode(node: Node, path: string): Node;
17
+ export declare function insertItem(node: Node, path: string, item: string): void;
package/tree/node.js ADDED
@@ -0,0 +1 @@
1
+ export function createNode(part){return[part,null,null,null,null]}export function createParamNode(nextNode){return[nextNode,null]}export function cloneNode(node,part){return[part,node[1],node[2],node[3],node[4]]}export function resetNode(node,part,children){node[0]=part;node[2]=children;node[1]=null;node[3]=null;node[4]=null}export function visitNode(node,path){let parts=path.split("*");for(let i=0,{length}=parts;i<length;++i){if(i!==0){if(node[3]===null){let nextNode=createNode(parts[i]);node[3]=createParamNode(nextNode);node=nextNode}else node=node[3][0]??=createNode(parts[i])}for(let j=0,pathPart=parts[i];;++j){let nodePart=node[0];if(j===pathPart.length){if(j<nodePart.length){let children={};children[nodePart.charCodeAt(j)]=cloneNode(node,nodePart.slice(j));resetNode(node,pathPart,children)}break}if(j===nodePart.length){if(node[2]===null)node[2]={};else{let nextNode=node[2][pathPart.charCodeAt(j)];if(typeof nextNode!=="undefined"){node=nextNode;pathPart=pathPart.slice(j);j=0;continue}}let nextNode=createNode(pathPart.slice(j));node[2][pathPart.charCodeAt(j)]=nextNode;node=nextNode;break}if(pathPart.charCodeAt(j)!==nodePart.charCodeAt(j)){let children={};children[nodePart.charCodeAt(j)]=cloneNode(node,nodePart.slice(j));let nextNode=createNode(pathPart.slice(j));children[pathPart.charCodeAt(j)]=nextNode;resetNode(node,nodePart.substring(0,j),children);node=nextNode;break}}}return node}export function insertItem(node,path,item){if(path.charCodeAt(path.length-1)===42){if(path.charCodeAt(path.length-2)===42)visitNode(node,path.substring(0,path.length-2))[4]=item;else(visitNode(node,path.substring(0,path.length-1))[3]??=createParamNode(null))[1]=item}else visitNode(node,path)[1]=item}
package/eslint.config.js DELETED
@@ -1,589 +0,0 @@
1
- //@ts-check
2
- import tsEslint from "typescript-eslint";
3
- import stylistic from "@stylistic/eslint-plugin";
4
- import jsdoc from "eslint-plugin-jsdoc";
5
-
6
- export default tsEslint.config(
7
- {
8
- ignores: ["**/*.js", "**/*.d.ts", "lib/**/*", "node_modules/**/*"],
9
- },
10
- {
11
- files: ["src/**/*.ts"],
12
- plugins: {
13
- "@typescript-eslint": tsEslint.plugin,
14
- "@stylistic": stylistic,
15
- jsdoc,
16
- },
17
- languageOptions: {
18
- parser: tsEslint.parser,
19
- ecmaVersion: "latest",
20
- parserOptions: {
21
- tsconfigRootDir: ".",
22
- project: ["./tsconfig.json"],
23
- },
24
- },
25
- rules: {
26
- // #region Eslint
27
- "array-callback-return": "error",
28
- "constructor-super": "error",
29
- "for-direction": "error",
30
- "getter-return": "error",
31
- "no-async-promise-executor": "error",
32
- "no-await-in-loop": "error",
33
- "no-class-assign": "error",
34
- "no-compare-neg-zero": "error",
35
- "no-cond-assign": "error",
36
- "no-constant-binary-expression": "error",
37
- "no-constant-condition": "error",
38
- "no-constructor-return": "error",
39
- "no-control-regex": "error",
40
- "no-debugger": "error",
41
- "no-dupe-else-if": "error",
42
- "no-duplicate-case": "error",
43
- "no-empty-character-class": "error",
44
- "no-empty-pattern": "error",
45
- "no-ex-assign": "error",
46
- "no-fallthrough": "error",
47
- "no-func-assign": "error",
48
- "no-import-assign": "error",
49
- "no-inner-declarations": "error",
50
- "no-invalid-regexp": "error",
51
- "no-misleading-character-class": "error",
52
- "no-obj-calls": "error",
53
- "no-promise-executor-return": "error",
54
- "no-prototype-builtins": "error",
55
- "no-self-assign": "error",
56
- "no-self-compare": "error",
57
- "no-sparse-arrays": "error",
58
- "no-template-curly-in-string": "error",
59
- "no-unexpected-multiline": "error",
60
- "no-unmodified-loop-condition": "error",
61
- "no-unreachable-loop": "error",
62
- "no-unsafe-finally": "error",
63
- "no-unsafe-negation": "error",
64
- "no-unsafe-optional-chaining": "error",
65
- "no-unused-private-class-members": "error",
66
- "no-useless-backreference": "error",
67
- "require-atomic-updates": "error",
68
- "use-isnan": "error",
69
- "accessor-pairs": "error",
70
- // "consistent-return": "error", For some reason is not working with TS
71
- "grouped-accessor-pairs": "error",
72
- "logical-assignment-operators": "warn",
73
- "no-array-constructor": "error",
74
- "no-delete-var": "error",
75
- "no-div-regex": "warn",
76
- "no-else-return": "error",
77
- "no-empty-static-block": "error",
78
- "no-eval": "error",
79
- "no-extend-native": "error",
80
- "no-extra-bind": "error",
81
- "no-extra-boolean-cast": "warn",
82
- "no-global-assign": "error",
83
- "no-iterator": "error",
84
- "no-lone-blocks": "error",
85
- "no-lonely-if": "warn",
86
- "no-multi-str": "error",
87
- "no-new": "error",
88
- "no-nonoctal-decimal-escape": "warn",
89
- "no-octal": "error",
90
- "no-octal-escape": "error",
91
- "no-proto": "error",
92
- "no-regex-spaces": "warn",
93
- "no-return-assign": "error",
94
- "no-sequences": "error",
95
- "no-shadow-restricted-names": "error",
96
- "no-underscore-dangle": "error",
97
- "no-unneeded-ternary": "warn",
98
- "no-unused-labels": "warn",
99
- "no-useless-call": "error",
100
- "no-useless-catch": "error",
101
- "no-useless-computed-key": "warn",
102
- "no-useless-concat": "error",
103
- "no-useless-escape": "error",
104
- "no-useless-rename": "error",
105
- "no-var": "error",
106
- "no-void": "error",
107
- "no-with": "error",
108
- "operator-assignment": "error",
109
- "prefer-promise-reject-errors": "error",
110
- "prefer-regex-literals": "error",
111
- "prefer-rest-params": "error",
112
- "prefer-spread": "error",
113
- "prefer-template": "warn",
114
- curly: ["error", "multi-or-nest"],
115
- eqeqeq: [
116
- "error",
117
- "always",
118
- {
119
- null: "ignore",
120
- },
121
- ],
122
- "func-style": ["error", "declaration"],
123
- "no-empty": [
124
- "error",
125
- {
126
- allowEmptyCatch: true,
127
- },
128
- ],
129
- "one-var": ["error", "never"],
130
- "prefer-const": [
131
- "error",
132
- {
133
- destructuring: "all",
134
- },
135
- ],
136
- // #endregion Eslint
137
- // #region TSLint
138
- "@typescript-eslint/adjacent-overload-signatures": "error",
139
- "@typescript-eslint/await-thenable": "error",
140
- "@typescript-eslint/ban-ts-comment": "error",
141
- "@typescript-eslint/consistent-generic-constructors": "error",
142
- "@typescript-eslint/consistent-indexed-object-style": "warn",
143
- "@typescript-eslint/consistent-type-exports": "warn",
144
- "@typescript-eslint/consistent-type-imports": "warn",
145
- "@typescript-eslint/default-param-last": "error",
146
- "@typescript-eslint/dot-notation": "warn",
147
- "@typescript-eslint/explicit-member-accessibility": "warn",
148
- "@typescript-eslint/method-signature-style": "warn",
149
- "@typescript-eslint/no-array-constructor": "warn",
150
- "@typescript-eslint/no-base-to-string": "error",
151
- "@typescript-eslint/no-confusing-non-null-assertion": "warn",
152
- "@typescript-eslint/no-confusing-void-expression": "warn",
153
- "@typescript-eslint/no-duplicate-enum-values": "error",
154
- "@typescript-eslint/no-duplicate-type-constituents": "error",
155
- "@typescript-eslint/no-dynamic-delete": "error",
156
- "@typescript-eslint/no-extra-non-null-assertion": "warn",
157
- "@typescript-eslint/no-extraneous-class": "error",
158
- "@typescript-eslint/no-for-in-array": "error",
159
- "@typescript-eslint/no-import-type-side-effects": "error",
160
- "@typescript-eslint/no-loop-func": "error",
161
- "@typescript-eslint/no-loss-of-precision": "error",
162
- "@typescript-eslint/no-meaningless-void-operator": "warn",
163
- "@typescript-eslint/no-misused-new": "error",
164
- "@typescript-eslint/no-mixed-enums": "error",
165
- "@typescript-eslint/no-namespace": "error",
166
- "@typescript-eslint/no-non-null-asserted-nullish-coalescing": "error",
167
- "@typescript-eslint/no-non-null-asserted-optional-chain": "error",
168
- "@typescript-eslint/no-redundant-type-constituents": "error",
169
- "@typescript-eslint/no-require-imports": "error",
170
- "@typescript-eslint/no-restricted-imports": "error",
171
- "@typescript-eslint/no-shadow": "error",
172
- "@typescript-eslint/no-this-alias": "error",
173
- "@typescript-eslint/no-unnecessary-boolean-literal-compare": "warn",
174
- "@typescript-eslint/no-unnecessary-qualifier": "warn",
175
- "@typescript-eslint/no-unnecessary-type-arguments": "warn",
176
- "@typescript-eslint/no-unnecessary-type-assertion": "warn",
177
- "@typescript-eslint/no-unnecessary-type-constraint": "error",
178
- "@typescript-eslint/no-unsafe-argument": "error",
179
- "@typescript-eslint/no-unsafe-assignment": "error",
180
- "@typescript-eslint/no-unsafe-call": "error",
181
- "@typescript-eslint/no-unsafe-declaration-merging": "error",
182
- "@typescript-eslint/no-unsafe-enum-comparison": "error",
183
- "@typescript-eslint/no-unsafe-member-access": "error",
184
- "@typescript-eslint/no-unsafe-unary-minus": "error",
185
- "@typescript-eslint/no-unused-vars": "error",
186
- "@typescript-eslint/no-useless-constructor": "error",
187
- "@typescript-eslint/no-useless-empty-export": "warn",
188
- "@typescript-eslint/no-var-requires": "error",
189
- "@typescript-eslint/non-nullable-type-assertion-style": "error",
190
- "@typescript-eslint/parameter-properties": "error",
191
- "@typescript-eslint/prefer-function-type": "warn",
192
- "@typescript-eslint/prefer-includes": "warn",
193
- "@typescript-eslint/prefer-literal-enum-member": "error",
194
- "@typescript-eslint/prefer-nullish-coalescing": "error",
195
- "@typescript-eslint/prefer-optional-chain": "error",
196
- "@typescript-eslint/prefer-readonly": "warn",
197
- "@typescript-eslint/prefer-reduce-type-parameter": "warn",
198
- "@typescript-eslint/prefer-regexp-exec": "warn",
199
- "@typescript-eslint/prefer-return-this-type": "warn",
200
- "@typescript-eslint/prefer-string-starts-ends-with": "warn",
201
- "@typescript-eslint/prefer-ts-expect-error": "warn",
202
- "@typescript-eslint/promise-function-async": "warn",
203
- "@typescript-eslint/require-await": "error",
204
- "@typescript-eslint/restrict-plus-operands": "error",
205
- "@typescript-eslint/restrict-template-expressions": "error",
206
- "@typescript-eslint/return-await": "error",
207
- "@typescript-eslint/switch-exhaustiveness-check": "error",
208
- "@typescript-eslint/triple-slash-reference": "error",
209
- "@typescript-eslint/unified-signatures": "error",
210
- "@typescript-eslint/explicit-function-return-type": [
211
- "error",
212
- {
213
- allowExpressions: true,
214
- },
215
- ],
216
- "@typescript-eslint/naming-convention": [
217
- "error",
218
- {
219
- selector: "variable",
220
- format: ["camelCase", "UPPER_CASE"],
221
- },
222
- {
223
- selector: "function",
224
- format: ["camelCase"],
225
- },
226
- {
227
- selector: "parameter",
228
- format: ["camelCase", "UPPER_CASE"],
229
- leadingUnderscore: "allow",
230
- trailingUnderscore: "allow",
231
- },
232
- {
233
- selector: "classProperty",
234
- format: ["camelCase"],
235
- leadingUnderscore: "allow",
236
- trailingUnderscore: "allow",
237
- },
238
- {
239
- selector: "objectLiteralProperty",
240
- format: ["camelCase"],
241
- },
242
- {
243
- selector: "typeProperty",
244
- format: ["camelCase"],
245
- },
246
- {
247
- selector: "classMethod",
248
- format: ["camelCase"],
249
- },
250
- {
251
- selector: "objectLiteralMethod",
252
- format: ["camelCase"],
253
- },
254
- {
255
- selector: "typeMethod",
256
- format: ["camelCase"],
257
- },
258
- {
259
- selector: "accessor",
260
- format: ["camelCase"],
261
- },
262
- {
263
- selector: "enumMember",
264
- format: ["UPPER_CASE"],
265
- },
266
- {
267
- selector: "class",
268
- format: ["PascalCase"],
269
- },
270
- {
271
- selector: "interface",
272
- format: ["PascalCase"],
273
- },
274
- {
275
- selector: "typeAlias",
276
- format: ["camelCase", "PascalCase"],
277
- },
278
- {
279
- selector: "enum",
280
- format: ["PascalCase"],
281
- },
282
- {
283
- selector: "typeParameter",
284
- format: ["camelCase", "PascalCase"],
285
- },
286
- ],
287
- "@typescript-eslint/no-empty-function": [
288
- "error",
289
- {
290
- allow: [
291
- "private-constructors",
292
- "protected-constructors",
293
- "decoratedFunctions",
294
- ],
295
- },
296
- ],
297
- "@typescript-eslint/no-empty-interface": [
298
- "warn",
299
- {
300
- allowSingleExtends: true,
301
- },
302
- ],
303
- "@typescript-eslint/no-floating-promises": [
304
- "error",
305
- {
306
- ignoreIIFE: true,
307
- },
308
- ],
309
- "@typescript-eslint/no-inferrable-types": [
310
- "warn",
311
- {
312
- ignoreParameters: true,
313
- ignoreProperties: true,
314
- },
315
- ],
316
- "@typescript-eslint/no-invalid-void-type": [
317
- "error",
318
- {
319
- allowInGenericTypeArguments: true,
320
- allowAsThisParameter: true,
321
- },
322
- ],
323
- "@typescript-eslint/no-misused-promises": [
324
- "error",
325
- {
326
- checksVoidReturn: false,
327
- },
328
- ],
329
- "@typescript-eslint/no-unnecessary-condition": [
330
- "warn",
331
- {
332
- allowConstantLoopConditions: true,
333
- },
334
- ],
335
- "@typescript-eslint/no-unused-expressions": [
336
- "error",
337
- {
338
- allowTaggedTemplates: true,
339
- allowShortCircuit: true,
340
- },
341
- ],
342
- "@typescript-eslint/no-use-before-define": [
343
- "error",
344
- {
345
- functions: false,
346
- classes: false,
347
- },
348
- ],
349
- "@typescript-eslint/require-array-sort-compare": [
350
- "error",
351
- {
352
- ignoreStringArrays: true,
353
- },
354
- ],
355
- "@typescript-eslint/strict-boolean-expressions": [
356
- "warn",
357
- {
358
- allowAny: true,
359
- allowNullableString: true,
360
- allowNullableNumber: true,
361
- allowNullableBoolean: true,
362
- },
363
- ],
364
- "@typescript-eslint/unbound-method": [
365
- "error",
366
- {
367
- ignoreStatic: true,
368
- },
369
- ],
370
- // #endregion TSLint
371
- // #region Stylistic
372
- "@stylistic/arrow-parens": "warn",
373
- "@stylistic/arrow-spacing": "warn",
374
- "@stylistic/block-spacing": "warn",
375
- "@stylistic/comma-dangle": "warn",
376
- "@stylistic/comma-spacing": "warn",
377
- "@stylistic/comma-style": "warn",
378
- "@stylistic/computed-property-spacing": "warn",
379
- "@stylistic/eol-last": "warn",
380
- "@stylistic/function-call-spacing": "warn",
381
- "@stylistic/implicit-arrow-linebreak": "warn",
382
- "@stylistic/jsx-quotes": "warn",
383
- "@stylistic/key-spacing": "warn",
384
- "@stylistic/linebreak-style": "warn",
385
- "@stylistic/new-parens": "warn",
386
- "@stylistic/no-confusing-arrow": "warn",
387
- "@stylistic/no-extra-parens": "warn",
388
- "@stylistic/no-extra-semi": "warn",
389
- "@stylistic/no-floating-decimal": "warn",
390
- "@stylistic/no-mixed-operators": "warn",
391
- "@stylistic/no-mixed-spaces-and-tabs": "warn",
392
- "@stylistic/no-multi-spaces": "warn",
393
- "@stylistic/no-tabs": "warn",
394
- "@stylistic/no-trailing-spaces": "warn",
395
- "@stylistic/no-whitespace-before-property": "warn",
396
- "@stylistic/padding-line-between-statements": "warn",
397
- "@stylistic/rest-spread-spacing": "warn",
398
- "@stylistic/semi": "warn",
399
- "@stylistic/semi-spacing": "warn",
400
- "@stylistic/semi-style": "warn",
401
- "@stylistic/space-before-blocks": "warn",
402
- "@stylistic/space-in-parens": "warn",
403
- "@stylistic/space-infix-ops": "warn",
404
- "@stylistic/switch-colon-spacing": "warn",
405
- "@stylistic/template-curly-spacing": "warn",
406
- "@stylistic/type-annotation-spacing": "warn",
407
- "@stylistic/wrap-regex": "warn",
408
- "@stylistic/array-bracket-newline": [
409
- "warn",
410
- {
411
- multiline: true,
412
- },
413
- ],
414
- "@stylistic/array-bracket-spacing": [
415
- "warn",
416
- "never",
417
- {
418
- objectsInArrays: true,
419
- },
420
- ],
421
- "@stylistic/array-element-newline": ["warn", "consistent"],
422
- "@stylistic/brace-style": [
423
- "warn",
424
- "1tbs",
425
- {
426
- allowSingleLine: true,
427
- },
428
- ],
429
- "@stylistic/dot-location": ["warn", "property"],
430
- "@stylistic/function-call-argument-newline": ["warn", "consistent"],
431
- "@stylistic/function-paren-newline": ["warn", "multiline"],
432
- "@stylistic/generator-star-spacing": ["warn", "after"],
433
- "@stylistic/indent": [
434
- "warn",
435
- 2,
436
- {
437
- SwitchCase: 1,
438
- },
439
- ],
440
- "@stylistic/keyword-spacing": [
441
- "error",
442
- {
443
- before: true,
444
- after: true,
445
- },
446
- ],
447
- "@stylistic/lines-between-class-members": [
448
- "warn",
449
- "always",
450
- {
451
- exceptAfterSingleLine: true,
452
- },
453
- ],
454
- "@stylistic/max-len": [
455
- "error",
456
- {
457
- code: 500,
458
- },
459
- ],
460
- "@stylistic/max-statements-per-line": [
461
- "error",
462
- {
463
- max: 2,
464
- },
465
- ],
466
- "@stylistic/member-delimiter-style": [
467
- "warn",
468
- {
469
- multiline: {
470
- delimiter: "comma",
471
- requireLast: false,
472
- },
473
- singleline: {
474
- delimiter: "comma",
475
- requireLast: false,
476
- },
477
- overrides: {
478
- interface: {
479
- multiline: {
480
- delimiter: "semi",
481
- requireLast: true,
482
- },
483
- singleline: {
484
- delimiter: "semi",
485
- requireLast: false,
486
- },
487
- },
488
- },
489
- multilineDetection: "brackets",
490
- },
491
- ],
492
- "@stylistic/multiline-ternary": ["warn", "always-multiline"],
493
- "@stylistic/newline-per-chained-call": [
494
- "warn",
495
- {
496
- ignoreChainWithDepth: 4,
497
- },
498
- ],
499
- "@stylistic/no-multiple-empty-lines": [
500
- "warn",
501
- {
502
- max: 1,
503
- },
504
- ],
505
- "@stylistic/nonblock-statement-body-position": [
506
- "warn",
507
- "beside",
508
- {
509
- overrides: {
510
- while: "any",
511
- if: "any",
512
- else: "any",
513
- },
514
- },
515
- ],
516
- "@stylistic/object-curly-newline": [
517
- "warn",
518
- {
519
- consistent: true,
520
- multiline: true,
521
- },
522
- ],
523
- "@stylistic/object-curly-spacing": ["warn", "always"],
524
- "@stylistic/object-property-newline": [
525
- "warn",
526
- {
527
- allowAllPropertiesOnSameLine: true,
528
- },
529
- ],
530
- "@stylistic/operator-linebreak": [
531
- "warn",
532
- "none",
533
- {
534
- overrides: {
535
- "?": "ignore",
536
- ":": "ignore",
537
- "||": "before",
538
- },
539
- },
540
- ],
541
- "@stylistic/padded-blocks": ["warn", "never"],
542
- "@stylistic/quote-props": ["warn", "as-needed"],
543
- "@stylistic/quotes": [
544
- "warn",
545
- "single",
546
- {
547
- avoidEscape: true,
548
- },
549
- ],
550
- "@stylistic/space-before-function-paren": [
551
- "warn",
552
- {
553
- anonymous: "always",
554
- named: "never",
555
- asyncArrow: "always",
556
- },
557
- ],
558
- "@stylistic/space-unary-ops": [
559
- "warn",
560
- {
561
- words: true,
562
- nonwords: false,
563
- },
564
- ],
565
- "@stylistic/template-tag-spacing": ["warn", "never"],
566
- "@stylistic/wrap-iife": ["warn", "any"],
567
- "@stylistic/yield-star-spacing": ["warn", "after"],
568
- "jsdoc/check-access": "error",
569
- "jsdoc/check-alignment": "warn",
570
- "jsdoc/check-indentation": "error",
571
- "jsdoc/check-param-names": "warn",
572
- "jsdoc/check-property-names": "warn",
573
- "jsdoc/check-tag-names": "warn",
574
- "jsdoc/check-values": "error",
575
- "jsdoc/empty-tags": "warn",
576
- "jsdoc/implements-on-classes": "error",
577
- "jsdoc/informative-docs": "error",
578
- "jsdoc/multiline-blocks": "warn",
579
- "jsdoc/no-bad-blocks": "warn",
580
- "jsdoc/no-blank-block-descriptions": "warn",
581
- "jsdoc/no-blank-blocks": "warn",
582
- "jsdoc/no-defaults": "warn",
583
- "jsdoc/no-multi-asterisks": "warn",
584
- "jsdoc/no-types": "warn",
585
- "jsdoc/require-asterisk-prefix": "warn",
586
- "jsdoc/require-hyphen-before-param-description": ["error", "always"],
587
- },
588
- },
589
- );
package/globals.d.ts DELETED
@@ -1,6 +0,0 @@
1
- import * as constants from './src/constants.js';
2
-
3
- // Zero-cost constants at runtime
4
- declare global {
5
- const compilerConstants: typeof constants;
6
- }
package/scripts/bench.ts DELETED
@@ -1,7 +0,0 @@
1
- import { Glob } from 'bun';
2
- import { exec } from './utils';
3
-
4
- for (const path of new Glob('**/*.bench.ts').scanSync('.')) {
5
- console.log('Running benchmark:', path);
6
- await exec`bun run ${path}`;
7
- }
package/scripts/build.ts DELETED
@@ -1,48 +0,0 @@
1
- /// <reference types='bun-types' />
2
- import { existsSync, rmSync } from 'node:fs';
3
- import { exec } from './utils';
4
- import tsconfig from '../tsconfig.json';
5
- import * as constants from '../src/constants.ts';
6
-
7
- // Constants
8
- const SOURCEDIR = './src';
9
- const OUTDIR = tsconfig.compilerOptions.declarationDir;
10
-
11
- // Remove old content
12
- if (existsSync(OUTDIR)) rmSync(OUTDIR, { recursive: true });
13
-
14
- // Emit declaration files
15
- exec`bun x tsc`;
16
-
17
- const constantEntries = Object.entries(constants);
18
-
19
- // Transpile files concurrently
20
- const transpiler = new Bun.Transpiler({
21
- loader: 'tsx',
22
- target: 'node',
23
-
24
- // Lighter and more optimized output
25
- treeShaking: true,
26
- minifyWhitespace: true,
27
- inline: true,
28
-
29
- // Inline constants
30
- define: Object.fromEntries(constantEntries.map((entry) => [`compilerConstants.${entry[0]}`, JSON.stringify(entry[1])]))
31
- });
32
-
33
- for (const path of new Bun.Glob('**/*.ts').scanSync(SOURCEDIR))
34
- Bun.file(`${SOURCEDIR}/${path}`)
35
- .arrayBuffer()
36
- .then((buf) => transpiler.transform(buf)
37
- .then((res) => {
38
- if (res.length !== 0) {
39
- const pathExtStart = path.lastIndexOf('.');
40
- Bun.write(
41
- `${OUTDIR}/${path.substring(0, pathExtStart === -1 ? path.length : pathExtStart) + '.js'}`,
42
- res
43
- .replace(/export const /g, "export var ")
44
- .replace(/const /g, "let ")
45
- );
46
- }
47
- })
48
- );
@@ -1,6 +0,0 @@
1
- import { cpToLib, exec } from './utils';
2
-
3
- // Write required files
4
- await Promise.all(['./README.md', './package.json'].map(cpToLib));
5
-
6
- await exec`cd lib && bun publish --access=public`;
package/scripts/utils.ts DELETED
@@ -1,5 +0,0 @@
1
- import { join } from 'node:path';
2
- import { write, file, $ } from 'bun';
3
-
4
- export const cpToLib = (path: string) => write(join('./lib', path), file(path));
5
- export const exec: (...args: Parameters<typeof $>) => Promise<any> = async (...args) => $(...args).catch((err) => process.stderr.write(err.stderr));
package/src/constants.ts DELETED
@@ -1,7 +0,0 @@
1
- // Compiler constants
2
- export const REQ = '__req';
3
- export const PATH = `${REQ}_p`;
4
- export const PATH_LEN = `${REQ}_pl`;
5
- export const PARAMS = `${REQ}_ps`;
6
- export const PREV_PARAM_IDX = `${REQ}_ppi`;
7
- export const CURRENT_PARAM_IDX = `${REQ}_cpi`;
package/src/index.ts DELETED
@@ -1,40 +0,0 @@
1
- import type { Builder } from '@mapl/compiler';
2
-
3
- import { compileNode } from './tree/compiler.js';
4
- import { createNode, insertItem as nodeInsertItem, type Node } from './tree/node.js';
5
-
6
- export type Router = [staticMap: Record<string, string> | null, root: Node | null];
7
-
8
- export function createRouter(): Router {
9
- return [null, null];
10
- }
11
-
12
- export function insertItem(router: Router, path: string, item: string): void {
13
- if (path.includes('*'))
14
- nodeInsertItem(router[1] ??= createNode('/'), path, item);
15
- else
16
- (router[0] ??= {})[path] = item;
17
- }
18
-
19
- export function compileRouter(router: Router, contentBuilder: Builder<string>): void {
20
- const hasStatic = router[0] !== null;
21
-
22
- if (hasStatic) {
23
- const staticMap = router[0];
24
- let hasMultiple = false;
25
-
26
- for (const key in staticMap) {
27
- contentBuilder.push(`${hasMultiple ? 'else ' : ''}if(${compilerConstants.PATH}==="${key.slice(1).replace(/"/g, '\\"')}"){${staticMap[key]}}`);
28
- hasMultiple = true;
29
- }
30
- }
31
-
32
- if (router[1] !== null) {
33
- if (hasStatic) contentBuilder.push('else{');
34
-
35
- contentBuilder.push(`let ${compilerConstants.PATH_LEN}=${compilerConstants.PATH}.length;`);
36
- compileNode(router[1], contentBuilder, false, false, -1, '');
37
-
38
- if (hasStatic) contentBuilder.push('}');
39
- }
40
- }
@@ -1,133 +0,0 @@
1
- import type { Builder } from '@mapl/compiler';
2
- import type { Node } from './node.js';
3
-
4
- export function compileNode(
5
- node: Node,
6
- builder: Builder<string>,
7
-
8
- // Whether the current path has a parameter
9
- hasParam: boolean,
10
- hasMultipleParams: boolean,
11
-
12
- // Current start index
13
- startIndexValue: number,
14
- startIndexPrefix: string
15
- ): void {
16
- const part = node[0];
17
- const partLen = part.length;
18
-
19
- // Same optimization as in the matcher
20
- startIndexValue++;
21
- if (partLen !== 1) {
22
- builder.push(`if(${compilerConstants.PATH_LEN}>${startIndexPrefix}${startIndexValue + partLen - 2})`);
23
-
24
- for (let i = 1; i < partLen; i++, startIndexValue++) builder.push(`if(${compilerConstants.PATH}.charCodeAt(${startIndexPrefix}${startIndexValue})===${part.charCodeAt(i)})`);
25
-
26
- builder.push('{');
27
- }
28
-
29
- if (node[1] !== null)
30
- builder.push(`if(${compilerConstants.PATH_LEN}===${startIndexPrefix}${startIndexValue}){${node[1]}}`);
31
-
32
- if (node[2] !== null) {
33
- const children = node[2];
34
- const childrenKeys = Object.keys(children);
35
-
36
- if (childrenKeys.length === 1) {
37
- // A single if statement is enough
38
- builder.push(`if(${compilerConstants.PATH}.charCodeAt(${startIndexPrefix}${startIndexValue})===${childrenKeys[0]}){`);
39
- compileNode(
40
- children[childrenKeys[0] as unknown as number],
41
- builder,
42
- hasParam,
43
- hasMultipleParams,
44
- startIndexValue,
45
- startIndexPrefix
46
- );
47
- builder.push('}');
48
- } else {
49
- // Setup switch cases
50
- builder.push(`switch(${compilerConstants.PATH}.charCodeAt(${startIndexPrefix}${startIndexValue})){`);
51
-
52
- for (let i = 0, l = childrenKeys.length; i < l; i++) {
53
- builder.push(`case ${childrenKeys[i]}:`);
54
- compileNode(
55
- children[childrenKeys[i] as unknown as number],
56
- builder,
57
- hasParam,
58
- hasMultipleParams,
59
- startIndexValue,
60
- startIndexPrefix
61
- );
62
- builder.push('break;');
63
- }
64
-
65
- builder.push('}');
66
- }
67
- }
68
-
69
- if (node[3] !== null) {
70
- const params = node[3];
71
- const hasStore = params[1] !== null;
72
- const hasChild = params[0] !== null;
73
-
74
- // Whether to wrap the parameter check in a scope
75
- const requireAllocation = hasParam
76
- ? hasMultipleParams
77
- : hasChild || !hasStore;
78
- if (requireAllocation) builder.push('{');
79
-
80
- // Declare a variable to save previous param index
81
- if (hasParam)
82
- builder.push(`${hasMultipleParams ? '' : 'let '}${compilerConstants.PREV_PARAM_IDX}=${startIndexPrefix}${startIndexValue};`);
83
-
84
- const currentIndex = hasParam
85
- ? compilerConstants.PREV_PARAM_IDX
86
- : startIndexPrefix + startIndexValue;
87
- const slashIndex = `${compilerConstants.PATH}.indexOf('/',${currentIndex})`;
88
-
89
- // Need to save the current parameter index if the parameter node is not a leaf node
90
- if (hasChild || !hasStore)
91
- builder.push(`${hasParam ? '' : 'let '}${compilerConstants.CURRENT_PARAM_IDX}=${slashIndex};`);
92
-
93
- if (hasStore) {
94
- const paramsVal = `${compilerConstants.PATH}.slice(${currentIndex})`;
95
- builder.push(`if(${hasChild ? compilerConstants.CURRENT_PARAM_IDX : slashIndex}===-1){${hasParam ? `${compilerConstants.PARAMS}.push(${paramsVal})` : `let ${compilerConstants.PARAMS}=[${paramsVal}]`};${params[1]}}`);
96
- }
97
-
98
- if (hasChild) {
99
- const paramsVal = `${compilerConstants.PATH}.substring(${currentIndex},${compilerConstants.CURRENT_PARAM_IDX})`;
100
- builder.push(`if(${hasStore ? '' : `${compilerConstants.CURRENT_PARAM_IDX}!==-1&&`}${compilerConstants.CURRENT_PARAM_IDX}!==${currentIndex}){${hasParam ? `${compilerConstants.PARAMS}.push(${paramsVal})` : `let ${compilerConstants.PARAMS}=[${paramsVal}]`};`);
101
- compileNode(
102
- params[0]!,
103
- builder,
104
- true,
105
- hasParam,
106
- 0,
107
- `${compilerConstants.CURRENT_PARAM_IDX}+`
108
- );
109
-
110
- // Don't need to pop when scope is closed
111
- if (!requireAllocation) builder.push(`${compilerConstants.PARAMS}.pop();`);
112
-
113
- builder.push('}');
114
- }
115
-
116
- // Close the scope
117
- if (requireAllocation) builder.push('}');
118
- }
119
-
120
- if (node[4] !== null) {
121
- const noStore = node[1] === null;
122
-
123
- // Wildcard should not match static case
124
- if (noStore) builder.push(`if(${compilerConstants.PATH_LEN}!==${startIndexPrefix}${startIndexValue}){`);
125
-
126
- const paramsVal = `${compilerConstants.PATH}.slice(${startIndexPrefix}${startIndexValue})`;
127
- builder.push(`${hasParam ? `${compilerConstants.PARAMS}.push(${paramsVal})` : `let ${compilerConstants.PARAMS}=[${paramsVal}]`};${node[4]}`);
128
-
129
- if (noStore) builder.push('}');
130
- }
131
-
132
- if (partLen !== 1) builder.push('}');
133
- }
package/src/tree/node.ts DELETED
@@ -1,122 +0,0 @@
1
- export type Node = [
2
- part: string,
3
-
4
- store: string | null,
5
- children: Record<number, Node> | null,
6
- params: ParamNode | null,
7
-
8
- wildcardStore: string | null
9
- ];
10
-
11
- export type ParamNode = [
12
- child: Node | null,
13
- store: string | null
14
- ];
15
-
16
- // Implementations
17
- export function createNode(part: string): Node {
18
- return [part, null, null, null, null];
19
- }
20
-
21
- export function createParamNode(nextNode: ParamNode[0]): ParamNode {
22
- return [nextNode, null];
23
- }
24
-
25
- export function cloneNode(node: Node, part: string): Node {
26
- return [part, node[1], node[2], node[3], node[4]];
27
- }
28
-
29
- export function resetNode(node: Node, part: string, children: Node[2]): void {
30
- node[0] = part;
31
- node[2] = children;
32
-
33
- node[1] = null;
34
- node[3] = null;
35
- node[4] = null;
36
- }
37
-
38
- // Travel until the end of the node (path should not include end param or wildcard)
39
- export function visitNode(node: Node, path: string): Node {
40
- // Split path by param separator
41
- const parts = path.split('*');
42
-
43
- for (let i = 0, { length } = parts; i < length; ++i) {
44
- // Set param node
45
- if (i !== 0) {
46
- if (node[3] === null) {
47
- const nextNode = createNode(parts[i]);
48
- node[3] = createParamNode(nextNode);
49
- node = nextNode;
50
- } else
51
- node = node[3][0] ??= createNode(parts[i]);
52
- }
53
-
54
- for (let j = 0, pathPart = parts[i]; ; ++j) {
55
- const nodePart = node[0];
56
-
57
- // Reach the end of the pathname but node still continues
58
- if (j === pathPart.length) {
59
- if (j < nodePart.length) {
60
- const children: Node[2] = {};
61
- children[nodePart.charCodeAt(j)] = cloneNode(node, nodePart.slice(j));
62
- resetNode(node, pathPart, children);
63
- }
64
-
65
- break;
66
- }
67
-
68
- // Add static child
69
- if (j === nodePart.length) {
70
- if (node[2] === null)
71
- node[2] = {};
72
- else {
73
- const nextNode = node[2][pathPart.charCodeAt(j)];
74
-
75
- // Re-run loop with existing static node
76
- if (typeof nextNode !== 'undefined') {
77
- node = nextNode;
78
- pathPart = pathPart.slice(j);
79
- j = 0;
80
- continue;
81
- }
82
- }
83
-
84
- // Create and add new node
85
- const nextNode = createNode(pathPart.slice(j));
86
- node[2][pathPart.charCodeAt(j)] = nextNode;
87
- node = nextNode;
88
-
89
- break;
90
- }
91
-
92
- // Split into two paths
93
- if (pathPart.charCodeAt(j) !== nodePart.charCodeAt(j)) {
94
- // Split the old path
95
- const children: Node[2] = {};
96
- children[nodePart.charCodeAt(j)] = cloneNode(node, nodePart.slice(j));
97
-
98
- const nextNode = createNode(pathPart.slice(j));
99
- children[pathPart.charCodeAt(j)] = nextNode;
100
-
101
- resetNode(node, nodePart.substring(0, j), children);
102
-
103
- node = nextNode;
104
- break;
105
- }
106
- }
107
- }
108
-
109
- return node;
110
- }
111
-
112
- export function insertItem(node: Node, path: string, item: string): void {
113
- if (path.charCodeAt(path.length - 1) === 42) {
114
- // Ends with wildcard
115
- if (path.charCodeAt(path.length - 2) === 42)
116
- visitNode(node, path.substring(0, path.length - 2))[4] = item;
117
- // End with params
118
- else
119
- (visitNode(node, path.substring(0, path.length - 1))[3] ??= createParamNode(null))[1] = item;
120
- } else
121
- visitNode(node, path)[1] = item;
122
- }
@@ -1,54 +0,0 @@
1
- import { describe, test, expect } from 'bun:test';
2
- import { createRouter, insertItem } from '@mapl/router/index';
3
- import compileRouter from './utils/compileRouter';
4
-
5
- function runTest(samplePaths: string[]) {
6
- // Build the tree
7
- const router = createRouter();
8
- for (let i = 0; i < samplePaths.length; i++)
9
- insertItem(router, samplePaths[i], `return ${i};`);
10
- console.log(Bun.inspect(router));
11
-
12
- // Build result paths
13
- const resultPaths = samplePaths.map(
14
- (pattern) => pattern.endsWith('**')
15
- ? pattern.substring(1, pattern.length - 2) + '1/2/3'
16
- : pattern.slice(1)
17
- );
18
-
19
- describe(samplePaths.join(' - '), () => {
20
- const match = compileRouter(router);
21
- console.log(match.toString());
22
-
23
- for (let i = 0; i < samplePaths.length; i++)
24
- test(`${samplePaths[i]}: ${i}`, () => {
25
- expect(match(resultPaths[i])).toBe(i);
26
- });
27
- });
28
- }
29
-
30
- runTest([
31
- '/',
32
- '/about',
33
-
34
- '/*',
35
- '/*/navigate',
36
- '/**',
37
-
38
- '/user/*',
39
- '/user/*/dashboard/**',
40
-
41
- '/category/*',
42
- '/category/*/filter/*',
43
- '/category/*/filter/*/exclude',
44
- ]);
45
-
46
- runTest([
47
- '/*/file',
48
- '/*'
49
- ]);
50
-
51
- runTest([
52
- '/api/works/*/lock',
53
- '/api/staff/*'
54
- ]);
@@ -1,50 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- // Enable latest features
4
- "lib": [
5
- "ESNext",
6
- "DOM",
7
- "DOM.Iterable"
8
- ],
9
- "target": "ESNext",
10
- "module": "Preserve",
11
- "moduleDetection": "force",
12
- "resolveJsonModule": true,
13
- "isolatedModules": true,
14
- "jsx": "react-jsx",
15
- "allowJs": true,
16
- // Bundler mode
17
- "moduleResolution": "bundler",
18
- "allowImportingTsExtensions": true,
19
- "verbatimModuleSyntax": true,
20
- // Best practices
21
- "strict": true,
22
- "skipLibCheck": true,
23
- "noFallthroughCasesInSwitch": true,
24
- // Some stricter flags (disabled by default)
25
- "noUnusedLocals": false,
26
- "noImplicitAny": true,
27
- "noImplicitOverride": true,
28
- "noImplicitThis": true,
29
- "noUnusedParameters": false,
30
- "noPropertyAccessFromIndexSignature": false,
31
- // Output
32
- "declaration": true,
33
- "declarationDir": "lib",
34
- "emitDeclarationOnly": true,
35
- "stripInternal": true,
36
- "extendedDiagnostics": true,
37
- // Alias
38
- "paths": {
39
- "@mapl/router/*": [
40
- "../lib/*"
41
- ],
42
- "@mapl/router": [
43
- "../lib/index.js"
44
- ]
45
- }
46
- },
47
- "include": [
48
- "."
49
- ]
50
- }
@@ -1,10 +0,0 @@
1
- import { PATH } from '@mapl/router/constants';
2
- import { compileRouter as compileRouterContent, type Router } from '@mapl/router/index';
3
-
4
- export default function compileRouter(root: Router): (path: string) => any {
5
- const contentBuilder = [] as string[];
6
- compileRouterContent(root, contentBuilder);
7
-
8
- // eslint-disable-next-line
9
- return Function(`return (${PATH})=>{${contentBuilder.join('')}return null;}`)();
10
- }
package/tsconfig.json DELETED
@@ -1,35 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- // Enable latest features
4
- "lib": ["ESNext", "DOM", "DOM.Iterable"],
5
- "target": "ESNext",
6
- "module": "NodeNext",
7
- "moduleDetection": "force",
8
- "resolveJsonModule": true,
9
- "isolatedModules": true,
10
- "jsx": "react-jsx",
11
- "allowJs": true,
12
- // Bundler mode
13
- "moduleResolution": "NodeNext",
14
- "allowImportingTsExtensions": true,
15
- "verbatimModuleSyntax": true,
16
- // Best practices
17
- "strict": true,
18
- "skipLibCheck": true,
19
- "noFallthroughCasesInSwitch": true,
20
- // Some stricter flags (disabled by default)
21
- "noUnusedLocals": false,
22
- "noImplicitAny": true,
23
- "noImplicitOverride": true,
24
- "noImplicitThis": true,
25
- "noUnusedParameters": false,
26
- "noPropertyAccessFromIndexSignature": false,
27
- // Output
28
- "declaration": true,
29
- "declarationDir": "lib",
30
- "emitDeclarationOnly": true,
31
- "stripInternal": true,
32
- "extendedDiagnostics": true
33
- },
34
- "include": ["src", "./globals.d.ts"]
35
- }