@aerogel/plugin-routing 0.0.0-next.33c058471a47b828f174aca4d2b5aeadfeb2c627

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/.eslintrc.js ADDED
@@ -0,0 +1,7 @@
1
+ module.exports = {
2
+ env: {
3
+ browser: true,
4
+ es2021: true,
5
+ },
6
+ extends: ['@noeldemartin/eslint-config-typescript'],
7
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("virtual:aerogel"),t=require("@noeldemartin/utils"),r=require("vue-router");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=u(e);function a(e){const u=r.createRouter({history:r.createWebHistory(e.basePath),routes:e.routes});return u.beforeEach(t.once((()=>function(e){const r=t.Storage.pull("static-404-redirect");r&&e.replace(r)}(u)))),u}exports.default=function(e){return{install(t){const r=a({routes:e.routes,basePath:e.basePath??o.default.basePath});t.use(r)}}};
2
+ //# sourceMappingURL=aerogel-plugin-routing.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aerogel-plugin-routing.cjs.js","sources":["../src/router.ts","../src/main.ts"],"sourcesContent":["import { Storage, once } from '@noeldemartin/utils';\nimport { createRouter, createWebHistory } from 'vue-router';\nimport type { Plugin } from 'vue';\nimport type { RouteLocationRaw, RouteRecordRaw, Router } from 'vue-router';\n\nfunction handleStatic404Redirect(router: Router): void {\n const route = Storage.pull<RouteLocationRaw>('static-404-redirect');\n\n route && router.replace(route);\n}\n\nexport function createAppRouter(options: { routes: RouteRecordRaw[]; basePath?: string }): Plugin {\n const router = createRouter({\n history: createWebHistory(options.basePath),\n routes: options.routes,\n });\n\n router.beforeEach(once(() => handleStatic404Redirect(router)));\n\n return router;\n}\n","import Build from 'virtual:aerogel';\n\nimport type { Plugin } from '@aerogel/core';\nimport type { RouteRecordRaw } from 'vue-router';\n\nimport { createAppRouter } from './router';\n\ninterface Options {\n routes: RouteRecordRaw[];\n basePath?: string;\n}\n\nexport default function routing(options: Options): Plugin {\n return {\n install(app) {\n const plugin = createAppRouter({\n routes: options.routes,\n basePath: options.basePath ?? Build.basePath,\n });\n\n app.use(plugin);\n },\n };\n}\n"],"names":["createAppRouter","options","router","createRouter","history","createWebHistory","basePath","routes","beforeEach","once","route","Storage","pull","replace","handleStatic404Redirect","install","app","plugin","Build","use"],"mappings":"iPAWM,SAAUA,EAAgBC,GAC5B,MAAMC,EAASC,EAAAA,aAAa,CACxBC,QAASC,EAAAA,iBAAiBJ,EAAQK,UAClCC,OAAQN,EAAQM,SAKpB,OAFAL,EAAOM,WAAWC,EAAIA,MAAC,IAZ3B,SAAiCP,GAC7B,MAAMQ,EAAQC,EAAAA,QAAQC,KAAuB,uBAE7CF,GAASR,EAAOW,QAAQH,EAC5B,CAQiCI,CAAwBZ,MAE9CA,CACX,iBCRwB,SAAQD,GAC5B,MAAO,CACHc,OAAAA,CAAQC,GACJ,MAAMC,EAASjB,EAAgB,CAC3BO,OAAQN,EAAQM,OAChBD,SAAUL,EAAQK,UAAYY,EAAAA,QAAMZ,WAGxCU,EAAIG,IAAIF,EACZ,EAER"}
@@ -0,0 +1,12 @@
1
+ import type { Plugin as Plugin_2 } from '@aerogel/core';
2
+ import type { RouteRecordRaw } from 'vue-router';
3
+
4
+ declare interface Options {
5
+ routes: RouteRecordRaw[];
6
+ basePath?: string;
7
+ }
8
+
9
+ declare function routing(options: Options): Plugin_2;
10
+ export default routing;
11
+
12
+ export { }
@@ -0,0 +1,2 @@
1
+ import t from"virtual:aerogel";import{once as e,Storage as r}from"@noeldemartin/utils";import{createRouter as o,createWebHistory as a}from"vue-router";function s(t){const s=o({history:a(t.basePath),routes:t.routes});return s.beforeEach(e((()=>function(t){const e=r.pull("static-404-redirect");e&&t.replace(e)}(s)))),s}function u(e){return{install(r){const o=s({routes:e.routes,basePath:e.basePath??t.basePath});r.use(o)}}}export{u as default};
2
+ //# sourceMappingURL=aerogel-plugin-routing.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aerogel-plugin-routing.esm.js","sources":["../src/router.ts","../src/main.ts"],"sourcesContent":["import { Storage, once } from '@noeldemartin/utils';\nimport { createRouter, createWebHistory } from 'vue-router';\nimport type { Plugin } from 'vue';\nimport type { RouteLocationRaw, RouteRecordRaw, Router } from 'vue-router';\n\nfunction handleStatic404Redirect(router: Router): void {\n const route = Storage.pull<RouteLocationRaw>('static-404-redirect');\n\n route && router.replace(route);\n}\n\nexport function createAppRouter(options: { routes: RouteRecordRaw[]; basePath?: string }): Plugin {\n const router = createRouter({\n history: createWebHistory(options.basePath),\n routes: options.routes,\n });\n\n router.beforeEach(once(() => handleStatic404Redirect(router)));\n\n return router;\n}\n","import Build from 'virtual:aerogel';\n\nimport type { Plugin } from '@aerogel/core';\nimport type { RouteRecordRaw } from 'vue-router';\n\nimport { createAppRouter } from './router';\n\ninterface Options {\n routes: RouteRecordRaw[];\n basePath?: string;\n}\n\nexport default function routing(options: Options): Plugin {\n return {\n install(app) {\n const plugin = createAppRouter({\n routes: options.routes,\n basePath: options.basePath ?? Build.basePath,\n });\n\n app.use(plugin);\n },\n };\n}\n"],"names":["createAppRouter","options","router","createRouter","history","createWebHistory","basePath","routes","beforeEach","once","route","Storage","pull","replace","handleStatic404Redirect","routing","install","app","plugin","Build","use"],"mappings":"uJAWM,SAAUA,EAAgBC,GAC5B,MAAMC,EAASC,EAAa,CACxBC,QAASC,EAAiBJ,EAAQK,UAClCC,OAAQN,EAAQM,SAKpB,OAFAL,EAAOM,WAAWC,GAAK,IAZ3B,SAAiCP,GAC7B,MAAMQ,EAAQC,EAAQC,KAAuB,uBAE7CF,GAASR,EAAOW,QAAQH,EAC5B,CAQiCI,CAAwBZ,MAE9CA,CACX,CCRwB,SAAAa,EAAQd,GAC5B,MAAO,CACHe,OAAAA,CAAQC,GACJ,MAAMC,EAASlB,EAAgB,CAC3BO,OAAQN,EAAQM,OAChBD,SAAUL,EAAQK,UAAYa,EAAMb,WAGxCW,EAAIG,IAAIF,EACZ,EAER"}
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@aerogel/plugin-routing",
3
+ "description": "Aerogel routing plugin",
4
+ "version": "0.0.0-next.33c058471a47b828f174aca4d2b5aeadfeb2c627",
5
+ "main": "dist/aerogel-plugin-routing.cjs.js",
6
+ "module": "dist/aerogel-plugin-routing.esm.js",
7
+ "types": "dist/aerogel-plugin-routing.d.ts",
8
+ "sideEffects": false,
9
+ "scripts": {
10
+ "build": "rm dist -rf && npm run build:js && npm run build:types",
11
+ "build:js": "noeldemartin-build-javascript",
12
+ "build:types": "noeldemartin-build-types",
13
+ "publish-next": "noeldemartin-publish-next",
14
+ "lint": "noeldemartin-lint src"
15
+ },
16
+ "engines": {
17
+ "node": ">=18.x"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/NoelDeMartin/aerogeljs.git"
22
+ },
23
+ "keywords": [
24
+ "javascript",
25
+ "aerogel"
26
+ ],
27
+ "author": "Noel De Martin",
28
+ "license": "MIT",
29
+ "bugs": {
30
+ "url": "https://github.com/NoelDeMartin/aerogeljs/issues"
31
+ },
32
+ "peerDependencies": {
33
+ "@aerogel/core": "*"
34
+ },
35
+ "dependencies": {
36
+ "@noeldemartin/utils": "0.4.0-next.ac00beaecf32bb02ed8e335225d7948d946d73bd",
37
+ "vue-router": "^4.2.1"
38
+ },
39
+ "devDependencies": {
40
+ "@aerogel/core": "*"
41
+ }
42
+ }
package/src/main.ts ADDED
@@ -0,0 +1,24 @@
1
+ import Build from 'virtual:aerogel';
2
+
3
+ import type { Plugin } from '@aerogel/core';
4
+ import type { RouteRecordRaw } from 'vue-router';
5
+
6
+ import { createAppRouter } from './router';
7
+
8
+ interface Options {
9
+ routes: RouteRecordRaw[];
10
+ basePath?: string;
11
+ }
12
+
13
+ export default function routing(options: Options): Plugin {
14
+ return {
15
+ install(app) {
16
+ const plugin = createAppRouter({
17
+ routes: options.routes,
18
+ basePath: options.basePath ?? Build.basePath,
19
+ });
20
+
21
+ app.use(plugin);
22
+ },
23
+ };
24
+ }
package/src/router.ts ADDED
@@ -0,0 +1,21 @@
1
+ import { Storage, once } from '@noeldemartin/utils';
2
+ import { createRouter, createWebHistory } from 'vue-router';
3
+ import type { Plugin } from 'vue';
4
+ import type { RouteLocationRaw, RouteRecordRaw, Router } from 'vue-router';
5
+
6
+ function handleStatic404Redirect(router: Router): void {
7
+ const route = Storage.pull<RouteLocationRaw>('static-404-redirect');
8
+
9
+ route && router.replace(route);
10
+ }
11
+
12
+ export function createAppRouter(options: { routes: RouteRecordRaw[]; basePath?: string }): Plugin {
13
+ const router = createRouter({
14
+ history: createWebHistory(options.basePath),
15
+ routes: options.routes,
16
+ });
17
+
18
+ router.beforeEach(once(() => handleStatic404Redirect(router)));
19
+
20
+ return router;
21
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "types": ["@aerogel/core/dist/virtual"]
5
+ },
6
+ "include": ["src/**/*.ts"]
7
+ }