@xwiki/cristal-page-default 0.21.1 → 0.22.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/CHANGELOG.md +6 -3
- package/api-extractor.json +4 -0
- package/dist/defaultPageReader.d.ts +1 -0
- package/dist/defaultPageWriter.d.ts +1 -0
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/etc/cristal-page-default.api.md +30 -0
- package/package.json +10 -8
- package/src/defaultPageReader.ts +2 -1
- package/src/defaultPageWriter.ts +2 -1
- package/vitest.config.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
# @xwiki/cristal-page-default
|
|
2
2
|
|
|
3
|
-
## 0.
|
|
3
|
+
## 0.22.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Cristal 0.22 Release
|
|
4
8
|
|
|
5
9
|
### Patch Changes
|
|
6
10
|
|
|
7
|
-
- Cristal 0.21.1 Release
|
|
8
11
|
- Updated dependencies
|
|
9
|
-
- @xwiki/cristal-page-api@0.
|
|
12
|
+
- @xwiki/cristal-page-api@0.22.0
|
|
10
13
|
|
|
11
14
|
## 0.21.0
|
|
12
15
|
|
package/dist/index.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../src/defaultPageReader.ts","../src/defaultPageWriter.ts"],"sourcesContent":["/**\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\nimport {
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../src/defaultPageReader.ts","../src/defaultPageWriter.ts"],"sourcesContent":["/**\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\nimport { parse } from \"yaml\";\nimport type { PageReader } from \"@xwiki/cristal-page-api\";\n\n/**\n * @since 0.20\n * @beta\n */\nclass DefaultPageReader implements PageReader {\n readPage(pageContent: string): { content: string; [key: string]: unknown } {\n const lines = pageContent.split(\"\\n\");\n if (lines[0] == \"---\") {\n // Remove the first element\n lines.shift();\n const endFrontMatterIndex = lines.findIndex((line) => line == \"---\");\n if (endFrontMatterIndex >= 0) {\n // We only try to read the front matter if we can find two '---' lines\n const frontMatterContent = lines\n .slice(0, endFrontMatterIndex)\n .join(\"\\n\");\n const parsedYaml = parse(frontMatterContent);\n return {\n ...parsedYaml,\n content: lines.slice(endFrontMatterIndex + 1).join(\"\\n\"),\n };\n } else {\n return {\n content: pageContent,\n };\n }\n } else {\n // When the page does not start with '---' it's content is returned as-is\n return {\n content: pageContent,\n };\n }\n }\n}\n\nexport { DefaultPageReader };\n","/**\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\nimport { stringify } from \"yaml\";\nimport type { PageWriter } from \"@xwiki/cristal-page-api\";\n\n/**\n * @since 0.20\n * @beta\n */\nclass DefaultPageWriter implements PageWriter {\n writePage(page: { content: string; [key: string]: unknown }): string {\n const { content, ...metadata } = page;\n if (metadata && Object.keys(metadata).length > 0) {\n return `---\n${stringify(metadata)}---\n${content ?? \"\"}`;\n } else {\n return (content ?? \"\") as string;\n }\n }\n}\n\nexport { DefaultPageWriter };\n"],"names":["DefaultPageReader","pageContent","lines","endFrontMatterIndex","line","frontMatterContent","parse","DefaultPageWriter","page","content","metadata","stringify"],"mappings":";AA0BA,MAAMA,EAAwC;AAAA,EAC5C,SAASC,GAAkE;AACzE,UAAMC,IAAQD,EAAY,MAAM;AAAA,CAAI;AACpC,QAAIC,EAAM,CAAC,KAAK,OAAO;AAErB,MAAAA,EAAM,MAAA;AACN,YAAMC,IAAsBD,EAAM,UAAU,CAACE,MAASA,KAAQ,KAAK;AACnE,UAAID,KAAuB,GAAG;AAE5B,cAAME,IAAqBH,EACxB,MAAM,GAAGC,CAAmB,EAC5B,KAAK;AAAA,CAAI;AAEZ,eAAO;AAAA,UACL,GAFiBG,EAAMD,CAAkB;AAAA,UAGzC,SAASH,EAAM,MAAMC,IAAsB,CAAC,EAAE,KAAK;AAAA,CAAI;AAAA,QAAA;AAAA,MAE3D;AACE,eAAO;AAAA,UACL,SAASF;AAAA,QAAA;AAAA,IAGf;AAEE,aAAO;AAAA,QACL,SAASA;AAAA,MAAA;AAAA,EAGf;AACF;AC7BA,MAAMM,EAAwC;AAAA,EAC5C,UAAUC,GAA2D;AACnE,UAAM,EAAE,SAAAC,GAAS,GAAGC,EAAA,IAAaF;AACjC,WAAIE,KAAY,OAAO,KAAKA,CAAQ,EAAE,SAAS,IACtC;AAAA,EACXC,EAAUD,CAAQ,CAAC;AAAA,EACnBD,KAAW,EAAE,KAEDA,KAAW;AAAA,EAEvB;AACF;"}
|
package/dist/index.umd.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
(function(e,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("yaml")):typeof define=="function"&&define.amd?define(["exports","yaml"],i):(e=typeof globalThis<"u"?globalThis:e||self,i(e["cristal_page-default"]={},e.yaml))})(this,function(e,i){"use strict";class a{readPage(r){const t=r.split(`
|
|
1
|
+
(function(e,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("yaml")):typeof define=="function"&&define.amd?define(["exports","yaml"],i):(e=typeof globalThis<"u"?globalThis:e||self,i(e["cristal_page-default"]={},e.yaml))})(this,(function(e,i){"use strict";class a{readPage(r){const t=r.split(`
|
|
2
2
|
`);if(t[0]=="---"){t.shift();const n=t.findIndex(s=>s=="---");if(n>=0){const s=t.slice(0,n).join(`
|
|
3
3
|
`);return{...i.parse(s),content:t.slice(n+1).join(`
|
|
4
4
|
`)}}else return{content:r}}else return{content:r}}}class f{writePage(r){const{content:t,...n}=r;return n&&Object.keys(n).length>0?`---
|
|
5
5
|
${i.stringify(n)}---
|
|
6
|
-
${t??""}`:t??""}}e.DefaultPageReader=a,e.DefaultPageWriter=f,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
|
|
6
|
+
${t??""}`:t??""}}e.DefaultPageReader=a,e.DefaultPageWriter=f,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
|
|
7
7
|
//# sourceMappingURL=index.umd.js.map
|
package/dist/index.umd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../src/defaultPageReader.ts","../src/defaultPageWriter.ts"],"sourcesContent":["/**\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\nimport {
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../src/defaultPageReader.ts","../src/defaultPageWriter.ts"],"sourcesContent":["/**\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\nimport { parse } from \"yaml\";\nimport type { PageReader } from \"@xwiki/cristal-page-api\";\n\n/**\n * @since 0.20\n * @beta\n */\nclass DefaultPageReader implements PageReader {\n readPage(pageContent: string): { content: string; [key: string]: unknown } {\n const lines = pageContent.split(\"\\n\");\n if (lines[0] == \"---\") {\n // Remove the first element\n lines.shift();\n const endFrontMatterIndex = lines.findIndex((line) => line == \"---\");\n if (endFrontMatterIndex >= 0) {\n // We only try to read the front matter if we can find two '---' lines\n const frontMatterContent = lines\n .slice(0, endFrontMatterIndex)\n .join(\"\\n\");\n const parsedYaml = parse(frontMatterContent);\n return {\n ...parsedYaml,\n content: lines.slice(endFrontMatterIndex + 1).join(\"\\n\"),\n };\n } else {\n return {\n content: pageContent,\n };\n }\n } else {\n // When the page does not start with '---' it's content is returned as-is\n return {\n content: pageContent,\n };\n }\n }\n}\n\nexport { DefaultPageReader };\n","/**\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\nimport { stringify } from \"yaml\";\nimport type { PageWriter } from \"@xwiki/cristal-page-api\";\n\n/**\n * @since 0.20\n * @beta\n */\nclass DefaultPageWriter implements PageWriter {\n writePage(page: { content: string; [key: string]: unknown }): string {\n const { content, ...metadata } = page;\n if (metadata && Object.keys(metadata).length > 0) {\n return `---\n${stringify(metadata)}---\n${content ?? \"\"}`;\n } else {\n return (content ?? \"\") as string;\n }\n }\n}\n\nexport { DefaultPageWriter };\n"],"names":["DefaultPageReader","pageContent","lines","endFrontMatterIndex","line","frontMatterContent","parse","DefaultPageWriter","page","content","metadata","stringify"],"mappings":"gRA0BA,MAAMA,CAAwC,CAC5C,SAASC,EAAkE,CACzE,MAAMC,EAAQD,EAAY,MAAM;AAAA,CAAI,EACpC,GAAIC,EAAM,CAAC,GAAK,MAAO,CAErBA,EAAM,MAAA,EACN,MAAMC,EAAsBD,EAAM,UAAWE,GAASA,GAAQ,KAAK,EACnE,GAAID,GAAuB,EAAG,CAE5B,MAAME,EAAqBH,EACxB,MAAM,EAAGC,CAAmB,EAC5B,KAAK;AAAA,CAAI,EAEZ,MAAO,CACL,GAFiBG,EAAAA,MAAMD,CAAkB,EAGzC,QAASH,EAAM,MAAMC,EAAsB,CAAC,EAAE,KAAK;AAAA,CAAI,CAAA,CAE3D,KACE,OAAO,CACL,QAASF,CAAA,CAGf,KAEE,OAAO,CACL,QAASA,CAAA,CAGf,CACF,CC7BA,MAAMM,CAAwC,CAC5C,UAAUC,EAA2D,CACnE,KAAM,CAAE,QAAAC,EAAS,GAAGC,CAAA,EAAaF,EACjC,OAAIE,GAAY,OAAO,KAAKA,CAAQ,EAAE,OAAS,EACtC;AAAA,EACXC,EAAAA,UAAUD,CAAQ,CAAC;AAAA,EACnBD,GAAW,EAAE,GAEDA,GAAW,EAEvB,CACF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
## API Report File for "@xwiki/cristal-page-default"
|
|
2
|
+
|
|
3
|
+
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
|
|
7
|
+
import { PageReader } from '@xwiki/cristal-page-api';
|
|
8
|
+
import { PageWriter } from '@xwiki/cristal-page-api';
|
|
9
|
+
|
|
10
|
+
// @beta (undocumented)
|
|
11
|
+
export class DefaultPageReader implements PageReader {
|
|
12
|
+
// (undocumented)
|
|
13
|
+
readPage(pageContent: string): {
|
|
14
|
+
content: string;
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// @beta (undocumented)
|
|
20
|
+
export class DefaultPageWriter implements PageWriter {
|
|
21
|
+
// (undocumented)
|
|
22
|
+
writePage(page: {
|
|
23
|
+
content: string;
|
|
24
|
+
[key: string]: unknown;
|
|
25
|
+
}): string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// (No @packageDocumentation comment for this package)
|
|
29
|
+
|
|
30
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xwiki/cristal-page-default",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"license": "LGPL 2.1",
|
|
5
5
|
"author": "XWiki Org Community <contact@xwiki.org>",
|
|
6
6
|
"homepage": "https://cristal.xwiki.org/",
|
|
@@ -26,20 +26,22 @@
|
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
"main": "./dist/index.es.js",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
29
30
|
"dependencies": {
|
|
30
31
|
"yaml": "2.8.0",
|
|
31
|
-
"@xwiki/cristal-page-api": "0.
|
|
32
|
+
"@xwiki/cristal-page-api": "0.22.0"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
35
|
"typescript": "5.9.2",
|
|
35
|
-
"vite": "7.
|
|
36
|
-
"@xwiki/cristal-dev-config": "0.
|
|
36
|
+
"vite": "7.1.5",
|
|
37
|
+
"@xwiki/cristal-dev-config": "0.22.0"
|
|
37
38
|
},
|
|
38
39
|
"scripts": {
|
|
39
|
-
"
|
|
40
|
+
"api-extractor:local": "api-extractor run --local",
|
|
41
|
+
"build": "vite build",
|
|
40
42
|
"clean": "rimraf dist",
|
|
41
43
|
"lint": "eslint \"./src/**/*.{ts,tsx,vue}\" --max-warnings=0",
|
|
42
|
-
"test": "vitest --run"
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
"test": "vitest --run",
|
|
45
|
+
"typecheck": "tsc"
|
|
46
|
+
}
|
|
45
47
|
}
|
package/src/defaultPageReader.ts
CHANGED
|
@@ -17,11 +17,12 @@
|
|
|
17
17
|
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
|
18
18
|
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
|
19
19
|
*/
|
|
20
|
-
import { PageReader } from "@xwiki/cristal-page-api";
|
|
21
20
|
import { parse } from "yaml";
|
|
21
|
+
import type { PageReader } from "@xwiki/cristal-page-api";
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* @since 0.20
|
|
25
|
+
* @beta
|
|
25
26
|
*/
|
|
26
27
|
class DefaultPageReader implements PageReader {
|
|
27
28
|
readPage(pageContent: string): { content: string; [key: string]: unknown } {
|
package/src/defaultPageWriter.ts
CHANGED
|
@@ -17,11 +17,12 @@
|
|
|
17
17
|
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
|
18
18
|
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
|
19
19
|
*/
|
|
20
|
-
import { PageWriter } from "@xwiki/cristal-page-api";
|
|
21
20
|
import { stringify } from "yaml";
|
|
21
|
+
import type { PageWriter } from "@xwiki/cristal-page-api";
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* @since 0.20
|
|
25
|
+
* @beta
|
|
25
26
|
*/
|
|
26
27
|
class DefaultPageWriter implements PageWriter {
|
|
27
28
|
writePage(page: { content: string; [key: string]: unknown }): string {
|
package/vitest.config.ts
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
import localConfig from "./vite.config";
|
|
22
|
+
import { vitestVue as defaultConfig } from "@xwiki/cristal-dev-config";
|
|
22
23
|
import { mergeConfig } from "vitest/config";
|
|
23
|
-
import defaultConfig from "@xwiki/cristal-dev-config/vitest-vue.config";
|
|
24
24
|
|
|
25
25
|
export default mergeConfig(defaultConfig, localConfig);
|