@growi/core 1.0.0-next.0
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/dist/consts/accepted-upload-file-type.cjs +2 -0
- package/dist/consts/accepted-upload-file-type.cjs.map +1 -0
- package/dist/consts/accepted-upload-file-type.d.ts +6 -0
- package/dist/consts/accepted-upload-file-type.js +9 -0
- package/dist/consts/accepted-upload-file-type.js.map +1 -0
- package/dist/consts/growi-plugin.cjs +2 -0
- package/dist/consts/growi-plugin.cjs.map +1 -0
- package/dist/consts/growi-plugin.d.ts +7 -0
- package/dist/consts/growi-plugin.js +10 -0
- package/dist/consts/growi-plugin.js.map +1 -0
- package/dist/consts/index.cjs +2 -0
- package/dist/consts/index.cjs.map +1 -0
- package/dist/consts/index.d.ts +2 -0
- package/dist/consts/index.js +7 -0
- package/dist/consts/index.js.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/attachment.cjs +2 -0
- package/dist/interfaces/attachment.cjs.map +1 -0
- package/dist/interfaces/attachment.d.ts +19 -0
- package/dist/interfaces/attachment.js +2 -0
- package/dist/interfaces/attachment.js.map +1 -0
- package/dist/interfaces/color-scheme.cjs +2 -0
- package/dist/interfaces/color-scheme.cjs.map +1 -0
- package/dist/interfaces/color-scheme.d.ts +5 -0
- package/dist/interfaces/color-scheme.js +8 -0
- package/dist/interfaces/color-scheme.js.map +1 -0
- package/dist/interfaces/common.cjs +2 -0
- package/dist/interfaces/common.cjs.map +1 -0
- package/dist/interfaces/common.d.ts +6 -0
- package/dist/interfaces/common.js +6 -0
- package/dist/interfaces/common.js.map +1 -0
- package/dist/interfaces/external-account.cjs +2 -0
- package/dist/interfaces/external-account.cjs.map +1 -0
- package/dist/interfaces/external-account.d.ts +19 -0
- package/dist/interfaces/external-account.js +12 -0
- package/dist/interfaces/external-account.js.map +1 -0
- package/dist/interfaces/growi-facade.cjs +2 -0
- package/dist/interfaces/growi-facade.cjs.map +1 -0
- package/dist/interfaces/growi-facade.d.ts +11 -0
- package/dist/interfaces/growi-facade.js +2 -0
- package/dist/interfaces/growi-facade.js.map +1 -0
- package/dist/interfaces/growi-theme-metadata.cjs +2 -0
- package/dist/interfaces/growi-theme-metadata.cjs.map +1 -0
- package/dist/interfaces/growi-theme-metadata.d.ts +19 -0
- package/dist/interfaces/growi-theme-metadata.js +9 -0
- package/dist/interfaces/growi-theme-metadata.js.map +1 -0
- package/dist/interfaces/has-object-id.cjs +2 -0
- package/dist/interfaces/has-object-id.cjs.map +1 -0
- package/dist/interfaces/has-object-id.d.ts +3 -0
- package/dist/interfaces/has-object-id.js +2 -0
- package/dist/interfaces/has-object-id.js.map +1 -0
- package/dist/interfaces/index.cjs +2 -0
- package/dist/interfaces/index.cjs.map +1 -0
- package/dist/interfaces/index.d.ts +16 -0
- package/dist/interfaces/index.js +32 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/interfaces/lang.cjs +2 -0
- package/dist/interfaces/lang.cjs.map +1 -0
- package/dist/interfaces/lang.d.ts +8 -0
- package/dist/interfaces/lang.js +11 -0
- package/dist/interfaces/lang.js.map +1 -0
- package/dist/interfaces/page.cjs +2 -0
- package/dist/interfaces/page.cjs.map +1 -0
- package/dist/interfaces/page.d.ts +113 -0
- package/dist/interfaces/page.js +20 -0
- package/dist/interfaces/page.js.map +1 -0
- package/dist/interfaces/revision.cjs +2 -0
- package/dist/interfaces/revision.cjs.map +1 -0
- package/dist/interfaces/revision.d.ts +36 -0
- package/dist/interfaces/revision.js +9 -0
- package/dist/interfaces/revision.js.map +1 -0
- package/dist/interfaces/subscription.cjs +2 -0
- package/dist/interfaces/subscription.cjs.map +1 -0
- package/dist/interfaces/subscription.d.ts +19 -0
- package/dist/interfaces/subscription.js +9 -0
- package/dist/interfaces/subscription.js.map +1 -0
- package/dist/interfaces/tag.cjs +2 -0
- package/dist/interfaces/tag.cjs.map +1 -0
- package/dist/interfaces/tag.d.ts +4 -0
- package/dist/interfaces/tag.js +2 -0
- package/dist/interfaces/tag.js.map +1 -0
- package/dist/interfaces/user.cjs +2 -0
- package/dist/interfaces/user.cjs.map +1 -0
- package/dist/interfaces/user.d.ts +57 -0
- package/dist/interfaces/user.js +11 -0
- package/dist/interfaces/user.js.map +1 -0
- package/dist/interfaces/vite.cjs +2 -0
- package/dist/interfaces/vite.cjs.map +1 -0
- package/dist/interfaces/vite.d.ts +9 -0
- package/dist/interfaces/vite.js +2 -0
- package/dist/interfaces/vite.js.map +1 -0
- package/dist/interfaces/websocket.cjs +2 -0
- package/dist/interfaces/websocket.cjs.map +1 -0
- package/dist/interfaces/websocket.d.ts +5 -0
- package/dist/interfaces/websocket.js +9 -0
- package/dist/interfaces/websocket.js.map +1 -0
- package/dist/models/devided-page-path.cjs +2 -0
- package/dist/models/devided-page-path.cjs.map +1 -0
- package/dist/models/devided-page-path.d.ts +7 -0
- package/dist/models/devided-page-path.js +29 -0
- package/dist/models/devided-page-path.js.map +1 -0
- package/dist/models/index.cjs +2 -0
- package/dist/models/index.cjs.map +1 -0
- package/dist/models/index.d.ts +2 -0
- package/dist/models/index.js +7 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/vo/error-apiv3.cjs +2 -0
- package/dist/models/vo/error-apiv3.cjs.map +1 -0
- package/dist/models/vo/error-apiv3.d.ts +5 -0
- package/dist/models/vo/error-apiv3.js +9 -0
- package/dist/models/vo/error-apiv3.js.map +1 -0
- package/dist/remark-plugins/index.cjs +2 -0
- package/dist/remark-plugins/index.cjs.map +1 -0
- package/dist/remark-plugins/index.d.ts +2 -0
- package/dist/remark-plugins/index.js +5 -0
- package/dist/remark-plugins/index.js.map +1 -0
- package/dist/remark-plugins/interfaces/option-parser.cjs +2 -0
- package/dist/remark-plugins/interfaces/option-parser.cjs.map +1 -0
- package/dist/remark-plugins/interfaces/option-parser.d.ts +4 -0
- package/dist/remark-plugins/interfaces/option-parser.js +2 -0
- package/dist/remark-plugins/interfaces/option-parser.js.map +1 -0
- package/dist/remark-plugins/util/option-parser.cjs +2 -0
- package/dist/remark-plugins/util/option-parser.cjs.map +1 -0
- package/dist/remark-plugins/util/option-parser.d.ts +26 -0
- package/dist/remark-plugins/util/option-parser.js +39 -0
- package/dist/remark-plugins/util/option-parser.js.map +1 -0
- package/dist/remark-plugins/util/option-parser.spec.d.ts +1 -0
- package/dist/swr/index.cjs +2 -0
- package/dist/swr/index.cjs.map +1 -0
- package/dist/swr/index.d.ts +3 -0
- package/dist/swr/index.js +11 -0
- package/dist/swr/index.js.map +1 -0
- package/dist/swr/use-global-socket.cjs +2 -0
- package/dist/swr/use-global-socket.cjs.map +1 -0
- package/dist/swr/use-global-socket.d.ts +6 -0
- package/dist/swr/use-global-socket.js +8 -0
- package/dist/swr/use-global-socket.js.map +1 -0
- package/dist/swr/use-swr-static.cjs +2 -0
- package/dist/swr/use-swr-static.cjs.map +1 -0
- package/dist/swr/use-swr-static.d.ts +5 -0
- package/dist/swr/use-swr-static.js +17 -0
- package/dist/swr/use-swr-static.js.map +1 -0
- package/dist/swr/with-utils.cjs +2 -0
- package/dist/swr/with-utils.cjs.map +1 -0
- package/dist/swr/with-utils.d.ts +4 -0
- package/dist/swr/with-utils.js +5 -0
- package/dist/swr/with-utils.js.map +1 -0
- package/dist/utils/browser-utils.cjs +2 -0
- package/dist/utils/browser-utils.cjs.map +1 -0
- package/dist/utils/browser-utils.d.ts +2 -0
- package/dist/utils/browser-utils.js +6 -0
- package/dist/utils/browser-utils.js.map +1 -0
- package/dist/utils/env-utils.cjs +2 -0
- package/dist/utils/env-utils.cjs.map +1 -0
- package/dist/utils/env-utils.d.ts +5 -0
- package/dist/utils/env-utils.js +7 -0
- package/dist/utils/env-utils.js.map +1 -0
- package/dist/utils/env-utils.spec.d.ts +1 -0
- package/dist/utils/growi-theme-metadata.cjs +2 -0
- package/dist/utils/growi-theme-metadata.cjs.map +1 -0
- package/dist/utils/growi-theme-metadata.d.ts +4 -0
- package/dist/utils/growi-theme-metadata.js +6 -0
- package/dist/utils/growi-theme-metadata.js.map +1 -0
- package/dist/utils/index.cjs +2 -0
- package/dist/utils/index.cjs.map +1 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/index.js +21 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/objectid-utils.cjs +2 -0
- package/dist/utils/objectid-utils.cjs.map +1 -0
- package/dist/utils/objectid-utils.d.ts +3 -0
- package/dist/utils/objectid-utils.js +8 -0
- package/dist/utils/objectid-utils.js.map +1 -0
- package/dist/utils/objectid-utils.spec.d.ts +1 -0
- package/dist/utils/page-path-utils/index.cjs +2 -0
- package/dist/utils/page-path-utils/index.cjs.map +1 -0
- package/dist/utils/page-path-utils/index.d.ts +125 -0
- package/dist/utils/page-path-utils/index.js +91 -0
- package/dist/utils/page-path-utils/index.js.map +1 -0
- package/dist/utils/page-path-utils/index.spec.d.ts +1 -0
- package/dist/utils/page-path-utils/is-top-page.cjs +2 -0
- package/dist/utils/page-path-utils/is-top-page.cjs.map +1 -0
- package/dist/utils/page-path-utils/is-top-page.d.ts +5 -0
- package/dist/utils/page-path-utils/is-top-page.js +5 -0
- package/dist/utils/page-path-utils/is-top-page.js.map +1 -0
- package/dist/utils/page-path-utils/is-top-page.spec.d.ts +1 -0
- package/dist/utils/page-utils.cjs +2 -0
- package/dist/utils/page-utils.cjs.map +1 -0
- package/dist/utils/page-utils.d.ts +18 -0
- package/dist/utils/page-utils.js +13 -0
- package/dist/utils/page-utils.js.map +1 -0
- package/dist/utils/path-utils.cjs +2 -0
- package/dist/utils/path-utils.cjs.map +1 -0
- package/dist/utils/path-utils.d.ts +66 -0
- package/dist/utils/path-utils.js +45 -0
- package/dist/utils/path-utils.js.map +1 -0
- package/dist/utils/path-utils.spec.d.ts +1 -0
- package/dist/utils/template-checker.cjs +2 -0
- package/dist/utils/template-checker.cjs.map +1 -0
- package/dist/utils/template-checker.d.ts +4 -0
- package/dist/utils/template-checker.js +7 -0
- package/dist/utils/template-checker.js.map +1 -0
- package/package.json +75 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { isTopPage as n } from "./page-path-utils/is-top-page.js";
|
|
2
|
+
const u = 2, s = 3, o = "deleted", i = (t) => {
|
|
3
|
+
const { path: r, parent: e } = t;
|
|
4
|
+
return !!(n(r) || e != null);
|
|
5
|
+
}, a = (t) => {
|
|
6
|
+
const { grant: r, status: e } = t;
|
|
7
|
+
return r === u || r === s || e === o || i(t), !0;
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
i as isOnTree,
|
|
11
|
+
a as isPageNormalized
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=page-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-utils.js","sources":["../../src/utils/page-utils.ts"],"sourcesContent":["import { IPage } from '..';\n\nimport { isTopPage } from './page-path-utils/is-top-page';\n\n// const GRANT_PUBLIC = 1;\nconst GRANT_RESTRICTED = 2;\nconst GRANT_SPECIFIED = 3; // DEPRECATED\n// const GRANT_OWNER = 4;\n// const GRANT_USER_GROUP = 5;\n// const PAGE_GRANT_ERROR = 1;\n// const STATUS_PUBLISHED = 'published';\nconst STATUS_DELETED = 'deleted';\n\n/**\n * Returns true if the page is on tree including the top page.\n * @param page Page\n * @returns boolean\n */\nexport const isOnTree = (page: IPage): boolean => {\n const { path, parent } = page;\n\n if (isTopPage(path)) {\n return true;\n }\n\n if (parent != null) {\n return true;\n }\n\n return false;\n};\n\n/**\n * Returns true if the page meet the condition below.\n * - The page is on tree (has parent or the top page)\n * - The page's grant is GRANT_RESTRICTED or GRANT_SPECIFIED\n * - The page's status is STATUS_DELETED\n * This does not check grantedUser or grantedGroup.\n * @param page PageDocument\n * @returns boolean\n */\nexport const isPageNormalized = (page: IPage): boolean => {\n const { grant, status } = page;\n\n if (grant === GRANT_RESTRICTED || grant === GRANT_SPECIFIED) {\n return true;\n }\n\n if (status === STATUS_DELETED) {\n return true;\n }\n\n if (isOnTree(page)) {\n return true;\n }\n\n return true;\n};\n"],"names":["GRANT_RESTRICTED","GRANT_SPECIFIED","STATUS_DELETED","isOnTree","page","path","parent","isTopPage","isPageNormalized","grant","status"],"mappings":";AAKA,MAAMA,IAAmB,GACnBC,IAAkB,GAKlBC,IAAiB,WAOVC,IAAW,CAACC,MAAyB;AAC1C,QAAA,EAAE,MAAAC,GAAM,QAAAC,EAAW,IAAAF;AAMzB,SAJI,GAAAG,EAAUF,CAAI,KAIdC,KAAU;AAKhB,GAWaE,IAAmB,CAACJ,MAAyB;AAClD,QAAA,EAAE,OAAAK,GAAO,QAAAC,EAAW,IAAAN;AAUtB,SARAK,MAAUT,KAAoBS,MAAUR,KAIxCS,MAAWR,KAIXC,EAASC,CAAI,GACR;AAIX;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function e(n){return n.match(/^((\/+)?(.+?))(\/+)?$/)}function i(n){return n===""?!1:e(n)[2]!=null}function t(n){return n===""?!1:e(n)[4]!=null}function u(n){return n==="/"||i(n)?n:`/${n}`}function a(n){return n==="/"||t(n)?n:`${n}/`}function l(n){return n==="/"?n:i(n)?n.substring(1):n}function s(n){return n==="/"?n:e(n)[1]}function c(n){if(n===""||n==="/")return"/";const r=e(n);return r==null?"/":`/${r[3]}`}function o(n){return`# ${n}`}function f(n,r){return n==="/"?n:u(r)}exports.addHeadingSlash=u;exports.addTrailingSlash=a;exports.attachTitleHeader=o;exports.hasHeadingSlash=i;exports.hasTrailingSlash=t;exports.normalizePath=c;exports.removeHeadingSlash=l;exports.removeTrailingSlash=s;exports.returnPathForURL=f;
|
|
2
|
+
//# sourceMappingURL=path-utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-utils.cjs","sources":["../../src/utils/path-utils.js"],"sourcesContent":["/**\n * @private\n *\n *\n * @param {string} path\n * @returns {RegExpMatchArray}\n * @memberof pathUtils\n */\nfunction matchSlashes(path) {\n // https://regex101.com/r/Z21fEd/5\n return path.match(/^((\\/+)?(.+?))(\\/+)?$/);\n}\n\n/**\n *\n * @param {string} path\n * @returns {boolean}\n * @memberof pathUtils\n */\nexport function hasHeadingSlash(path) {\n if (path === '') {\n return false;\n }\n const match = matchSlashes(path);\n return (match[2] != null);\n}\n\n/**\n *\n * @param {string} path\n * @returns {boolean}\n * @memberof pathUtils\n */\nexport function hasTrailingSlash(path) {\n if (path === '') {\n return false;\n }\n const match = matchSlashes(path);\n return (match[4] != null);\n}\n\n/**\n *\n * @param {string} path\n * @returns {string}\n * @memberof pathUtils\n */\nexport function addHeadingSlash(path) {\n if (path === '/') {\n return path;\n }\n\n if (!hasHeadingSlash(path)) {\n return `/${path}`;\n }\n return path;\n}\n\n/**\n *\n * @param {string} path\n * @returns {string}\n * @memberof pathUtils\n */\nexport function addTrailingSlash(path) {\n if (path === '/') {\n return path;\n }\n\n if (!hasTrailingSlash(path)) {\n return `${path}/`;\n }\n return path;\n}\n\n/**\n *\n * @param {string} path\n * @returns {string}\n * @memberof pathUtils\n */\nexport function removeHeadingSlash(path) {\n if (path === '/') {\n return path;\n }\n\n return hasHeadingSlash(path)\n ? path.substring(1)\n : path;\n}\n\n/**\n *\n * @param {string} path\n * @returns {string}\n * @memberof pathUtils\n */\nexport function removeTrailingSlash(path) {\n if (path === '/') {\n return path;\n }\n\n const match = matchSlashes(path);\n return match[1];\n}\n\n/**\n * A short-hand method to add heading slash and remove trailing slash.\n *\n * @param {string} path\n * @returns {string}\n * @memberof pathUtils\n */\nexport function normalizePath(path) {\n if (path === '' || path === '/') {\n return '/';\n }\n\n const match = matchSlashes(path);\n if (match == null) {\n return '/';\n }\n return `/${match[3]}`;\n}\n\n\n/**\n *\n * @param {string} path\n * @returns {string}\n * @memberof pathUtils\n */\nexport function attachTitleHeader(path) {\n return `# ${path}`;\n}\n\n/**\n * If the pagePath is top page path, eliminate the pageId from the url path.\n *\n * @param {string} path\n * @param {string} id\n * @returns {string}\n * @memberof pathUtils\n */\nexport function returnPathForURL(path, id) {\n if (path === '/') {\n return path;\n }\n\n return addHeadingSlash(id);\n}\n"],"names":["matchSlashes","path","hasHeadingSlash","hasTrailingSlash","addHeadingSlash","addTrailingSlash","removeHeadingSlash","removeTrailingSlash","normalizePath","match","attachTitleHeader","returnPathForURL","id"],"mappings":"gFAQA,SAASA,EAAaC,EAAM,CAE1B,OAAOA,EAAK,MAAM,uBAAuB,CAC3C,CAQO,SAASC,EAAgBD,EAAM,CACpC,OAAIA,IAAS,GACJ,GAEKD,EAAaC,CAAI,EACjB,CAAC,GAAK,IACtB,CAQO,SAASE,EAAiBF,EAAM,CACrC,OAAIA,IAAS,GACJ,GAEKD,EAAaC,CAAI,EACjB,CAAC,GAAK,IACtB,CAQO,SAASG,EAAgBH,EAAM,CACpC,OAAIA,IAAS,KAIRC,EAAgBD,CAAI,EAHhBA,EAIA,IAAIA,CAAI,EAGnB,CAQO,SAASI,EAAiBJ,EAAM,CACrC,OAAIA,IAAS,KAIRE,EAAiBF,CAAI,EAHjBA,EAIA,GAAGA,CAAI,GAGlB,CAQO,SAASK,EAAmBL,EAAM,CACvC,OAAIA,IAAS,IACJA,EAGFC,EAAgBD,CAAI,EACvBA,EAAK,UAAU,CAAC,EAChBA,CACN,CAQO,SAASM,EAAoBN,EAAM,CACxC,OAAIA,IAAS,IACJA,EAGKD,EAAaC,CAAI,EAClB,CAAC,CAChB,CASO,SAASO,EAAcP,EAAM,CAClC,GAAIA,IAAS,IAAMA,IAAS,IAC1B,MAAO,IAGT,MAAMQ,EAAQT,EAAaC,CAAI,EAC/B,OAAIQ,GAAS,KACJ,IAEF,IAAIA,EAAM,CAAC,CAAC,EACrB,CASO,SAASC,EAAkBT,EAAM,CACtC,MAAO,KAAKA,CAAI,EAClB,CAUO,SAASU,EAAiBV,EAAMW,EAAI,CACzC,OAAIX,IAAS,IACJA,EAGFG,EAAgBQ,CAAE,CAC3B"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {string} path
|
|
4
|
+
* @returns {boolean}
|
|
5
|
+
* @memberof pathUtils
|
|
6
|
+
*/
|
|
7
|
+
export function hasHeadingSlash(path: string): boolean;
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param {string} path
|
|
11
|
+
* @returns {boolean}
|
|
12
|
+
* @memberof pathUtils
|
|
13
|
+
*/
|
|
14
|
+
export function hasTrailingSlash(path: string): boolean;
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @param {string} path
|
|
18
|
+
* @returns {string}
|
|
19
|
+
* @memberof pathUtils
|
|
20
|
+
*/
|
|
21
|
+
export function addHeadingSlash(path: string): string;
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* @param {string} path
|
|
25
|
+
* @returns {string}
|
|
26
|
+
* @memberof pathUtils
|
|
27
|
+
*/
|
|
28
|
+
export function addTrailingSlash(path: string): string;
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @param {string} path
|
|
32
|
+
* @returns {string}
|
|
33
|
+
* @memberof pathUtils
|
|
34
|
+
*/
|
|
35
|
+
export function removeHeadingSlash(path: string): string;
|
|
36
|
+
/**
|
|
37
|
+
*
|
|
38
|
+
* @param {string} path
|
|
39
|
+
* @returns {string}
|
|
40
|
+
* @memberof pathUtils
|
|
41
|
+
*/
|
|
42
|
+
export function removeTrailingSlash(path: string): string;
|
|
43
|
+
/**
|
|
44
|
+
* A short-hand method to add heading slash and remove trailing slash.
|
|
45
|
+
*
|
|
46
|
+
* @param {string} path
|
|
47
|
+
* @returns {string}
|
|
48
|
+
* @memberof pathUtils
|
|
49
|
+
*/
|
|
50
|
+
export function normalizePath(path: string): string;
|
|
51
|
+
/**
|
|
52
|
+
*
|
|
53
|
+
* @param {string} path
|
|
54
|
+
* @returns {string}
|
|
55
|
+
* @memberof pathUtils
|
|
56
|
+
*/
|
|
57
|
+
export function attachTitleHeader(path: string): string;
|
|
58
|
+
/**
|
|
59
|
+
* If the pagePath is top page path, eliminate the pageId from the url path.
|
|
60
|
+
*
|
|
61
|
+
* @param {string} path
|
|
62
|
+
* @param {string} id
|
|
63
|
+
* @returns {string}
|
|
64
|
+
* @memberof pathUtils
|
|
65
|
+
*/
|
|
66
|
+
export function returnPathForURL(path: string, id: string): string;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
function e(n) {
|
|
2
|
+
return n.match(/^((\/+)?(.+?))(\/+)?$/);
|
|
3
|
+
}
|
|
4
|
+
function u(n) {
|
|
5
|
+
return n === "" ? !1 : e(n)[2] != null;
|
|
6
|
+
}
|
|
7
|
+
function i(n) {
|
|
8
|
+
return n === "" ? !1 : e(n)[4] != null;
|
|
9
|
+
}
|
|
10
|
+
function t(n) {
|
|
11
|
+
return n === "/" || u(n) ? n : `/${n}`;
|
|
12
|
+
}
|
|
13
|
+
function c(n) {
|
|
14
|
+
return n === "/" || i(n) ? n : `${n}/`;
|
|
15
|
+
}
|
|
16
|
+
function f(n) {
|
|
17
|
+
return n === "/" ? n : u(n) ? n.substring(1) : n;
|
|
18
|
+
}
|
|
19
|
+
function l(n) {
|
|
20
|
+
return n === "/" ? n : e(n)[1];
|
|
21
|
+
}
|
|
22
|
+
function o(n) {
|
|
23
|
+
if (n === "" || n === "/")
|
|
24
|
+
return "/";
|
|
25
|
+
const r = e(n);
|
|
26
|
+
return r == null ? "/" : `/${r[3]}`;
|
|
27
|
+
}
|
|
28
|
+
function s(n) {
|
|
29
|
+
return `# ${n}`;
|
|
30
|
+
}
|
|
31
|
+
function a(n, r) {
|
|
32
|
+
return n === "/" ? n : t(r);
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
t as addHeadingSlash,
|
|
36
|
+
c as addTrailingSlash,
|
|
37
|
+
s as attachTitleHeader,
|
|
38
|
+
u as hasHeadingSlash,
|
|
39
|
+
i as hasTrailingSlash,
|
|
40
|
+
o as normalizePath,
|
|
41
|
+
f as removeHeadingSlash,
|
|
42
|
+
l as removeTrailingSlash,
|
|
43
|
+
a as returnPathForURL
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=path-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-utils.js","sources":["../../src/utils/path-utils.js"],"sourcesContent":["/**\n * @private\n *\n *\n * @param {string} path\n * @returns {RegExpMatchArray}\n * @memberof pathUtils\n */\nfunction matchSlashes(path) {\n // https://regex101.com/r/Z21fEd/5\n return path.match(/^((\\/+)?(.+?))(\\/+)?$/);\n}\n\n/**\n *\n * @param {string} path\n * @returns {boolean}\n * @memberof pathUtils\n */\nexport function hasHeadingSlash(path) {\n if (path === '') {\n return false;\n }\n const match = matchSlashes(path);\n return (match[2] != null);\n}\n\n/**\n *\n * @param {string} path\n * @returns {boolean}\n * @memberof pathUtils\n */\nexport function hasTrailingSlash(path) {\n if (path === '') {\n return false;\n }\n const match = matchSlashes(path);\n return (match[4] != null);\n}\n\n/**\n *\n * @param {string} path\n * @returns {string}\n * @memberof pathUtils\n */\nexport function addHeadingSlash(path) {\n if (path === '/') {\n return path;\n }\n\n if (!hasHeadingSlash(path)) {\n return `/${path}`;\n }\n return path;\n}\n\n/**\n *\n * @param {string} path\n * @returns {string}\n * @memberof pathUtils\n */\nexport function addTrailingSlash(path) {\n if (path === '/') {\n return path;\n }\n\n if (!hasTrailingSlash(path)) {\n return `${path}/`;\n }\n return path;\n}\n\n/**\n *\n * @param {string} path\n * @returns {string}\n * @memberof pathUtils\n */\nexport function removeHeadingSlash(path) {\n if (path === '/') {\n return path;\n }\n\n return hasHeadingSlash(path)\n ? path.substring(1)\n : path;\n}\n\n/**\n *\n * @param {string} path\n * @returns {string}\n * @memberof pathUtils\n */\nexport function removeTrailingSlash(path) {\n if (path === '/') {\n return path;\n }\n\n const match = matchSlashes(path);\n return match[1];\n}\n\n/**\n * A short-hand method to add heading slash and remove trailing slash.\n *\n * @param {string} path\n * @returns {string}\n * @memberof pathUtils\n */\nexport function normalizePath(path) {\n if (path === '' || path === '/') {\n return '/';\n }\n\n const match = matchSlashes(path);\n if (match == null) {\n return '/';\n }\n return `/${match[3]}`;\n}\n\n\n/**\n *\n * @param {string} path\n * @returns {string}\n * @memberof pathUtils\n */\nexport function attachTitleHeader(path) {\n return `# ${path}`;\n}\n\n/**\n * If the pagePath is top page path, eliminate the pageId from the url path.\n *\n * @param {string} path\n * @param {string} id\n * @returns {string}\n * @memberof pathUtils\n */\nexport function returnPathForURL(path, id) {\n if (path === '/') {\n return path;\n }\n\n return addHeadingSlash(id);\n}\n"],"names":["matchSlashes","path","hasHeadingSlash","hasTrailingSlash","addHeadingSlash","addTrailingSlash","removeHeadingSlash","removeTrailingSlash","normalizePath","match","attachTitleHeader","returnPathForURL","id"],"mappings":"AAQA,SAASA,EAAaC,GAAM;AAE1B,SAAOA,EAAK,MAAM,uBAAuB;AAC3C;AAQO,SAASC,EAAgBD,GAAM;AACpC,SAAIA,MAAS,KACJ,KAEKD,EAAaC,CAAI,EACjB,CAAC,KAAK;AACtB;AAQO,SAASE,EAAiBF,GAAM;AACrC,SAAIA,MAAS,KACJ,KAEKD,EAAaC,CAAI,EACjB,CAAC,KAAK;AACtB;AAQO,SAASG,EAAgBH,GAAM;AACpC,SAAIA,MAAS,OAIRC,EAAgBD,CAAI,IAHhBA,IAIA,IAAIA,CAAI;AAGnB;AAQO,SAASI,EAAiBJ,GAAM;AACrC,SAAIA,MAAS,OAIRE,EAAiBF,CAAI,IAHjBA,IAIA,GAAGA,CAAI;AAGlB;AAQO,SAASK,EAAmBL,GAAM;AACvC,SAAIA,MAAS,MACJA,IAGFC,EAAgBD,CAAI,IACvBA,EAAK,UAAU,CAAC,IAChBA;AACN;AAQO,SAASM,EAAoBN,GAAM;AACxC,SAAIA,MAAS,MACJA,IAGKD,EAAaC,CAAI,EAClB,CAAC;AAChB;AASO,SAASO,EAAcP,GAAM;AAClC,MAAIA,MAAS,MAAMA,MAAS;AAC1B,WAAO;AAGT,QAAMQ,IAAQT,EAAaC,CAAI;AAC/B,SAAIQ,KAAS,OACJ,MAEF,IAAIA,EAAM,CAAC,CAAC;AACrB;AASO,SAASC,EAAkBT,GAAM;AACtC,SAAO,KAAKA,CAAI;AAClB;AAUO,SAASU,EAAiBV,GAAMW,GAAI;AACzC,SAAIX,MAAS,MACJA,IAGFG,EAAgBQ,CAAE;AAC3B;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-checker.cjs","sources":["../../src/utils/template-checker.ts"],"sourcesContent":["/**\n * templateChecker\n */\n\nexport function checkTemplatePath(path: string): boolean {\n if (path.match(/^.*\\/_{1,2}template$/)) {\n return true;\n }\n\n return false;\n}\n"],"names":["checkTemplatePath","path"],"mappings":"gFAIO,SAASA,EAAkBC,EAAuB,CACnD,MAAA,EAAAA,EAAK,MAAM,sBAAsB,CAKvC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-checker.js","sources":["../../src/utils/template-checker.ts"],"sourcesContent":["/**\n * templateChecker\n */\n\nexport function checkTemplatePath(path: string): boolean {\n if (path.match(/^.*\\/_{1,2}template$/)) {\n return true;\n }\n\n return false;\n}\n"],"names":["checkTemplatePath","path"],"mappings":"AAIO,SAASA,EAAkBC,GAAuB;AACnD,SAAA,EAAAA,EAAK,MAAM,sBAAsB;AAKvC;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@growi/core",
|
|
3
|
+
"version": "1.0.0-next.0",
|
|
4
|
+
"description": "GROWI Core Libraries",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"growi"
|
|
8
|
+
],
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"type": "module",
|
|
13
|
+
"main": "dist/index.cjs",
|
|
14
|
+
"module": "dist/index.js",
|
|
15
|
+
"types": "dist/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"import": "./dist/index.js",
|
|
19
|
+
"require": "./dist/index.cjs"
|
|
20
|
+
},
|
|
21
|
+
"./dist/consts": {
|
|
22
|
+
"import": "./dist/consts/index.js",
|
|
23
|
+
"require": "./dist/consts/index.cjs"
|
|
24
|
+
},
|
|
25
|
+
"./dist/interfaces": {
|
|
26
|
+
"import": "./dist/interfaces/index.js",
|
|
27
|
+
"require": "./dist/interfaces/index.cjs"
|
|
28
|
+
},
|
|
29
|
+
"./dist/models": {
|
|
30
|
+
"import": "./dist/models/index.js",
|
|
31
|
+
"require": "./dist/models/index.cjs"
|
|
32
|
+
},
|
|
33
|
+
"./dist/remark-plugins": {
|
|
34
|
+
"import": "./dist/remark-plugins/index.js",
|
|
35
|
+
"require": "./dist/remark-plugins/index.cjs"
|
|
36
|
+
},
|
|
37
|
+
"./dist/swr": {
|
|
38
|
+
"import": "./dist/swr/index.js",
|
|
39
|
+
"require": "./dist/swr/index.cjs"
|
|
40
|
+
},
|
|
41
|
+
"./dist/utils": {
|
|
42
|
+
"import": "./dist/utils/index.js",
|
|
43
|
+
"require": "./dist/utils/index.cjs"
|
|
44
|
+
},
|
|
45
|
+
"./dist/utils/page-path-utils": {
|
|
46
|
+
"import": "./dist/utils/page-path-utils/index.js",
|
|
47
|
+
"require": "./dist/utils/page-path-utils/index.cjs"
|
|
48
|
+
},
|
|
49
|
+
"./dist/utils/*": {
|
|
50
|
+
"import": "./dist/utils/*.js",
|
|
51
|
+
"require": "./dist/utils/*.cjs"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build": "vite build",
|
|
56
|
+
"clean": "shx rm -rf dist",
|
|
57
|
+
"dev": "vite build --mode dev",
|
|
58
|
+
"watch": "yarn dev -w --emptyOutDir=false",
|
|
59
|
+
"lint:js": "yarn eslint **/*.{js,ts}",
|
|
60
|
+
"lint:typecheck": "tsc",
|
|
61
|
+
"lint": "npm-run-all -p lint:*",
|
|
62
|
+
"test": "vitest run --coverage"
|
|
63
|
+
},
|
|
64
|
+
"// comments for dependencies": {
|
|
65
|
+
"escape-string-regexp": "5.0.0 or above exports only ESM"
|
|
66
|
+
},
|
|
67
|
+
"dependencies": {
|
|
68
|
+
"bson-objectid": "^2.0.4",
|
|
69
|
+
"escape-string-regexp": "^4.0.0"
|
|
70
|
+
},
|
|
71
|
+
"devDependencies": {
|
|
72
|
+
"eslint-plugin-regex": "^1.8.0",
|
|
73
|
+
"swr": "^2.2.2"
|
|
74
|
+
}
|
|
75
|
+
}
|