unplugin-vue-router
Advanced tools
Comparing version 0.3.0 to 0.3.1
import * as esbuild from 'esbuild'; | ||
import { O as Options } from './options-adeff310.js'; | ||
import { O as Options } from './options-ccb73a7b.js'; | ||
import 'vue-router'; | ||
@@ -4,0 +4,0 @@ |
@@ -68,3 +68,3 @@ "use strict"; | ||
const { children } = child; | ||
treeStr += `${`${parentPre}${hasNext ? "\u251C" : "\u2514"}\u2500\u2500 `}${child} | ||
treeStr += `${`${parentPre}${hasNext ? "\u251C" : "\u2514"}${"\u2500" + (children.size > 0 ? "\u252C" : "")} `}${child} | ||
`; | ||
@@ -75,3 +75,3 @@ if (children) { | ||
level + 1, | ||
`${parentPre}${hasNext ? "\u2502" : " "} ` | ||
`${parentPre}${hasNext ? "\u2502" : " "} ` | ||
); | ||
@@ -91,5 +91,10 @@ } | ||
var isArray = Array.isArray; | ||
function trimExtension(path) { | ||
const lastDot = path.lastIndexOf("."); | ||
return lastDot < 0 ? path : path.slice(0, lastDot); | ||
function trimExtension(path, extensions) { | ||
for (const extension of extensions) { | ||
const lastDot = path.endsWith(extension) ? -extension.length : 0; | ||
if (lastDot < 0) { | ||
return path.slice(0, lastDot); | ||
} | ||
} | ||
return path; | ||
} | ||
@@ -325,3 +330,6 @@ function throttle(fn, wait, initialWait) { | ||
insert(path, filePath = path) { | ||
const { tail, segment, viewName, isComponent } = splitFilePath(path); | ||
const { tail, segment, viewName, isComponent } = splitFilePath( | ||
path, | ||
this.options | ||
); | ||
if (!this.children.has(segment)) { | ||
@@ -348,3 +356,6 @@ this.children.set(segment, new TreeNode(this.options, segment, this)); | ||
remove(path) { | ||
const { tail, segment, viewName, isComponent } = splitFilePath(path); | ||
const { tail, segment, viewName, isComponent } = splitFilePath( | ||
path, | ||
this.options | ||
); | ||
const child = this.children.get(segment); | ||
@@ -409,3 +420,3 @@ if (!child) { | ||
} | ||
function splitFilePath(filePath) { | ||
function splitFilePath(filePath, options) { | ||
const slashPos = filePath.indexOf("/"); | ||
@@ -416,3 +427,3 @@ let head = slashPos < 0 ? filePath : filePath.slice(0, slashPos); | ||
if (!tail) { | ||
segment = trimExtension(head); | ||
segment = trimExtension(head, options.extensions); | ||
} | ||
@@ -834,2 +845,3 @@ let viewName = "default"; | ||
var MACRO_DEFINE_PAGE = "definePage"; | ||
var MACRO_DEFINE_PAGE_QUERY = /[?&]definePage\b/; | ||
function definePageTransform({ | ||
@@ -844,4 +856,5 @@ code, | ||
return; | ||
const isExtractingDefinePage = MACRO_DEFINE_PAGE_QUERY.test(id); | ||
const { script, scriptSetup, scriptCompiled } = sfc; | ||
const definePageNodes = scriptCompiled.scriptSetupAst.map((node) => { | ||
const definePageNodes = ((scriptCompiled == null ? void 0 : scriptCompiled.scriptSetupAst) || []).map((node) => { | ||
if (node.type === "ExpressionStatement") | ||
@@ -852,3 +865,3 @@ node = node.expression; | ||
if (!definePageNodes.length) { | ||
return; | ||
return isExtractingDefinePage ? "export default {}" : null; | ||
} else if (definePageNodes.length > 1) { | ||
@@ -859,3 +872,3 @@ throw new SyntaxError(`duplicate definePage() call`); | ||
const setupOffset = scriptSetup.loc.start.offset; | ||
if (id.includes(MACRO_DEFINE_PAGE)) { | ||
if (isExtractingDefinePage) { | ||
const s = new import_common.MagicString(code); | ||
@@ -879,2 +892,3 @@ const routeRecord = definePageNode.arguments[0]; | ||
function extractDefinePageNameAndPath(sfcCode, id) { | ||
var _a; | ||
if (!sfcCode.includes(MACRO_DEFINE_PAGE)) | ||
@@ -886,3 +900,3 @@ return; | ||
const { script, scriptSetup, scriptCompiled } = sfc; | ||
const definePageNodes = scriptCompiled.scriptSetupAst.map((node) => { | ||
const definePageNodes = ((_a = scriptCompiled == null ? void 0 : scriptCompiled.scriptSetupAst) != null ? _a : []).map((node) => { | ||
if (node.type === "ExpressionStatement") | ||
@@ -898,3 +912,2 @@ node = node.expression; | ||
const definePageNode = definePageNodes[0]; | ||
const setupOffset = scriptSetup.loc.start.offset; | ||
const routeRecord = definePageNode.arguments[0]; | ||
@@ -1145,2 +1158,5 @@ if (routeRecord.type !== "ObjectExpression") { | ||
})); | ||
if (options.extensions) { | ||
options.extensions.sort((a, b) => b.length - a.length); | ||
} | ||
return __spreadProps(__spreadValues(__spreadValues({}, DEFAULT_OPTIONS), options), { | ||
@@ -1147,0 +1163,0 @@ routesFolder |
import * as unplugin from 'unplugin'; | ||
import { R as ResolvedOptions, S as ServerContext, O as Options } from './options-adeff310.js'; | ||
export { T as TreeNode, b as TreeNodeValueParam, d as TreeNodeValueStatic, c as createPrefixTree, a as createTreeNodeValue } from './options-adeff310.js'; | ||
import { L as LiteralStringUnion } from './defineLoader-23e4921c.js'; | ||
export { b as _DataLoader, D as _DefineLoaderOptions, g as getFileBasedRouteName, a as getPascalCaseRouteName } from './defineLoader-23e4921c.js'; | ||
import { R as ResolvedOptions, S as ServerContext, O as Options } from './options-ccb73a7b.js'; | ||
export { T as TreeNode, b as TreeNodeValueParam, d as TreeNodeValueStatic, c as createPrefixTree, a as createTreeNodeValue } from './options-ccb73a7b.js'; | ||
import { L as LiteralStringUnion } from './defineLoader-6f6b8cea.js'; | ||
export { b as _DataLoader, D as _DefineLoaderOptions, g as getFileBasedRouteName, a as getPascalCaseRouteName } from './defineLoader-6f6b8cea.js'; | ||
import { RouteParamsRaw, RouteParams, RouteMeta, RouteLocationNormalized, RouteRecordName, RouteLocationNormalizedLoaded, RouteQueryAndHash, RouteLocationOptions, RouteLocation, NavigationGuardNext, NavigationFailure, Router, RouteLocationRaw, RouterLinkProps as RouterLinkProps$1 } from 'vue-router'; | ||
@@ -7,0 +7,0 @@ import { Ref, AllowedComponentProps, ComponentCustomProps, VNodeProps, UnwrapRef, VNode, ComputedRef } from 'vue'; |
@@ -76,3 +76,3 @@ "use strict"; | ||
const { children } = child; | ||
treeStr += `${`${parentPre}${hasNext ? "\u251C" : "\u2514"}\u2500\u2500 `}${child} | ||
treeStr += `${`${parentPre}${hasNext ? "\u251C" : "\u2514"}${"\u2500" + (children.size > 0 ? "\u252C" : "")} `}${child} | ||
`; | ||
@@ -83,3 +83,3 @@ if (children) { | ||
level + 1, | ||
`${parentPre}${hasNext ? "\u2502" : " "} ` | ||
`${parentPre}${hasNext ? "\u2502" : " "} ` | ||
); | ||
@@ -99,5 +99,10 @@ } | ||
var isArray = Array.isArray; | ||
function trimExtension(path) { | ||
const lastDot = path.lastIndexOf("."); | ||
return lastDot < 0 ? path : path.slice(0, lastDot); | ||
function trimExtension(path, extensions) { | ||
for (const extension of extensions) { | ||
const lastDot = path.endsWith(extension) ? -extension.length : 0; | ||
if (lastDot < 0) { | ||
return path.slice(0, lastDot); | ||
} | ||
} | ||
return path; | ||
} | ||
@@ -352,3 +357,6 @@ function throttle(fn, wait, initialWait) { | ||
insert(path, filePath = path) { | ||
const { tail, segment, viewName, isComponent } = splitFilePath(path); | ||
const { tail, segment, viewName, isComponent } = splitFilePath( | ||
path, | ||
this.options | ||
); | ||
if (!this.children.has(segment)) { | ||
@@ -375,3 +383,6 @@ this.children.set(segment, new TreeNode(this.options, segment, this)); | ||
remove(path) { | ||
const { tail, segment, viewName, isComponent } = splitFilePath(path); | ||
const { tail, segment, viewName, isComponent } = splitFilePath( | ||
path, | ||
this.options | ||
); | ||
const child = this.children.get(segment); | ||
@@ -436,3 +447,3 @@ if (!child) { | ||
} | ||
function splitFilePath(filePath) { | ||
function splitFilePath(filePath, options) { | ||
const slashPos = filePath.indexOf("/"); | ||
@@ -443,3 +454,3 @@ let head = slashPos < 0 ? filePath : filePath.slice(0, slashPos); | ||
if (!tail) { | ||
segment = trimExtension(head); | ||
segment = trimExtension(head, options.extensions); | ||
} | ||
@@ -861,2 +872,3 @@ let viewName = "default"; | ||
var MACRO_DEFINE_PAGE = "definePage"; | ||
var MACRO_DEFINE_PAGE_QUERY = /[?&]definePage\b/; | ||
function definePageTransform({ | ||
@@ -871,4 +883,5 @@ code, | ||
return; | ||
const isExtractingDefinePage = MACRO_DEFINE_PAGE_QUERY.test(id); | ||
const { script, scriptSetup, scriptCompiled } = sfc; | ||
const definePageNodes = scriptCompiled.scriptSetupAst.map((node) => { | ||
const definePageNodes = ((scriptCompiled == null ? void 0 : scriptCompiled.scriptSetupAst) || []).map((node) => { | ||
if (node.type === "ExpressionStatement") | ||
@@ -879,3 +892,3 @@ node = node.expression; | ||
if (!definePageNodes.length) { | ||
return; | ||
return isExtractingDefinePage ? "export default {}" : null; | ||
} else if (definePageNodes.length > 1) { | ||
@@ -886,3 +899,3 @@ throw new SyntaxError(`duplicate definePage() call`); | ||
const setupOffset = scriptSetup.loc.start.offset; | ||
if (id.includes(MACRO_DEFINE_PAGE)) { | ||
if (isExtractingDefinePage) { | ||
const s = new import_common.MagicString(code); | ||
@@ -906,2 +919,3 @@ const routeRecord = definePageNode.arguments[0]; | ||
function extractDefinePageNameAndPath(sfcCode, id) { | ||
var _a; | ||
if (!sfcCode.includes(MACRO_DEFINE_PAGE)) | ||
@@ -913,3 +927,3 @@ return; | ||
const { script, scriptSetup, scriptCompiled } = sfc; | ||
const definePageNodes = scriptCompiled.scriptSetupAst.map((node) => { | ||
const definePageNodes = ((_a = scriptCompiled == null ? void 0 : scriptCompiled.scriptSetupAst) != null ? _a : []).map((node) => { | ||
if (node.type === "ExpressionStatement") | ||
@@ -925,3 +939,2 @@ node = node.expression; | ||
const definePageNode = definePageNodes[0]; | ||
const setupOffset = scriptSetup.loc.start.offset; | ||
const routeRecord = definePageNode.arguments[0]; | ||
@@ -1172,2 +1185,5 @@ if (routeRecord.type !== "ObjectExpression") { | ||
})); | ||
if (options.extensions) { | ||
options.extensions.sort((a, b) => b.length - a.length); | ||
} | ||
return __spreadProps(__spreadValues(__spreadValues({}, DEFAULT_OPTIONS), options), { | ||
@@ -1174,0 +1190,0 @@ routesFolder |
@@ -1,2 +0,2 @@ | ||
export { D as DEFAULT_OPTIONS, O as Options, R as ResolvedOptions, f as RoutesFolder, e as RoutesFolderOption, S as ServerContext, g as _OptionsImportMode, _ as _RoutesFolder, r as resolveOptions } from './options-adeff310.js'; | ||
export { D as DEFAULT_OPTIONS, O as Options, R as ResolvedOptions, f as RoutesFolder, e as RoutesFolderOption, S as ServerContext, g as _OptionsImportMode, _ as _RoutesFolder, r as resolveOptions } from './options-ccb73a7b.js'; | ||
import 'vue-router'; |
@@ -82,2 +82,5 @@ "use strict"; | ||
})); | ||
if (options.extensions) { | ||
options.extensions.sort((a, b) => b.length - a.length); | ||
} | ||
return __spreadProps(__spreadValues(__spreadValues({}, DEFAULT_OPTIONS), options), { | ||
@@ -84,0 +87,0 @@ routesFolder |
import * as rollup from 'rollup'; | ||
import { O as Options } from './options-adeff310.js'; | ||
import { O as Options } from './options-ccb73a7b.js'; | ||
import 'vue-router'; | ||
@@ -4,0 +4,0 @@ |
@@ -68,3 +68,3 @@ "use strict"; | ||
const { children } = child; | ||
treeStr += `${`${parentPre}${hasNext ? "\u251C" : "\u2514"}\u2500\u2500 `}${child} | ||
treeStr += `${`${parentPre}${hasNext ? "\u251C" : "\u2514"}${"\u2500" + (children.size > 0 ? "\u252C" : "")} `}${child} | ||
`; | ||
@@ -75,3 +75,3 @@ if (children) { | ||
level + 1, | ||
`${parentPre}${hasNext ? "\u2502" : " "} ` | ||
`${parentPre}${hasNext ? "\u2502" : " "} ` | ||
); | ||
@@ -91,5 +91,10 @@ } | ||
var isArray = Array.isArray; | ||
function trimExtension(path) { | ||
const lastDot = path.lastIndexOf("."); | ||
return lastDot < 0 ? path : path.slice(0, lastDot); | ||
function trimExtension(path, extensions) { | ||
for (const extension of extensions) { | ||
const lastDot = path.endsWith(extension) ? -extension.length : 0; | ||
if (lastDot < 0) { | ||
return path.slice(0, lastDot); | ||
} | ||
} | ||
return path; | ||
} | ||
@@ -325,3 +330,6 @@ function throttle(fn, wait, initialWait) { | ||
insert(path, filePath = path) { | ||
const { tail, segment, viewName, isComponent } = splitFilePath(path); | ||
const { tail, segment, viewName, isComponent } = splitFilePath( | ||
path, | ||
this.options | ||
); | ||
if (!this.children.has(segment)) { | ||
@@ -348,3 +356,6 @@ this.children.set(segment, new TreeNode(this.options, segment, this)); | ||
remove(path) { | ||
const { tail, segment, viewName, isComponent } = splitFilePath(path); | ||
const { tail, segment, viewName, isComponent } = splitFilePath( | ||
path, | ||
this.options | ||
); | ||
const child = this.children.get(segment); | ||
@@ -409,3 +420,3 @@ if (!child) { | ||
} | ||
function splitFilePath(filePath) { | ||
function splitFilePath(filePath, options) { | ||
const slashPos = filePath.indexOf("/"); | ||
@@ -416,3 +427,3 @@ let head = slashPos < 0 ? filePath : filePath.slice(0, slashPos); | ||
if (!tail) { | ||
segment = trimExtension(head); | ||
segment = trimExtension(head, options.extensions); | ||
} | ||
@@ -834,2 +845,3 @@ let viewName = "default"; | ||
var MACRO_DEFINE_PAGE = "definePage"; | ||
var MACRO_DEFINE_PAGE_QUERY = /[?&]definePage\b/; | ||
function definePageTransform({ | ||
@@ -844,4 +856,5 @@ code, | ||
return; | ||
const isExtractingDefinePage = MACRO_DEFINE_PAGE_QUERY.test(id); | ||
const { script, scriptSetup, scriptCompiled } = sfc; | ||
const definePageNodes = scriptCompiled.scriptSetupAst.map((node) => { | ||
const definePageNodes = ((scriptCompiled == null ? void 0 : scriptCompiled.scriptSetupAst) || []).map((node) => { | ||
if (node.type === "ExpressionStatement") | ||
@@ -852,3 +865,3 @@ node = node.expression; | ||
if (!definePageNodes.length) { | ||
return; | ||
return isExtractingDefinePage ? "export default {}" : null; | ||
} else if (definePageNodes.length > 1) { | ||
@@ -859,3 +872,3 @@ throw new SyntaxError(`duplicate definePage() call`); | ||
const setupOffset = scriptSetup.loc.start.offset; | ||
if (id.includes(MACRO_DEFINE_PAGE)) { | ||
if (isExtractingDefinePage) { | ||
const s = new import_common.MagicString(code); | ||
@@ -879,2 +892,3 @@ const routeRecord = definePageNode.arguments[0]; | ||
function extractDefinePageNameAndPath(sfcCode, id) { | ||
var _a; | ||
if (!sfcCode.includes(MACRO_DEFINE_PAGE)) | ||
@@ -886,3 +900,3 @@ return; | ||
const { script, scriptSetup, scriptCompiled } = sfc; | ||
const definePageNodes = scriptCompiled.scriptSetupAst.map((node) => { | ||
const definePageNodes = ((_a = scriptCompiled == null ? void 0 : scriptCompiled.scriptSetupAst) != null ? _a : []).map((node) => { | ||
if (node.type === "ExpressionStatement") | ||
@@ -898,3 +912,2 @@ node = node.expression; | ||
const definePageNode = definePageNodes[0]; | ||
const setupOffset = scriptSetup.loc.start.offset; | ||
const routeRecord = definePageNode.arguments[0]; | ||
@@ -1145,2 +1158,5 @@ if (routeRecord.type !== "ObjectExpression") { | ||
})); | ||
if (options.extensions) { | ||
options.extensions.sort((a, b) => b.length - a.length); | ||
} | ||
return __spreadProps(__spreadValues(__spreadValues({}, DEFAULT_OPTIONS), options), { | ||
@@ -1147,0 +1163,0 @@ routesFolder |
import { Router, RouteLocationNormalized, RouteRecordRaw } from 'vue-router'; | ||
import { b as DataLoader, A as Awaitable } from './defineLoader-23e4921c.js'; | ||
export { D as DefineLoaderOptions, d as _defineLoader, s as _stopDataFetchingScope } from './defineLoader-23e4921c.js'; | ||
import './options-adeff310.js'; | ||
import { b as DataLoader, A as Awaitable } from './defineLoader-6f6b8cea.js'; | ||
export { D as DefineLoaderOptions, d as _defineLoader, s as _stopDataFetchingScope } from './defineLoader-6f6b8cea.js'; | ||
import './options-ccb73a7b.js'; | ||
import 'vue'; | ||
@@ -6,0 +6,0 @@ |
import * as vite from 'vite'; | ||
import { O as Options } from './options-adeff310.js'; | ||
import { O as Options } from './options-ccb73a7b.js'; | ||
import 'vue-router'; | ||
@@ -4,0 +4,0 @@ |
@@ -68,3 +68,3 @@ "use strict"; | ||
const { children } = child; | ||
treeStr += `${`${parentPre}${hasNext ? "\u251C" : "\u2514"}\u2500\u2500 `}${child} | ||
treeStr += `${`${parentPre}${hasNext ? "\u251C" : "\u2514"}${"\u2500" + (children.size > 0 ? "\u252C" : "")} `}${child} | ||
`; | ||
@@ -75,3 +75,3 @@ if (children) { | ||
level + 1, | ||
`${parentPre}${hasNext ? "\u2502" : " "} ` | ||
`${parentPre}${hasNext ? "\u2502" : " "} ` | ||
); | ||
@@ -91,5 +91,10 @@ } | ||
var isArray = Array.isArray; | ||
function trimExtension(path) { | ||
const lastDot = path.lastIndexOf("."); | ||
return lastDot < 0 ? path : path.slice(0, lastDot); | ||
function trimExtension(path, extensions) { | ||
for (const extension of extensions) { | ||
const lastDot = path.endsWith(extension) ? -extension.length : 0; | ||
if (lastDot < 0) { | ||
return path.slice(0, lastDot); | ||
} | ||
} | ||
return path; | ||
} | ||
@@ -325,3 +330,6 @@ function throttle(fn, wait, initialWait) { | ||
insert(path, filePath = path) { | ||
const { tail, segment, viewName, isComponent } = splitFilePath(path); | ||
const { tail, segment, viewName, isComponent } = splitFilePath( | ||
path, | ||
this.options | ||
); | ||
if (!this.children.has(segment)) { | ||
@@ -348,3 +356,6 @@ this.children.set(segment, new TreeNode(this.options, segment, this)); | ||
remove(path) { | ||
const { tail, segment, viewName, isComponent } = splitFilePath(path); | ||
const { tail, segment, viewName, isComponent } = splitFilePath( | ||
path, | ||
this.options | ||
); | ||
const child = this.children.get(segment); | ||
@@ -409,3 +420,3 @@ if (!child) { | ||
} | ||
function splitFilePath(filePath) { | ||
function splitFilePath(filePath, options) { | ||
const slashPos = filePath.indexOf("/"); | ||
@@ -416,3 +427,3 @@ let head = slashPos < 0 ? filePath : filePath.slice(0, slashPos); | ||
if (!tail) { | ||
segment = trimExtension(head); | ||
segment = trimExtension(head, options.extensions); | ||
} | ||
@@ -834,2 +845,3 @@ let viewName = "default"; | ||
var MACRO_DEFINE_PAGE = "definePage"; | ||
var MACRO_DEFINE_PAGE_QUERY = /[?&]definePage\b/; | ||
function definePageTransform({ | ||
@@ -844,4 +856,5 @@ code, | ||
return; | ||
const isExtractingDefinePage = MACRO_DEFINE_PAGE_QUERY.test(id); | ||
const { script, scriptSetup, scriptCompiled } = sfc; | ||
const definePageNodes = scriptCompiled.scriptSetupAst.map((node) => { | ||
const definePageNodes = ((scriptCompiled == null ? void 0 : scriptCompiled.scriptSetupAst) || []).map((node) => { | ||
if (node.type === "ExpressionStatement") | ||
@@ -852,3 +865,3 @@ node = node.expression; | ||
if (!definePageNodes.length) { | ||
return; | ||
return isExtractingDefinePage ? "export default {}" : null; | ||
} else if (definePageNodes.length > 1) { | ||
@@ -859,3 +872,3 @@ throw new SyntaxError(`duplicate definePage() call`); | ||
const setupOffset = scriptSetup.loc.start.offset; | ||
if (id.includes(MACRO_DEFINE_PAGE)) { | ||
if (isExtractingDefinePage) { | ||
const s = new import_common.MagicString(code); | ||
@@ -879,2 +892,3 @@ const routeRecord = definePageNode.arguments[0]; | ||
function extractDefinePageNameAndPath(sfcCode, id) { | ||
var _a; | ||
if (!sfcCode.includes(MACRO_DEFINE_PAGE)) | ||
@@ -886,3 +900,3 @@ return; | ||
const { script, scriptSetup, scriptCompiled } = sfc; | ||
const definePageNodes = scriptCompiled.scriptSetupAst.map((node) => { | ||
const definePageNodes = ((_a = scriptCompiled == null ? void 0 : scriptCompiled.scriptSetupAst) != null ? _a : []).map((node) => { | ||
if (node.type === "ExpressionStatement") | ||
@@ -898,3 +912,2 @@ node = node.expression; | ||
const definePageNode = definePageNodes[0]; | ||
const setupOffset = scriptSetup.loc.start.offset; | ||
const routeRecord = definePageNode.arguments[0]; | ||
@@ -1145,2 +1158,5 @@ if (routeRecord.type !== "ObjectExpression") { | ||
})); | ||
if (options.extensions) { | ||
options.extensions.sort((a, b) => b.length - a.length); | ||
} | ||
return __spreadProps(__spreadValues(__spreadValues({}, DEFAULT_OPTIONS), options), { | ||
@@ -1147,0 +1163,0 @@ routesFolder |
import * as webpack from 'webpack'; | ||
import { O as Options } from './options-adeff310.js'; | ||
import { O as Options } from './options-ccb73a7b.js'; | ||
import 'vue-router'; | ||
@@ -4,0 +4,0 @@ |
@@ -68,3 +68,3 @@ "use strict"; | ||
const { children } = child; | ||
treeStr += `${`${parentPre}${hasNext ? "\u251C" : "\u2514"}\u2500\u2500 `}${child} | ||
treeStr += `${`${parentPre}${hasNext ? "\u251C" : "\u2514"}${"\u2500" + (children.size > 0 ? "\u252C" : "")} `}${child} | ||
`; | ||
@@ -75,3 +75,3 @@ if (children) { | ||
level + 1, | ||
`${parentPre}${hasNext ? "\u2502" : " "} ` | ||
`${parentPre}${hasNext ? "\u2502" : " "} ` | ||
); | ||
@@ -91,5 +91,10 @@ } | ||
var isArray = Array.isArray; | ||
function trimExtension(path) { | ||
const lastDot = path.lastIndexOf("."); | ||
return lastDot < 0 ? path : path.slice(0, lastDot); | ||
function trimExtension(path, extensions) { | ||
for (const extension of extensions) { | ||
const lastDot = path.endsWith(extension) ? -extension.length : 0; | ||
if (lastDot < 0) { | ||
return path.slice(0, lastDot); | ||
} | ||
} | ||
return path; | ||
} | ||
@@ -325,3 +330,6 @@ function throttle(fn, wait, initialWait) { | ||
insert(path, filePath = path) { | ||
const { tail, segment, viewName, isComponent } = splitFilePath(path); | ||
const { tail, segment, viewName, isComponent } = splitFilePath( | ||
path, | ||
this.options | ||
); | ||
if (!this.children.has(segment)) { | ||
@@ -348,3 +356,6 @@ this.children.set(segment, new TreeNode(this.options, segment, this)); | ||
remove(path) { | ||
const { tail, segment, viewName, isComponent } = splitFilePath(path); | ||
const { tail, segment, viewName, isComponent } = splitFilePath( | ||
path, | ||
this.options | ||
); | ||
const child = this.children.get(segment); | ||
@@ -409,3 +420,3 @@ if (!child) { | ||
} | ||
function splitFilePath(filePath) { | ||
function splitFilePath(filePath, options) { | ||
const slashPos = filePath.indexOf("/"); | ||
@@ -416,3 +427,3 @@ let head = slashPos < 0 ? filePath : filePath.slice(0, slashPos); | ||
if (!tail) { | ||
segment = trimExtension(head); | ||
segment = trimExtension(head, options.extensions); | ||
} | ||
@@ -834,2 +845,3 @@ let viewName = "default"; | ||
var MACRO_DEFINE_PAGE = "definePage"; | ||
var MACRO_DEFINE_PAGE_QUERY = /[?&]definePage\b/; | ||
function definePageTransform({ | ||
@@ -844,4 +856,5 @@ code, | ||
return; | ||
const isExtractingDefinePage = MACRO_DEFINE_PAGE_QUERY.test(id); | ||
const { script, scriptSetup, scriptCompiled } = sfc; | ||
const definePageNodes = scriptCompiled.scriptSetupAst.map((node) => { | ||
const definePageNodes = ((scriptCompiled == null ? void 0 : scriptCompiled.scriptSetupAst) || []).map((node) => { | ||
if (node.type === "ExpressionStatement") | ||
@@ -852,3 +865,3 @@ node = node.expression; | ||
if (!definePageNodes.length) { | ||
return; | ||
return isExtractingDefinePage ? "export default {}" : null; | ||
} else if (definePageNodes.length > 1) { | ||
@@ -859,3 +872,3 @@ throw new SyntaxError(`duplicate definePage() call`); | ||
const setupOffset = scriptSetup.loc.start.offset; | ||
if (id.includes(MACRO_DEFINE_PAGE)) { | ||
if (isExtractingDefinePage) { | ||
const s = new import_common.MagicString(code); | ||
@@ -879,2 +892,3 @@ const routeRecord = definePageNode.arguments[0]; | ||
function extractDefinePageNameAndPath(sfcCode, id) { | ||
var _a; | ||
if (!sfcCode.includes(MACRO_DEFINE_PAGE)) | ||
@@ -886,3 +900,3 @@ return; | ||
const { script, scriptSetup, scriptCompiled } = sfc; | ||
const definePageNodes = scriptCompiled.scriptSetupAst.map((node) => { | ||
const definePageNodes = ((_a = scriptCompiled == null ? void 0 : scriptCompiled.scriptSetupAst) != null ? _a : []).map((node) => { | ||
if (node.type === "ExpressionStatement") | ||
@@ -898,3 +912,2 @@ node = node.expression; | ||
const definePageNode = definePageNodes[0]; | ||
const setupOffset = scriptSetup.loc.start.offset; | ||
const routeRecord = definePageNode.arguments[0]; | ||
@@ -1145,2 +1158,5 @@ if (routeRecord.type !== "ObjectExpression") { | ||
})); | ||
if (options.extensions) { | ||
options.extensions.sort((a, b) => b.length - a.length); | ||
} | ||
return __spreadProps(__spreadValues(__spreadValues({}, DEFAULT_OPTIONS), options), { | ||
@@ -1147,0 +1163,0 @@ routesFolder |
{ | ||
"name": "unplugin-vue-router", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"packageManager": "pnpm@7.21.0", | ||
@@ -102,3 +102,3 @@ "description": "File based typed routing for Vue Router", | ||
"devDependencies": { | ||
"@volar/vue-language-core": "^1.0.19", | ||
"@volar/vue-language-core": "^1.0.22", | ||
"c8": "^7.12.0", | ||
@@ -114,5 +114,5 @@ "chalk": "^5.2.0", | ||
"p-series": "^3.0.0", | ||
"prettier": "^2.8.1", | ||
"prettier": "^2.8.2", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^3.9.0", | ||
"rollup": "^3.9.1", | ||
"semver": "^7.3.8", | ||
@@ -123,3 +123,3 @@ "ts-expect": "^1.3.0", | ||
"unplugin-auto-import": "^0.12.1", | ||
"vite": "^4.0.3", | ||
"vite": "^4.0.4", | ||
"vitest": "^0.26.3", | ||
@@ -126,0 +126,0 @@ "vue": "^3.2.45", |
@@ -217,2 +217,3 @@ # unplugin-vue-router | ||
// e.g. ['**/__*/**/*'] will exclude all files within folders starting with `__` | ||
// e.g. ['*.component.vue'] will exclude components ending with `.component.vue` | ||
exclude: [], | ||
@@ -219,0 +220,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
320536
8746
581
38