@vaadin/hilla-file-router 25.1.0 → 25.1.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/hilla-file-router",
3
- "version": "25.1.0",
3
+ "version": "25.1.2",
4
4
  "description": "Hilla file-based router",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
@@ -62,9 +62,9 @@
62
62
  },
63
63
  "dependencies": {
64
64
  "@ungap/with-resolvers": "0.1.0",
65
- "@vaadin/hilla-generator-utils": "25.1.0",
66
- "@vaadin/hilla-react-auth": "25.1.0",
67
- "@vaadin/hilla-react-signals": "25.1.0",
65
+ "@vaadin/hilla-generator-utils": "25.1.2",
66
+ "@vaadin/hilla-react-auth": "25.1.2",
67
+ "@vaadin/hilla-react-signals": "25.1.2",
68
68
  "tsc-template": "0.2.3",
69
69
  "typescript": "5.9.3"
70
70
  }
@@ -19,7 +19,7 @@ export function createMenuItems() {
19
19
  vaadinObj.registrations ??= [];
20
20
  vaadinObj.registrations.push({
21
21
  is: feature ? `@vaadin/hilla-file-router/${feature}` : "@vaadin/hilla-file-router",
22
- version: "25.1.0"
22
+ version: "25.1.2"
23
23
  });
24
24
  })("createMenuItems", window.Vaadin);
25
25
  const collator = new Intl.Collator("en-US");
