Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cn-font-split

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cn-font-split - npm Package Compare versions

Comparing version 4.10.6 to 4.11.0

dist/convert.worker-4992cbf0.js

2

dist/index.analyze.txt

@@ -5,3 +5,3 @@ -----------------------------

bundle size: 66.797 KB
original size: 102.735 KB
original size: 102.736 KB
code reduction: 34.98 %

@@ -8,0 +8,0 @@ module count: 54

@@ -1,2 +0,2 @@

import{s as t,d as e}from"./detectFormat-db568c54.js";import{decompress as n,compress as r}from"@chinese-fonts/wawoff2";import{Logger as o}from"tslog";import s from"path";import a from"byte-size";import{UnicodeRange as i}from"@japont/unicode-range";import c from"crypto";import l from"@konghayao/opentype.js/src/tables/gsub.js";import f from"@konghayao/opentype.js/src/parse.js";import u from"@konghayao/opentype.js/src/substitution.js";import h from"@konghayao/opentype.js/src/tables/name.js";import p from"@konghayao/opentype.js/src/tables/ltag.js";import g from"@konghayao/opentype.js/src/tables/cmap.js";import{tinf_uncompress as d}from"@konghayao/opentype.js/src/tiny-inflate@1.0.3.esm.js";import{pool as m}from"workerpool";import{fileURLToPath as b}from"node:url";const y=async function(o,s,a){const i=["truetype","ttf","otf"];if(i.includes(s)&&(s="sfnt"),i.includes(a||"")&&(a="sfnt"),!t.has(s))throw new Error(`Unsupported target format: ${s}`);if(a){if(!t.has(a))throw new Error(`Unsupported source format: ${a}`)}else a=e(o);if(a===s)return o;if("woff"===a)throw new Error("Unsupported source format: woff");return"woff2"===a&&(o=await n(o)),"woff2"===s&&(o=await r(o)),o};function w(t){return(255&t.charCodeAt(0))<<24|(255&t.charCodeAt(1))<<16|(255&t.charCodeAt(2))<<8|(255&t.charCodeAt(3))<<0}function _(t){const e=t.exports,n=new Uint8Array(e.memory.buffer),r=new Uint32Array(e.memory.buffer),o=new Int32Array(e.memory.buffer),s=new Float32Array(e.memory.buffer),a=new TextDecoder("utf8"),i=-1;function c(t,a){let c=n;a===Uint32Array?c=r:a===Int32Array?c=o:a===Float32Array&&(c=s);const l=a.BYTES_PER_ELEMENT,f=e.hb_set_get_population(t),u=e.malloc(f*l),h=u/l,p=c.subarray(h,h+f);return c.set(p,h),e.hb_set_next_many(t,i,u,f),p}function l(t){const n=e.hb_set_create();e.hb_face_collect_unicodes(t,n);const r=c(n,Uint32Array);return e.hb_set_destroy(n),r}function f(t){if(!t)return{ptr:0,length:0,free(){}};const r=e.malloc(t.length+1);for(let e=0;e<t.length;++e){const o=t.charCodeAt(e);if(o>127)throw new Error("Expected ASCII text");n[r+e]=o}return n[r+t.length]=0,{ptr:r,length:t.length,free(){e.free(r)}}}return{createSubset:function(t,r,o){const s=e.hb_subset_input_create_or_fail();if(0===s)throw new Error("hb_subset_input_create_or_fail (harfbuzz) returned zero, indicating failure");let a;const i=e.hb_subset_input_unicode_set(s);return{ptr:s,clearTableDrop(){e.hb_set_clear(e.hb_subset_input_set(s,3))},adjustLayout(){for(const t of[6,7]){const n=e.hb_subset_input_set(s,t);e.hb_set_clear(n),e.hb_set_invert(n)}if(r){const t=e.hb_subset_input_set(s,4);for(const n of r)e.hb_set_add(t,n)}if(o)for(const[n,r]of Object.entries(o))e.hb_subset_input_pin_axis_location(s,t.ptr,n.split("").reduce((function(t,e){return(t<<8)+e.charCodeAt(0)}),0),r)},deleteChar(t){for(const n of t)e.hb_set_del(i,n)},addChars(t){for(const n of t)if(n instanceof Array){const[t,r]=n;for(let n=t;n<=r;n++)e.hb_set_add(i,n)}else e.hb_set_add(i,n)},getResult:()=>a,runSubset(){if(a=e.hb_subset_or_fail(t.ptr,s),0===a)throw new Error("hb_subset_or_fail (harfbuzz) returned zero, indicating failure. Maybe the input file is corrupted?");return a},destroy(){a&&"number"==typeof a&&e.hb_face_destroy(a),e.hb_subset_input_destroy(s)},toBinary(){const t=e.hb_face_reference_blob(a),r=e.hb_blob_get_data(t,0),o=e.hb_blob_get_length(t);if(0===o)throw e.hb_blob_destroy(t),new Error("Failed to create subset font, maybe the input file is corrupted?");return{destroy(){e.hb_blob_destroy(t)},offset:r,subsetByteLength:o,blobPtr:t,data:()=>n.subarray(r,r+o)}}}},createBlob:function(t){const r=e.malloc(t.byteLength);n.set(t,r);const o=e.hb_blob_create(r,t.byteLength,2,r,e.free_ptr());return{ptr:o,blobPtr:r,destroy(){e.hb_blob_destroy(o)},free(){e.free(r)}}},createFace:function(t,o){const a=e.hb_face_create(t.ptr,o),i=e.hb_face_get_upem(a);return{ptr:a,upem:i,reference_table(t){const r=e.hb_face_reference_table(a,w(t)),o=e.hb_blob_get_length(r);if(!o)throw new Error(" 引用字体文件中 table 失败");const s=e.hb_blob_get_data(r,null);return n.subarray(s,s+o)},collectUnicodes:()=>l(a),getAxisInfos(){const t=e.malloc(2048),n=e.malloc(4);r[n/4]=64,e.hb_ot_var_get_axis_infos(a,0,n,t);const o={};return Array.from({length:r[n/4]}).forEach((function(e,n){var a;o[(a=r[t/4+8*n+1],[String.fromCharCode(a>>24&255),String.fromCharCode(a>>16&255),String.fromCharCode(a>>8&255),String.fromCharCode(a>>0&255)].join(""))]={min:s[t/4+8*n+4],default:s[t/4+8*n+5],max:s[t/4+8*n+6]}})),e.free(n),e.free(t),o},destroy(){e.hb_face_destroy(a)},free(){e.hb_face_destroy(a)}}},createFont:function(t){const o=e.hb_font_create(t.ptr),i=e.malloc(65536),c=e.malloc(256);function l(t){const r=e.hbjs_glyph_svg(o,t,i,65536);return r>0?a.decode(n.subarray(i,i+r)):""}return{ptr:o,glyphName:function(t){e.hb_font_glyph_to_string(o,t,c,256);const r=n.subarray(c,c+256);return a.decode(r.slice(0,r.indexOf(0)))},glyphToPath:l,glyphToJson:t=>l(t).replace(/([MLQCZ])/g,"|$1 ").split("|").filter((function(t){return t.length})).map((function(t){const e=t.split(/[ ,]/g);return{type:e[0],values:e.slice(1).filter((function(t){return t.length})).map((function(t){return+t}))}})),setScale(t,n){e.hb_font_set_scale(o,t,n)},setletiations(t){const n=Object.entries(t),a=e.malloc(8*n.length);n.forEach((function(t,e){r[a/4+2*e+0]=w(t[0]),s[a/4+2*e+1]=t[1]})),e.hb_font_set_letiations(o,a,n.length),e.free(a)},destroy(){e.hb_font_destroy(o)}}},createBuffer:function(){const t=e.hb_buffer_create();return{ptr:t,addText(n){const r=function(t){const n=e.malloc(2*t.length),r=new Uint16Array(e.memory.buffer,n,t.length);for(let e=0;e<r.length;++e)r[e]=t.charCodeAt(e);return{ptr:n,length:r.length,free(){e.free(n)}}}(n);e.hb_buffer_add_utf16(t,r.ptr,r.length,0,r.length),r.free()},guessSegmentProperties:()=>e.hb_buffer_guess_segment_properties(t),setDirection(n){e.hb_buffer_set_direction(t,{ltr:4,rtl:5,ttb:6,btt:7}[n]||0)},setFlags(n){let r=0;n.forEach((function(t){r|=function(t){return{BOT:1,EOT:2,PRESERVE_DEFAULT_IGNORABLES:4,REMOVE_DEFAULT_IGNORABLES:8,DO_NOT_INSERT_DOTTED_CIRCLE:16,PRODUCE_UNSAFE_TO_CONCAT:64}[t]||0}(t)})),e.hb_buffer_set_flags(t,r)},setLanguage(n){const r=f(n);e.hb_buffer_set_language(t,e.hb_language_from_string(r.ptr,-1)),r.free()},setScript(n){const r=f(n);e.hb_buffer_set_script(t,e.hb_script_from_string(r.ptr,-1)),r.free()},setClusterLevel(n){e.hb_buffer_set_cluster_level(t,n)},json(){const n=e.hb_buffer_get_length(t),s=[],a=e.hb_buffer_get_glyph_infos(t,0),i=a/4,c=e.hb_buffer_get_glyph_positions(t,0)/4,l=r.subarray(i,i+5*n),f=o.subarray(c,c+5*n);for(let t=0;t<n;++t)s.push({g:l[5*t+0],cl:l[5*t+2],ax:f[5*t+0],ay:f[5*t+1],dx:f[5*t+2],dy:f[5*t+3],flags:e.hb_glyph_info_get_glyph_flags(a+20*t)});return s},destroy(){e.hb_buffer_destroy(t)}}},shape:function(t,n,r){const o=f(r);e.hb_shape(t.ptr,n.ptr,o.ptr,o.length),o.free()},shapeWithTrace:function(t,r,o,s,i){const c=1048576,l=e.malloc(c),u=f(o),h=e.hbjs_shape_with_trace(t.ptr,r.ptr,u.ptr,s,i,l,c);u.free();const p=a.decode(n.subarray(l,l+h-1));return e.free(l),JSON.parse(p)},exports:e,heapu8:n,heapf32:s,heapi32:o,heapu32:r,typedArrayFromSet:c,collectUnicodes:l}}class v extends o{constructor(t={},e={}){super(e?.log?.settings,e?.log?.logObj),this._originData=t}recordLog(t){this.attachTransport((e=>{const n=Object.keys(e).filter((t=>!isNaN(parseInt(t)))).map((t=>[parseInt(t),e[t]])).sort(((t,e)=>t[0]-e[0])).map((t=>t[1]));t(this._prettyFormatLogObjMeta(e._meta),...n)}))}set(t,e){this._originData[t]=e}free(...t){for(const e of t)delete this._originData[e]}check(t){return t in this._originData}destroy(){this._originData={}}pick(...t){if(0===t.length)throw new Error("Context pick: please send some name to access the keys you sure to be existed!");const e={};return t.forEach((t=>{t in this._originData?e[t]=this._originData[t]:console.warn(`[Warning] Context: ${t} isn't found in context, It could cause Error`)})),e}}class T{constructor(t,e){this.to=t,this.task=e}}class F{constructor(t,e){this.steps=t,this.context=e}ptr=-1;setPtr(t){if(t<=this.steps.length&&t>=0)return this.ptr=t,this.ptr;throw new Error("setPtr: Array boundary number error: "+t)}records=[];startTask(t){this.context.info("--\x3e\t\t"+t.name+"\tStart");const e=performance.now();return{start:e,p:(async()=>t(this.context))().then((()=>this.endTask({start:e,task:t}))),task:t}}endTask({start:t,task:e}){const n=performance.now();this.context.info("<--\t"+(n-t).toFixed(0)+"ms\t"+e.name+"\tDone\t");const r={name:e.name,start:t,end:n};this.records.push(r)}async nextStep(){const t=this.setPtr(this.ptr+1),e=this.steps[t];if("function"==typeof e){const t=this.startTask(e);await t.p;const n=this.concurrentMap.get(e.name);return n&&await Promise.all(n.map((async t=>t.p))),!0}if(e instanceof T){const t=this.concurrentMap.get(e.to)??[];return t.push(this.startTask(e.task)),this.concurrentMap.set(e.to,t),!0}return!1}concurrentMap=new Map;async run(t=1.5){if(!this.steps)throw new Error("run: Please defineOrder for the tasks");const e=this.steps.length*t;let n=0,r=!0;for(;r;)if(r=await this.nextStep(),n++,n>=e)throw new Error("Executor run: too many times task to run!");return this.context}}const j="object"==typeof navigator&&navigator.userAgent&&navigator.userAgent.includes("jsdom"),k="object"==typeof globalThis.process&&!!globalThis.process.versions&&!!globalThis.process.versions.node,x="object"==typeof window&&"object"==typeof document&&9===document.nodeType,S=globalThis.Deno,L="object"==typeof S&&S.version,E=(()=>{if(globalThis.self&&"function"==typeof globalThis.importScripts)try{return globalThis.importScripts(),"classic"}catch(t){return"module"}return!1})(),A=k?"node":x?"browser":L?"deno":E?"worker_"+E:"unknown";class U extends Map{constructor(t){super(t instanceof Array?t:Object.entries(t))}ensureGet(t){let e;return this.has(t)?(e=this.get(t),this.pathTransform?this.pathTransform(e):e):t}async loadFileAsync(t){const e=this.ensureGet(t);if(k){const{promises:{readFile:t}}=await import("fs");return t(await(async t=>{switch(t[0]){case".":case"/":case"~":return t;case"&":const{resolve:e,dirname:n}=await import("path"),{fileURLToPath:r}=await import("node:url");return e(n(r(import.meta.url)),t.slice(1));default:const{default:o}=await import("node:module");return o.createRequire(import.meta.url).resolve(t)}})(e)).then((t=>new Uint8Array(t.buffer)))}if(x||E||["https://","http://"].some((t=>e.startsWith(t))))return this.loadFileResponse(t).then((t=>t.arrayBuffer())).then((t=>new Uint8Array(t)));if(L)return Deno.readFile(e);throw new Error("loadFileAsync 适配环境失败")}async loadFileStream(t){const{createReadStream:e}=await import("fs-extra");return e(this.ensureGet(t))}async loadFileResponse(t){if(!globalThis.fetch)throw new Error("fetch 函数不存在,请适配 fetch 或者升级更高级的 Nodejs ");return fetch(new URL(this.ensureGet(t),import.meta.url))}redefine(t){t instanceof Array?t.map((([t,e])=>this.set(t,e))):Object.entries(t).map((([t,e])=>this.set(t,e)))}outputFile=async(t,e,n)=>{if(k){return(0,(await import("fs-extra")).outputFile)(t,e,n)}if(L){const{outputFile:n}=await import("./fs-extra-54a5e6d5.js");return n(t,e)}throw new Error("你的环境好像不支持内部的 outputFile,请你适配 outputFile 参数")}}const C={node:{"hb-subset.wasm":"@konghayao/harfbuzzjs/hb-subset.wasm","cn_char_rank.dat":"&../data/cn_char_rank.dat","template.html":"&../data/template.html","unicodes_contours.dat":"@chinese-fonts/font-contours/data/unicodes_contours.dat"},browser:{"hb-subset.wasm":"./hb-subset.wasm","cn_char_rank.dat":"./cn_char_rank.dat","template.html":"./template.html","unicodes_contours.dat":"./unicodes_contours.dat"}},O=new U(L||x||E?C.browser:C.node),M=()=>{const t=window;let e="",n="",r="",o=t.navigator&&t.navigator.userAgent||"",s="";const a=t.navigator&&t.navigator.language||t.navigator&&t.navigator.languages&&t.navigator.languages[0]||"",i=t.navigator.userAgentData;var c;return"object"==typeof(c=i)&&null!==c&&"getHighEntropyValues"in c&&i.getHighEntropyValues(["architecture","model","platform","platformVersion","fullVersionList"]).then((t=>{if(e=t.platform||"",r=t.architecture||"",s=t.model||"",n=t.platformVersion||"",t.fullVersionList&&t.fullVersionList.length>0){const e=t.fullVersionList[t.fullVersionList.length-1];o=`${e.brand} ${e.version}`}})).catch((t=>{})),{runtime:{name:"javascript",version:navigator.userAgent},os:{name:e,version:n,build_number:o},device:{cpus:navigator.hardwareConcurrency,locale:a,model:s,manufacturer:o,architecture:r},createdTime:(new Date).toUTCString()}};const R=async t=>"browser"===t?M():"node"===t?(async()=>{const t=await import("os"),{osLocale:e}=await import("os-locale");return{runtime:{name:"javascript",version:process.versions.node},os:{name:t.platform(),version:t.version(),release:t.release()},device:{cpus:t.cpus().length,locale:await e(),architecture:t.arch()},createdTime:(new Date).toUTCString()}})():"deno"===t?(async()=>{const{default:t}=await import("https://deno.land/x/dos@v0.11.0/mod.ts"),e=M(),n=globalThis.Deno.version;return e.runtime.version=n.deno,e.os={name:t.platform(),version:""},e.device.architecture=await t.arch(),e.runtime.name="typescript",e})():void 0,$={".otc":"collection",".ttc":"collection",".eot":"embedded-opentype",".otf":"opentype",".ttf":"truetype",".svg":"svg",".svgz":"svg",".woff":"woff",".woff2":"woff2"},z=t=>{const e=Object.keys($);for(const n of e)if(t.endsWith(n))return $[n]},D=new Map([["extra light",200],["ultra light",200],["extra bold",800],["ultra bold",800],["semi bold",600],["demi bold",600]]),P=new Map([["light",300],["normal",400],["regular",400],["medium",500],["bold",700],["heavy",900],["black",900]]),B=(t,e,n)=>{const r=Object.fromEntries(Object.entries(e?.windows??e?.macintosh??{}).map((([t,e])=>[t,"string"==typeof e?e:e.en]))),o=n||{},s=n?.comment||{},a=o.fontFamily||r.fontFamily,c=r.preferredSubFamily||r.fontSubFamily||"",l=o.fontStyle||(c.toLowerCase().includes("italic")?"italic":"normal");const f=function(t,e){if(!1===t?.localFamily)return[];const n="string"==typeof t.localFamily?[t.localFamily]:t.localFamily??[];return n.push(e.fontFamily),n.map((t=>`local("${t}")`))}(o,r),u="string"==typeof o.polyfill?[{name:o.polyfill,format:z(o.polyfill)}]:o.polyfill?.map((t=>"string"==typeof t?{name:t,format:z(t)}:t))??[],h=o.fontWeight||(t=>{const e=[...D.keys()].find((e=>t.includes(e)));if(e)return D.get(e);const n=[...P.keys()].find((e=>t.includes(e)));return n?P.get(n):400})(c),p=t.reverse().map((({path:t,unicodeRange:e})=>{const n=`@font-face {\nfont-family: "${a}";\nsrc:${[...f,`url("./${t}") format("woff2")`,...u.map((t=>`url("${t.name}") ${t.format?`format("${t.format}")`:""}`))].join(",")};\nfont-style: ${l};\n${!1!==o.fontWeight?`font-weight: ${h};`:""}\nfont-display: ${o.fontDisplay||"swap"};\nunicode-range:${e};\n}`;var r;return(!0===s.unicodes?(r=e,`/* ${String.fromCharCode(...i.parse(r.split(",")))} */\n`):"")+(!1!==o.compress?n.replace(/\n/g,""):n)})).join("\n"),g=((t,e)=>{const n=e?.comment||{};if(!1===e?.comment)return"";const r=!1!==n.nameTable?"\nOrigin File Name Table:\n"+Object.entries(t).map((t=>t.join(": "))).join("\n"):"";return"/* "+(!1!==n.base?`Generated By cn-font-split@4.10.6 https://www.npmjs.com/package/@konghayao/cn-font-split\nCreateTime: ${(new Date).toUTCString()};`:"")+r+"\n */\n\n"})(r,n);return g+p};const I=t=>{const e=new Set;return t.forEach((t=>{t.forEach((t=>{if("number"==typeof t)e.add(t);else{const[n,r]=t;for(let t=n;t<=r;t++)e.add(t)}}))})),e},N={otf:"otf",ttf:"ttf",sfnt:"otf",truetype:"ttf",woff:"woff",woff2:"woff2"};function W(t,e,n,{preserveNameIds:r,variationAxes:o}={}){if(0===e.length)throw new Error(" 发现空分包");const s=n.createSubset(t,r,o);s.adjustLayout(),s.addChars(e);const a=s.runSubset(),i=n.collectUnicodes(a);let c;if(i.length){const t=s.toBinary();c=t.data().slice(),t.destroy()}else c=null;return s.destroy(),[c,i]}let V;V=t=>{const e=Buffer.from(t),n=c.createHash("md5");return n.update(e),n.digest("hex")};var G=V;const H=/\[\\*([\w:]+)\\*\]/gi,q=(t,e)=>{const n=new Map;n.set("index",J(e.index.toString())),n.set("ext",J(e.ext));const r=Z(J((()=>G(e.transferred))));n.set("hash",r),n.set("md5",r);return t.replace(H,((t,e)=>{if(e.length+2===t.length){const r=/^(\w+)(?::(\w+))?$/.exec(e);if(!r)return t;const[,o,s]=r,a=n.get(o);if(void 0!==a)return a(s)}else if(t.startsWith("[\\")&&t.endsWith("\\]"))return`[${t.slice(2,-2)}]`;return t}))},J=t=>()=>("function"==typeof t&&(t=t()),t),Z=t=>e=>{const n=e&&parseInt(e,10),r=t();return n?r.slice(0,n):r};const Q=(t,e)=>(e-t).toFixed(0)+"ms";const Y=["aalt","abvf","abvm","abvs","afrc","akhn","blwf","blwm","blws","calt","case","ccmp","cfar","chws","cjct","clig","cpct","cpsp","cswh","curs",...[...Array(99).keys()].map((t=>"cv"+(t+1).toString().padStart(2,"0"))),"c2pc","c2sc","dist","dlig","dnom","dtls","expt","falt","fin2","fin3","fina","flac","frac","fwid","half","haln","halt","hist","hkna","hlig","hngl","hojo","hwid","init","isol","ital","jalt","jp78","jp83","jp90","jp04","kern","lfbd","liga","ljmo","lnum","locl","ltra","ltrm","mark","med2","medi","mgrk","mkmk","mset","nalt","nlck","nukt","numr","onum","opbd","ordn","ornm","palt","pcap","pkna","pnum","pref","pres","pstf","psts","pwid","qwid","rand","rclt","rkrf","rlig","rphf","rtbd","rtla","rtlm","ruby","rvrn","salt","sinf","size","smcp","smpl","ss01","ss02","ss03","ss04","ss05","ss06","ss07","ss08","ss09","ss10","ss11","ss12","ss13","ss14","ss15","ss16","ss17","ss18","ss19","ss20","ssty","stch","subs","sups","swsh","titl","tjmo","tnam","tnum","trad","twid","unic","valt","vatu","vchw","vert","vhal","vjmo","vkna","vkrn","vpal","vrt2","vrtr","zero"];function K(t,e){const n=new Map;let r=12;for(let o=0;o<e;o+=1){const e=f.getTag(t,r),o=f.getULong(t,r+4),s=f.getULong(t,r+8),a=f.getULong(t,r+12);n.set(e,{tag:e,checksum:o,offset:s,length:a,compression:!1}),r+=16}return n}const X=t=>{t.constructor!==ArrayBuffer&&(t=new Uint8Array(t).buffer);const e=new DataView(t,0);let n,r;const o=f.getTag(e,0);if(o===String.fromCharCode(0,1,0,0)||"true"===o||"typ1"===o)n=f.getUShort(e,4),r=K(e,n);else if("OTTO"===o)n=f.getUShort(e,4),r=K(e,n);else{if("wOFF"!==o){if("wOF2"===o){throw new Error("WOFF2 require an external decompressor library, see examples at: https://github.com/opentypejs/opentype.js/issues/183#issuecomment-1147228025")}throw new Error("Unsupported OpenType signature "+o)}{const t=f.getTag(e,4);if(t===String.fromCharCode(0,1,0,0));else if("OTTO"!==t)throw new Error("Unsupported OpenType flavor "+o);n=f.getUShort(e,12),r=function(t,e){const n=new Map;let r=44;for(let o=0;o<e;o+=1){const e=f.getTag(t,r),o=f.getULong(t,r+4),s=f.getULong(t,r+8),a=f.getULong(t,r+12);let i;i=s<a&&"WOFF",n.set(e,{tag:e,offset:o,compression:i,compressedLength:s,length:a}),r+=20}return n}(e,n)}}return{tableEntries:r,data:e,font:{tables:{},outlinesFormat:"truetype"},getTable(t,n,...o){const s=r.get(n);if(!s)return;const a=function(t,e){if("WOFF"===e.compression){console.log(e);const n=new Uint8Array(t.buffer,e.offset+2,e.compressedLength-2),r=new Uint8Array(e.length);if(d(n,r),r.byteLength!==e.length)throw new Error("Decompression error: "+e.tag+" decompressed length doesn't match recorded length");return{data:new DataView(r.buffer,0),offset:0}}return{data:t,offset:e.offset}}(e,s);return t.parse(a.data,a.offset,...o)}}},tt=t=>{const e=t.getTable(g,"cmap");return t.font.tables.cmap=e,e};const et=t=>{const e=((n=t).font.tables.gsub=n.getTable(l,"GSUB"),new u(n.font));var n;tt(t);const r=function(t){const e=t.font,n=new Map;e.tables.cmap||tt(t);const r=e.tables.cmap.glyphIndexMap,o=Object.keys(r);for(let t=0;t<o.length;t+=1){const e=o[t],s=r[e];n.has(s)?n.get(s).push(parseInt(e)):n.set(s,[parseInt(e)])}return n}(t);return Y.flatMap((t=>e.getFeature(t)?.map((t=>[t.sub,t.by].flat())).map((t=>t.map((t=>r.get(t)??[])).flat()))??[])).filter((t=>t.length>1))},nt=(t,e)=>{const n=e.get(t);return void 0===n?[t]:null===n?[]:(n.forEach((t=>e.set(t,null))),[...n])},rt=async(t,e,n,r,o,s)=>{const{input:a}=s.pick("input"),i=(t=>"."+N[t])(o),c=[];if(s.trace("开始分包 分包数",n.length),s.trace("序号\thb\twoff2\t大小/字符\t名称"),a.threads)await Promise.all(n.map((async(n,l)=>ot(t,n,e,a,o,r,i,c,s,l).catch((t=>{s.warn("分包失败 "+l+" "+t.message)})))));else{let l=0;for(const f of n)await ot(t,f,e,a,o,r,i,c,s,l),l++}return s.trace("结束分包"),c};async function ot(t,e,n,r,o,s,c,l,f,u){const h=performance.now();if(0===e.length)return void f.warn("发现空分包"+e);const[p,g]=W(t,e,n,{}),d=[h,performance.now()];if(!p||0===p.byteLength)return void f.warn("发现空分包"+e);const m=performance.now(),b=r.threads&&r.threads?.service,w=b?await b.pool.exec("convert",[p,o],{transfer:[p.buffer]}):await y(p,o),_=[m,performance.now()],v=await async function(t,e,n,r,o,s,a){const c=s.renameOutputFont||"[hash][ext]",l={transferred:n,ext:e,index:a},f="string"==typeof c?q(c,l):c(l);await t(f,n);const u=i.stringify(o);return{size:n.byteLength,path:f,unicodeRange:u.join(","),subset:u.map((t=>(t=t.replace("U+","")).includes("-")?t.split("-").map((t=>parseInt(t))):parseInt(t))),diff:r.length-o.length,charLength:o.length}}(s,c,w,e,Array.from(g),r,u);l.push(v),async function(t,e,n,r,o,s,i){const c=o;t.trace([s,Q(...n),Q(...r),a(e.byteLength)+"/"+c.length,i.slice(0,7)].join(" \t"))}(f,w,d,_,g,u,v.path)}const st=(t,e,n,r,o)=>{let s=0,a=[];const i=[],c=n.get(0);for(const l of t){const t=nt(l,r);s+=t.reduce(((t,e)=>t+(n.get(e)??c)),0),a.push(...t),(s>=e||a.length>=o)&&(i.push(a),a=[],s=0)}return a.length&&i.push(a),i},at=[...I([[[0,255],305,[338,339],[699,700],710,730,732,772,776,809,[8192,8303],8308,8364,8482,8593,8595,8722,8725,65279,65533],[[256,687],772,776,809,[7680,7839],[7922,7935],8224,[8352,8363],[8365,8399],8467,[11360,11391],[42784,43007]]])],it=async()=>[...new Uint16Array((await O.loadFileAsync("cn_char_rank.dat")).buffer)];const ct=t=>{const e=new URL(t,import.meta.url);return k?b(e.toString()):e.toString()};class lt{constructor(t){this.pool=m(((t,e="module")=>{if(x){if("module"===e){const e=new Blob([`import "${new URL(t,import.meta.url)}"`],{type:"text/javascript"}),n=URL.createObjectURL(e);return ct(n)}{const e=new Blob([`importScripts("${new URL(t,import.meta.url)}")`],{type:"application/javascript"});return URL.createObjectURL(e)}}return ct(t)})("./convert.worker-959a7c78.js"),{...t,workerOpts:{type:"module"}})}destroy(){this.pool.terminate()}}const ft=(t,e)=>t.map((t=>((t,e)=>t.flatMap((t=>{if("number"==typeof t)return nt(t,e);{const[n,r]=t,o=new Set;for(let t=n;t<=r;t++)nt(t,e).forEach((t=>o.add(t)));return[...o.values()]}})))(t,e)));const ut=t=>{let e=null;return function(...n){return null===e&&(e=t.apply(this,n)),e}},ht=ut((async()=>{const t=await O.loadFileAsync("unicodes_contours.dat"),e=new Uint8Array(t.buffer),n=new Map;for(let t=0;t<e.length;t++){const r=e[t];0!==r?n.set(t,r):0}return n}));const pt=(t,e)=>{const[n,r,o]=function(t,e,n=3){const r=e.reduce(((t,e)=>t+e),0)/e.length,o=Math.sqrt(e.reduce(((t,e)=>t+Math.pow(e-r,2)),0)/(e.length-1)),s=[],a=[];for(let i=0;i<e.length;i++)(e[i]-r)/o<-n?s.push(t[i]):a.push(t[i]);return[s,a,r]}(t,t.map((t=>t.length)),1),s=n.length;if(!n.length)return t;const a=n.sort(((t,e)=>t.length-e.length)).reduce(((t,e)=>{const n=t[t.length-1];return n.length+e.length<=1.1*o?n.push(...e):t.push([...e]),t}),[[]]);return e.info(`减少分包碎片 ${s} => ${a.length} `),[...a,...r]},gt={difference(t,e){const n=e instanceof Set?e.values():e;for(const e of n)t.has(e)&&t.delete(e);return t}},dt=async t=>{const e=t.outputFile??O.outputFile,n=new F([async function(e){e.info("cn-font-split@4.10.6 环境检测\t",A),"function"==typeof t.log&&e.recordLog(t.log);const{input:n}=e.pick("input");let r;"string"==typeof n.FontPath?r=await O.loadFileAsync(n.FontPath):n.FontPath instanceof Uint8Array&&(r=new Uint8Array(n.FontPath)),e.trace("输入文件大小:"+a(r.byteLength)),e.set("bundleMessage",{originLength:r.byteLength}),e.set("originFile",r)},async function(t){const{originFile:e,bundleMessage:n}=t.pick("input","originFile","bundleMessage"),r=(await y(e,"truetype")).slice(0);n.ttfLength=r.byteLength,t.set("ttfBufferSize",r.byteLength),t.set("ttfFile",r),t.free("originFile")},async function(e){const{ttfFile:n}=e.pick("input","ttfFile"),r=await(async(t="hb-subset.wasm")=>k||L?WebAssembly.instantiate(await O.loadFileAsync(t)):WebAssembly.instantiateStreaming(O.loadFileResponse(t)))();if(!r)throw new Error("启动 harfbuzz 失败");const o=_(r.instance),s=o.createBlob(n),a=o.createFace(s,0);s.destroy(),e.set("hb",o),e.set("face",a),e.set("blob",s),!1!==t.threads&&(t.threads=t.threads||{},t.threads.service=new lt(t.threads.options))},async function(t){const{ttfFile:e}=t.pick("input","ttfFile"),n=X(e.buffer);t.set("fontTool",n),t.free("ttfFile")},async function(t){const{input:n,hb:r,face:o}=t.pick("input","hb","face");if(n.previewImage){const t=r.createFont(o),a=await((t,e,n="中文网字计划\nThe Project For Web",{baseLine:r=24,lineHeight:o=1}={})=>{const s=function(t,e,n){e.setScale(100,-100);const r=t.createBuffer();r.addText(n),r.guessSegmentProperties(),t.shape(e,r);const o=r.json().map((function(t){return{...t,glyph:e.glyphToPath(t.g)}}));return r.destroy(),o}(t,e,n),a=100*o,i={height:a,width:0},c=s.map((t=>{if(0===t.g)return i.height+=a,void(i.width=0);const e=`<path transform="translate(${t.dx+i.width} ${i.height+t.dy})" d="${t.glyph}"></path>`;return i.width+=t.ax,e}));return`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="${i.width}" height="${i.height}" viewBox="0 0 ${i.width+r} ${i.height+r}">${c.join("")}</svg>`})(r,t,n.previewImage?.text);t.destroy(),await e(s.join(n.destFold,"preview.svg"),a)}},async function(t){const{fontTool:e}=t.pick("fontTool","face"),n=(t=>{const e=t.getTable(p,"ltag"),n=t.getTable(h,"name",e);return t.font.tables.name=n,n})(e);t.set("nameTable",n)},async function(e){const{input:n,hb:r,face:o,ttfBufferSize:s,bundleMessage:a,fontTool:i}=e.pick("input","face","hb","ttfBufferSize","bundleMessage","fontTool"),c=t.subsets??[],l=o.collectUnicodes();e.trace("总字符数",l.length),a.originSize=l.length;const f=new Set([...l]);gt.difference(f,I(c));const u=(t.unicodeRank??[at,await it()]).map((t=>t.filter((t=>{const e=f.has(t);return f.delete(t),e})))),h=(t=>{const e=new Map;return t.forEach((t=>{for(const n of t){if(e.has(n)){const r=e.get(n);t.forEach((t=>r.add(t))),r.forEach((t=>e.set(t,r)));break}e.set(n,new Set(t))}})),e})(et(i)),p=ft(c,h);gt.difference(f,p.flat()),u.push([...f]);const g=await ht(),d=await async function(t,e,n,r,o,s){let a=Math.floor(s.size/100);a=Math.max(a,1);const i=[];let c=0;for(const t of s)c%a==0&&i.push(t),c++;const[l,f]=W(e,i,t,{threads:!1});if(!l)throw new Error("尝试测试分包比率时,分包失败");const u=await y(new Uint8Array(l.buffer),n);return o*(f.reduce(((t,e)=>t+(r.get(e)??r.get(0))),0)/u.byteLength)}(r,o,n.targetType??"woff2",g,n.chunkSize??71680,new Set([...l])),m=[],b=(t.chunkSizeTolerance??1.7)*l.length*(n.chunkSize??71680)/s;for(const t of u){const e=st(t,d,g,h,b);m.push(...e)}for(const[t,n]of h.entries())n&&e.warn("featureMap "+t+" 未使用"+n.size);const w=!1!==n.autoChunk?[...p,...m]:p,_=pt(w,e),v=_.reduce(((t,e)=>t+=e.length),0);if(!1!==n.autoChunk&&v<l.length&&console.log("字符缺漏",v,l.length),_.length>=(n.maxAllowSubsetsCount??600))throw new Error("分包数为"+_.length+",超过了期望最大分包数,将会导致您的机器过久运行");e.set("subsetsToRun",_),e.free("ttfFile")},async function(t){const{input:n,face:r,blob:o,subsetsToRun:a,hb:i,bundleMessage:c}=t.pick("input","face","blob","hb","subsetsToRun","bundleMessage"),l=await rt(r,i,a,(async(t,r)=>e(s.join(n.destFold,t),r)),n.targetType??"woff2",t);c.bundledSize=l.reduce(((t,e)=>t+e.charLength),0),c.bundledTotalLength=l.reduce(((t,e)=>t+e.size),0),t.set("subsetResult",l),r.destroy(),o.free(),t.free("blob","face","hb")},async function(t){const{nameTable:n,subsetResult:r,input:o}=t.pick("input","nameTable","subsetResult"),a=B(r,n,o.css);await e(s.join(o.destFold,o.cssFileName??"result.css"),a)},async function(t){const{input:n}=t.pick("input");if(!1!==n.testHTML){const{createTestHTML:t}=await import("./index-33ed7236.js"),r=t();await e(s.join(n.destFold,"index.html"),await r)}},async function(t){const{nameTable:r,subsetResult:o,input:a,bundleMessage:i}=t.pick("input","nameTable","subsetResult","bundleMessage");if(!1!==a.testHTML||!1!==a.reporter){const t=await(async(t,e,n,r,o)=>{const s=t.map((t=>({name:t.path,size:t.size,chars:t.unicodeRange,diff:t.diff,charsSize:t.charLength})));return{config:{...n,fontPath:"string"!=typeof n.FontPath?"it is a binary input":n.FontPath,threads:{...n.threads,service:void 0}},message:e,data:s,record:r,version:"4.10.6",env:{envName:A,...await R(A)},bundleMessage:o}})(o,r,a,n.records,i);await e(s.join(a.destFold,"reporter.json"),JSON.stringify(t))}},async function(t){const{input:e}=t.pick("input");e.threads&&e.threads?.service?.destroy()}],(t=>new v({input:t},{log:{settings:{prettyLogTimeZone:"local",prettyLogTemplate:"{{logLevelName}}\t",...t?.logger?.settings??{}}}}))(t));await n.run()},mt=t=>{const e=t.match(/@font-face[\s\S]+?\}/g);return e?e.map((t=>{const e=t.match(/unicode-range:(.*(?:[,;]))+/);if(!e)return[];return e[1].split(/[,;]/).map((t=>t.trim())).filter(Boolean).map((t=>(t=t.replace("U+","")).includes("-")?t.split("-").map((t=>parseInt("0x"+t))):parseInt("0x"+t)))})):[]},bt="4.10.6";export{O as Assets,at as Latin,bt as VERSION_CN_FONT_SPLIT,ut as cacheResult,y as convert,A as env,dt as fontSplit,it as getCN_SC_Rank,R as getDeviceMessage,mt as getSubsetsFromCSS,_ as hbjs,x as isBrowser,L as isDeno,E as isInWorker,j as isJsDom,k as isNode};
import{s as t,d as e}from"./detectFormat-db568c54.js";import{decompress as n,compress as r}from"@chinese-fonts/wawoff2";import{Logger as o}from"tslog";import s from"path";import a from"byte-size";import{UnicodeRange as i}from"@japont/unicode-range";import c from"crypto";import l from"@konghayao/opentype.js/src/tables/gsub.js";import f from"@konghayao/opentype.js/src/parse.js";import u from"@konghayao/opentype.js/src/substitution.js";import h from"@konghayao/opentype.js/src/tables/name.js";import p from"@konghayao/opentype.js/src/tables/ltag.js";import g from"@konghayao/opentype.js/src/tables/cmap.js";import{tinf_uncompress as d}from"@konghayao/opentype.js/src/tiny-inflate@1.0.3.esm.js";import{pool as m}from"workerpool";import{fileURLToPath as b}from"node:url";const y=async function(o,s,a){const i=["truetype","ttf","otf"];if(i.includes(s)&&(s="sfnt"),i.includes(a||"")&&(a="sfnt"),!t.has(s))throw new Error(`Unsupported target format: ${s}`);if(a){if(!t.has(a))throw new Error(`Unsupported source format: ${a}`)}else a=e(o);if(a===s)return o;if("woff"===a)throw new Error("Unsupported source format: woff");return"woff2"===a&&(o=await n(o)),"woff2"===s&&(o=await r(o)),o};function w(t){return(255&t.charCodeAt(0))<<24|(255&t.charCodeAt(1))<<16|(255&t.charCodeAt(2))<<8|(255&t.charCodeAt(3))<<0}function _(t){const e=t.exports,n=new Uint8Array(e.memory.buffer),r=new Uint32Array(e.memory.buffer),o=new Int32Array(e.memory.buffer),s=new Float32Array(e.memory.buffer),a=new TextDecoder("utf8"),i=-1;function c(t,a){let c=n;a===Uint32Array?c=r:a===Int32Array?c=o:a===Float32Array&&(c=s);const l=a.BYTES_PER_ELEMENT,f=e.hb_set_get_population(t),u=e.malloc(f*l),h=u/l,p=c.subarray(h,h+f);return c.set(p,h),e.hb_set_next_many(t,i,u,f),p}function l(t){const n=e.hb_set_create();e.hb_face_collect_unicodes(t,n);const r=c(n,Uint32Array);return e.hb_set_destroy(n),r}function f(t){if(!t)return{ptr:0,length:0,free(){}};const r=e.malloc(t.length+1);for(let e=0;e<t.length;++e){const o=t.charCodeAt(e);if(o>127)throw new Error("Expected ASCII text");n[r+e]=o}return n[r+t.length]=0,{ptr:r,length:t.length,free(){e.free(r)}}}return{createSubset:function(t,r,o){const s=e.hb_subset_input_create_or_fail();if(0===s)throw new Error("hb_subset_input_create_or_fail (harfbuzz) returned zero, indicating failure");let a;const i=e.hb_subset_input_unicode_set(s);return{ptr:s,clearTableDrop(){e.hb_set_clear(e.hb_subset_input_set(s,3))},adjustLayout(){for(const t of[6,7]){const n=e.hb_subset_input_set(s,t);e.hb_set_clear(n),e.hb_set_invert(n)}if(r){const t=e.hb_subset_input_set(s,4);for(const n of r)e.hb_set_add(t,n)}if(o)for(const[n,r]of Object.entries(o))e.hb_subset_input_pin_axis_location(s,t.ptr,n.split("").reduce((function(t,e){return(t<<8)+e.charCodeAt(0)}),0),r)},deleteChar(t){for(const n of t)e.hb_set_del(i,n)},addChars(t){for(const n of t)if(n instanceof Array){const[t,r]=n;for(let n=t;n<=r;n++)e.hb_set_add(i,n)}else e.hb_set_add(i,n)},getResult:()=>a,runSubset(){if(a=e.hb_subset_or_fail(t.ptr,s),0===a)throw new Error("hb_subset_or_fail (harfbuzz) returned zero, indicating failure. Maybe the input file is corrupted?");return a},destroy(){a&&"number"==typeof a&&e.hb_face_destroy(a),e.hb_subset_input_destroy(s)},toBinary(){const t=e.hb_face_reference_blob(a),r=e.hb_blob_get_data(t,0),o=e.hb_blob_get_length(t);if(0===o)throw e.hb_blob_destroy(t),new Error("Failed to create subset font, maybe the input file is corrupted?");return{destroy(){e.hb_blob_destroy(t)},offset:r,subsetByteLength:o,blobPtr:t,data:()=>n.subarray(r,r+o)}}}},createBlob:function(t){const r=e.malloc(t.byteLength);n.set(t,r);const o=e.hb_blob_create(r,t.byteLength,2,r,e.free_ptr());return{ptr:o,blobPtr:r,destroy(){e.hb_blob_destroy(o)},free(){e.free(r)}}},createFace:function(t,o){const a=e.hb_face_create(t.ptr,o),i=e.hb_face_get_upem(a);return{ptr:a,upem:i,reference_table(t){const r=e.hb_face_reference_table(a,w(t)),o=e.hb_blob_get_length(r);if(!o)throw new Error(" 引用字体文件中 table 失败");const s=e.hb_blob_get_data(r,null);return n.subarray(s,s+o)},collectUnicodes:()=>l(a),getAxisInfos(){const t=e.malloc(2048),n=e.malloc(4);r[n/4]=64,e.hb_ot_var_get_axis_infos(a,0,n,t);const o={};return Array.from({length:r[n/4]}).forEach((function(e,n){var a;o[(a=r[t/4+8*n+1],[String.fromCharCode(a>>24&255),String.fromCharCode(a>>16&255),String.fromCharCode(a>>8&255),String.fromCharCode(a>>0&255)].join(""))]={min:s[t/4+8*n+4],default:s[t/4+8*n+5],max:s[t/4+8*n+6]}})),e.free(n),e.free(t),o},destroy(){e.hb_face_destroy(a)},free(){e.hb_face_destroy(a)}}},createFont:function(t){const o=e.hb_font_create(t.ptr),i=e.malloc(65536),c=e.malloc(256);function l(t){const r=e.hbjs_glyph_svg(o,t,i,65536);return r>0?a.decode(n.subarray(i,i+r)):""}return{ptr:o,glyphName:function(t){e.hb_font_glyph_to_string(o,t,c,256);const r=n.subarray(c,c+256);return a.decode(r.slice(0,r.indexOf(0)))},glyphToPath:l,glyphToJson:t=>l(t).replace(/([MLQCZ])/g,"|$1 ").split("|").filter((function(t){return t.length})).map((function(t){const e=t.split(/[ ,]/g);return{type:e[0],values:e.slice(1).filter((function(t){return t.length})).map((function(t){return+t}))}})),setScale(t,n){e.hb_font_set_scale(o,t,n)},setletiations(t){const n=Object.entries(t),a=e.malloc(8*n.length);n.forEach((function(t,e){r[a/4+2*e+0]=w(t[0]),s[a/4+2*e+1]=t[1]})),e.hb_font_set_letiations(o,a,n.length),e.free(a)},destroy(){e.hb_font_destroy(o)}}},createBuffer:function(){const t=e.hb_buffer_create();return{ptr:t,addText(n){const r=function(t){const n=e.malloc(2*t.length),r=new Uint16Array(e.memory.buffer,n,t.length);for(let e=0;e<r.length;++e)r[e]=t.charCodeAt(e);return{ptr:n,length:r.length,free(){e.free(n)}}}(n);e.hb_buffer_add_utf16(t,r.ptr,r.length,0,r.length),r.free()},guessSegmentProperties:()=>e.hb_buffer_guess_segment_properties(t),setDirection(n){e.hb_buffer_set_direction(t,{ltr:4,rtl:5,ttb:6,btt:7}[n]||0)},setFlags(n){let r=0;n.forEach((function(t){r|=function(t){return{BOT:1,EOT:2,PRESERVE_DEFAULT_IGNORABLES:4,REMOVE_DEFAULT_IGNORABLES:8,DO_NOT_INSERT_DOTTED_CIRCLE:16,PRODUCE_UNSAFE_TO_CONCAT:64}[t]||0}(t)})),e.hb_buffer_set_flags(t,r)},setLanguage(n){const r=f(n);e.hb_buffer_set_language(t,e.hb_language_from_string(r.ptr,-1)),r.free()},setScript(n){const r=f(n);e.hb_buffer_set_script(t,e.hb_script_from_string(r.ptr,-1)),r.free()},setClusterLevel(n){e.hb_buffer_set_cluster_level(t,n)},json(){const n=e.hb_buffer_get_length(t),s=[],a=e.hb_buffer_get_glyph_infos(t,0),i=a/4,c=e.hb_buffer_get_glyph_positions(t,0)/4,l=r.subarray(i,i+5*n),f=o.subarray(c,c+5*n);for(let t=0;t<n;++t)s.push({g:l[5*t+0],cl:l[5*t+2],ax:f[5*t+0],ay:f[5*t+1],dx:f[5*t+2],dy:f[5*t+3],flags:e.hb_glyph_info_get_glyph_flags(a+20*t)});return s},destroy(){e.hb_buffer_destroy(t)}}},shape:function(t,n,r){const o=f(r);e.hb_shape(t.ptr,n.ptr,o.ptr,o.length),o.free()},shapeWithTrace:function(t,r,o,s,i){const c=1048576,l=e.malloc(c),u=f(o),h=e.hbjs_shape_with_trace(t.ptr,r.ptr,u.ptr,s,i,l,c);u.free();const p=a.decode(n.subarray(l,l+h-1));return e.free(l),JSON.parse(p)},exports:e,heapu8:n,heapf32:s,heapi32:o,heapu32:r,typedArrayFromSet:c,collectUnicodes:l}}class v extends o{constructor(t={},e={}){super(e?.log?.settings,e?.log?.logObj),this._originData=t}recordLog(t){this.attachTransport((e=>{const n=Object.keys(e).filter((t=>!isNaN(parseInt(t)))).map((t=>[parseInt(t),e[t]])).sort(((t,e)=>t[0]-e[0])).map((t=>t[1]));t(this._prettyFormatLogObjMeta(e._meta),...n)}))}set(t,e){this._originData[t]=e}free(...t){for(const e of t)delete this._originData[e]}check(t){return t in this._originData}destroy(){this._originData={}}pick(...t){if(0===t.length)throw new Error("Context pick: please send some name to access the keys you sure to be existed!");const e={};return t.forEach((t=>{t in this._originData?e[t]=this._originData[t]:console.warn(`[Warning] Context: ${t} isn't found in context, It could cause Error`)})),e}}class T{constructor(t,e){this.to=t,this.task=e}}class F{constructor(t,e){this.steps=t,this.context=e}ptr=-1;setPtr(t){if(t<=this.steps.length&&t>=0)return this.ptr=t,this.ptr;throw new Error("setPtr: Array boundary number error: "+t)}records=[];startTask(t){this.context.info("--\x3e\t\t"+t.name+"\tStart");const e=performance.now();return{start:e,p:(async()=>t(this.context))().then((()=>this.endTask({start:e,task:t}))),task:t}}endTask({start:t,task:e}){const n=performance.now();this.context.info("<--\t"+(n-t).toFixed(0)+"ms\t"+e.name+"\tDone\t");const r={name:e.name,start:t,end:n};this.records.push(r)}async nextStep(){const t=this.setPtr(this.ptr+1),e=this.steps[t];if("function"==typeof e){const t=this.startTask(e);await t.p;const n=this.concurrentMap.get(e.name);return n&&await Promise.all(n.map((async t=>t.p))),!0}if(e instanceof T){const t=this.concurrentMap.get(e.to)??[];return t.push(this.startTask(e.task)),this.concurrentMap.set(e.to,t),!0}return!1}concurrentMap=new Map;async run(t=1.5){if(!this.steps)throw new Error("run: Please defineOrder for the tasks");const e=this.steps.length*t;let n=0,r=!0;for(;r;)if(r=await this.nextStep(),n++,n>=e)throw new Error("Executor run: too many times task to run!");return this.context}}const j="object"==typeof navigator&&navigator.userAgent&&navigator.userAgent.includes("jsdom"),k="object"==typeof globalThis.process&&!!globalThis.process.versions&&!!globalThis.process.versions.node,x="object"==typeof window&&"object"==typeof document&&9===document.nodeType,S=globalThis.Deno,L="object"==typeof S&&S.version,E=(()=>{if(globalThis.self&&"function"==typeof globalThis.importScripts)try{return globalThis.importScripts(),"classic"}catch(t){return"module"}return!1})(),A=k?"node":x?"browser":L?"deno":E?"worker_"+E:"unknown";class U extends Map{constructor(t){super(t instanceof Array?t:Object.entries(t))}ensureGet(t){let e;return this.has(t)?(e=this.get(t),this.pathTransform?this.pathTransform(e):e):t}async loadFileAsync(t){const e=this.ensureGet(t);if(k){const{promises:{readFile:t}}=await import("fs");return t(await(async t=>{switch(t[0]){case".":case"/":case"~":return t;case"&":const{resolve:e,dirname:n}=await import("path"),{fileURLToPath:r}=await import("node:url");return e(n(r(import.meta.url)),t.slice(1));default:const{default:o}=await import("node:module");return o.createRequire(import.meta.url).resolve(t)}})(e)).then((t=>new Uint8Array(t.buffer)))}if(x||E||["https://","http://"].some((t=>e.startsWith(t))))return this.loadFileResponse(t).then((t=>t.arrayBuffer())).then((t=>new Uint8Array(t)));if(L)return Deno.readFile(e);throw new Error("loadFileAsync 适配环境失败")}async loadFileStream(t){const{createReadStream:e}=await import("fs-extra");return e(this.ensureGet(t))}async loadFileResponse(t){if(!globalThis.fetch)throw new Error("fetch 函数不存在,请适配 fetch 或者升级更高级的 Nodejs ");return fetch(new URL(this.ensureGet(t),import.meta.url))}redefine(t){t instanceof Array?t.map((([t,e])=>this.set(t,e))):Object.entries(t).map((([t,e])=>this.set(t,e)))}outputFile=async(t,e,n)=>{if(k){return(0,(await import("fs-extra")).outputFile)(t,e,n)}if(L){const{outputFile:n}=await import("./fs-extra-54a5e6d5.js");return n(t,e)}throw new Error("你的环境好像不支持内部的 outputFile,请你适配 outputFile 参数")}}const C={node:{"hb-subset.wasm":"@konghayao/harfbuzzjs/hb-subset.wasm","cn_char_rank.dat":"&../data/cn_char_rank.dat","template.html":"&../data/template.html","unicodes_contours.dat":"@chinese-fonts/font-contours/data/unicodes_contours.dat"},browser:{"hb-subset.wasm":"./hb-subset.wasm","cn_char_rank.dat":"./cn_char_rank.dat","template.html":"./template.html","unicodes_contours.dat":"./unicodes_contours.dat"}},O=new U(L||x||E?C.browser:C.node),M=()=>{const t=window;let e="",n="",r="",o=t.navigator&&t.navigator.userAgent||"",s="";const a=t.navigator&&t.navigator.language||t.navigator&&t.navigator.languages&&t.navigator.languages[0]||"",i=t.navigator.userAgentData;var c;return"object"==typeof(c=i)&&null!==c&&"getHighEntropyValues"in c&&i.getHighEntropyValues(["architecture","model","platform","platformVersion","fullVersionList"]).then((t=>{if(e=t.platform||"",r=t.architecture||"",s=t.model||"",n=t.platformVersion||"",t.fullVersionList&&t.fullVersionList.length>0){const e=t.fullVersionList[t.fullVersionList.length-1];o=`${e.brand} ${e.version}`}})).catch((t=>{})),{runtime:{name:"javascript",version:navigator.userAgent},os:{name:e,version:n,build_number:o},device:{cpus:navigator.hardwareConcurrency,locale:a,model:s,manufacturer:o,architecture:r},createdTime:(new Date).toUTCString()}};const R=async t=>"browser"===t?M():"node"===t?(async()=>{const t=await import("os"),{osLocale:e}=await import("os-locale");return{runtime:{name:"javascript",version:process.versions.node},os:{name:t.platform(),version:t.version(),release:t.release()},device:{cpus:t.cpus().length,locale:await e(),architecture:t.arch()},createdTime:(new Date).toUTCString()}})():"deno"===t?(async()=>{const{default:t}=await import("https://deno.land/x/dos@v0.11.0/mod.ts"),e=M(),n=globalThis.Deno.version;return e.runtime.version=n.deno,e.os={name:t.platform(),version:""},e.device.architecture=await t.arch(),e.runtime.name="typescript",e})():void 0,$={".otc":"collection",".ttc":"collection",".eot":"embedded-opentype",".otf":"opentype",".ttf":"truetype",".svg":"svg",".svgz":"svg",".woff":"woff",".woff2":"woff2"},z=t=>{const e=Object.keys($);for(const n of e)if(t.endsWith(n))return $[n]},D=new Map([["extra light",200],["ultra light",200],["extra bold",800],["ultra bold",800],["semi bold",600],["demi bold",600]]),P=new Map([["light",300],["normal",400],["regular",400],["medium",500],["bold",700],["heavy",900],["black",900]]),B=(t,e,n)=>{const r=Object.fromEntries(Object.entries(e?.windows??e?.macintosh??{}).map((([t,e])=>[t,"string"==typeof e?e:e.en]))),o=n||{},s=n?.comment||{},a=o.fontFamily||r.fontFamily,c=r.preferredSubFamily||r.fontSubFamily||"",l=o.fontStyle||(c.toLowerCase().includes("italic")?"italic":"normal");const f=function(t,e){if(!1===t?.localFamily)return[];const n="string"==typeof t.localFamily?[t.localFamily]:t.localFamily??[];return n.push(e.fontFamily),n.map((t=>`local("${t}")`))}(o,r),u="string"==typeof o.polyfill?[{name:o.polyfill,format:z(o.polyfill)}]:o.polyfill?.map((t=>"string"==typeof t?{name:t,format:z(t)}:t))??[],h=o.fontWeight||(t=>{const e=[...D.keys()].find((e=>t.includes(e)));if(e)return D.get(e);const n=[...P.keys()].find((e=>t.includes(e)));return n?P.get(n):400})(c),p=t.reverse().map((({path:t,unicodeRange:e})=>{const n=`@font-face {\nfont-family: "${a}";\nsrc:${[...f,`url("./${t}") format("woff2")`,...u.map((t=>`url("${t.name}") ${t.format?`format("${t.format}")`:""}`))].join(",")};\nfont-style: ${l};\n${!1!==o.fontWeight?`font-weight: ${h};`:""}\nfont-display: ${o.fontDisplay||"swap"};\nunicode-range:${e};\n}`;var r;return(!0===s.unicodes?(r=e,`/* ${String.fromCharCode(...i.parse(r.split(",")))} */\n`):"")+(!1!==o.compress?n.replace(/\n/g,""):n)})).join("\n"),g=((t,e)=>{const n=e?.comment||{};if(!1===e?.comment)return"";const r=!1!==n.nameTable?"\nOrigin File Name Table:\n"+Object.entries(t).map((t=>t.join(": "))).join("\n"):"";return"/* "+(!1!==n.base?`Generated By cn-font-split@4.11.0 https://www.npmjs.com/package/@konghayao/cn-font-split\nCreateTime: ${(new Date).toUTCString()};`:"")+r+"\n */\n\n"})(r,n);return g+p};const I=t=>{const e=new Set;return t.forEach((t=>{t.forEach((t=>{if("number"==typeof t)e.add(t);else{const[n,r]=t;for(let t=n;t<=r;t++)e.add(t)}}))})),e},N={otf:"otf",ttf:"ttf",sfnt:"otf",truetype:"ttf",woff:"woff",woff2:"woff2"};function W(t,e,n,{preserveNameIds:r,variationAxes:o}={}){if(0===e.length)throw new Error(" 发现空分包");const s=n.createSubset(t,r,o);s.adjustLayout(),s.addChars(e);const a=s.runSubset(),i=n.collectUnicodes(a);let c;if(i.length){const t=s.toBinary();c=t.data().slice(),t.destroy()}else c=null;return s.destroy(),[c,i]}let V;V=t=>{const e=Buffer.from(t),n=c.createHash("md5");return n.update(e),n.digest("hex")};var G=V;const H=/\[\\*([\w:]+)\\*\]/gi,q=(t,e)=>{const n=new Map;n.set("index",J(e.index.toString())),n.set("ext",J(e.ext));const r=Z(J((()=>G(e.transferred))));n.set("hash",r),n.set("md5",r);return t.replace(H,((t,e)=>{if(e.length+2===t.length){const r=/^(\w+)(?::(\w+))?$/.exec(e);if(!r)return t;const[,o,s]=r,a=n.get(o);if(void 0!==a)return a(s)}else if(t.startsWith("[\\")&&t.endsWith("\\]"))return`[${t.slice(2,-2)}]`;return t}))},J=t=>()=>("function"==typeof t&&(t=t()),t),Z=t=>e=>{const n=e&&parseInt(e,10),r=t();return n?r.slice(0,n):r};const Q=(t,e)=>(e-t).toFixed(0)+"ms";const Y=["aalt","abvf","abvm","abvs","afrc","akhn","blwf","blwm","blws","calt","case","ccmp","cfar","chws","cjct","clig","cpct","cpsp","cswh","curs",...[...Array(99).keys()].map((t=>"cv"+(t+1).toString().padStart(2,"0"))),"c2pc","c2sc","dist","dlig","dnom","dtls","expt","falt","fin2","fin3","fina","flac","frac","fwid","half","haln","halt","hist","hkna","hlig","hngl","hojo","hwid","init","isol","ital","jalt","jp78","jp83","jp90","jp04","kern","lfbd","liga","ljmo","lnum","locl","ltra","ltrm","mark","med2","medi","mgrk","mkmk","mset","nalt","nlck","nukt","numr","onum","opbd","ordn","ornm","palt","pcap","pkna","pnum","pref","pres","pstf","psts","pwid","qwid","rand","rclt","rkrf","rlig","rphf","rtbd","rtla","rtlm","ruby","rvrn","salt","sinf","size","smcp","smpl","ss01","ss02","ss03","ss04","ss05","ss06","ss07","ss08","ss09","ss10","ss11","ss12","ss13","ss14","ss15","ss16","ss17","ss18","ss19","ss20","ssty","stch","subs","sups","swsh","titl","tjmo","tnam","tnum","trad","twid","unic","valt","vatu","vchw","vert","vhal","vjmo","vkna","vkrn","vpal","vrt2","vrtr","zero"];function K(t,e){const n=new Map;let r=12;for(let o=0;o<e;o+=1){const e=f.getTag(t,r),o=f.getULong(t,r+4),s=f.getULong(t,r+8),a=f.getULong(t,r+12);n.set(e,{tag:e,checksum:o,offset:s,length:a,compression:!1}),r+=16}return n}const X=t=>{t.constructor!==ArrayBuffer&&(t=new Uint8Array(t).buffer);const e=new DataView(t,0);let n,r;const o=f.getTag(e,0);if(o===String.fromCharCode(0,1,0,0)||"true"===o||"typ1"===o)n=f.getUShort(e,4),r=K(e,n);else if("OTTO"===o)n=f.getUShort(e,4),r=K(e,n);else{if("wOFF"!==o){if("wOF2"===o){throw new Error("WOFF2 require an external decompressor library, see examples at: https://github.com/opentypejs/opentype.js/issues/183#issuecomment-1147228025")}throw new Error("Unsupported OpenType signature "+o)}{const t=f.getTag(e,4);if(t===String.fromCharCode(0,1,0,0));else if("OTTO"!==t)throw new Error("Unsupported OpenType flavor "+o);n=f.getUShort(e,12),r=function(t,e){const n=new Map;let r=44;for(let o=0;o<e;o+=1){const e=f.getTag(t,r),o=f.getULong(t,r+4),s=f.getULong(t,r+8),a=f.getULong(t,r+12);let i;i=s<a&&"WOFF",n.set(e,{tag:e,offset:o,compression:i,compressedLength:s,length:a}),r+=20}return n}(e,n)}}return{tableEntries:r,data:e,font:{tables:{},outlinesFormat:"truetype"},getTable(t,n,...o){const s=r.get(n);if(!s)return;const a=function(t,e){if("WOFF"===e.compression){console.log(e);const n=new Uint8Array(t.buffer,e.offset+2,e.compressedLength-2),r=new Uint8Array(e.length);if(d(n,r),r.byteLength!==e.length)throw new Error("Decompression error: "+e.tag+" decompressed length doesn't match recorded length");return{data:new DataView(r.buffer,0),offset:0}}return{data:t,offset:e.offset}}(e,s);return t.parse(a.data,a.offset,...o)}}},tt=t=>{const e=t.getTable(g,"cmap");return t.font.tables.cmap=e,e};const et=t=>{const e=((n=t).font.tables.gsub=n.getTable(l,"GSUB"),new u(n.font));var n;tt(t);const r=function(t){const e=t.font,n=new Map;e.tables.cmap||tt(t);const r=e.tables.cmap.glyphIndexMap,o=Object.keys(r);for(let t=0;t<o.length;t+=1){const e=o[t],s=r[e];n.has(s)?n.get(s).push(parseInt(e)):n.set(s,[parseInt(e)])}return n}(t);return Y.flatMap((t=>e.getFeature(t)?.map((t=>[t.sub,t.by].flat())).map((t=>t.map((t=>r.get(t)??[])).flat()))??[])).filter((t=>t.length>1))},nt=(t,e)=>{const n=e.get(t);return void 0===n?[t]:null===n?[]:(n.forEach((t=>e.set(t,null))),[...n])},rt=async(t,e,n,r,o,s)=>{const{input:a}=s.pick("input"),i=(t=>"."+N[t])(o),c=[];if(s.trace("开始分包 分包数",n.length),s.trace("序号\thb\twoff2\t大小/字符\t名称"),a.threads)await Promise.all(n.map((async(n,l)=>ot(t,n,e,a,o,r,i,c,s,l).catch((t=>{s.warn("分包失败 "+l+" "+t.message)})))));else{let l=0;for(const f of n)await ot(t,f,e,a,o,r,i,c,s,l),l++}return s.trace("结束分包"),c};async function ot(t,e,n,r,o,s,c,l,f,u){const h=performance.now();if(0===e.length)return void f.warn("发现空分包"+e);const[p,g]=W(t,e,n,{}),d=[h,performance.now()];if(!p||0===p.byteLength)return void f.warn("发现空分包"+e);const m=performance.now(),b=r.threads&&r.threads?.service,w=b?await b.pool.exec("convert",[p,o],{transfer:[p.buffer]}):await y(p,o),_=[m,performance.now()],v=await async function(t,e,n,r,o,s,a){const c=s.renameOutputFont||"[hash][ext]",l={transferred:n,ext:e,index:a},f="string"==typeof c?q(c,l):c(l);await t(f,n);const u=i.stringify(o);return{size:n.byteLength,path:f,unicodeRange:u.join(","),subset:u.map((t=>(t=t.replace("U+","")).includes("-")?t.split("-").map((t=>parseInt(t))):parseInt(t))),diff:r.length-o.length,charLength:o.length}}(s,c,w,e,Array.from(g),r,u);l.push(v),async function(t,e,n,r,o,s,i){const c=o;t.trace([s,Q(...n),Q(...r),a(e.byteLength)+"/"+c.length,i.slice(0,7)].join(" \t"))}(f,w,d,_,g,u,v.path)}const st=(t,e,n,r,o)=>{let s=0,a=[];const i=[],c=n.get(0);for(const l of t){const t=nt(l,r);s+=t.reduce(((t,e)=>t+(n.get(e)??c)),0),a.push(...t),(s>=e||a.length>=o)&&(i.push(a),a=[],s=0)}return a.length&&i.push(a),i},at=[...I([[[0,255],305,[338,339],[699,700],710,730,732,772,776,809,[8192,8303],8308,8364,8482,8593,8595,8722,8725,65279,65533],[[256,687],772,776,809,[7680,7839],[7922,7935],8224,[8352,8363],[8365,8399],8467,[11360,11391],[42784,43007]]])],it=async()=>[...new Uint16Array((await O.loadFileAsync("cn_char_rank.dat")).buffer)];const ct=t=>{const e=new URL(t,import.meta.url);return k?b(e.toString()):e.toString()};class lt{constructor(t){this.pool=m(((t,e="module")=>{if(x){if("module"===e){const e=new Blob([`import "${new URL(t,import.meta.url)}"`],{type:"text/javascript"}),n=URL.createObjectURL(e);return ct(n)}{const e=new Blob([`importScripts("${new URL(t,import.meta.url)}")`],{type:"application/javascript"});return URL.createObjectURL(e)}}return ct(t)})("./convert.worker-4992cbf0.js"),{...t,workerOpts:{type:"module"}})}destroy(){this.pool.terminate()}}const ft=(t,e)=>t.map((t=>((t,e)=>t.flatMap((t=>{if("number"==typeof t)return nt(t,e);{const[n,r]=t,o=new Set;for(let t=n;t<=r;t++)nt(t,e).forEach((t=>o.add(t)));return[...o.values()]}})))(t,e)));const ut=t=>{let e=null;return function(...n){return null===e&&(e=t.apply(this,n)),e}},ht=ut((async()=>{const t=await O.loadFileAsync("unicodes_contours.dat"),e=new Uint8Array(t.buffer),n=new Map;for(let t=0;t<e.length;t++){const r=e[t];0!==r?n.set(t,r):0}return n}));const pt=(t,e)=>{const[n,r,o]=function(t,e,n=3){const r=e.reduce(((t,e)=>t+e),0)/e.length,o=Math.sqrt(e.reduce(((t,e)=>t+Math.pow(e-r,2)),0)/(e.length-1)),s=[],a=[];for(let i=0;i<e.length;i++)(e[i]-r)/o<-n?s.push(t[i]):a.push(t[i]);return[s,a,r]}(t,t.map((t=>t.length)),1),s=n.length;if(!n.length)return t;const a=n.sort(((t,e)=>t.length-e.length)).reduce(((t,e)=>{const n=t[t.length-1];return n.length+e.length<=1.1*o?n.push(...e):t.push([...e]),t}),[[]]);return e.info(`减少分包碎片 ${s} => ${a.length} `),[...a,...r]},gt={difference(t,e){const n=e instanceof Set?e.values():e;for(const e of n)t.has(e)&&t.delete(e);return t}},dt=async t=>{const e=t.outputFile??O.outputFile,n=new F([async function(e){e.info("cn-font-split@4.11.0 环境检测\t",A),"function"==typeof t.log&&e.recordLog(t.log);const{input:n}=e.pick("input");let r;"string"==typeof n.FontPath?r=await O.loadFileAsync(n.FontPath):n.FontPath instanceof Uint8Array&&(r=new Uint8Array(n.FontPath)),e.trace("输入文件大小:"+a(r.byteLength)),e.set("bundleMessage",{originLength:r.byteLength}),e.set("originFile",r)},async function(t){const{originFile:e,bundleMessage:n}=t.pick("input","originFile","bundleMessage"),r=(await y(e,"truetype")).slice(0);n.ttfLength=r.byteLength,t.set("ttfBufferSize",r.byteLength),t.set("ttfFile",r),t.free("originFile")},async function(e){const{ttfFile:n}=e.pick("input","ttfFile"),r=await(async(t="hb-subset.wasm")=>k||L?WebAssembly.instantiate(await O.loadFileAsync(t)):WebAssembly.instantiateStreaming(O.loadFileResponse(t)))();if(!r)throw new Error("启动 harfbuzz 失败");const o=_(r.instance),s=o.createBlob(n),a=o.createFace(s,0);s.destroy(),e.set("hb",o),e.set("face",a),e.set("blob",s),!1!==t.threads&&(t.threads=t.threads||{},t.threads.service=new lt(t.threads.options))},async function(t){const{ttfFile:e}=t.pick("input","ttfFile"),n=X(e.buffer);t.set("fontTool",n),t.free("ttfFile")},async function(t){const{input:n,hb:r,face:o}=t.pick("input","hb","face");if(n.previewImage){const t=r.createFont(o),a=await((t,e,n="中文网字计划\nThe Project For Web",{baseLine:r=24,lineHeight:o=1}={})=>{const s=function(t,e,n){e.setScale(100,-100);const r=t.createBuffer();r.addText(n),r.guessSegmentProperties(),t.shape(e,r);const o=r.json().map((function(t){return{...t,glyph:e.glyphToPath(t.g)}}));return r.destroy(),o}(t,e,n),a=100*o,i={height:a,width:0},c=s.map((t=>{if(0===t.g)return i.height+=a,void(i.width=0);const e=`<path transform="translate(${t.dx+i.width} ${i.height+t.dy})" d="${t.glyph}"></path>`;return i.width+=t.ax,e}));return`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="${i.width}" height="${i.height}" viewBox="0 0 ${i.width+r} ${i.height+r}">${c.join("")}</svg>`})(r,t,n.previewImage?.text);t.destroy(),await e(s.join(n.destFold,"preview.svg"),a)}},async function(t){const{fontTool:e}=t.pick("fontTool","face"),n=(t=>{const e=t.getTable(p,"ltag"),n=t.getTable(h,"name",e);return t.font.tables.name=n,n})(e);t.set("nameTable",n)},async function(e){const{input:n,hb:r,face:o,ttfBufferSize:s,bundleMessage:a,fontTool:i}=e.pick("input","face","hb","ttfBufferSize","bundleMessage","fontTool"),c=t.subsets??[],l=o.collectUnicodes();e.trace("总字符数",l.length),a.originSize=l.length;const f=new Set([...l]);gt.difference(f,I(c));const u=(t.unicodeRank??[at,await it()]).map((t=>t.filter((t=>{const e=f.has(t);return f.delete(t),e})))),h=(t=>{const e=new Map;return t.forEach((t=>{for(const n of t){if(e.has(n)){const r=e.get(n);t.forEach((t=>r.add(t))),r.forEach((t=>e.set(t,r)));break}e.set(n,new Set(t))}})),e})(et(i)),p=ft(c,h);gt.difference(f,p.flat()),u.push([...f]);const g=await ht(),d=await async function(t,e,n,r,o,s){let a=Math.floor(s.size/100);a=Math.max(a,1);const i=[];let c=0;for(const t of s)c%a==0&&i.push(t),c++;const[l,f]=W(e,i,t,{threads:!1});if(!l)throw new Error("尝试测试分包比率时,分包失败");const u=await y(new Uint8Array(l.buffer),n);return o*(f.reduce(((t,e)=>t+(r.get(e)??r.get(0))),0)/u.byteLength)}(r,o,n.targetType??"woff2",g,n.chunkSize??71680,new Set([...l])),m=[],b=(t.chunkSizeTolerance??1.7)*l.length*(n.chunkSize??71680)/s;for(const t of u){const e=st(t,d,g,h,b);m.push(...e)}for(const[t,n]of h.entries())n&&e.warn("featureMap "+t+" 未使用"+n.size);const w=!1!==n.autoChunk?[...p,...m]:p,_=pt(w,e),v=_.reduce(((t,e)=>t+=e.length),0);if(!1!==n.autoChunk&&v<l.length&&console.log("字符缺漏",v,l.length),_.length>=(n.maxAllowSubsetsCount??600))throw new Error("分包数为"+_.length+",超过了期望最大分包数,将会导致您的机器过久运行");e.set("subsetsToRun",_),e.free("ttfFile")},async function(t){const{input:n,face:r,blob:o,subsetsToRun:a,hb:i,bundleMessage:c}=t.pick("input","face","blob","hb","subsetsToRun","bundleMessage"),l=await rt(r,i,a,(async(t,r)=>e(s.join(n.destFold,t),r)),n.targetType??"woff2",t);c.bundledSize=l.reduce(((t,e)=>t+e.charLength),0),c.bundledTotalLength=l.reduce(((t,e)=>t+e.size),0),t.set("subsetResult",l),r.destroy(),o.free(),t.free("blob","face","hb")},async function(t){const{nameTable:n,subsetResult:r,input:o}=t.pick("input","nameTable","subsetResult"),a=B(r,n,o.css);await e(s.join(o.destFold,o.cssFileName??"result.css"),a)},async function(t){const{input:n}=t.pick("input");if(!1!==n.testHTML){const{createTestHTML:t}=await import("./index-33ed7236.js"),r=t();await e(s.join(n.destFold,"index.html"),await r)}},async function(t){const{nameTable:r,subsetResult:o,input:a,bundleMessage:i}=t.pick("input","nameTable","subsetResult","bundleMessage");if(!1!==a.testHTML||!1!==a.reporter){const t=await(async(t,e,n,r,o)=>{const s=t.map((t=>({name:t.path,size:t.size,chars:t.unicodeRange,diff:t.diff,charsSize:t.charLength})));return{config:{...n,fontPath:"string"!=typeof n.FontPath?"it is a binary input":n.FontPath,threads:{...n.threads,service:void 0}},message:e,data:s,record:r,version:"4.11.0",env:{envName:A,...await R(A)},bundleMessage:o}})(o,r,a,n.records,i);await e(s.join(a.destFold,"reporter.json"),JSON.stringify(t))}},async function(t){const{input:e}=t.pick("input");e.threads&&e.threads?.service?.destroy()}],(t=>new v({input:t},{log:{settings:{prettyLogTimeZone:"local",prettyLogTemplate:"{{logLevelName}}\t",...t?.logger?.settings??{}}}}))(t));await n.run()},mt=t=>{const e=t.match(/@font-face[\s\S]+?\}/g);return e?e.map((t=>{const e=t.match(/unicode-range:(.*(?:[,;]))+/);if(!e)return[];return e[1].split(/[,;]/).map((t=>t.trim())).filter(Boolean).map((t=>(t=t.replace("U+","")).includes("-")?t.split("-").map((t=>parseInt("0x"+t))):parseInt("0x"+t)))})):[]},bt="4.11.0";export{O as Assets,at as Latin,bt as VERSION_CN_FONT_SPLIT,ut as cacheResult,y as convert,A as env,dt as fontSplit,it as getCN_SC_Rank,R as getDeviceMessage,mt as getSubsetsFromCSS,_ as hbjs,x as isBrowser,L as isDeno,E as isInWorker,j as isJsDom,k as isNode};
//# sourceMappingURL=index.js.map
{
"name": "cn-font-split",
"version": "4.10.6",
"version": "4.11.0",
"description": "中文 web font 切割工具",

@@ -48,3 +48,3 @@ "main": "dist/index.js",

"@konghayao/opentype.js": "2023.11.20",
"@napi-rs/ttf2woff2": "^0.0.5",
"@napi-rs/woff-build": "^0.1.1",
"byte-size": "^8.1.1",

@@ -51,0 +51,0 @@ "fs-extra": "^11.1.1",

# 中文 Web Font 切割工具
![updateTime](https://img.shields.io/badge/更新时间-2023/11/20-green)
![updateTime](https://img.shields.io/badge/更新时间-2023/12/18-green)
![author](https://img.shields.io/badge/author-江夏尧-green)
![npmVersion](https://img.shields.io/badge/LTS_version-4.10.6-green)
![npmVersion](https://img.shields.io/badge/LTS_version-4.11.0-green)
[![](https://data.jsdelivr.com/v1/package/npm/@konghayao/cn-font-split/badge)](https://www.jsdelivr.com/package/npm/@konghayao/cn-font-split)

@@ -10,7 +10,5 @@

![NPM License](https://img.shields.io/npm/l/%40konghayao%2Fcn-font-split)
![downloadCount](https://img.shields.io/npm/dw/%40konghayao%2Fcn-font-split)
| [中文网字计划](https://chinese-font.netlify.app/) | [Github](https://github.com/KonghaYao/cn-font-split) | [在线使用](https://chinese-font.netlify.app/online-split/)|
| ------------------------------------------------- | ---------------------------------------------------- |---------------------------------------------------- |
| [中文网字计划](https://chinese-font.netlify.app/) | [Github](https://github.com/KonghaYao/cn-font-split) |
| ------------------------------------------------- | ---------------------------------------------------- |
## 简介

@@ -17,0 +15,0 @@

@@ -9,3 +9,3 @@ import {

convertWOFF2ToTTFAsync,
} from '@napi-rs/ttf2woff2';
} from '@napi-rs/woff-build';

@@ -12,0 +12,0 @@ /** 字体格式转化, node 特供版本,速度非常快 */

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc