@formulaxjs/kity-runtime 0.1.0 → 0.3.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/README.md +3 -4
- package/dist/{chunk-EKIJQ64F.js → chunk-AOMNUFFB.js} +73 -19
- package/dist/chunk-AOMNUFFB.js.map +1 -0
- package/dist/index.cjs +389 -131
- package/dist/index.cjs.map +1 -1
- package/dist/index.global.js +369 -160
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +186 -54
- package/dist/index.js.map +1 -1
- package/dist/{install-ARHGHFNJ.js → install-TIZBWEFU.js} +62 -45
- package/dist/install-TIZBWEFU.js.map +1 -0
- package/dist/{start-GQH6XUBI.js → start-LTYA5XON.js} +2 -2
- package/package.json +9 -5
- package/public/assets/images/scrollbar/custom/bar-bg.png +0 -0
- package/public/assets/images/scrollbar/custom/bar.png +0 -0
- package/public/assets/images/scrollbar/custom/bg.png +0 -0
- package/public/assets/images/scrollbar/custom/bottom.png +0 -0
- package/public/assets/images/scrollbar/custom/btn.png +0 -0
- package/public/assets/images/scrollbar/custom/down.png +0 -0
- package/public/assets/images/scrollbar/custom/top.png +0 -0
- package/public/assets/images/scrollbar/custom/up.png +0 -0
- package/public/assets/images/scrollbar/edit/bar-bg.png +0 -0
- package/public/assets/images/scrollbar/edit/bar-left.png +0 -0
- package/public/assets/images/scrollbar/edit/bar-right.png +0 -0
- package/public/assets/images/scrollbar/edit/thumb-bg.png +0 -0
- package/public/assets/images/scrollbar/edit/thumb-left.png +0 -0
- package/public/assets/images/scrollbar/edit/thumb-right.png +0 -0
- package/public/assets/images/toolbar/btn.png +0 -0
- package/public/assets/images/toolbar/other.png +0 -0
- package/public/assets/styles/base.css +47 -0
- package/public/assets/styles/editor.css +3 -0
- package/public/assets/styles/page.css +12 -0
- package/public/assets/styles/scrollbar.css +78 -0
- package/public/assets/styles/ui.css +593 -0
- package/public/assets/theme/default/fui.css +540 -0
- package/public/assets/theme/default/images/close.png +0 -0
- package/public/assets/theme/default/images/down.png +0 -0
- package/public/assets/theme/default/images/open.png +0 -0
- package/public/assets/theme/default/images/up.png +0 -0
- package/public/resource/KF_AMS_BB.woff +0 -0
- package/public/resource/KF_AMS_CAL.woff +0 -0
- package/public/resource/KF_AMS_FRAK.woff +0 -0
- package/public/resource/KF_AMS_MAIN.woff +0 -0
- package/public/resource/KF_AMS_ROMAN.woff +0 -0
- package/dist/chunk-EKIJQ64F.js.map +0 -1
- package/dist/install-ARHGHFNJ.js.map +0 -1
- /package/dist/{start-GQH6XUBI.js.map → start-LTYA5XON.js.map} +0 -0
package/dist/index.global.js
CHANGED
|
@@ -21,6 +21,105 @@ var FormulaX = (() => {
|
|
|
21
21
|
};
|
|
22
22
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
23
|
|
|
24
|
+
// public/assets/images/toolbar/btn.png
|
|
25
|
+
var btn_default;
|
|
26
|
+
var init_btn = __esm({
|
|
27
|
+
"public/assets/images/toolbar/btn.png"() {
|
|
28
|
+
btn_default = "./btn-5DANP6JY.png";
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// public/assets/images/toolbar/other.png
|
|
33
|
+
var other_default;
|
|
34
|
+
var init_other = __esm({
|
|
35
|
+
"public/assets/images/toolbar/other.png"() {
|
|
36
|
+
other_default = "./other-OMWJFGL5.png";
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// public/assets/styles/editor.css?url
|
|
41
|
+
var editor_default;
|
|
42
|
+
var init_editor = __esm({
|
|
43
|
+
"public/assets/styles/editor.css?url"() {
|
|
44
|
+
editor_default = "./editor-JT5KLVXX.css?url";
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// public/resource/KF_AMS_BB.woff
|
|
49
|
+
var KF_AMS_BB_default;
|
|
50
|
+
var init_KF_AMS_BB = __esm({
|
|
51
|
+
"public/resource/KF_AMS_BB.woff"() {
|
|
52
|
+
KF_AMS_BB_default = "./KF_AMS_BB-5QF7FUSO.woff";
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// public/resource/KF_AMS_CAL.woff
|
|
57
|
+
var KF_AMS_CAL_default;
|
|
58
|
+
var init_KF_AMS_CAL = __esm({
|
|
59
|
+
"public/resource/KF_AMS_CAL.woff"() {
|
|
60
|
+
KF_AMS_CAL_default = "./KF_AMS_CAL-NXRNLAZN.woff";
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// public/resource/KF_AMS_FRAK.woff
|
|
65
|
+
var KF_AMS_FRAK_default;
|
|
66
|
+
var init_KF_AMS_FRAK = __esm({
|
|
67
|
+
"public/resource/KF_AMS_FRAK.woff"() {
|
|
68
|
+
KF_AMS_FRAK_default = "./KF_AMS_FRAK-CO33WWN4.woff";
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// public/resource/KF_AMS_MAIN.woff
|
|
73
|
+
var KF_AMS_MAIN_default;
|
|
74
|
+
var init_KF_AMS_MAIN = __esm({
|
|
75
|
+
"public/resource/KF_AMS_MAIN.woff"() {
|
|
76
|
+
KF_AMS_MAIN_default = "./KF_AMS_MAIN-25QJVAWY.woff";
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// public/resource/KF_AMS_ROMAN.woff
|
|
81
|
+
var KF_AMS_ROMAN_default;
|
|
82
|
+
var init_KF_AMS_ROMAN = __esm({
|
|
83
|
+
"public/resource/KF_AMS_ROMAN.woff"() {
|
|
84
|
+
KF_AMS_ROMAN_default = "./KF_AMS_ROMAN-243BR7HH.woff";
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// src/asset-manifest.ts
|
|
89
|
+
var kityFontAssets, kityToolbarAssets, kityStyleAssets, kityAssetManifest;
|
|
90
|
+
var init_asset_manifest = __esm({
|
|
91
|
+
"src/asset-manifest.ts"() {
|
|
92
|
+
"use strict";
|
|
93
|
+
init_btn();
|
|
94
|
+
init_other();
|
|
95
|
+
init_editor();
|
|
96
|
+
init_KF_AMS_BB();
|
|
97
|
+
init_KF_AMS_CAL();
|
|
98
|
+
init_KF_AMS_FRAK();
|
|
99
|
+
init_KF_AMS_MAIN();
|
|
100
|
+
init_KF_AMS_ROMAN();
|
|
101
|
+
kityFontAssets = {
|
|
102
|
+
KF_AMS_BB: KF_AMS_BB_default,
|
|
103
|
+
KF_AMS_CAL: KF_AMS_CAL_default,
|
|
104
|
+
KF_AMS_FRAK: KF_AMS_FRAK_default,
|
|
105
|
+
KF_AMS_MAIN: KF_AMS_MAIN_default,
|
|
106
|
+
KF_AMS_ROMAN: KF_AMS_ROMAN_default
|
|
107
|
+
};
|
|
108
|
+
kityToolbarAssets = {
|
|
109
|
+
btn: btn_default,
|
|
110
|
+
other: other_default
|
|
111
|
+
};
|
|
112
|
+
kityStyleAssets = {
|
|
113
|
+
editor: editor_default
|
|
114
|
+
};
|
|
115
|
+
kityAssetManifest = {
|
|
116
|
+
fonts: kityFontAssets,
|
|
117
|
+
toolbar: kityToolbarAssets,
|
|
118
|
+
styles: kityStyleAssets
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
|
|
24
123
|
// src/vendor/legacy-box-type.ts
|
|
25
124
|
var legacyBoxType;
|
|
26
125
|
var init_legacy_box_type = __esm({
|
|
@@ -4919,28 +5018,30 @@ var FormulaX = (() => {
|
|
|
4919
5018
|
|
|
4920
5019
|
// src/vendor/legacy-ui-utils.ts
|
|
4921
5020
|
function createLegacyUiUtils() {
|
|
4922
|
-
return
|
|
4923
|
-
ele: createElement,
|
|
4924
|
-
getRectBox,
|
|
4925
|
-
on(target, type, fn) {
|
|
4926
|
-
addEvent(target, type, fn);
|
|
4927
|
-
return this;
|
|
4928
|
-
},
|
|
4929
|
-
delegate(target, selector, type, fn) {
|
|
4930
|
-
delegateEvent(target, selector, type, fn);
|
|
4931
|
-
return this;
|
|
4932
|
-
},
|
|
4933
|
-
publish(topic, ...args) {
|
|
4934
|
-
publish(topic, ...args);
|
|
4935
|
-
},
|
|
4936
|
-
subscribe,
|
|
4937
|
-
getClassList
|
|
4938
|
-
};
|
|
5021
|
+
return legacyUiUtils;
|
|
4939
5022
|
}
|
|
5023
|
+
var legacyUiUtils;
|
|
4940
5024
|
var init_legacy_ui_utils = __esm({
|
|
4941
5025
|
"src/vendor/legacy-ui-utils.ts"() {
|
|
4942
5026
|
"use strict";
|
|
4943
5027
|
init_dom_utils();
|
|
5028
|
+
legacyUiUtils = {
|
|
5029
|
+
ele: createElement,
|
|
5030
|
+
getRectBox,
|
|
5031
|
+
on(target, type, fn) {
|
|
5032
|
+
addEvent(target, type, fn);
|
|
5033
|
+
return this;
|
|
5034
|
+
},
|
|
5035
|
+
delegate(target, selector, type, fn) {
|
|
5036
|
+
delegateEvent(target, selector, type, fn);
|
|
5037
|
+
return this;
|
|
5038
|
+
},
|
|
5039
|
+
publish(topic, ...args) {
|
|
5040
|
+
publish(topic, ...args);
|
|
5041
|
+
},
|
|
5042
|
+
subscribe,
|
|
5043
|
+
getClassList
|
|
5044
|
+
};
|
|
4944
5045
|
}
|
|
4945
5046
|
});
|
|
4946
5047
|
|
|
@@ -4963,7 +5064,11 @@ var FormulaX = (() => {
|
|
|
4963
5064
|
var init_toolbar_assets = __esm({
|
|
4964
5065
|
"src/toolbar-assets.ts"() {
|
|
4965
5066
|
"use strict";
|
|
4966
|
-
|
|
5067
|
+
init_asset_manifest();
|
|
5068
|
+
toolbarAssetFileMap = {
|
|
5069
|
+
"btn.png": kityToolbarAssets.btn,
|
|
5070
|
+
"other.png": kityToolbarAssets.other
|
|
5071
|
+
};
|
|
4967
5072
|
}
|
|
4968
5073
|
});
|
|
4969
5074
|
|
|
@@ -5831,13 +5936,15 @@ var FormulaX = (() => {
|
|
|
5831
5936
|
});
|
|
5832
5937
|
|
|
5833
5938
|
// src/vendor/kity-formula/font-installer.ts
|
|
5834
|
-
var FontInstallerModule, createFontInstallerClass;
|
|
5939
|
+
var MAIN_FONT_FAMILY, FontInstallerModule, createFontInstallerClass;
|
|
5835
5940
|
var init_font_installer = __esm({
|
|
5836
5941
|
"src/vendor/kity-formula/font-installer.ts"() {
|
|
5837
5942
|
"use strict";
|
|
5943
|
+
MAIN_FONT_FAMILY = "KF AMS MAIN";
|
|
5838
5944
|
FontInstallerModule = class {
|
|
5839
5945
|
static create(kity26, FontManager, fontConfig, checkerTemplate) {
|
|
5840
5946
|
let nodeList = [];
|
|
5947
|
+
let checkerNode = null;
|
|
5841
5948
|
return kity26.createClass("FontInstaller", {
|
|
5842
5949
|
constructor: function(doc, resource) {
|
|
5843
5950
|
const normalized = typeof resource === "string" ? { path: resource } : resource ?? {};
|
|
@@ -5847,36 +5954,30 @@ var FormulaX = (() => {
|
|
|
5847
5954
|
},
|
|
5848
5955
|
mount: function(callback) {
|
|
5849
5956
|
const fontList = FontManager.getFontList();
|
|
5850
|
-
let count = 0;
|
|
5851
5957
|
kity26.Utils.each(fontList, (fontInfo) => {
|
|
5852
|
-
count += 1;
|
|
5853
5958
|
fontInfo.meta.src = resolveFontSource(this.fonts, this.resource, fontInfo.meta.src);
|
|
5854
5959
|
this.createFontStyle(fontInfo);
|
|
5855
|
-
|
|
5856
|
-
|
|
5857
|
-
|
|
5858
|
-
|
|
5859
|
-
|
|
5860
|
-
complete(this.doc, callback);
|
|
5861
|
-
}
|
|
5862
|
-
});
|
|
5960
|
+
if (fontInfo.meta.fontFamily === MAIN_FONT_FAMILY) {
|
|
5961
|
+
checkerNode = createFontCheckerNode(this.doc);
|
|
5962
|
+
return;
|
|
5963
|
+
}
|
|
5964
|
+
applyFonts(this.doc, fontInfo);
|
|
5863
5965
|
});
|
|
5966
|
+
complete(this.doc, callback);
|
|
5864
5967
|
},
|
|
5865
5968
|
createFontStyle: function(fontInfo) {
|
|
5969
|
+
const styleId = createFontStyleId(fontInfo);
|
|
5970
|
+
if (this.doc.getElementById(styleId)) {
|
|
5971
|
+
return;
|
|
5972
|
+
}
|
|
5866
5973
|
const stylesheet = this.doc.createElement("style");
|
|
5867
5974
|
const tpl = '@font-face{\nfont-family: "${fontFamily}";\nsrc: url("${src}");\n}';
|
|
5868
5975
|
stylesheet.setAttribute("type", "text/css");
|
|
5976
|
+
stylesheet.id = styleId;
|
|
5869
5977
|
stylesheet.innerHTML = tpl.replace("${fontFamily}", fontInfo.meta.fontFamily).replace("${src}", fontInfo.meta.src);
|
|
5870
5978
|
this.doc.head.appendChild(stylesheet);
|
|
5871
5979
|
}
|
|
5872
5980
|
});
|
|
5873
|
-
function preloadFont(doc, fontInfo) {
|
|
5874
|
-
const view = doc.defaultView ?? window;
|
|
5875
|
-
if (view.fetch) {
|
|
5876
|
-
return view.fetch(fontInfo.meta.src, { method: "GET" }).then(() => void 0);
|
|
5877
|
-
}
|
|
5878
|
-
return Promise.resolve();
|
|
5879
|
-
}
|
|
5880
5981
|
function resolveFontSource(fonts, resourceBase, originalSrc) {
|
|
5881
5982
|
const directMatch = fonts[originalSrc];
|
|
5882
5983
|
if (directMatch) {
|
|
@@ -5889,34 +5990,29 @@ var FormulaX = (() => {
|
|
|
5889
5990
|
}
|
|
5890
5991
|
return resourceBase + originalSrc;
|
|
5891
5992
|
}
|
|
5892
|
-
function
|
|
5993
|
+
function createFontStyleId(fontInfo) {
|
|
5994
|
+
const raw = `${fontInfo.meta.fontFamily}::${fontInfo.meta.src}`;
|
|
5995
|
+
let hash = 0;
|
|
5996
|
+
for (let index = 0; index < raw.length; index += 1) {
|
|
5997
|
+
hash = (hash << 5) - hash + raw.charCodeAt(index) | 0;
|
|
5998
|
+
}
|
|
5999
|
+
return `formulax-kity-font-${Math.abs(hash).toString(36)}`;
|
|
6000
|
+
}
|
|
6001
|
+
function waitForFontsReady(doc) {
|
|
5893
6002
|
const view = doc.defaultView ?? window;
|
|
5894
6003
|
if (view.document.fonts) {
|
|
5895
|
-
|
|
5896
|
-
return view.document.fonts.load(`50px "${fontInfo.meta.fontFamily}"`);
|
|
5897
|
-
});
|
|
5898
|
-
return Promise.all(fontLoadPromises).then(() => view.document.fonts.ready).then(() => {
|
|
5899
|
-
return new Promise((resolve) => {
|
|
5900
|
-
requestAnimationFrame(() => {
|
|
5901
|
-
requestAnimationFrame(() => {
|
|
5902
|
-
resolve();
|
|
5903
|
-
});
|
|
5904
|
-
});
|
|
5905
|
-
});
|
|
5906
|
-
});
|
|
6004
|
+
return view.document.fonts.ready.then(() => void 0);
|
|
5907
6005
|
}
|
|
5908
6006
|
return Promise.resolve();
|
|
5909
6007
|
}
|
|
5910
6008
|
function complete(doc, callback) {
|
|
5911
6009
|
const view = doc.defaultView ?? window;
|
|
5912
|
-
|
|
5913
|
-
|
|
5914
|
-
|
|
5915
|
-
|
|
5916
|
-
|
|
5917
|
-
|
|
5918
|
-
callback();
|
|
5919
|
-
}, 100);
|
|
6010
|
+
waitForFontsReady(doc).then(() => {
|
|
6011
|
+
return waitForNextFrames(view, 2);
|
|
6012
|
+
}).then(() => {
|
|
6013
|
+
initFontSystemInfo(doc);
|
|
6014
|
+
removeTmpNode();
|
|
6015
|
+
callback();
|
|
5920
6016
|
}).catch(() => {
|
|
5921
6017
|
view.setTimeout(() => {
|
|
5922
6018
|
initFontSystemInfo(doc);
|
|
@@ -5937,12 +6033,37 @@ var FormulaX = (() => {
|
|
|
5937
6033
|
doc.body.appendChild(node);
|
|
5938
6034
|
nodeList.push(node);
|
|
5939
6035
|
}
|
|
6036
|
+
function createFontCheckerNode(doc) {
|
|
6037
|
+
if (checkerNode) {
|
|
6038
|
+
return checkerNode;
|
|
6039
|
+
}
|
|
6040
|
+
const node = doc.createElement("div");
|
|
6041
|
+
node.style.cssText = "position: absolute; top: 0; left: -100000px;";
|
|
6042
|
+
node.innerHTML = checkerTemplate.join("");
|
|
6043
|
+
doc.body.appendChild(node);
|
|
6044
|
+
checkerNode = node;
|
|
6045
|
+
return node;
|
|
6046
|
+
}
|
|
6047
|
+
function waitForNextFrames(view, frameCount) {
|
|
6048
|
+
if (typeof view.requestAnimationFrame !== "function") {
|
|
6049
|
+
return Promise.resolve();
|
|
6050
|
+
}
|
|
6051
|
+
return new Promise((resolve) => {
|
|
6052
|
+
const step = (remaining) => {
|
|
6053
|
+
if (remaining <= 0) {
|
|
6054
|
+
resolve();
|
|
6055
|
+
return;
|
|
6056
|
+
}
|
|
6057
|
+
view.requestAnimationFrame(() => {
|
|
6058
|
+
step(remaining - 1);
|
|
6059
|
+
});
|
|
6060
|
+
};
|
|
6061
|
+
step(frameCount);
|
|
6062
|
+
});
|
|
6063
|
+
}
|
|
5940
6064
|
function initFontSystemInfo(doc) {
|
|
5941
|
-
const
|
|
5942
|
-
|
|
5943
|
-
tmpNode.innerHTML = checkerTemplate.join("");
|
|
5944
|
-
doc.body.appendChild(tmpNode);
|
|
5945
|
-
const rectBox = tmpNode.getElementsByTagName("text")[0].getBBox();
|
|
6065
|
+
const activeCheckerNode = checkerNode ?? createFontCheckerNode(doc);
|
|
6066
|
+
const rectBox = activeCheckerNode.getElementsByTagName("text")[0].getBBox();
|
|
5946
6067
|
fontConfig.spaceHeight = rectBox.height;
|
|
5947
6068
|
fontConfig.topSpace = -rectBox.y - fontConfig.baseline;
|
|
5948
6069
|
fontConfig.bottomSpace = fontConfig.spaceHeight - fontConfig.topSpace - fontConfig.baseHeight;
|
|
@@ -5951,7 +6072,8 @@ var FormulaX = (() => {
|
|
|
5951
6072
|
fontConfig.meanlinePosition = (fontConfig.topSpace + fontConfig.meanline) / fontConfig.spaceHeight;
|
|
5952
6073
|
fontConfig.ascenderPosition = fontConfig.topSpace / fontConfig.spaceHeight;
|
|
5953
6074
|
fontConfig.descenderPosition = (fontConfig.topSpace + fontConfig.baseHeight) / fontConfig.spaceHeight;
|
|
5954
|
-
|
|
6075
|
+
activeCheckerNode.parentNode?.removeChild(activeCheckerNode);
|
|
6076
|
+
checkerNode = null;
|
|
5955
6077
|
}
|
|
5956
6078
|
function removeTmpNode() {
|
|
5957
6079
|
kity26.Utils.each(nodeList, (node) => {
|
|
@@ -14871,7 +14993,7 @@ var FormulaX = (() => {
|
|
|
14871
14993
|
return serviceObject;
|
|
14872
14994
|
}
|
|
14873
14995
|
var defaultOptions, components, kity2, kf, KFEditor, editor_default2;
|
|
14874
|
-
var
|
|
14996
|
+
var init_editor2 = __esm({
|
|
14875
14997
|
"src/legacy/editor.ts"() {
|
|
14876
14998
|
"use strict";
|
|
14877
14999
|
init_legacy_utils();
|
|
@@ -14991,7 +15113,7 @@ var FormulaX = (() => {
|
|
|
14991
15113
|
var init_factory = __esm({
|
|
14992
15114
|
"src/legacy/factory.ts"() {
|
|
14993
15115
|
"use strict";
|
|
14994
|
-
|
|
15116
|
+
init_editor2();
|
|
14995
15117
|
init_runtime_interop();
|
|
14996
15118
|
EditorWrapper = class {
|
|
14997
15119
|
callbacks = [];
|
|
@@ -19949,7 +20071,7 @@ var FormulaX = (() => {
|
|
|
19949
20071
|
var init_start = __esm({
|
|
19950
20072
|
"src/boot/start.ts"() {
|
|
19951
20073
|
"use strict";
|
|
19952
|
-
|
|
20074
|
+
init_editor2();
|
|
19953
20075
|
init_factory();
|
|
19954
20076
|
init_ui();
|
|
19955
20077
|
init_parser();
|
|
@@ -19977,6 +20099,10 @@ var FormulaX = (() => {
|
|
|
19977
20099
|
getClassList: () => getClassList,
|
|
19978
20100
|
getRectBox: () => getRectBox,
|
|
19979
20101
|
installLegacyKityData: () => installLegacyKityData,
|
|
20102
|
+
kityAssetManifest: () => kityAssetManifest,
|
|
20103
|
+
kityFontAssets: () => kityFontAssets,
|
|
20104
|
+
kityStyleAssets: () => kityStyleAssets,
|
|
20105
|
+
kityToolbarAssets: () => kityToolbarAssets,
|
|
19980
20106
|
legacyBaseUtils: () => legacyBaseUtils,
|
|
19981
20107
|
legacyBoxType: () => legacyBoxType,
|
|
19982
20108
|
legacyCommonUtils: () => legacyCommonUtils,
|
|
@@ -19989,58 +20115,16 @@ var FormulaX = (() => {
|
|
|
19989
20115
|
legacyKfExtDef: () => legacyKfExtDef,
|
|
19990
20116
|
legacySysconf: () => legacySysconf,
|
|
19991
20117
|
legacyUiDef: () => legacyUiDef,
|
|
20118
|
+
legacyUiUtils: () => legacyUiUtils,
|
|
19992
20119
|
mountKityEditor: () => mountKityEditor,
|
|
19993
20120
|
normalizeMouseEvent: () => normalizeMouseEvent,
|
|
19994
20121
|
publish: () => publish,
|
|
19995
20122
|
subscribe: () => subscribe
|
|
19996
20123
|
});
|
|
19997
|
-
|
|
19998
|
-
// ../kity-assets/public/assets/images/toolbar/btn.png
|
|
19999
|
-
var btn_default = "./btn-5DANP6JY.png";
|
|
20000
|
-
|
|
20001
|
-
// ../kity-assets/public/assets/images/toolbar/other.png
|
|
20002
|
-
var other_default = "./other-OMWJFGL5.png";
|
|
20003
|
-
|
|
20004
|
-
// ../kity-assets/public/assets/styles/editor.css?url
|
|
20005
|
-
var editor_default = "./editor-JT5KLVXX.css?url";
|
|
20006
|
-
|
|
20007
|
-
// ../kity-assets/public/resource/KF_AMS_BB.woff
|
|
20008
|
-
var KF_AMS_BB_default = "./KF_AMS_BB-5QF7FUSO.woff";
|
|
20009
|
-
|
|
20010
|
-
// ../kity-assets/public/resource/KF_AMS_CAL.woff
|
|
20011
|
-
var KF_AMS_CAL_default = "./KF_AMS_CAL-NXRNLAZN.woff";
|
|
20012
|
-
|
|
20013
|
-
// ../kity-assets/public/resource/KF_AMS_FRAK.woff
|
|
20014
|
-
var KF_AMS_FRAK_default = "./KF_AMS_FRAK-CO33WWN4.woff";
|
|
20015
|
-
|
|
20016
|
-
// ../kity-assets/public/resource/KF_AMS_MAIN.woff
|
|
20017
|
-
var KF_AMS_MAIN_default = "./KF_AMS_MAIN-25QJVAWY.woff";
|
|
20018
|
-
|
|
20019
|
-
// ../kity-assets/public/resource/KF_AMS_ROMAN.woff
|
|
20020
|
-
var KF_AMS_ROMAN_default = "./KF_AMS_ROMAN-243BR7HH.woff";
|
|
20021
|
-
|
|
20022
|
-
// ../kity-assets/src/index.ts
|
|
20023
|
-
var kityFontAssets = {
|
|
20024
|
-
KF_AMS_BB: KF_AMS_BB_default,
|
|
20025
|
-
KF_AMS_CAL: KF_AMS_CAL_default,
|
|
20026
|
-
KF_AMS_FRAK: KF_AMS_FRAK_default,
|
|
20027
|
-
KF_AMS_MAIN: KF_AMS_MAIN_default,
|
|
20028
|
-
KF_AMS_ROMAN: KF_AMS_ROMAN_default
|
|
20029
|
-
};
|
|
20030
|
-
var kityToolbarAssets = {
|
|
20031
|
-
btn: btn_default,
|
|
20032
|
-
other: other_default
|
|
20033
|
-
};
|
|
20034
|
-
var kityStyleAssets = {
|
|
20035
|
-
editor: editor_default
|
|
20036
|
-
};
|
|
20037
|
-
var kityAssetManifest = {
|
|
20038
|
-
fonts: kityFontAssets,
|
|
20039
|
-
toolbar: kityToolbarAssets,
|
|
20040
|
-
styles: kityStyleAssets
|
|
20041
|
-
};
|
|
20124
|
+
init_asset_manifest();
|
|
20042
20125
|
|
|
20043
20126
|
// src/create-editor.ts
|
|
20127
|
+
init_asset_manifest();
|
|
20044
20128
|
init_legacy_box_type();
|
|
20045
20129
|
|
|
20046
20130
|
// src/vendor/char-position.ts
|
|
@@ -23443,6 +23527,80 @@ var FormulaX = (() => {
|
|
|
23443
23527
|
targetWindow.kity = kity;
|
|
23444
23528
|
}
|
|
23445
23529
|
|
|
23530
|
+
// src/perf.ts
|
|
23531
|
+
function getPerfHost() {
|
|
23532
|
+
return globalThis;
|
|
23533
|
+
}
|
|
23534
|
+
function getPerfState() {
|
|
23535
|
+
const host = getPerfHost();
|
|
23536
|
+
host.__FORMULAX_PERF_STATE__ ??= {
|
|
23537
|
+
reportedMeasureCount: 0,
|
|
23538
|
+
reportScheduled: false
|
|
23539
|
+
};
|
|
23540
|
+
return host.__FORMULAX_PERF_STATE__;
|
|
23541
|
+
}
|
|
23542
|
+
function hasPerfSupport() {
|
|
23543
|
+
return typeof performance !== "undefined" && typeof performance.mark === "function" && typeof performance.measure === "function" && typeof performance.getEntriesByType === "function";
|
|
23544
|
+
}
|
|
23545
|
+
function isPerfDebugEnabled() {
|
|
23546
|
+
return getPerfHost().__FORMULAX_PERF__ === true;
|
|
23547
|
+
}
|
|
23548
|
+
function schedulePerfReport() {
|
|
23549
|
+
if (!hasPerfSupport() || !isPerfDebugEnabled()) {
|
|
23550
|
+
return;
|
|
23551
|
+
}
|
|
23552
|
+
const state = getPerfState();
|
|
23553
|
+
if (state.reportScheduled) {
|
|
23554
|
+
return;
|
|
23555
|
+
}
|
|
23556
|
+
state.reportScheduled = true;
|
|
23557
|
+
queueMicrotask(() => {
|
|
23558
|
+
state.reportScheduled = false;
|
|
23559
|
+
const entries = performance.getEntriesByType("measure").filter((entry) => entry.name.startsWith("fx:")).sort((left, right) => left.startTime - right.startTime);
|
|
23560
|
+
const nextEntries = entries.slice(state.reportedMeasureCount);
|
|
23561
|
+
state.reportedMeasureCount = entries.length;
|
|
23562
|
+
if (!nextEntries.length) {
|
|
23563
|
+
return;
|
|
23564
|
+
}
|
|
23565
|
+
console.table(nextEntries.map((entry) => ({
|
|
23566
|
+
name: entry.name,
|
|
23567
|
+
duration: Number(entry.duration.toFixed(2)),
|
|
23568
|
+
startTime: Number(entry.startTime.toFixed(2))
|
|
23569
|
+
})));
|
|
23570
|
+
});
|
|
23571
|
+
}
|
|
23572
|
+
function markFormulaXPerf(name) {
|
|
23573
|
+
if (!hasPerfSupport()) {
|
|
23574
|
+
return null;
|
|
23575
|
+
}
|
|
23576
|
+
const markName = `${name}::${Date.now()}::${Math.random().toString(36).slice(2, 8)}`;
|
|
23577
|
+
performance.mark(markName);
|
|
23578
|
+
return markName;
|
|
23579
|
+
}
|
|
23580
|
+
function measureFormulaXPerf(name, startMark, endMark) {
|
|
23581
|
+
if (!hasPerfSupport() || !startMark) {
|
|
23582
|
+
return null;
|
|
23583
|
+
}
|
|
23584
|
+
const resolvedEndMark = endMark ?? markFormulaXPerf(`${name}:end`);
|
|
23585
|
+
if (!resolvedEndMark) {
|
|
23586
|
+
return null;
|
|
23587
|
+
}
|
|
23588
|
+
performance.measure(name, startMark, resolvedEndMark);
|
|
23589
|
+
schedulePerfReport();
|
|
23590
|
+
return resolvedEndMark;
|
|
23591
|
+
}
|
|
23592
|
+
function clearFormulaXPerfMarks(...marks) {
|
|
23593
|
+
if (!hasPerfSupport()) {
|
|
23594
|
+
return;
|
|
23595
|
+
}
|
|
23596
|
+
for (const mark of marks) {
|
|
23597
|
+
if (!mark) {
|
|
23598
|
+
continue;
|
|
23599
|
+
}
|
|
23600
|
+
performance.clearMarks(mark);
|
|
23601
|
+
}
|
|
23602
|
+
}
|
|
23603
|
+
|
|
23446
23604
|
// src/create-editor.ts
|
|
23447
23605
|
init_toolbar_assets();
|
|
23448
23606
|
var DEFAULT_LATEX = "x=\\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}";
|
|
@@ -23483,13 +23641,14 @@ var FormulaX = (() => {
|
|
|
23483
23641
|
}
|
|
23484
23642
|
function ensureKityStylesheet(doc, href) {
|
|
23485
23643
|
if (doc.getElementById(KITY_STYLE_ID)) {
|
|
23486
|
-
return;
|
|
23644
|
+
return false;
|
|
23487
23645
|
}
|
|
23488
23646
|
const link = doc.createElement("link");
|
|
23489
23647
|
link.id = KITY_STYLE_ID;
|
|
23490
23648
|
link.rel = "stylesheet";
|
|
23491
23649
|
link.href = href;
|
|
23492
23650
|
doc.head.appendChild(link);
|
|
23651
|
+
return true;
|
|
23493
23652
|
}
|
|
23494
23653
|
function hydrateLegacyKf(runtimeWindow) {
|
|
23495
23654
|
const requireFormula = runtimeWindow.__kityFormulaRequire__;
|
|
@@ -23537,7 +23696,7 @@ var FormulaX = (() => {
|
|
|
23537
23696
|
kity: runtimeWindow.kity,
|
|
23538
23697
|
otherPosition: legacyOtherPosition,
|
|
23539
23698
|
uiDef: legacyUiDef,
|
|
23540
|
-
uiUtils:
|
|
23699
|
+
uiUtils: legacyUiUtils
|
|
23541
23700
|
};
|
|
23542
23701
|
}
|
|
23543
23702
|
async function ensureKityRuntime() {
|
|
@@ -23545,64 +23704,114 @@ var FormulaX = (() => {
|
|
|
23545
23704
|
return runtimePromise;
|
|
23546
23705
|
}
|
|
23547
23706
|
runtimePromise = (async () => {
|
|
23707
|
+
const runtimeTotalStart = markFormulaXPerf("fx:kity-runtime:total");
|
|
23548
23708
|
const runtimeWindow = window;
|
|
23549
23709
|
runtimeWindow.kf = runtimeWindow.kf ?? {};
|
|
23550
23710
|
installKityRuntime(runtimeWindow);
|
|
23551
|
-
|
|
23552
|
-
|
|
23553
|
-
|
|
23554
|
-
|
|
23555
|
-
|
|
23556
|
-
|
|
23557
|
-
|
|
23558
|
-
|
|
23711
|
+
try {
|
|
23712
|
+
const formulaImportStart = markFormulaXPerf("fx:kity-runtime:formula-import");
|
|
23713
|
+
const { installLegacyKityFormulaRuntime: installLegacyKityFormulaRuntime2 } = await Promise.resolve().then(() => (init_install(), install_exports));
|
|
23714
|
+
const formulaImportEnd = markFormulaXPerf("fx:kity-runtime:formula-import:end");
|
|
23715
|
+
measureFormulaXPerf("fx:kity-runtime:formula-import", formulaImportStart, formulaImportEnd);
|
|
23716
|
+
clearFormulaXPerfMarks(formulaImportStart, formulaImportEnd);
|
|
23717
|
+
const formulaInstallStart = markFormulaXPerf("fx:kity-runtime:formula-install");
|
|
23718
|
+
installLegacyKityFormulaRuntime2(runtimeWindow);
|
|
23719
|
+
hydrateLegacyKf(runtimeWindow);
|
|
23720
|
+
const formulaInstallEnd = markFormulaXPerf("fx:kity-runtime:formula-install:end");
|
|
23721
|
+
measureFormulaXPerf("fx:kity-runtime:formula-install", formulaInstallStart, formulaInstallEnd);
|
|
23722
|
+
clearFormulaXPerfMarks(formulaInstallStart, formulaInstallEnd);
|
|
23723
|
+
const parserImportStart = markFormulaXPerf("fx:kity-runtime:parser-import");
|
|
23724
|
+
const { installLegacyParserRuntime: installLegacyParserRuntime2 } = await Promise.resolve().then(() => (init_install2(), install_exports2));
|
|
23725
|
+
const parserImportEnd = markFormulaXPerf("fx:kity-runtime:parser-import:end");
|
|
23726
|
+
measureFormulaXPerf("fx:kity-runtime:parser-import", parserImportStart, parserImportEnd);
|
|
23727
|
+
clearFormulaXPerfMarks(parserImportStart, parserImportEnd);
|
|
23728
|
+
const parserInstallStart = markFormulaXPerf("fx:kity-runtime:parser-install");
|
|
23729
|
+
installLegacyParserRuntime2(runtimeWindow);
|
|
23730
|
+
const parserInstallEnd = markFormulaXPerf("fx:kity-runtime:parser-install:end");
|
|
23731
|
+
measureFormulaXPerf("fx:kity-runtime:parser-install", parserInstallStart, parserInstallEnd);
|
|
23732
|
+
clearFormulaXPerfMarks(parserInstallStart, parserInstallEnd);
|
|
23733
|
+
installLegacyRuntime(runtimeWindow);
|
|
23734
|
+
const bootImportStart = markFormulaXPerf("fx:kity-runtime:boot-import");
|
|
23735
|
+
const { installKityEditorStart: installKityEditorStart2 } = await Promise.resolve().then(() => (init_start(), start_exports));
|
|
23736
|
+
const bootImportEnd = markFormulaXPerf("fx:kity-runtime:boot-import:end");
|
|
23737
|
+
measureFormulaXPerf("fx:kity-runtime:boot-import", bootImportStart, bootImportEnd);
|
|
23738
|
+
clearFormulaXPerfMarks(bootImportStart, bootImportEnd);
|
|
23739
|
+
const bootInstallStart = markFormulaXPerf("fx:kity-runtime:boot-install");
|
|
23740
|
+
installKityEditorStart2(runtimeWindow);
|
|
23741
|
+
const bootInstallEnd = markFormulaXPerf("fx:kity-runtime:boot-install:end");
|
|
23742
|
+
measureFormulaXPerf("fx:kity-runtime:boot-install", bootInstallStart, bootInstallEnd);
|
|
23743
|
+
clearFormulaXPerfMarks(bootInstallStart, bootInstallEnd);
|
|
23744
|
+
} finally {
|
|
23745
|
+
const runtimeTotalEnd = markFormulaXPerf("fx:kity-runtime:total:end");
|
|
23746
|
+
measureFormulaXPerf("fx:kity-runtime:total", runtimeTotalStart, runtimeTotalEnd);
|
|
23747
|
+
clearFormulaXPerfMarks(runtimeTotalStart, runtimeTotalEnd);
|
|
23748
|
+
}
|
|
23559
23749
|
})();
|
|
23560
23750
|
return runtimePromise;
|
|
23561
23751
|
}
|
|
23562
23752
|
async function createKityEditor(container, options = {}) {
|
|
23753
|
+
const createEditorStart = markFormulaXPerf("fx:create-kity-editor:total");
|
|
23563
23754
|
const fontsize = options.render?.fontsize ?? 40;
|
|
23564
23755
|
const editorHeight = normalizeCssSize(options.height, DEFAULT_EDITOR_HEIGHT);
|
|
23565
23756
|
const assets = resolveEditorAssets(options.assets);
|
|
23566
|
-
|
|
23567
|
-
|
|
23568
|
-
|
|
23569
|
-
|
|
23570
|
-
|
|
23571
|
-
|
|
23572
|
-
}
|
|
23573
|
-
container.innerHTML = "";
|
|
23574
|
-
const host = document.createElement("div");
|
|
23575
|
-
host.className = "kf-editor";
|
|
23576
|
-
host.style.width = "100%";
|
|
23577
|
-
host.style.height = editorHeight;
|
|
23578
|
-
container.appendChild(host);
|
|
23579
|
-
const factory2 = runtimeWindow.kf.EditorFactory.create(host, {
|
|
23580
|
-
render: {
|
|
23581
|
-
fontsize
|
|
23582
|
-
},
|
|
23583
|
-
resource: {
|
|
23584
|
-
path: "",
|
|
23585
|
-
fonts: assets.fonts
|
|
23757
|
+
try {
|
|
23758
|
+
const stylesheetInserted = ensureKityStylesheet(document, assets.styles.editor);
|
|
23759
|
+
if (stylesheetInserted) {
|
|
23760
|
+
const stylesheetInsertedMark = markFormulaXPerf("fx:kity-css:link-inserted");
|
|
23761
|
+
measureFormulaXPerf("fx:kity-css:link-inserted", createEditorStart, stylesheetInsertedMark);
|
|
23762
|
+
clearFormulaXPerfMarks(stylesheetInsertedMark);
|
|
23586
23763
|
}
|
|
23587
|
-
|
|
23588
|
-
|
|
23589
|
-
|
|
23590
|
-
|
|
23591
|
-
|
|
23592
|
-
|
|
23593
|
-
|
|
23594
|
-
|
|
23595
|
-
|
|
23596
|
-
|
|
23597
|
-
|
|
23598
|
-
|
|
23599
|
-
|
|
23600
|
-
|
|
23601
|
-
|
|
23602
|
-
|
|
23603
|
-
host,
|
|
23604
|
-
|
|
23605
|
-
|
|
23764
|
+
setToolbarAssetUrls(assets.toolbar);
|
|
23765
|
+
await ensureKityRuntime();
|
|
23766
|
+
const runtimeReadyMark = markFormulaXPerf("fx:kity-runtime:ready-for-editor");
|
|
23767
|
+
measureFormulaXPerf("fx:kity-runtime:ready-for-editor", createEditorStart, runtimeReadyMark);
|
|
23768
|
+
clearFormulaXPerfMarks(runtimeReadyMark);
|
|
23769
|
+
const runtimeWindow = window;
|
|
23770
|
+
if (!runtimeWindow.kf?.EditorFactory) {
|
|
23771
|
+
throw new Error("Kity editor runtime did not initialize");
|
|
23772
|
+
}
|
|
23773
|
+
container.innerHTML = "";
|
|
23774
|
+
const host = document.createElement("div");
|
|
23775
|
+
host.className = "kf-editor";
|
|
23776
|
+
host.style.width = "100%";
|
|
23777
|
+
host.style.height = editorHeight;
|
|
23778
|
+
container.appendChild(host);
|
|
23779
|
+
const factoryCreateStart = markFormulaXPerf("fx:kity-editor-factory:create");
|
|
23780
|
+
const factory2 = runtimeWindow.kf.EditorFactory.create(host, {
|
|
23781
|
+
render: {
|
|
23782
|
+
fontsize
|
|
23783
|
+
},
|
|
23784
|
+
resource: {
|
|
23785
|
+
path: "",
|
|
23786
|
+
fonts: assets.fonts
|
|
23787
|
+
}
|
|
23788
|
+
});
|
|
23789
|
+
const factoryCreateEnd = markFormulaXPerf("fx:kity-editor-factory:create:end");
|
|
23790
|
+
measureFormulaXPerf("fx:kity-editor-factory:create", factoryCreateStart, factoryCreateEnd);
|
|
23791
|
+
clearFormulaXPerfMarks(factoryCreateStart, factoryCreateEnd);
|
|
23792
|
+
return {
|
|
23793
|
+
ready: factory2.ready.bind(factory2),
|
|
23794
|
+
execCommand(name, value) {
|
|
23795
|
+
factory2.ready(function execWhenReady() {
|
|
23796
|
+
this.execCommand(name, value);
|
|
23797
|
+
});
|
|
23798
|
+
},
|
|
23799
|
+
focus() {
|
|
23800
|
+
factory2.ready(function focusWhenReady() {
|
|
23801
|
+
this.execCommand("focus");
|
|
23802
|
+
});
|
|
23803
|
+
},
|
|
23804
|
+
destroy() {
|
|
23805
|
+
container.innerHTML = "";
|
|
23806
|
+
},
|
|
23807
|
+
host,
|
|
23808
|
+
raw: factory2
|
|
23809
|
+
};
|
|
23810
|
+
} finally {
|
|
23811
|
+
const createEditorEnd = markFormulaXPerf("fx:create-kity-editor:total:end");
|
|
23812
|
+
measureFormulaXPerf("fx:create-kity-editor:total", createEditorStart, createEditorEnd);
|
|
23813
|
+
clearFormulaXPerfMarks(createEditorStart, createEditorEnd);
|
|
23814
|
+
}
|
|
23606
23815
|
}
|
|
23607
23816
|
async function mountKityEditor(container, options = {}) {
|
|
23608
23817
|
const editor = await createKityEditor(container, options);
|