ソースを参照

refactor @growi/core exports

Yuki Takei 2 年 前
コミット
21811d547f

+ 2 - 4
apps/app/src/components/Page/PageView.tsx

@@ -3,7 +3,8 @@ import React, {
 } from 'react';
 
 
-import { type IPagePopulatedToShowRevision, pagePathUtils } from '@growi/core';
+import type { IPagePopulatedToShowRevision } from '@growi/core';
+import { isUsersHomePage } from '@growi/core/dist/utils/page-path-utils';
 import dynamic from 'next/dynamic';
 
 import type { RendererConfig } from '~/interfaces/services/renderer';
@@ -29,9 +30,6 @@ import RevisionRenderer from './RevisionRenderer';
 import styles from './PageView.module.scss';
 
 
-const { isUsersHomePage } = pagePathUtils;
-
-
 const NotCreatablePage = dynamic(() => import('../NotCreatablePage').then(mod => mod.NotCreatablePage), { ssr: false });
 const ForbiddenPage = dynamic(() => import('../ForbiddenPage'), { ssr: false });
 const NotFoundPage = dynamic(() => import('../NotFoundPage'), { ssr: false });

+ 1 - 3
apps/app/src/components/PageAlert/OldRevisionAlert.tsx

@@ -1,6 +1,6 @@
 import React from 'react';
 
-import { pathUtils } from '@growi/core';
+import { returnPathForURL } from '@growi/core/dist/utils/path-utils';
 import Link from 'next/link';
 import { useTranslation } from 'react-i18next';
 
