@wavelengthusaf/client-router 0.0.1 → 0.0.2

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.
Files changed (68) hide show
  1. package/dist/src/elements/RouteElement.d.ts +11 -0
  2. package/dist/src/elements/RouteElement.d.ts.map +1 -0
  3. package/dist/src/elements/RouterElement.d.ts +12 -0
  4. package/dist/src/elements/RouterElement.d.ts.map +1 -0
  5. package/dist/src/index.d.ts +6 -0
  6. package/dist/src/index.d.ts.map +1 -0
  7. package/dist/src/models/CompiledRoute.d.ts +7 -0
  8. package/dist/src/models/CompiledRoute.d.ts.map +1 -0
  9. package/dist/src/models/MatchedRoute.d.ts +7 -0
  10. package/dist/src/models/MatchedRoute.d.ts.map +1 -0
  11. package/dist/src/models/RouteComponent.d.ts +6 -0
  12. package/dist/src/models/RouteComponent.d.ts.map +1 -0
  13. package/dist/src/models/RouteContext.d.ts +7 -0
  14. package/dist/src/models/RouteContext.d.ts.map +1 -0
  15. package/dist/src/models/RouteDefinition.d.ts +6 -0
  16. package/dist/src/models/RouteDefinition.d.ts.map +1 -0
  17. package/dist/src/models/RouteGuard.d.ts +3 -0
  18. package/dist/src/models/RouteGuard.d.ts.map +1 -0
  19. package/dist/src/models/RouteParams.d.ts +4 -0
  20. package/dist/src/models/RouteParams.d.ts.map +1 -0
  21. package/dist/src/models/index.d.ts +9 -0
  22. package/dist/src/models/index.d.ts.map +1 -0
  23. package/dist/src/router/Router.d.ts +20 -0
  24. package/dist/src/router/Router.d.ts.map +1 -0
  25. package/dist/src/utils/compileRoute.d.ts +3 -0
  26. package/dist/src/utils/compileRoute.d.ts.map +1 -0
  27. package/dist/src/utils/index.d.ts +4 -0
  28. package/dist/src/utils/index.d.ts.map +1 -0
  29. package/dist/src/utils/matchRoute.d.ts +3 -0
  30. package/dist/src/utils/matchRoute.d.ts.map +1 -0
  31. package/package.json +7 -1
  32. package/.gitlab-ci.yml +0 -84
  33. package/.husky/pre-commit +0 -38
  34. package/.storybook/main.ts +0 -16
  35. package/.storybook/manager.ts +0 -7
  36. package/.storybook/preview.ts +0 -23
  37. package/.storybook/theme.ts +0 -30
  38. package/.storybook/vitest.setup.ts +0 -7
  39. package/eslint.config.mjs +0 -89
  40. package/index.ts +0 -15
  41. package/prettier.config.ts +0 -30
  42. package/src/elements/RouteElement.ts +0 -67
  43. package/src/elements/RouterElement.ts +0 -97
  44. package/src/elements/__tests__/RouteElement.test.ts +0 -89
  45. package/src/elements/__tests__/RouterElement.test.ts +0 -253
  46. package/src/index.ts +0 -15
  47. package/src/models/CompiledRoute.ts +0 -7
  48. package/src/models/MatchedRoute.ts +0 -7
  49. package/src/models/RouteComponent.ts +0 -6
  50. package/src/models/RouteContext.ts +0 -7
  51. package/src/models/RouteDefinition.ts +0 -6
  52. package/src/models/RouteGuard.ts +0 -6
  53. package/src/models/RouteParams.ts +0 -3
  54. package/src/models/index.ts +0 -17
  55. package/src/router/Router.ts +0 -225
  56. package/src/router/__tests__/Router.test.ts +0 -464
  57. package/src/stories/RouterElement.stories.test.ts +0 -310
  58. package/src/stories/RouterElement.stories.ts +0 -208
  59. package/src/utils/__tests__/compileRoute.test.ts +0 -97
  60. package/src/utils/__tests__/matchRoute.test.ts +0 -180
  61. package/src/utils/compileRoute.ts +0 -37
  62. package/src/utils/index.ts +0 -4
  63. package/src/utils/matchRoute.ts +0 -37
  64. package/tsconfig.build.json +0 -20
  65. package/tsconfig.json +0 -55
  66. package/vitest.config.ts +0 -34
  67. package/vitest.setup.ts +0 -3
  68. package/vitest.shims.d.ts +0 -1