@@ -1 +1 @@
1
- {"mappings":"AACA,SAAsB,2CAA4C;AAIlE,OAAO,MAAMA,cAAkF,OAC5F,OAAwB,QAAQ,MAClC;AAED,SAAS,WAAWC,OAA4B;AAC9C,UAAS,MAAM,MAAM;AACtB;AAED,SAAS,uBAAuBC,MAAuB;AACrD,QAAO,KAAK,MAAM,IAAI,CAAC,KAAK,CAAC,YAAY,QAAQ,WAAW,IAAI,CAAC;AAClE;;;;;;;;;AAUD,OAAO,SAAS,kBAA2D;AAGzE,EAAC,CAAC,SAAS,YAAa,WAAW,WAAW,CAAE,MAAM;AACtD,YAAU,kBAAkB,CAAE;AAC9B,YAAU,cAAc,KAAK;GAC3B,IAAI,WAAW,4BAA4B,QAAQ,IAAI;GACvD,SAAS;EACV,EAAC;CACH,GAAE,mBAAoB,OAAwB,OAAO;CACpD,MAAM,WAAW,IAAI,KAAK,SAAS;AACnC,MAAK,YAAY,OAAO;AACtB,SAAO,CAAE;CACV;CAED,MAAM,QAAQ,OAAO,QAAQ,YAAY,MAAM;AAE/C,QACE,MAEG,OAAO,CAAC,CAAC,MAAM,MAAM,MAAM,WAAW,MAAM,KAAK,uBAAuB,KAAK,CAAC,CAE9E,IAAI,CAAC,CAAC,MAAM,OAAO,MAAM;EACxB,IAAI;EACJ,MAAM,OAAO,MAAM;EACnB,OAAO,OAAO,MAAM,SAAS,OAAO;EACpC,OAAO,OAAO,MAAM;EACpB,QAAQ,OAAO;CAChB,GAAE,CAEF,KAAK,CAAC,OAAO,UAAU;EACtB,MAAM,cAAc,MAAM,SAAS,OAAO,cAAc,MAAM,SAAS,OAAO;AAC9E,SAAO,eAAe,IAAI,aAAa,SAAS,QAAQ,MAAM,IAAI,MAAM,GAAG;CAC5E,EAAC;AAEP;AAED,IAAI,OAAO,KAAK,KAAK;AACnB,QAAO,KAAK,IAAI,GAAG,mBAAmB,MAAM;AAC1C,QAAM,iBAAiB,CACpB,KAAK,OAAO,SAAS,KAAK,MAAM,CAAC,CACjC,KAAK,CAAC,SAAS;AACd,eAAY,QAAQ;EACrB,EAAC,CACD,MAAM,CAACC,MAAe;AACrB,WAAQ,MAAM,8BAA8B,EAAE;EAC/C,EAAC;CACL,EAAC;AACH","names":["viewsSignal: Signal<Readonly<Record<string, Readonly<ViewConfig>>> | undefined>","value: ViewConfig","path: string","e: unknown"],"sources":["/opt/agent/work/649c11185a3798db/packages/ts/file-router/src/runtime/createMenuItems.ts"],"sourcesContent":["/// <reference types=\"vite/client\" />\nimport { type Signal, signal } from '@vaadin/hilla-react-signals';\nimport type { VaadinWindow } from '../shared/internal.js';\nimport type { MenuItem, ViewConfig } from '../types.js';\n\nexport const viewsSignal: Signal<Readonly<Record<string, Readonly<ViewConfig>>> | undefined> = signal(\n (window as VaadinWindow).Vaadin?.views,\n);\n\nfunction isExcluded(value: ViewConfig): boolean {\n return !!value.menu?.exclude;\n}\n\nfunction hasVariablePathSegment(path: string): boolean {\n return path.split('/').some((segment) => segment.startsWith(':'));\n}\n\n/**\n * Creates menu items from the views provided by the server. The views are sorted according to the\n * {@link ViewConfig.menu.order}, filtered out if they are explicitly excluded via {@link ViewConfig.menu.exclude}.\n * Note that views with no order are put below views with an order. Ties are resolved based on the path string\n * comparison.\n *\n * @returns A list of menu items.\n */\nexport function createMenuItems<T = unknown>(): ReadonlyArray<MenuItem<T>> {\n // @ts-expect-error: esbuild injection\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n ((feature, vaadinObj = (globalThis.Vaadin ??= {})) => {\n vaadinObj.registrations ??= [];\n vaadinObj.registrations.push({\n is: feature ? `@vaadin/hilla-file-router/${feature}` : '@vaadin/hilla-file-router',\n version: '25.1.0',\n });\n})('createMenuItems', (window as VaadinWindow).Vaadin);\n const collator = new Intl.Collator('en-US');\n if (!viewsSignal.value) {\n return [];\n }\n\n const views = Object.entries(viewsSignal.value);\n\n return (\n views\n // Filter out the views that are explicitly excluded from the menu.\n .filter(([path, value]) => !isExcluded(value) && !hasVariablePathSegment(path))\n // Map the views to menu items.\n .map(([path, config]) => ({\n to: path,\n icon: config.menu?.icon,\n title: config.menu?.title ?? config.title,\n order: config.menu?.order,\n detail: config.detail as T | undefined,\n }))\n // Sort views according to the order specified in the view configuration.\n .sort((menuA, menuB) => {\n const ordersDiff = (menuA.order ?? Number.MAX_VALUE) - (menuB.order ?? Number.MAX_VALUE);\n return ordersDiff !== 0 ? ordersDiff : collator.compare(menuA.to, menuB.to);\n })\n );\n}\n\nif (import.meta.hot) {\n import.meta.hot.on('fs-route-update', () => {\n fetch('?v-r=routeinfo')\n .then(async (resp) => resp.json())\n .then((json) => {\n viewsSignal.value = json;\n })\n .catch((e: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AAS,KAAK,MAAM,CAAC,CACjC,KAAK,CAAC,SAAS;AACd,eAAY,QAAQ;EACrB,EAAC,CACD,MAAM,CAACC,MAAe;AACrB,WAAQ,MAAM,8BAA8B,EAAE;EAC/C,EAAC;CACL,EAAC;AACH","names":["viewsSignal: Signal<Readonly<Record<string, Readonly<ViewConfig>>> | undefined>","value: ViewConfig","path: string","e: unknown"],"sources":["/opt/agent/work/649c11185a3798db/packages/ts/file-router/src/runtime/createMenuItems.ts"],"sourcesContent":["/// <reference types=\"vite/client\" />\nimport { type Signal, signal } from '@vaadin/hilla-react-signals';\nimport type { VaadinWindow } from '../shared/internal.js';\nimport type { MenuItem, ViewConfig } from '../types.js';\n\nexport const viewsSignal: Signal<Readonly<Record<string, Readonly<ViewConfig>>> | undefined> = signal(\n (window as VaadinWindow).Vaadin?.views,\n);\n\nfunction isExcluded(value: ViewConfig): boolean {\n return !!value.menu?.exclude;\n}\n\nfunction hasVariablePathSegment(path: string): boolean {\n return path.split('/').some((segment) => segment.startsWith(':'));\n}\n\n/**\n * Creates menu items from the views provided by the server. The views are sorted according to the\n * {@link ViewConfig.menu.order}, filtered out if they are explicitly excluded via {@link ViewConfig.menu.exclude}.\n * Note that views with no order are put below views with an order. Ties are resolved based on the path string\n * comparison.\n *\n * @returns A list of menu items.\n */\nexport function createMenuItems<T = unknown>(): ReadonlyArray<MenuItem<T>> {\n // @ts-expect-error: esbuild injection\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n ((feature, vaadinObj = (globalThis.Vaadin ??= {})) => {\n vaadinObj.registrations ??= [];\n vaadinObj.registrations.push({\n is: feature ? `@vaadin/hilla-file-router/${feature}` : '@vaadin/hilla-file-router',\n version: '25.1.2',\n });\n})('createMenuItems', (window as VaadinWindow).Vaadin);\n const collator = new Intl.Collator('en-US');\n if (!viewsSignal.value) {\n return [];\n }\n\n const views = Object.entries(viewsSignal.value);\n\n return (\n views\n // Filter out the views that are explicitly excluded from the menu.\n .filter(([path, value]) => !isExcluded(value) && !hasVariablePathSegment(path))\n // Map the views to menu items.\n .map(([path, config]) => ({\n to: path,\n icon: config.menu?.icon,\n title: config.menu?.title ?? config.title,\n order: config.menu?.order,\n detail: config.detail as T | undefined,\n }))\n // Sort views according to the order specified in the view configuration.\n .sort((menuA, menuB) => {\n const ordersDiff = (menuA.order ?? Number.MAX_VALUE) - (menuB.order ?? Number.MAX_VALUE);\n return ordersDiff !== 0 ? ordersDiff : collator.compare(menuA.to, menuB.to);\n })\n );\n}\n\nif (import.meta.hot) {\n import.meta.hot.on('fs-route-update', () => {\n fetch('?v-r=routeinfo')\n .then(async (resp) => resp.json())\n .then((json) => {\n viewsSignal.value = json;\n })\n .catch((e: unknown) => {\n console.error('Failed to fetch route info', e);\n });\n });\n}\n"],"version":3}
@@ -1 +1 @@
1
- {"mappings":"AAAA,SAAS,kCAAmC;AAC5C,SAAS,MAAM,iCAAkC;AACjD,SAAS,iDAAkD;AAE3D,SAAS,yBAA0B;;;;;;;;AAgBnC,eAAe,eAAe,aAC5BA,WACAC,aAC+B;AAC/B,KAAI;EACF,MAAM,iBAAiB,MAAM,SAAS,aAAa,QAAQ;EAC3D,MAAMC,mBAA0C,KAAK,MAAM,eAAe;EAC1E,MAAM,cAAc,iBAAiB,IAAI,CAAC,WAAW,MAAM,OAAO,KAAK,CAAC;AAExE,SAAO,cACL,WACA,EAAE,MAAM,GAAI,GACZ,CAAC,OAAO,MAAM,QACZ,MAAM,IAAI,CAAC,SAAS;GAClB,MAAM,cAAc,KAAK,IAAI,MAAM,MAAM,KAAK,KAAK,CAAC;GACpD,MAAM,WAAW,KAAK,WAAW,KAAK,KAAK,UAAU,EAAE,MAAM,YAAa,EAAC,GAAG;AAE9E,UAAO,YAAY,KAAK,CAAC,UAAU,SAAS,MAAM,YAAY,CAAC,WAAW,KAAK,CAAC,GAC5E;IAAE,GAAG;IAAM,YAAY;IAAM;GAAU,IACvC;IAAE,GAAG;IAAM;GAAU;EAC1B,EAAC,CACL;CACF,SAAQC,GAAY;AACnB,MAAI,aAAa,SAAS,UAAU,KAAK,EAAE,SAAS,UAAU;AAC5D,UAAO;EACR;AAED,QAAM;CACP;AACF","names":["routeMeta: readonly RouteMeta[]","layoutsFile: URL","availableLayouts: readonly LayoutMeta[]","e: unknown"],"sources":["/opt/agent/work/649c11185a3798db/packages/ts/file-router/src/vite-plugin/applyLayouts.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { join, relative } from 'node:path/posix';\nimport { transformTree } from '../shared/transformTree.js';\nimport type { RouteMeta } from './collectRoutesFromFS.js';\nimport { strip } from './utils.js';\n\n/**\n * The information about a particular server-side layout.\n */\nexport type LayoutMeta = Readonly<{\n path: string;\n}>;\n\n/**\n * Enables Flow layout flag on the matching routes based on the information from the layouts JSON file.\n *\n * @param routeMeta - The routes tree to process.\n * @param layoutsFile - The server layouts JSON file.\n * @returns Processed routes tree.\n */\nexport default async function applyLayouts(\n routeMeta: readonly RouteMeta[],\n layoutsFile: URL,\n): Promise<readonly RouteMeta[]> {\n try {\n const layoutContents = await readFile(layoutsFile, 'utf-8');\n const availableLayouts: readonly LayoutMeta[] = JSON.parse(layoutContents);\n const layoutPaths = availableLayouts.map((layout) => strip(layout.path));\n\n return transformTree<readonly RouteMeta[], readonly RouteMeta[], { path: string }>(\n routeMeta,\n { path: '' },\n (metas, next, ctx) =>\n metas.map((meta) => {\n const currentPath = join(ctx.path, strip(meta.path));\n const children = meta.children ? next(meta.children, { path: currentPath }) : undefined;\n\n return layoutPaths.some((path) => !relative(path, currentPath).startsWith('..'))\n ? { ...meta, flowLayout: true, children }\n : { ...meta, children };\n }),\n );\n } catch (e: unknown) {\n if (e instanceof Error && 'code' in e && e.code === 'ENOENT') {\n return routeMeta;\n }\n\n throw e;\n }\n}\n"],"version":3}
1
+ {"mappings":"AAAA,SAAS,kCAAmC;AAC5C,SAAS,MAAM,iCAAkC;AACjD,SAAS,iDAAkD;AAE3D,SAAS,yBAA0B;;;;;;;;AAgBnC,eAAe,eAAe,aAC5BA,WACAC,aAC+B;AAC/B,KAAI;EACF,MAAM,iBAAiB,MAAM,SAAS,aAAa,QAAQ;EAC3D,MAAMC,mBAA0C,KAAK,MAAM,eAAe;EAC1E,MAAM,cAAc,iBAAiB,IAAI,CAAC,WAAW,MAAM,OAAO,KAAK,CAAC;AAGxE,SAAO,cACL,WACA,EAAE,MAAM,GAAI,GACZ,CAAC,OAAO,MAAM,QACZ,MAAM,IAAI,CAAC,SAAS;GAClB,MAAM,cAAc,KAAK,IAAI,MAAM,MAAM,KAAK,KAAK,CAAC;GACpD,MAAM,WAAW,KAAK,WAAW,KAAK,KAAK,UAAU,EAAE,MAAM,YAAa,EAAC,GAAG;AAE9E,UAAO,YAAY,KAAK,CAAC,UAAU,SAAS,MAAM,YAAY,CAAC,WAAW,KAAK,CAAC,GAC5E;IAAE,GAAG;IAAM,YAAY;IAAM;GAAU,IACvC;IAAE,GAAG;IAAM;GAAU;EAC1B,EAAC,CACL;CACF,SAAQC,GAAY;AACnB,MAAI,aAAa,SAAS,UAAU,KAAK,EAAE,SAAS,UAAU;AAC5D,UAAO;EACR;AAED,QAAM;CACP;AACF","names":["routeMeta: readonly RouteMeta[]","layoutsFile: URL","availableLayouts: readonly LayoutMeta[]","e: unknown"],"sources":["/opt/agent/work/649c11185a3798db/packages/ts/file-router/src/vite-plugin/applyLayouts.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { join, relative } from 'node:path/posix';\nimport { transformTree } from '../shared/transformTree.js';\nimport type { RouteMeta } from './collectRoutesFromFS.js';\nimport { strip } from './utils.js';\n\n/**\n * The information about a particular server-side layout.\n */\nexport type LayoutMeta = Readonly<{\n path: string;\n}>;\n\n/**\n * Enables Flow layout flag on the matching routes based on the information from the layouts JSON file.\n *\n * @param routeMeta - The routes tree to process.\n * @param layoutsFile - The server layouts JSON file.\n * @returns Processed routes tree.\n */\nexport default async function applyLayouts(\n routeMeta: readonly RouteMeta[],\n layoutsFile: URL,\n): Promise<readonly RouteMeta[]> {\n try {\n const layoutContents = await readFile(layoutsFile, 'utf-8');\n const availableLayouts: readonly LayoutMeta[] = JSON.parse(layoutContents);\n const layoutPaths = availableLayouts.map((layout) => strip(layout.path));\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-arguments\n return transformTree<readonly RouteMeta[], readonly RouteMeta[], { path: string }>(\n routeMeta,\n { path: '' },\n (metas, next, ctx) =>\n metas.map((meta) => {\n const currentPath = join(ctx.path, strip(meta.path));\n const children = meta.children ? next(meta.children, { path: currentPath }) : undefined;\n\n return layoutPaths.some((path) => !relative(path, currentPath).startsWith('..'))\n ? { ...meta, flowLayout: true, children }\n : { ...meta, children };\n }),\n );\n } catch (e: unknown) {\n if (e instanceof Error && 'code' in e && e.code === 'ENOENT') {\n return routeMeta;\n }\n\n throw e;\n }\n}\n"],"version":3}