writr 4.1.1 → 4.1.3

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/writr.d.ts CHANGED
@@ -3,7 +3,8 @@ import * as hast from 'hast';
3
3
  import * as mdast from 'mdast';
4
4
  import React from 'react';
5
5
  import { HTMLReactParserOptions } from 'html-react-parser';
6
- import { Cacheable, CacheableMemory, KeyvStoreAdapter } from 'cacheable';
6
+ import { Cacheable, CacheableMemory } from 'cacheable';
7
+ import { KeyvStoreAdapter } from 'keyv';
7
8
 
8
9
  declare class WritrCache {
9
10
  private _markdownStore;
package/dist/writr.js CHANGED
@@ -17,7 +17,6 @@ import parse from "html-react-parser";
17
17
  import * as yaml from "js-yaml";
18
18
 
19
19
  // src/writr-cache.ts
20
- import { createHash } from "node:crypto";
21
20
  import { Cacheable, CacheableMemory } from "cacheable";
22
21
  var WritrCache = class {
23
22
  _markdownStore = new Cacheable();
@@ -71,12 +70,13 @@ var WritrCache = class {
71
70
  this._markdownStore = new Cacheable({ primary: adapter });
72
71
  }
73
72
  hash(markdown, options) {
74
- const key = JSON.stringify({ markdown, options });
73
+ const content = { markdown, options };
74
+ const key = JSON.stringify(content);
75
75
  let result = this._hashStore.get(key);
76
76
  if (result) {
77
77
  return result;
78
78
  }
79
- result = createHash("sha256").update(key).digest("hex");
79
+ result = this._hashStore.hash(content);
80
80
  this._hashStore.set(key, result);
81
81
  return result;
82
82
  }
@@ -130,10 +130,10 @@ var Writr = class {
130
130
  return this._cache;
131
131
  }
132
132
  get frontMatterRaw() {
133
- const start = this._content.indexOf("---\n");
134
- if (start === -1) {
133
+ if (!this._content.trimStart().startsWith("---")) {
135
134
  return "";
136
135
  }
136
+ const start = this._content.indexOf("---\n");
137
137
  const end = this._content.indexOf("\n---\n", start + 4);
138
138
  if (end === -1) {
139
139
  return "";
@@ -141,14 +141,10 @@ var Writr = class {
141
141
  return this._content.slice(start, end + 5);
142
142
  }
143
143
  get body() {
144
- const start = this._content.indexOf("---\n");
145
- if (start === -1) {
146
- return this._content;
147
- }
148
- const end = this._content.indexOf("\n---\n", start + 4);
149
- if (end === -1) {
144
+ if (this.frontMatterRaw === "") {
150
145
  return this._content;
151
146
  }
147
+ const end = this._content.indexOf("\n---\n");
152
148
  return this._content.slice(Math.max(0, end + 5)).trim();
153
149
  }
154
150
  get markdown() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "writr",
3
- "version": "4.1.1",
3
+ "version": "4.1.3",
4
4
  "description": "Markdown Rendering Simplified",
5
5
  "type": "module",
6
6
  "main": "./dist/writr.js",
@@ -54,10 +54,9 @@
54
54
  },
55
55
  "dependencies": {
56
56
  "cacheable": "^1.8.0",
57
- "crypto": "^1.0.1",
58
- "fs": "^0.0.1-security",
59
- "html-react-parser": "^5.1.17",
57
+ "html-react-parser": "^5.1.18",
60
58
  "js-yaml": "^4.1.0",
59
+ "keyv": "^5.1.0",
61
60
  "react": "^18.3.1",
62
61
  "rehype-highlight": "^7.0.0",
63
62
  "rehype-katex": "^7.0.1",
@@ -75,7 +74,7 @@
75
74
  "devDependencies": {
76
75
  "@keyv/sqlite": "^4.0.1",
77
76
  "@types/js-yaml": "^4.0.9",
78
- "@types/node": "^22.7.4",
77
+ "@types/node": "^22.7.5",
79
78
  "@types/react": "^18.3.11",
80
79
  "@vitest/coverage-v8": "^2.1.2",
81
80
  "docula": "^0.9.1",