@@ -12,8 +12,6 @@ export const OldRevisionAlert = (): JSX.Element => {
   const { data: isLatestRevision } = useIsLatestRevision();
   const { data: page } = useSWRxCurrentPage();
 
-  const { returnPathForURL } = pathUtils;
-
   if (page == null || isLatestRevision == null || isLatestRevision) {
     return <></>;
   }

+ 1 - 1
apps/app/src/components/PageEditor/MarkdownTableInterceptor.js

@@ -1,4 +1,4 @@
-import { BasicInterceptor } from '@growi/core';
+import { BasicInterceptor } from '@growi/core/dist/utils';
 
 import MarkdownTable from '~/client/models/MarkdownTable';
 

+ 1 - 1
apps/app/src/components/PageEditor/PreventMarkdownListInterceptor.js

@@ -1,4 +1,4 @@
-import { BasicInterceptor } from '@growi/core';
+import { BasicInterceptor } from '@growi/core/dist/utils';
 
 import mlu from './MarkdownListUtil';
 

+ 2 - 1
apps/app/src/components/PageList/PageListItemL.tsx

@@ -4,11 +4,12 @@ import React, {
 } from 'react';
 
 
-import { DevidedPagePath, pathUtils } from '@growi/core';
 import type {
   IPageInfoAll, IPageWithMeta, IPageInfoForListing,
 } from '@growi/core/dist/interfaces';
 import { isIPageInfoForListing, isIPageInfoForEntity } from '@growi/core/dist/interfaces';
+import { DevidedPagePath } from '@growi/core/dist/models';
+import { pathUtils } from '@growi/core/dist/utils';
 import { UserPicture } from '@growi/ui/dist/components';
 import { PageListMeta } from '@growi/ui/dist/components/PagePath';
 import { format } from 'date-fns';

+ 3 - 3
apps/app/src/components/Sidebar/PageTree/Item.tsx

@@ -4,13 +4,13 @@ import React, {
 
 import nodePath from 'path';
 
-import {
-  pathUtils, pagePathUtils,
-} from '@growi/core';
 import type {
   Nullable,
   IPageHasId, IPageInfoAll, IPageToDeleteWithMeta,
 } from '@growi/core/dist/interfaces';
+import {
+  pathUtils, pagePathUtils,
+} from '@growi/core/dist/utils';
 import { useTranslation } from 'next-i18next';
 import Link from 'next/link';
 import { useDrag, useDrop } from 'react-dnd';

+ 2 - 2
apps/app/src/components/Sidebar/RecentChanges.tsx

@@ -2,8 +2,8 @@ import React, {
   memo, useCallback, useEffect, useState,
 } from 'react';
 
-import { DevidedPagePath, isPopulated } from '@growi/core';
-import type { IPageHasId } from '@growi/core/dist/interfaces';
+import { isPopulated, type IPageHasId } from '@growi/core';
+import { DevidedPagePath } from '@growi/core/dist/models';
 import { UserPicture, FootstampIcon } from '@growi/ui/dist/components';
 import { useTranslation } from 'next-i18next';
 import Link from 'next/link';

+ 2 - 2
apps/app/src/migrations/20191126173016-adjust-pages-path.js

@@ -1,4 +1,4 @@
-import { pathUtils } from '@growi/core';
+import { addHeadingSlash } from '@growi/core/dist/utils/path-utils';
 import mongoose from 'mongoose';
 
 import getPageModel from '~/server/models/page';
@@ -21,7 +21,7 @@ module.exports = {
 
     // create requests for bulkWrite
     const requests = pages.map((page) => {
-      const adjustedPath = pathUtils.addHeadingSlash(page.path);
+      const adjustedPath = addHeadingSlash(page.path);
       return {
         updateOne: {
           filter: { _id: page._id },

+ 2 - 2
apps/app/src/services/renderer/rehype-plugins/relative-links-by-pukiwiki-like-linker.ts

@@ -1,4 +1,4 @@
-import { pathUtils } from '@growi/core';
+import { addTrailingSlash } from '@growi/core/dist/utils/path-utils';
 import { selectAll } from 'hast-util-select';
 import type { Plugin } from 'unified';
 
@@ -13,7 +13,7 @@ const customAnchorsSelector: IAnchorsSelector = (node) => {
 
 const customUrlResolver: IUrlResolver = (relativeHref, basePath) => {
   // generate relative pathname
-  const baseUrl = new URL(pathUtils.addTrailingSlash(basePath), 'https://example.com');
+  const baseUrl = new URL(addTrailingSlash(basePath), 'https://example.com');
   return new URL(relativeHref, baseUrl);
 };
 

+ 1 - 1
apps/app/src/stores/global-notification.ts

@@ -1,4 +1,4 @@
-import { type SWRResponseWithUtils, withUtils } from '@growi/core';
+import { type SWRResponseWithUtils, withUtils } from '@growi/core/dist/utils';
 import useSWRImmutable from 'swr/immutable';
 
 import { IGlobalNotification } from '~/client/interfaces/global-notification';

+ 1 - 1
apps/app/src/stores/maintenanceMode.tsx

@@ -1,4 +1,4 @@
-import { withUtils, type SWRResponseWithUtils } from '@growi/core';
+import { withUtils, type SWRResponseWithUtils } from '@growi/core/dist/utils';
 
 import { apiv3Post } from '~/client/util/apiv3-client';
 

+ 3 - 4
apps/app/src/stores/ui.tsx

@@ -1,10 +1,9 @@
 import { type RefObject, useCallback, useEffect } from 'react';
 
+import { PageGrant, type Nullable } from '@growi/core';
 import {
-  isClient, isServer, pagePathUtils, PageGrant, withUtils,
-} from '@growi/core';
-import type { Nullable } from '@growi/core/dist/interfaces';
-import type { SWRResponseWithUtils } from '@growi/core/dist/utils';
+  type SWRResponseWithUtils, withUtils, pagePathUtils, isClient, isServer,
+} from '@growi/core/dist/utils';
 import { Breakpoint } from '@growi/ui/dist/interfaces';
 import { addBreakpointListener, cleanupBreakpointListener } from '@growi/ui/dist/utils';
 import type { HtmlElementNode } from 'rehype-toc';

+ 2 - 1
apps/app/src/stores/use-next-themes.tsx

@@ -1,4 +1,5 @@
-import { isClient, ColorScheme } from '@growi/core';
+import { ColorScheme } from '@growi/core';
+import { isClient } from '@growi/core/dist/utils';
 import { ThemeProvider, useTheme } from 'next-themes';
 import { ThemeProviderProps, UseThemeProps } from 'next-themes/dist/types';
 

+ 1 - 1
apps/app/src/utils/swr-utils.ts

@@ -1,4 +1,4 @@
-import { isServer } from '@growi/core';
+import { isServer } from '@growi/core/dist/utils';
 
 export const swrGlobalConfiguration = Object.assign(
   {

+ 0 - 4
packages/core/src/index.ts

@@ -1,6 +1,2 @@
 export * from './consts';
 export * from './interfaces';
-export * from './models/devided-page-path';
-export * from './models/vo/error-apiv3';
-export * from './plugin';
-export * from './utils';

+ 1 - 1
packages/remark-attachment-refs/src/client/services/renderer/refs.ts

@@ -1,4 +1,4 @@
-import { pathUtils } from '@growi/core';
+import { pathUtils } from '@growi/core/dist/utils';
 import { remarkGrowiDirectivePluginType } from '@growi/remark-growi-directive';
 import { Schema as SanitizeOption } from 'hast-util-sanitize';
 import { selectAll } from 'hast-util-select';

+ 1 - 1
packages/remark-attachment-refs/src/server/routes/refs.ts

@@ -1,4 +1,4 @@
-import { OptionParser } from '@growi/core';
+import { OptionParser } from '@growi/core/dist/plugin';
 
 import loggerFactory from '../../utils/logger';
 

+ 1 - 1
packages/remark-lsx/src/client/components/LsxPageList/LsxPage.tsx

@@ -1,6 +1,6 @@
 import React, { useMemo } from 'react';
 
-import { pathUtils } from '@growi/core';
+import { pathUtils } from '@growi/core/dist/utils';
 import { PageListMeta, PagePathLabel } from '@growi/ui/dist/components/PagePath';
 import Link from 'next/link';
 

+ 2 - 4
packages/remark-lsx/src/client/services/renderer/lsx.ts

@@ -1,6 +1,6 @@
 import assert from 'assert';
 
-import { pathUtils } from '@growi/core';
+import { hasHeadingSlash, removeTrailingSlash, addTrailingSlash } from '@growi/core/dist/utils/path-utils';
 import { remarkGrowiDirectivePluginType } from '@growi/remark-growi-directive';
 import { Schema as SanitizeOption } from 'hast-util-sanitize';
 import { selectAll } from 'hast-util-select';
@@ -12,8 +12,6 @@ import { visit } from 'unist-util-visit';
 const NODE_NAME_PATTERN = new RegExp(/ls|lsx/);
 const SUPPORTED_ATTRIBUTES = ['prefix', 'num', 'depth', 'sort', 'reverse', 'filter', 'except', 'isSharedPage'];
 
-const { hasHeadingSlash, removeTrailingSlash } = pathUtils;
-
 type DirectiveAttributes = Record<string, string>
 
 
@@ -68,7 +66,7 @@ const pathResolver = (href: string, basePath: string): string => {
   }
 
   // generate relative pathname
-  const baseUrl = new URL(pathUtils.addTrailingSlash(basePath), 'https://example.com');
+  const baseUrl = new URL(addTrailingSlash(basePath), 'https://example.com');
   const relativeUrl = new URL(href, baseUrl);
 
   return removeTrailingSlash(relativeUrl.pathname);

+ 2 - 1
packages/remark-lsx/src/server/routes/list-pages/index.ts

@@ -1,5 +1,6 @@
 
-import { type IUser, OptionParser } from '@growi/core';
+import type { IUser } from '@growi/core/dist/interfaces';
+import { OptionParser } from '@growi/core/dist/plugin';
 import { pathUtils } from '@growi/core/dist/utils';
 import escapeStringRegexp from 'escape-string-regexp';
 import type { Request, Response } from 'express';