@@ -0,0 +1,11 @@
1
+ import type { RouteDefinition } from '../models/index.ts';
2
+ export interface RouteElementEnv {
3
+ document?: Document;
4
+ }
5
+ export declare class RouteElement extends HTMLElement {
6
+ static readonly tag = "wavelength-route";
7
+ get path(): string;
8
+ get componentTag(): string;
9
+ toDefinition(env?: RouteElementEnv): RouteDefinition | null;
10
+ }
11
+ //# sourceMappingURL=RouteElement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RouteElement.d.ts","sourceRoot":"","sources":["../../../src/elements/RouteElement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,eAAe,EAChB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,qBAAa,YAAa,SAAQ,WAAW;IAC3C,gBAAuB,GAAG,sBAAsB;IAEhD,IAAW,IAAI,IAAI,MAAM,CAExB;IAED,IAAW,YAAY,IAAI,MAAM,CAEhC;IAEM,YAAY,CAAC,GAAG,GAAE,eAAoB,GAAG,eAAe,GAAG,IAAI;CAyCvE"}
@@ -0,0 +1,12 @@
1
+ export declare class RouterElement extends HTMLElement {
2
+ #private;
3
+ static readonly tag = "wavelength-router";
4
+ static get observedAttributes(): string[];
5
+ connectedCallback(): void;
6
+ disconnectedCallback(): void;
7
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
8
+ navigate(path: string): void;
9
+ replace(path: string): void;
10
+ back(): void;
11
+ }
12
+ //# sourceMappingURL=RouterElement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RouterElement.d.ts","sourceRoot":"","sources":["../../../src/elements/RouterElement.ts"],"names":[],"mappings":"AAIA,qBAAa,aAAc,SAAQ,WAAW;;IAC5C,gBAAuB,GAAG,uBAAuB;IAIjD,WAAkB,kBAAkB,IAAI,MAAM,EAAE,CAE/C;IAEM,iBAAiB,IAAI,IAAI;IAIzB,oBAAoB,IAAI,IAAI;IAI5B,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAK9F,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAI5B,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAI3B,IAAI,IAAI,IAAI;CA0DpB"}
@@ -0,0 +1,6 @@
1
+ export { Router } from './router/Router.ts';
2
+ export { RouterElement } from './elements/RouterElement.ts';
3
+ export { RouteElement } from './elements/RouteElement.ts';
4
+ export type { RouteComponent, RouteContext, RouteDefinition, RouteGuard, RouteParams, CompiledRoute, MatchedRoute, } from './models/index.ts';
5
+ export { compileRoute, matchRoute } from './utils/index.ts';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,YAAY,EACV,cAAc,EACd,YAAY,EACZ,eAAe,EACf,UAAU,EACV,WAAW,EACX,aAAa,EACb,YAAY,GACb,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { RouteDefinition } from './RouteDefinition.js';
2
+ export interface CompiledRoute {
3
+ routeDefinition: RouteDefinition;
4
+ pattern: RegExp;
5
+ paramNames: string[];
6
+ }
7
+ //# sourceMappingURL=CompiledRoute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CompiledRoute.d.ts","sourceRoot":"","sources":["../../../src/models/CompiledRoute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,MAAM,WAAW,aAAa;IAC5B,eAAe,EAAE,eAAe,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB"}
@@ -0,0 +1,7 @@
1
+ import type { RouteDefinition } from './RouteDefinition.ts';
2
+ import type { RouteParams } from './RouteParams.ts';
3
+ export interface MatchedRoute {
4
+ routeDefinition: RouteDefinition;
5
+ routeParams: RouteParams;
6
+ }
7
+ //# sourceMappingURL=MatchedRoute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MatchedRoute.d.ts","sourceRoot":"","sources":["../../../src/models/MatchedRoute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,MAAM,WAAW,YAAY;IAC3B,eAAe,EAAE,eAAe,CAAC;IACjC,WAAW,EAAE,WAAW,CAAC;CAC1B"}
@@ -0,0 +1,6 @@
1
+ import type { RouteContext } from './RouteContext.ts';
2
+ export interface RouteComponent {
3
+ mount(container: HTMLElement, context: RouteContext): void;
4
+ unmount?(): void;
5
+ }
6
+ //# sourceMappingURL=RouteComponent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RouteComponent.d.ts","sourceRoot":"","sources":["../../../src/models/RouteComponent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI,CAAC;IAC3D,OAAO,CAAC,IAAI,IAAI,CAAC;CAClB"}
@@ -0,0 +1,7 @@
1
+ import type { RouteParams } from './RouteParams.ts';
2
+ export interface RouteContext {
3
+ path: string;
4
+ routeParams: RouteParams;
5
+ query: URLSearchParams;
6
+ }
7
+ //# sourceMappingURL=RouteContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RouteContext.d.ts","sourceRoot":"","sources":["../../../src/models/RouteContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,WAAW,CAAC;IACzB,KAAK,EAAE,eAAe,CAAC;CACxB"}
@@ -0,0 +1,6 @@
1
+ import type { RouteComponent } from './RouteComponent.ts';
2
+ export interface RouteDefinition {
3
+ path: string;
4
+ routeComponent: RouteComponent;
5
+ }
6
+ //# sourceMappingURL=RouteDefinition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RouteDefinition.d.ts","sourceRoot":"","sources":["../../../src/models/RouteDefinition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,cAAc,CAAC;CAChC"}
@@ -0,0 +1,3 @@
1
+ import type { RouteContext } from './RouteContext.ts';
2
+ export type RouteGuard = (to: RouteContext, next: (redirect?: string) => void) => void;
3
+ //# sourceMappingURL=RouteGuard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RouteGuard.d.ts","sourceRoot":"","sources":["../../../src/models/RouteGuard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,MAAM,MAAM,UAAU,GAAG,CACvB,EAAE,EAAE,YAAY,EAChB,IAAI,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,KAC9B,IAAI,CAAC"}
@@ -0,0 +1,4 @@
1
+ export interface RouteParams {
2
+ [key: string]: string;
3
+ }
4
+ //# sourceMappingURL=RouteParams.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RouteParams.d.ts","sourceRoot":"","sources":["../../../src/models/RouteParams.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB"}
@@ -0,0 +1,9 @@
1
+ import type { CompiledRoute } from './CompiledRoute.ts';
2
+ import type { MatchedRoute } from './MatchedRoute.ts';
3
+ import type { RouteComponent } from './RouteComponent.ts';
4
+ import type { RouteContext } from './RouteContext.ts';
5
+ import type { RouteDefinition } from './RouteDefinition.ts';
6
+ import type { RouteGuard } from './RouteGuard.ts';
7
+ import type { RouteParams } from './RouteParams.ts';
8
+ export type { CompiledRoute, MatchedRoute, RouteComponent, RouteContext, RouteDefinition, RouteGuard, RouteParams, };
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/models/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,YAAY,EACV,aAAa,EACb,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,eAAe,EACf,UAAU,EACV,WAAW,GACZ,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { RouteDefinition, RouteGuard } from '../models/index.ts';
2
+ export interface RouterEnv {
3
+ window?: Window;
4
+ document?: Document;
5
+ }
6
+ export interface RouterOptions {
7
+ outlet?: HTMLElement;
8
+ hashMode?: boolean;
9
+ beforeEach?: RouteGuard;
10
+ }
11
+ export declare class Router {
12
+ #private;
13
+ constructor(routeDefinitions: RouteDefinition[], routerOptions?: RouterOptions, env?: RouterEnv);
14
+ start(): void;
15
+ destroy(): void;
16
+ navigate(path: string): void;
17
+ replace(path: string): void;
18
+ back(): void;
19
+ }
20
+ //# sourceMappingURL=Router.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Router.d.ts","sourceRoot":"","sources":["../../../src/router/Router.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAKV,eAAe,EACf,UAAU,EACX,MAAM,oBAAoB,CAAC;AAG5B,MAAM,WAAW,SAAS;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;AAED,qBAAa,MAAM;;gBAYf,gBAAgB,EAAE,eAAe,EAAE,EACnC,aAAa,GAAE,aAAkB,EACjC,GAAG,GAAE,SAAc;IAoBd,KAAK,IAAI,IAAI;IAab,OAAO,IAAI,IAAI;IAUf,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAY5B,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAY3B,IAAI,IAAI,IAAI;CA0HpB"}
@@ -0,0 +1,3 @@
1
+ import type { CompiledRoute, RouteDefinition } from '../models/index.ts';
2
+ export declare function compileRoute(routeDefinition: RouteDefinition): CompiledRoute;
3
+ //# sourceMappingURL=compileRoute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compileRoute.d.ts","sourceRoot":"","sources":["../../../src/utils/compileRoute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAMzE,wBAAgB,YAAY,CAAC,eAAe,EAAE,eAAe,GAAG,aAAa,CA8B5E"}
@@ -0,0 +1,4 @@
1
+ import { compileRoute } from './compileRoute.ts';
2
+ import { matchRoute } from './matchRoute.ts';
3
+ export { compileRoute, matchRoute };
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { CompiledRoute, MatchedRoute } from '../models/index.ts';
2
+ export declare function matchRoute(compiledRoutes: CompiledRoute[], pathname: string): MatchedRoute | null;
3
+ //# sourceMappingURL=matchRoute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matchRoute.d.ts","sourceRoot":"","sources":["../../../src/utils/matchRoute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EAEb,MAAM,oBAAoB,CAAC;AAE5B,wBAAgB,UAAU,CACtB,cAAc,EAAE,aAAa,EAAE,EAC/B,QAAQ,EAAE,MAAM,GACjB,YAAY,GAAG,IAAI,CA2BrB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wavelengthusaf/client-router",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Native TypeScript Router",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -22,6 +22,12 @@
22
22
  "author": "Wavelength",
