@avolgha/mgcrt 0.1.0
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/README.md +48 -0
- package/dist/mgcrt.d.ts +192 -0
- package/dist/mgcrt.js +22 -0
- package/dist/mgcrt.js.map +1 -0
- package/license +18 -0
- package/package.json +43 -0
package/README.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# mgcrt
|
|
2
|
+
|
|
3
|
+
Simple JavaScript SPA router implementation.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<div class="links">
|
|
9
|
+
<button data-page="/">Page 1</button>
|
|
10
|
+
<button data-page="/page2">Page 2</button>
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
<div id="root"></div>
|
|
14
|
+
|
|
15
|
+
<script type="module" src="..."></script>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
```javascript
|
|
19
|
+
import { init as initMgcrt } from "./mgcrt.js";
|
|
20
|
+
|
|
21
|
+
initMgcrt({
|
|
22
|
+
container: document.getElementById("root"),
|
|
23
|
+
pages: [
|
|
24
|
+
{
|
|
25
|
+
path: "/",
|
|
26
|
+
template: document.createTextNode("Hello World from Page 1!"),
|
|
27
|
+
populate: () => {},
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
path: "/page2",
|
|
31
|
+
template: document.createTextNode("Hello World from @!"),
|
|
32
|
+
populate: (element) => {
|
|
33
|
+
element.textContent = element.textContent.replace("@", "Page 2");
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Build it yourself
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
$ pnpm install
|
|
44
|
+
$ pnpm build
|
|
45
|
+
$ cp dist/mgcrt.js ...
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
There are also `mgcrt.js.map` and `mgcrt.d.ts` available.
|
package/dist/mgcrt.d.ts
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright © 2026 avolgha
|
|
3
|
+
*
|
|
4
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
* of this software and associated documentation files (the “Software”), to deal
|
|
6
|
+
* in the Software without restriction, including without limitation the rights
|
|
7
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
* copies of the Software, and to permit persons to whom the Software is furnished
|
|
9
|
+
* to do so, subject to the following conditions:
|
|
10
|
+
*
|
|
11
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
* copies or substantial portions of the Software.
|
|
13
|
+
*
|
|
14
|
+
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
18
|
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
19
|
+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
20
|
+
*/
|
|
21
|
+
//#region src/types.d.ts
|
|
22
|
+
/**
|
|
23
|
+
* structural representation of a page.
|
|
24
|
+
*/
|
|
25
|
+
interface Page<PreloadData = never> extends Component<PreloadData> {
|
|
26
|
+
/**
|
|
27
|
+
* the raw path to the page prefixed with a slash.
|
|
28
|
+
*/
|
|
29
|
+
path: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* structural representation of a component.
|
|
33
|
+
*/
|
|
34
|
+
interface Component<PreloadData = never> {
|
|
35
|
+
/**
|
|
36
|
+
* the name of the component.
|
|
37
|
+
*/
|
|
38
|
+
name: string;
|
|
39
|
+
/**
|
|
40
|
+
* the template of the component.
|
|
41
|
+
*/
|
|
42
|
+
template: HTMLElement;
|
|
43
|
+
/**
|
|
44
|
+
* perform actions on the element. should probably be used for inserting data
|
|
45
|
+
* into the component.
|
|
46
|
+
*
|
|
47
|
+
* @param element the template element which should be populated.
|
|
48
|
+
* @param data preloaded data from the `preload` function if it exists.
|
|
49
|
+
*/
|
|
50
|
+
populate(element: Node, data?: PreloadData): void;
|
|
51
|
+
/**
|
|
52
|
+
* an element which is to be shown while the `preload` function is running.
|
|
53
|
+
*/
|
|
54
|
+
loadingElement?: HTMLElement;
|
|
55
|
+
/**
|
|
56
|
+
* preload data for the page before it is shown. the returned data will be
|
|
57
|
+
* passed to the `populate` function.
|
|
58
|
+
*
|
|
59
|
+
* the function will only be called if there is a `loadingElement` defined.
|
|
60
|
+
*
|
|
61
|
+
* @returns a promise which resolves to the data to be passed to the
|
|
62
|
+
* `populate` function.
|
|
63
|
+
*/
|
|
64
|
+
preload?(): Promise<PreloadData>;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* options for the `init` function of the mgcrt router.
|
|
68
|
+
*/
|
|
69
|
+
interface InitOptions {
|
|
70
|
+
/**
|
|
71
|
+
* the main containing element for the router.
|
|
72
|
+
*/
|
|
73
|
+
container: HTMLElement;
|
|
74
|
+
/**
|
|
75
|
+
* the pages to be registered with the router.
|
|
76
|
+
*/
|
|
77
|
+
pages: Page[];
|
|
78
|
+
/**
|
|
79
|
+
* settings for the router. these settings can be used to change the default
|
|
80
|
+
* behavior of the router.
|
|
81
|
+
*/
|
|
82
|
+
settings?: Settings;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* settings for the router. these settings can be used to change the default
|
|
86
|
+
* behavior of the router.
|
|
87
|
+
*/
|
|
88
|
+
type Settings = {
|
|
89
|
+
/**
|
|
90
|
+
* determines whether a reload should be performed when trying to navigate
|
|
91
|
+
* to a page you are currently already on.
|
|
92
|
+
*
|
|
93
|
+
* can be set to a constant value or a filter function which determines the
|
|
94
|
+
* result by the provided path.
|
|
95
|
+
*/
|
|
96
|
+
linkReload?: boolean | ((path: string) => boolean);
|
|
97
|
+
/**
|
|
98
|
+
* determine whether a so called "404-page" should be shown when the user
|
|
99
|
+
* tries navigating to a page which is not registered within the router.
|
|
100
|
+
*
|
|
101
|
+
* if set to a boolean with value `true`, it will try to reroute to a page
|
|
102
|
+
* with the path `/404`.
|
|
103
|
+
*
|
|
104
|
+
* this behaviour can be alternated by passing in a string which results in
|
|
105
|
+
* the boolean to be automatically thought of as `true` but the route set
|
|
106
|
+
* to the provided string value.
|
|
107
|
+
*/
|
|
108
|
+
notFoundPage?: boolean | string;
|
|
109
|
+
};
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region src/init.d.ts
|
|
112
|
+
/**
|
|
113
|
+
* initialize the router. any other function should be called after this one.
|
|
114
|
+
*
|
|
115
|
+
* @param options configuration of the router
|
|
116
|
+
*/
|
|
117
|
+
declare function init(options: InitOptions): void;
|
|
118
|
+
//#endregion
|
|
119
|
+
//#region src/load.d.ts
|
|
120
|
+
/**
|
|
121
|
+
* load the current page into the page container specified in `init`.
|
|
122
|
+
*
|
|
123
|
+
* you might want to use this function with the `findPage(string)` function which
|
|
124
|
+
* searches for a page matching a specific path in the router.
|
|
125
|
+
*
|
|
126
|
+
* @param page the page object that should be loaded.
|
|
127
|
+
* @see loadComponent
|
|
128
|
+
*/
|
|
129
|
+
declare const loadPage: <PageData = never>(page: Page<PageData>) => void;
|
|
130
|
+
/**
|
|
131
|
+
* load a component into a container.
|
|
132
|
+
*
|
|
133
|
+
* if there is a loading element specified, the preload function will be called
|
|
134
|
+
* asynchronously loading data which will then be passed on to populate the
|
|
135
|
+
* template.
|
|
136
|
+
*
|
|
137
|
+
* @param container the container you want to put the component into.
|
|
138
|
+
* @param component the component you want to add to the container.
|
|
139
|
+
* @param onFinish an event function for when the component is fully loaded.
|
|
140
|
+
*/
|
|
141
|
+
declare function loadComponent<ComponentData = never>(container: HTMLElement, component: Component<ComponentData>, onFinish?: () => void): void;
|
|
142
|
+
//#endregion
|
|
143
|
+
//#region src/misc.d.ts
|
|
144
|
+
/**
|
|
145
|
+
* the default error thrown by mgcrt.
|
|
146
|
+
*
|
|
147
|
+
* prefixes all error messages with a `mgcrt:`.
|
|
148
|
+
*/
|
|
149
|
+
declare class MgcrtError extends Error {
|
|
150
|
+
constructor(message: string);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* tries to find a page matching the specified path in the router definitions.
|
|
154
|
+
* if no page could be found, an error will be thrown.
|
|
155
|
+
*
|
|
156
|
+
* @param path the path of the page to find.
|
|
157
|
+
* @param skip404Error whether or not handling of a not found page should be
|
|
158
|
+
* skipped. (for internal use "only". default is `false`)
|
|
159
|
+
* @returns the found page.
|
|
160
|
+
*/
|
|
161
|
+
declare function findPage<PageData = never>(path: string, skip404Error?: boolean): Page<PageData>;
|
|
162
|
+
/**
|
|
163
|
+
* checks if when navigating to a new page, the page should be reloaded or not.
|
|
164
|
+
*
|
|
165
|
+
* this is only then useful, when you want to listen to user link clicks and
|
|
166
|
+
* check if a reload should be performed when the user tries to load the same
|
|
167
|
+
* page he already is on.
|
|
168
|
+
*
|
|
169
|
+
* if the user tries to load a different page, this function will always return
|
|
170
|
+
* `true` since a reload is necessary in this case.
|
|
171
|
+
*
|
|
172
|
+
* the output can be tweaked with the `linkReload` setting in the `init` function.
|
|
173
|
+
*
|
|
174
|
+
* @param path the path to check.
|
|
175
|
+
* @returns whether a component reload should be performed.
|
|
176
|
+
*/
|
|
177
|
+
declare function checkPageReloadable(path: string): boolean;
|
|
178
|
+
//#endregion
|
|
179
|
+
//#region src/mgcrt.d.ts
|
|
180
|
+
declare global {
|
|
181
|
+
interface Window {
|
|
182
|
+
mgcrtContainer: HTMLElement;
|
|
183
|
+
mgcrtPages: Page[];
|
|
184
|
+
mgcrtSettings: Readonly<Settings>;
|
|
185
|
+
}
|
|
186
|
+
interface ObjectConstructor {
|
|
187
|
+
keys<T>(object: T): Array<keyof T>;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
//#endregion
|
|
191
|
+
export { type InitOptions, MgcrtError, type Page, type Settings, checkPageReloadable, findPage, init, loadComponent, loadPage };
|
|
192
|
+
//# sourceMappingURL=mgcrt.d.ts.map
|
package/dist/mgcrt.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright © 2026 avolgha
|
|
3
|
+
*
|
|
4
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
* of this software and associated documentation files (the “Software”), to deal
|
|
6
|
+
* in the Software without restriction, including without limitation the rights
|
|
7
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
* copies of the Software, and to permit persons to whom the Software is furnished
|
|
9
|
+
* to do so, subject to the following conditions:
|
|
10
|
+
*
|
|
11
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
* copies or substantial portions of the Software.
|
|
13
|
+
*
|
|
14
|
+
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
18
|
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
19
|
+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
20
|
+
*/
|
|
21
|
+
var e=class extends Error{constructor(e){super(`mgcrt: ${e}`)}};const t=()=>new e(`router was corrupted or not initialized.`);function n(r,i=!1){if(!window.mgcrtPages)throw t();let a=r.toLowerCase().replace(/^#?/g,``),o=window.mgcrtPages.find(e=>e.path===a);if(o)return o;let s=window.mgcrtSettings?.notFoundPage;if(s===void 0)throw t();if(!s||i)throw new e(`could not find page. (path: '${r}')`);return n(typeof s==`string`?s:`/404`,!0)}function r(e){if(window.mgcrtSettings?.linkReload===void 0)throw t();return window.location.hash.substring(1)===e?typeof window.mgcrtSettings?.linkReload==`boolean`?window.mgcrtSettings.linkReload:window.mgcrtSettings?.linkReload(e):!0}const i=e=>{if(!window.mgcrtContainer)throw t();a(window.mgcrtContainer,e,()=>{document.location.hash=e.path})};function a(t,n,r){if(!n.loadingElement){let e=document.importNode(n.template,!0);n.populate(e),t.replaceChildren(e),r&&r();return}if(!n.preload)throw new e(`loading element was specified but no preload function exists. (component: '${n.name}')`);t.replaceChildren(n.loadingElement),n.preload().then(e=>{let i=document.importNode(n.template,!0);n.populate(i,e),t.replaceChildren(i),r&&r()})}const o={linkReload:!1,notFoundPage:!1};function s(t){if(window.mgcrtContainer)throw new e(`there is already a mgcrt instance running.`);if(!t.container)throw new e(`container element does not exists.`);window.mgcrtContainer=t.container,window.mgcrtPages=t.pages.map(e=>(e.path=e.path.toLowerCase(),e)),window.mgcrtSettings=Object.freeze(Object.create(o,t.settings||{})),document.addEventListener(`click`,e=>{if(!(e.target instanceof HTMLButtonElement)||!e.target.dataset.page)return;let t=e.target.dataset.page;if(!r(t))return;let a=n(t);a&&i(a)}),i(n(document.location.hash||`/`))}export{e as MgcrtError,r as checkPageReloadable,n as findPage,s as init,a as loadComponent,i as loadPage};
|
|
22
|
+
//# sourceMappingURL=mgcrt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mgcrt.js","names":[],"sources":["../src/misc.ts","../src/load.ts","../src/init.ts"],"sourcesContent":["import type { Page } from \"./types\";\r\n\r\n/**\r\n * the default error thrown by mgcrt.\r\n *\r\n * prefixes all error messages with a `mgcrt:`.\r\n */\r\nexport class MgcrtError extends Error {\r\n constructor(message: string) {\r\n super(`mgcrt: ${message}`);\r\n }\r\n}\r\n\r\n/**\r\n * utility function to create a template error when the router should but was\r\n * not initialized when trying to call functions of that router.\r\n */\r\nexport const errorNotInit = () =>\r\n new MgcrtError(\"router was corrupted or not initialized.\");\r\n\r\n/**\r\n * tries to find a page matching the specified path in the router definitions.\r\n * if no page could be found, an error will be thrown.\r\n *\r\n * @param path the path of the page to find.\r\n * @param skip404Error whether or not handling of a not found page should be\r\n * skipped. (for internal use \"only\". default is `false`)\r\n * @returns the found page.\r\n */\r\nexport function findPage<PageData = never>(path: string, skip404Error = false) {\r\n if (!window.mgcrtPages) throw errorNotInit();\r\n\r\n const realPath = path.toLowerCase().replace(/^#?/g, \"\");\r\n const page = window.mgcrtPages.find((page) => page.path === realPath);\r\n if (page) return page as Page<PageData>;\r\n\r\n const notFoundPageSetting = window.mgcrtSettings?.notFoundPage;\r\n if (notFoundPageSetting === undefined) throw errorNotInit();\r\n if (!notFoundPageSetting || skip404Error)\r\n throw new MgcrtError(`could not find page. (path: '${path}')`);\r\n\r\n const notFoundPage =\r\n typeof notFoundPageSetting === \"string\" ? notFoundPageSetting : \"/404\";\r\n return findPage(notFoundPage, true);\r\n}\r\n\r\n/**\r\n * checks if when navigating to a new page, the page should be reloaded or not.\r\n *\r\n * this is only then useful, when you want to listen to user link clicks and\r\n * check if a reload should be performed when the user tries to load the same\r\n * page he already is on.\r\n *\r\n * if the user tries to load a different page, this function will always return\r\n * `true` since a reload is necessary in this case.\r\n *\r\n * the output can be tweaked with the `linkReload` setting in the `init` function.\r\n *\r\n * @param path the path to check.\r\n * @returns whether a component reload should be performed.\r\n */\r\nexport function checkPageReloadable(path: string) {\r\n if (window.mgcrtSettings?.linkReload === undefined) throw errorNotInit();\r\n else if (window.location.hash.substring(1) !== path) return true;\r\n else if (typeof window.mgcrtSettings?.linkReload === \"boolean\")\r\n return window.mgcrtSettings.linkReload;\r\n else return window.mgcrtSettings?.linkReload(path);\r\n}\r\n","import { errorNotInit, MgcrtError } from \"./misc\";\r\nimport type { Component, Page } from \"./types\";\r\n\r\n/**\r\n * load the current page into the page container specified in `init`.\r\n *\r\n * you might want to use this function with the `findPage(string)` function which\r\n * searches for a page matching a specific path in the router.\r\n *\r\n * @param page the page object that should be loaded.\r\n * @see loadComponent\r\n */\r\nexport const loadPage = <PageData = never>(page: Page<PageData>) => {\r\n if (!window.mgcrtContainer) throw errorNotInit();\r\n\r\n loadComponent(window.mgcrtContainer, page, () => {\r\n document.location.hash = page.path;\r\n });\r\n};\r\n\r\n/**\r\n * load a component into a container.\r\n *\r\n * if there is a loading element specified, the preload function will be called\r\n * asynchronously loading data which will then be passed on to populate the\r\n * template.\r\n *\r\n * @param container the container you want to put the component into.\r\n * @param component the component you want to add to the container.\r\n * @param onFinish an event function for when the component is fully loaded.\r\n */\r\nexport function loadComponent<ComponentData = never>(\r\n container: HTMLElement,\r\n component: Component<ComponentData>,\r\n onFinish?: () => void,\r\n) {\r\n if (!component.loadingElement) {\r\n const template = document.importNode(component.template, true);\r\n component.populate(template);\r\n container.replaceChildren(template);\r\n onFinish && onFinish();\r\n return;\r\n }\r\n\r\n if (!component.preload) {\r\n throw new MgcrtError(\r\n `loading element was specified but no preload function exists. (component: '${component.name}')`,\r\n );\r\n }\r\n\r\n container.replaceChildren(component.loadingElement);\r\n component.preload().then((data) => {\r\n const template = document.importNode(component.template, true);\r\n component.populate(template, data);\r\n container.replaceChildren(template);\r\n onFinish && onFinish();\r\n });\r\n}\r\n","import { loadPage } from \"./load\";\r\nimport { checkPageReloadable, findPage, MgcrtError } from \"./misc\";\r\nimport type { InitOptions, Settings } from \"./types\";\r\n\r\nconst defaultSettings: Settings = {\r\n // motivation: will only be triggered if user tries to load the same page\r\n // twice which is irrelevant in most cases.\r\n linkReload: false,\r\n\r\n // motivation: we dont implement default pages thus the user has to explicitly\r\n // create one by himself. should be set to `true` in most cases.\r\n notFoundPage: false,\r\n};\r\n\r\n/**\r\n * initialize the router. any other function should be called after this one.\r\n *\r\n * @param options configuration of the router\r\n */\r\nexport default function init(options: InitOptions) {\r\n if (window.mgcrtContainer) {\r\n throw new MgcrtError(\"there is already a mgcrt instance running.\");\r\n }\r\n\r\n if (!options.container) {\r\n throw new MgcrtError(\"container element does not exists.\");\r\n }\r\n\r\n window.mgcrtContainer = options.container;\r\n window.mgcrtPages = options.pages.map((page) => {\r\n page.path = page.path.toLowerCase();\r\n return page;\r\n });\r\n window.mgcrtSettings = Object.freeze(\r\n Object.create(defaultSettings, options.settings || {}),\r\n );\r\n\r\n document.addEventListener(\"click\", (event) => {\r\n if (!(event.target instanceof HTMLButtonElement)) return;\r\n if (!event.target.dataset.page) return;\r\n const nextPage = event.target.dataset.page;\r\n if (!checkPageReloadable(nextPage)) {\r\n return;\r\n }\r\n\r\n const page = findPage(nextPage);\r\n if (page) loadPage(page);\r\n });\r\n\r\n loadPage(findPage(document.location.hash || \"/\"));\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAOA,IAAa,EAAb,cAAgC,KAAM,CACpC,YAAY,EAAiB,CAC3B,MAAM,UAAU,IAAU,GAQ9B,MAAa,MACX,IAAI,EAAW,2CAA2C,CAW5D,SAAgB,EAA2B,EAAc,EAAe,GAAO,CAC7E,GAAI,CAAC,OAAO,WAAY,MAAM,GAAc,CAE5C,IAAM,EAAW,EAAK,aAAa,CAAC,QAAQ,OAAQ,GAAG,CACjD,EAAO,OAAO,WAAW,KAAM,GAAS,EAAK,OAAS,EAAS,CACrE,GAAI,EAAM,OAAO,EAEjB,IAAM,EAAsB,OAAO,eAAe,aAClD,GAAI,IAAwB,IAAA,GAAW,MAAM,GAAc,CAC3D,GAAI,CAAC,GAAuB,EAC1B,MAAM,IAAI,EAAW,gCAAgC,EAAK,IAAI,CAIhE,OAAO,EADL,OAAO,GAAwB,SAAW,EAAsB,OACpC,GAAK,CAkBrC,SAAgB,EAAoB,EAAc,CAChD,GAAI,OAAO,eAAe,aAAe,IAAA,GAAW,MAAM,GAAc,CAInE,OAHI,OAAO,SAAS,KAAK,UAAU,EAAE,GAAK,EACtC,OAAO,OAAO,eAAe,YAAe,UAC5C,OAAO,cAAc,WAClB,OAAO,eAAe,WAAW,EAAK,CAHU,GCnD9D,MAAa,EAA8B,GAAyB,CAClE,GAAI,CAAC,OAAO,eAAgB,MAAM,GAAc,CAEhD,EAAc,OAAO,eAAgB,MAAY,CAC/C,SAAS,SAAS,KAAO,EAAK,MAC9B,EAcJ,SAAgB,EACd,EACA,EACA,EACA,CACA,GAAI,CAAC,EAAU,eAAgB,CAC7B,IAAM,EAAW,SAAS,WAAW,EAAU,SAAU,GAAK,CAC9D,EAAU,SAAS,EAAS,CAC5B,EAAU,gBAAgB,EAAS,CACnC,GAAY,GAAU,CACtB,OAGF,GAAI,CAAC,EAAU,QACb,MAAM,IAAI,EACR,8EAA8E,EAAU,KAAK,IAC9F,CAGH,EAAU,gBAAgB,EAAU,eAAe,CACnD,EAAU,SAAS,CAAC,KAAM,GAAS,CACjC,IAAM,EAAW,SAAS,WAAW,EAAU,SAAU,GAAK,CAC9D,EAAU,SAAS,EAAU,EAAK,CAClC,EAAU,gBAAgB,EAAS,CACnC,GAAY,GAAU,EACtB,CCpDJ,MAAM,EAA4B,CAGhC,WAAY,GAIZ,aAAc,GACf,CAOD,SAAwB,EAAK,EAAsB,CACjD,GAAI,OAAO,eACT,MAAM,IAAI,EAAW,6CAA6C,CAGpE,GAAI,CAAC,EAAQ,UACX,MAAM,IAAI,EAAW,qCAAqC,CAG5D,OAAO,eAAiB,EAAQ,UAChC,OAAO,WAAa,EAAQ,MAAM,IAAK,IACrC,EAAK,KAAO,EAAK,KAAK,aAAa,CAC5B,GACP,CACF,OAAO,cAAgB,OAAO,OAC5B,OAAO,OAAO,EAAiB,EAAQ,UAAY,EAAE,CAAC,CACvD,CAED,SAAS,iBAAiB,QAAU,GAAU,CAE5C,GADI,EAAE,EAAM,kBAAkB,oBAC1B,CAAC,EAAM,OAAO,QAAQ,KAAM,OAChC,IAAM,EAAW,EAAM,OAAO,QAAQ,KACtC,GAAI,CAAC,EAAoB,EAAS,CAChC,OAGF,IAAM,EAAO,EAAS,EAAS,CAC3B,GAAM,EAAS,EAAK,EACxB,CAEF,EAAS,EAAS,SAAS,SAAS,MAAQ,IAAI,CAAC"}
|
package/license
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Copyright © 2026 avolgha
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the “Software”), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is furnished
|
|
8
|
+
to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
17
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
18
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@avolgha/mgcrt",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"description": "simple javascript router",
|
|
6
|
+
"author": "avolgha <avolgha@gmail.com>",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"homepage": "https://github.com/avolgha/mgcrt#readme",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/avolgha/mgcrt.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/avolgha/mgcrt/issues"
|
|
15
|
+
},
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/mgcrt.d.ts",
|
|
19
|
+
"default": "./dist/mgcrt.js"
|
|
20
|
+
},
|
|
21
|
+
"./package.json": "./package.json"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"license",
|
|
26
|
+
"README.md"
|
|
27
|
+
],
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@arethetypeswrong/core": "^0.18.2",
|
|
30
|
+
"@types/node": "^25.5.0",
|
|
31
|
+
"@typescript/native-preview": "7.0.0-dev.20260316.1",
|
|
32
|
+
"bumpp": "^11.0.1",
|
|
33
|
+
"publint": "^0.3.18",
|
|
34
|
+
"tsdown": "^0.21.3",
|
|
35
|
+
"typescript": "^5.9.3"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsdown",
|
|
39
|
+
"dev": "tsdown --watch",
|
|
40
|
+
"typecheck": "tsc --noEmit",
|
|
41
|
+
"release": "bumpp"
|
|
42
|
+
}
|
|
43
|
+
}
|