@lofcz/streamdown-cjk 1.0.3 → 1.0.4

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/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2023 Vercel, Inc.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
package/dist/index.d.ts CHANGED
@@ -1,9 +1,8 @@
1
- import { Pluggable } from 'unified';
2
-
1
+ import type { Pluggable } from "unified";
3
2
  /**
4
3
  * Plugin for CJK text handling
5
4
  */
6
- interface CjkPlugin {
5
+ export interface CjkPlugin {
7
6
  name: "cjk";
8
7
  /**
9
8
  * @deprecated Use remarkPluginsBefore and remarkPluginsAfter instead
@@ -25,10 +24,8 @@ interface CjkPlugin {
25
24
  /**
26
25
  * Create a CJK plugin
27
26
  */
28
- declare function createCjkPlugin(): CjkPlugin;
27
+ export declare function createCjkPlugin(): CjkPlugin;
29
28
  /**
30
29
  * Pre-configured CJK plugin with default settings
31
30
  */
32
- declare const cjk: CjkPlugin;
33
-
34
- export { type CjkPlugin, cjk, createCjkPlugin };
31
+ export declare const cjk: CjkPlugin;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import c from'remark-cjk-friendly';import a from'remark-cjk-friendly-gfm-strikethrough';import {visit}from'unist-util-visit';var k=new Set(["\u3002","\uFF0E","\uFF0C","\u3001","\uFF1F","\uFF01","\uFF1A","\uFF1B","\uFF08","\uFF09","\u3010","\u3011","\u300C","\u300D","\u300E","\u300F","\u3008","\u3009","\u300A","\u300B"]),m=/^(https?:\/\/|mailto:|www\.)/i,f=t=>{if(t.children.length!==1)return false;let r=t.children[0];return r.type==="text"&&r.value===t.url},P=t=>{let r=0;for(let e of t){if(k.has(e))return r;r+=e.length;}return null},p=(t,r)=>({...r,url:t,children:[{type:"text",value:t}]}),d=t=>({type:"text",value:t}),y=()=>t=>{visit(t,"link",(r,e,i)=>{if(!i||typeof e!="number"||!f(r)||!m.test(r.url))return;let n=P(r.url);if(n===null||n===0)return;let l=r.url.slice(0,n),u=r.url.slice(n),o=p(l,r),s=d(u);return i.children.splice(e,1,o,s),e+1});};function b(){let t=[c],r=[y,a],e=[...t,...r];return {name:"cjk",type:"cjk",remarkPluginsBefore:t,remarkPluginsAfter:r,remarkPlugins:e}}var A=b();export{A as cjk,b as createCjkPlugin};
1
+ import c from'remark-cjk-friendly';import k from'remark-cjk-friendly-gfm-strikethrough';import {visit}from'unist-util-visit';var m=new Set(["\u3002","\uFF0E","\uFF0C","\u3001","\uFF1F","\uFF01","\uFF1A","\uFF1B","\uFF08","\uFF09","\u3010","\u3011","\u300C","\u300D","\u300E","\u300F","\u3008","\u3009","\u300A","\u300B"]),s=/^(https?:\/\/|mailto:|www\.)/i,f=/https?:\/\/|mailto:|www\./i,d=e=>{if(e.children.length!==1)return false;let n=e.children[0];return n.type==="text"&&n.value===e.url},a=e=>{let n=0;for(let r of e){if(m.has(r))return n;n+=r.length;}return null},u=(e,n)=>({...n,url:e,children:[{type:"text",value:e}]}),o=e=>({type:"text",value:e}),p=(e,n)=>{let r=[],t=e;for(;t.length>0;){if(s.test(t)){let l=a(t);if(l===null||l===0){r.push(u(t,n));break}r.push(u(t.slice(0,l),n)),t=t.slice(l);continue}let i=t.match(f);if(!i||i.index===void 0){r.push(o(t));break}i.index>0&&r.push(o(t.slice(0,i.index))),t=t.slice(i.index);}return r},h=()=>e=>{visit(e,"link",(n,r,t)=>{if(!t||typeof r!="number"||!d(n)||!s.test(n.url))return;let i=a(n.url);if(i===null||i===0)return;let l=p(n.url,n);return t.children.splice(r,1,...l),r+l.length});};function P(){let e=[c],n=[h,k],r=[...e,...n];return {name:"cjk",type:"cjk",remarkPluginsBefore:e,remarkPluginsAfter:n,remarkPlugins:r}}var A=P();export{A as cjk,P as createCjkPlugin};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lofcz/streamdown-cjk",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -14,40 +14,40 @@
14
14
  "files": [
15
15
  "dist"
16
16
  ],
17
- "scripts": {
18
- "build": "tsup",
19
- "test": "vitest run",
20
- "test:coverage": "vitest --coverage run"
21
- },
22
17
  "peerDependencies": {
23
18
  "react": "^18.0.0 || ^19.0.0"
24
19
  },
25
20
  "dependencies": {
26
- "remark-cjk-friendly": "^2.0.1",
27
- "remark-cjk-friendly-gfm-strikethrough": "^2.0.1",
28
- "unist-util-visit": "^5.0.0"
21
+ "remark-cjk-friendly": "^2.3.1",
22
+ "remark-cjk-friendly-gfm-strikethrough": "^2.3.1",
23
+ "unist-util-visit": "^5.1.0"
29
24
  },
30
25
  "devDependencies": {
31
26
  "@types/mdast": "^4.0.4",
32
- "@vitest/coverage-v8": "^4.0.15",
27
+ "@vitest/coverage-v8": "^4.1.10",
33
28
  "@types/unist": "^3.0.3",
34
- "remark-gfm": "^4.0.1",
29
+ "remark-gfm": "npm:@lofcz/remark-gfm@^4.0.1",
35
30
  "remark-parse": "^11.0.0",
36
31
  "remark-stringify": "^11.0.0",
37
32
  "tsup": "^8.5.1",
38
- "typescript": "^5.9.3",
33
+ "typescript": "^7.0.2",
39
34
  "unified": "^11.0.5",
40
- "vitest": "^4.0.15"
35
+ "vitest": "^4.1.10"
41
36
  },
42
37
  "author": "Hayden Bleasel <hayden.bleasel@vercel.com>",
43
38
  "license": "Apache-2.0",
44
39
  "description": "CJK text handling plugin for Streamdown",
45
40
  "repository": {
46
41
  "type": "git",
47
- "url": "git+https://github.com/lofcz/streamdown.git",
42
+ "url": "git+https://github.com/lofcz/streamdown-ng.git",
48
43
  "directory": "packages/streamdown-cjk"
49
44
  },
50
45
  "publishConfig": {
51
46
  "access": "public"
47
+ },
48
+ "scripts": {
49
+ "build": "node scripts/build.mjs",
50
+ "test": "vitest run",
51
+ "test:coverage": "vitest --coverage run"
52
52
  }
53
- }
53
+ }