23
23
  "license": "ISC",
24
24
  "type": "module",
25
+ "files": [
26
+ "dist"
27
+ ],
28
+ "publishConfig": {
29
+ "access": "public"
30
+ },
25
31
  "devDependencies": {
26
32
  "@happy-dom/global-registrator": "^20.9.0",
27
33
  "@storybook/addon-a11y": "^10.3.5",
package/.gitlab-ci.yml DELETED
@@ -1,84 +0,0 @@
1
- stages:
2
- - setup
3
- - build
4
- - test
5
- - security
6
- - deploy
7
-
8
- variables:
9
- GIT_CLONE_PATH: $CI_BUILDS_DIR/$CI_CONCURRENT_ID/$CI_PROJECT_PATH
10
- NODE_VERSION: '22'
11
-
12
- cache:
13
- key: ${CI_COMMIT_REF_SLUG}
14
- paths:
15
- - node_modules/
16
-
17
- include:
18
- - template: Jobs/SAST.gitlab-ci.yml
19
- - template: Jobs/Secret-Detection.gitlab-ci.yml
20
- - template: Jobs/Dependency-Scanning.gitlab-ci.yml
21
-
22
- setup:
23
- stage: setup
24
- image: node:${NODE_VERSION}-alpine
25
- before_script:
26
- - npm ci
27
- script:
28
- - echo "Dependencies installed"
29
- artifacts:
30
- paths:
31
- - node_modules/
32
- expire_in: 1 week
33
-
34
- build:
35
- stage: build
36
- needs: ['setup']
37
- image: node:${NODE_VERSION}-alpine
38
- script:
39
- - npm run build
40
- artifacts:
41
- paths:
42
- - dist/
43
-
44
- lint:
45
- stage: test
46
- needs: ['setup']
47
- image: node:${NODE_VERSION}-alpine
48
- script:
49
- - npm run lint
50
- allow_failure: false
51
-
52
- test:
53
- stage: test
54
- needs: ['setup']
55
- image: node:${NODE_VERSION}-alpine
56
- script:
57
- - npm run test
58
- allow_failure: false
59
- coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/'
60
-
61
- publish:npm:
62
- stage: deploy
63
- image: node:${NODE_VERSION}-alpine
64
- needs: ['setup', 'test']
65
- script:
66
- - echo "//registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN" > .npmrc
67
- - npm publish --access public
68
- rules:
69
- - if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/
70
- - if: $CI_COMMIT_BRANCH == "master"
71
-
72
- pages:
73
- stage: deploy
74
- image: node:${NODE_VERSION}-alpine
75
- needs: ['setup', 'build']
76
- script:
77
- - npm run build-storybook -- -o public
78
- - echo '<meta name="robots" content="noindex" />' >> public/index.html
79
- artifacts:
80
- paths:
81
- - public/
82
- expire_in: 30 days
83
- rules:
84
- - if: $CI_COMMIT_BRANCH == "master"
package/.husky/pre-commit DELETED
@@ -1,38 +0,0 @@
1
- #!/usr/bin/env sh
2
- echo ------------------------------
3
- echo Running Husky Pre-Commit Hooks
4
- echo ------------------------------
5
- echo
6
- echo
7
- echo ----------------------------------
8
- echo Running Unit Tests
9
- echo ----------------------------------
10
- npm run test -- $(git diff --diff-filter=d --name-only --staged) --passWithNoTests
11
- if [ $? -ne 0 ]; then
12
- echo
13
- echo "Unit tests failed!"
14
- echo
15
- exit 1
16
- else
17
- echo
18
- echo "Unit tests passed!"
19
- echo
20
- fi
21
- echo ---------------------------
22
- echo Running Eslint and Prettier
23
- echo ---------------------------
24
- npx eslint --fix $(git diff --diff-filter=d --name-only --staged | grep -E '\.(js|ts|tsx)$')
25
- if [ $? -ne 0 ]; then
26
- echo
27
- echo "ESLint failed with errors."
28
- echo
29
- exit 1
30
- else
31
- echo
32
- echo "ESLint passed successfully."
33
- echo
34
- fi
35
- echo
36
- echo Pre-commit checks passed!
37
- exit 0
38
-
@@ -1,16 +0,0 @@
1
- const config = {
2
- stories: ['../src/stories/**/*.stories.ts'],
3
-
4
- framework: {
5
- name: '@storybook/web-components-vite',
6
- options: {},
7
- },
8
-
9
- addons: [
10
- '@storybook/addon-links',
11
- '@storybook/addon-docs',
12
- '@storybook/addon-a11y',
13
- ],
14
- };
15
-
16
- export default config;
@@ -1,7 +0,0 @@
1
- import { addons } from 'storybook/manager-api';
2
-
3
- import theme from './theme.ts';
4
-
5
- addons.setConfig({
6
- theme,
7
- });
@@ -1,23 +0,0 @@
1
- import type { Preview } from '@storybook/web-components';
2
-
3
- const preview: Preview = {
4
- parameters: {
5
- controls: {
6
- matchers: {
7
- color: /(background|color)$/i,
8
- date: /Date$/i,
9
- },
10
- },
11
- docs: {
12
- source: {
13
- language: 'ts',
14
- format: 'dedent',
15
- },
16
- },
17
- a11y: {
18
- element: 'wavelength-router',
19
- },
20
- },
21
- };
22
-
23
- export default preview;
@@ -1,30 +0,0 @@
1
- import { create } from 'storybook/theming';
2
-
3
- export default create({
4
- base: 'light',
5
-
6
- colorPrimary: '#007fff',
7
- colorSecondary: '#007fff',
8
-
9
- appBg: '#ffffff',
10
- appContentBg: '#ffffff',
11
- appBorderColor: '#e0e0e0',
12
- appBorderRadius: 4,
13
-
14
- textColor: 'rgba(0, 0, 0, 0.87)',
15
- textInverseColor: '#ffffff',
16
- textMutedColor: 'rgba(0, 0, 0, 0.6)',
17
-
18
- barTextColor: 'rgba(0, 0, 0, 0.6)',
19
- barSelectedColor: '#007fff',
20
- barBg: '#ffffff',
21
- barHoverColor: '#f0f0f0',
22
-
23
- inputBg: '#ffffff',
24
- inputBorder: '#e0e0e0',
25
- inputTextColor: 'rgba(0, 0, 0, 0.87)',
26
- inputBorderRadius: 4,
27
-
28
- booleanBg: '#f6f8fa',
29
- booleanSelectedBg: '#e6f4ff',
30
- });
@@ -1,7 +0,0 @@
1
- import { setProjectAnnotations } from '@storybook/web-components-vite';
2
-
3
- import * as projectAnnotations from './preview.ts';
4
-
5
- // This is an important step to apply the right configuration when testing your stories.
6
- // More info at: https://storybook.js.org/docs/api/portable-stories/portable-stories-vitest#setprojectannotations
7
- setProjectAnnotations([projectAnnotations]);
package/eslint.config.mjs DELETED
@@ -1,89 +0,0 @@
1
- import prettier from 'eslint-config-prettier';
2
- import sonarjs from 'eslint-plugin-sonarjs';
3
- import storybook from 'eslint-plugin-storybook';
4
- import wc from 'eslint-plugin-wc';
5
- import globals from 'globals';
6
- import tsEslint from 'typescript-eslint';
7
-
8
- export default tsEslint.config(
9
- {
10
- ignores: ['dist/**', 'node_modules/**', 'coverage/**', '.storybook/**'],
11
- },
12
-
13
- ...tsEslint.configs.recommended,
14
- sonarjs.configs.recommended,
15
-
16
- {
17
- files: ['src/**/*.ts'],
18
- plugins: {
19
- wc,
20
- },
21
- languageOptions: {
22
- parser: tsEslint.parser,
23
- parserOptions: {
24
- projectService: true,
25
- tsconfigRootDir: import.meta.dirname,
26
- },
27
- globals: {
28
- ...globals.browser,
29
- ...globals.node,
30
- },
31
- },
32
- rules: {
33
- '@typescript-eslint/explicit-member-accessibility': [
34
- 'error',
35
- {
36
- accessibility: 'explicit',
37
- overrides: {
38
- constructors: 'no-public',
39
- },
40
- },
41
- ],
42
- '@typescript-eslint/consistent-type-exports': 'error',
43
- '@typescript-eslint/no-import-type-side-effects': 'error',
44
- '@typescript-eslint/no-explicit-any': 'error',
45
-
46
- ...wc.configs.recommended.rules,
47
-
48
- 'wc/no-constructor-attributes': 'error',
49
- 'wc/no-invalid-element-name': 'error',
50
- 'wc/guard-super-call': 'error',
51
- 'wc/attach-shadow-constructor': 'off',
52
- 'wc/no-self-class': 'off',
53
-
54
- 'sonarjs/todo-tag': 'warn',
55
- 'sonarjs/no-selector-parameter': 'off',
56
- },
57
- },
58
-
59
- {
60
- files: ['**/*.test.ts', '**/*.spec.ts', 'src/**/*.stories.ts'],
61
- languageOptions: {
62
- parserOptions: {
63
- projectService: {
64
- allowDefaultProject: ['*.ts', '*.tsx'],
65
- extendedReports: true,
66
- },
67
- tsconfigRootDir: import.meta.dirname,
68
- },
69
- globals: {
70
- ...globals.node,
71
- Bun: 'readonly',
72
- describe: 'readonly',
73
- it: 'readonly',
74
- expect: 'readonly',
75
- test: 'readonly',
76
- beforeAll: 'readonly',
77
- afterAll: 'readonly',
78
- beforeEach: 'readonly',
79
- afterEach: 'readonly',
80
- },
81
- },
82
- rules: {
83
- '@typescript-eslint/no-unused-expressions': 'error',
84
- },
85
- },
86
-
87
- ...storybook.configs['flat/recommended'],
88
- prettier,
89
- );
package/index.ts DELETED
@@ -1,15 +0,0 @@
1
- export { Router } from './src/router/Router.ts';
2
- export { RouterElement } from './src/elements/RouterElement.ts';
3
- export { RouteElement } from './src/elements/RouteElement.ts';
4
-
5
- export type {
6
- RouteComponent,
7
- RouteContext,
8
- RouteDefinition,
9
- RouteGuard,
10
- RouteParams,
11
- CompiledRoute,
12
- MatchedRoute,
13
- } from './src/models/index.ts';
14
-
15
- export { compileRoute, matchRoute } from './src/utils/index.ts';
@@ -1,30 +0,0 @@
1
- import type { Config } from 'prettier';
2
-
3
- const config: Config = {
4
- endOfLine: 'lf',
5
- arrowParens: 'always',
6
- semi: true,
7
- trailingComma: 'all',
8
- singleQuote: true,
9
- printWidth: 80,
10
- tabWidth: 2,
11
- useTabs: false,
12
- plugins: ['@trivago/prettier-plugin-sort-imports'],
13
- importOrder: [
14
- '^bun.*$',
15
- '<THIRD_PARTY_MODULES>',
16
- '^@/(.*)$',
17
- '^[../]',
18
- '^[./]',
19
- '(.css|.scss)$',
20
- ],
21
- importOrderSeparation: true,
22
- importOrderSortSpecifiers: true,
23
- importOrderParserPlugins: [
24
- 'typescript',
25
- 'decorators-legacy',
26
- 'importAssertions',
27
- ],
28
- };
29
-
30
- export default config;
@@ -1,67 +0,0 @@
1
- import type {
2
- RouteComponent,
3
- RouteContext,
4
- RouteDefinition,
5
- } from '../models/index.ts';
6
-
7
- export interface RouteElementEnv {
8
- document?: Document;
9
- }
10
-
11
- export class RouteElement extends HTMLElement {
12
- public static readonly tag = 'wavelength-route';
13
-
14
- public get path(): string {
15
- return this.getAttribute('path') ?? '*';
16
- }
17
-
18
- public get componentTag(): string {
19
- return this.getAttribute('component') ?? '';
20
- }
21
-
22
- public toDefinition(env: RouteElementEnv = {}): RouteDefinition | null {
23
- const tag: string = this.componentTag;
24
- const doc: Document | undefined = env.document;
25
-
26
- if (!tag) {
27
- console.warn(
28
- `[route] Missing 'component' attribute on path="${this.path}"`,
29
- );
30
- return null;
31
- }
32
-
33
- if (!doc) {
34
- return {
35
- path: this.path,
36
- routeComponent: {
37
- mount() {},
38
- unmount() {},
39
- },
40
- };
41
- }
42
-
43
- const routeComponent: RouteComponent = {
44
- mount: (container: HTMLElement, routeContext: RouteContext) => {
45
- const element = doc.createElement(tag) as HTMLElement & {
46
- routeContext?: RouteContext;
47
- };
48
-
49
- element.routeContext = routeContext;
50
-
51
- container.appendChild(element);
52
- },
53
- unmount: () => {
54
- // optional: future cleanup hook
55
- },
56
- };
57
-
58
- return {
59
- path: this.path,
60
- routeComponent,
61
- };
62
- }
63
- }
64
-
65
- if (!customElements.get(RouteElement.tag)) {
66
- customElements.define(RouteElement.tag, RouteElement);
67
- }