Move router-slot exports to @umbraco-cms/backoffice/router (#18962)

* move router-slot files to core/router

* remove external module

* generate tsconfig

* fix imports

* ignore lint errors

* ignore diff package
This commit is contained in:
Mads Rasmussen
2025-04-09 08:45:20 +02:00
committed by GitHub
parent af07c42120
commit 10a70a8397
24 changed files with 17 additions and 16 deletions

View File

@@ -120,7 +120,6 @@
"./external/marked": "./dist-cms/external/marked/index.js",
"./external/monaco-editor": "./dist-cms/external/monaco-editor/index.js",
"./external/openid": "./dist-cms/external/openid/index.js",
"./external/router-slot": "./dist-cms/external/router-slot/index.js",
"./external/rxjs": "./dist-cms/external/rxjs/index.js",
"./external/tiptap": "./dist-cms/external/tiptap/index.js",
"./external/uui": "./dist-cms/external/uui/index.js"

View File

@@ -1,14 +1,13 @@
import { UmbModalToken } from '../token/modal-token.js';
import type { UmbModalConfig, UmbModalType } from '../types.js';
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
import type { IRouterSlot } from '@umbraco-cms/backoffice/external/router-slot';
import type { UUIModalElement, UUIModalSidebarSize } from '@umbraco-cms/backoffice/external/uui';
import { UmbId } from '@umbraco-cms/backoffice/id';
import { UmbObjectState, UmbStringState } from '@umbraco-cms/backoffice/observable-api';
import { UmbControllerBase } from '@umbraco-cms/backoffice/class-api';
import { type UmbDeepPartialObject, umbDeepMerge } from '@umbraco-cms/backoffice/utils';
import type { ElementLoaderProperty } from '@umbraco-cms/backoffice/extension-api';
import { UMB_ROUTE_CONTEXT } from '@umbraco-cms/backoffice/router';
import { UMB_ROUTE_CONTEXT, type IRouterSlot } from '@umbraco-cms/backoffice/router';
export interface UmbModalRejectReason {
type: string;

View File

@@ -1,12 +1,12 @@
import { umbGenerateRoutePathBuilder } from '../../generate-route-path-builder.function.js';
import type { UmbModalRouteRegistration } from '../../modal-registration/modal-route-registration.interface.js';
import type { UmbRoute } from './route.interface.js';
import type { IRouterSlot } from '@umbraco-cms/backoffice/external/router-slot';
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
import { UmbContextBase } from '@umbraco-cms/backoffice/class-api';
import { UMB_MODAL_MANAGER_CONTEXT } from '@umbraco-cms/backoffice/modal';
import { UmbStringState, mergeObservables } from '@umbraco-cms/backoffice/observable-api';
import type { IRouterSlot } from '../../router-slot/index.js';
const EmptyDiv = document.createElement('div');

View File

@@ -1 +1 @@
export type { IRoute as UmbRoute } from '@umbraco-cms/backoffice/external/router-slot';
export type { IRoute as UmbRoute } from '../../router-slot/index.js';

View File

@@ -1,4 +1,3 @@
import '@umbraco-cms/backoffice/external/router-slot';
import { UmbRoutePathAddendumResetContext } from '../../contexts/route-path-addendum-reset.context.js';
import { UmbRouterSlotInitEvent } from './router-slot-init.event.js';
import { UmbRouterSlotChangeEvent } from './router-slot-change.event.js';
@@ -6,7 +5,7 @@ import type { UmbRoute } from './route.interface.js';
import { UmbRouteContext } from './route.context.js';
import { css, html, type PropertyValueMap, customElement, property } from '@umbraco-cms/backoffice/external/lit';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
import type { IRouterSlot } from '@umbraco-cms/backoffice/external/router-slot';
import type { IRouterSlot } from '../../router-slot/index.js';
/**
* @element umb-router-slot

View File

@@ -1,5 +1,5 @@
import { type UrlParametersRecord, umbUrlPatternToString } from '../utils/path/url-pattern-to-string.function.js';
import { stripSlash } from '@umbraco-cms/backoffice/external/router-slot'; // This must only include the util to avoid side effects of registering the route element.
import { umbUrlPatternToString, type UrlParametersRecord } from '@umbraco-cms/backoffice/utils';
import { stripSlash } from './router-slot/util.js';
/**
*

View File

@@ -4,6 +4,6 @@ export * from './contexts/index.js';
export * from './encode-folder-name.function.js';
export * from './modal-registration/modal-route-registration.controller.js';
export * from './path-pattern.class.js';
export * from '@umbraco-cms/backoffice/external/router-slot';
export * from './router-slot/index.js';
export type * from './modal-registration/modal-route-registration.interface.js';
export type * from './types.js';

View File

@@ -1,4 +1,5 @@
import { UMB_ROUTE_CONTEXT, UMB_ROUTE_PATH_ADDENDUM_CONTEXT } from '../index.js';
import type { IRouterSlot, Params } from '../router-slot/index.js';
import { encodeFolderName } from '../encode-folder-name.function.js';
import type { UmbModalRouteRegistration } from './modal-route-registration.interface.js';
import type {
@@ -12,7 +13,6 @@ import type { UmbControllerAlias, UmbControllerHost } from '@umbraco-cms/backoff
import { UmbControllerBase } from '@umbraco-cms/backoffice/class-api';
import { UmbId } from '@umbraco-cms/backoffice/id';
import type { UmbDeepPartialObject } from '@umbraco-cms/backoffice/utils';
import type { IRouterSlot, Params } from '@umbraco-cms/backoffice/external/router-slot';
export type UmbModalRouteBuilder = (params: { [key: string]: string | number } | null) => string;

View File

@@ -1,5 +1,5 @@
import type { IRouterSlot, Params } from '../router-slot/index.js';
import type { UmbModalRouteBuilder } from './modal-route-registration.controller.js';
import type { IRouterSlot, Params } from '@umbraco-cms/backoffice/external/router-slot';
import type { UmbModalContext, UmbModalManagerContext, UmbModalToken } from '@umbraco-cms/backoffice/modal';
export interface UmbModalRouteRegistration<

View File

@@ -1,5 +1,6 @@
import type { PathMatch } from './model.js';
/* eslint-disable local-rules/exported-string-constant-naming */
export const CATCH_ALL_WILDCARD: string = '**';
export const TRAVERSE_FLAG: string = '\\.\\.\\/';
export const PARAM_IDENTIFIER: RegExp = /:([^\\/]+)/g;

View File

@@ -18,6 +18,7 @@ export type IRoutingInfo<D = any, P = any> = {
match: IRouteMatch<D>;
};
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export type CustomResolver<D = any, P = any> = (
info: IRoutingInfo<D>,
) => boolean | void | Promise<boolean> | Promise<void>;

View File

@@ -44,6 +44,7 @@ ensureAnchorHistory();
* @slot - Default content.
* @event changestate - Dispatched when the router slot state changes.
*/
// eslint-disable-next-line local-rules/enforce-element-suffix-on-element-class-name, local-rules/umb-class-prefix
export class RouterSlot<D = any, P = any> extends HTMLElement implements IRouterSlot<D, P> {
/**
* Method to cancel navigation if changed.

View File

@@ -1,5 +1,5 @@
import { GLOBAL_ROUTER_EVENTS_TARGET } from '../config.js';
import type { EventListenerSubscription, GlobalRouterEvent, IRoute, IRoutingInfo } from '../model.js';
import type { EventListenerSubscription, GlobalRouterEvent, IRoutingInfo } from '../model.js';
/**
* Dispatches a did change route event.

View File

@@ -1,3 +1,4 @@
/* eslint-disable no-useless-escape */
import { CATCH_ALL_WILDCARD, DEFAULT_PATH_MATCH, PARAM_IDENTIFIER, TRAVERSE_FLAG } from '../config.js';
import type {
IComponentRoute,
@@ -131,6 +132,7 @@ export async function resolvePageComponent(route: IComponentRoute, info: IRoutin
let cmp = route.component;
if (cmp instanceof Function) {
try {
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
cmp = (cmp as Function)();
} catch (err) {
// The invocation most likely failed because the function is a class.
@@ -188,7 +190,7 @@ export function isResolverRoute(route: IRoute): route is IResolverRoute {
*/
export function traverseRouterTree(slot: IRouterSlot): { tree: RouterTree; depth: number } {
// Find the nodes from the route up to the root route
let routes: IRouterSlot[] = [slot];
const routes: IRouterSlot[] = [slot];
while (slot.parent != null) {
slot = slot.parent;
routes.push(slot);

View File

@@ -1,5 +1,5 @@
import type { IRoutingInfo, PageComponent } from '@umbraco-cms/backoffice/external/router-slot';
import type { UmbApi } from '@umbraco-cms/backoffice/extension-api';
import type { IRoutingInfo, PageComponent } from './router-slot/index.js';
export interface UmbRouteEntry extends UmbApi {
getPath?(): string;

View File

@@ -149,7 +149,6 @@ DON'T EDIT THIS FILE DIRECTLY. It is generated by /devops/tsconfig/index.js
"@umbraco-cms/backoffice/external/marked": ["./src/external/marked/index.ts"],
"@umbraco-cms/backoffice/external/monaco-editor": ["./src/external/monaco-editor/index.ts"],
"@umbraco-cms/backoffice/external/openid": ["./src/external/openid/index.ts"],
"@umbraco-cms/backoffice/external/router-slot": ["./src/external/router-slot/index.ts"],
"@umbraco-cms/backoffice/external/rxjs": ["./src/external/rxjs/index.ts"],
"@umbraco-cms/backoffice/external/tiptap": ["./src/external/tiptap/index.ts"],
"@umbraco-cms/backoffice/external/uui": ["./src/external/uui/index.ts"]