@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.cjs
CHANGED
|
@@ -20,6 +20,105 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
20
20
|
};
|
|
21
21
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
22
|
|
|
23
|
+
// public/assets/images/toolbar/btn.png
|
|
24
|
+
var btn_default;
|
|
25
|
+
var init_btn = __esm({
|
|
26
|
+
"public/assets/images/toolbar/btn.png"() {
|
|
27
|
+
btn_default = "./btn-5DANP6JY.png";
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// public/assets/images/toolbar/other.png
|
|
32
|
+
var other_default;
|
|
33
|
+
var init_other = __esm({
|
|
34
|
+
"public/assets/images/toolbar/other.png"() {
|
|
35
|
+
other_default = "./other-OMWJFGL5.png";
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// public/assets/styles/editor.css?url
|
|
40
|
+
var editor_default;
|
|
41
|
+
var init_editor = __esm({
|
|
42
|
+
"public/assets/styles/editor.css?url"() {
|
|
43
|
+
editor_default = "./editor-JT5KLVXX.css?url";
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// public/resource/KF_AMS_BB.woff
|
|
48
|
+
var KF_AMS_BB_default;
|
|
49
|
+
var init_KF_AMS_BB = __esm({
|
|
50
|
+
"public/resource/KF_AMS_BB.woff"() {
|
|
51
|
+
KF_AMS_BB_default = "./KF_AMS_BB-5QF7FUSO.woff";
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// public/resource/KF_AMS_CAL.woff
|
|
56
|
+
var KF_AMS_CAL_default;
|
|
57
|
+
var init_KF_AMS_CAL = __esm({
|
|
58
|
+
"public/resource/KF_AMS_CAL.woff"() {
|
|
59
|
+
KF_AMS_CAL_default = "./KF_AMS_CAL-NXRNLAZN.woff";
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// public/resource/KF_AMS_FRAK.woff
|
|
64
|
+
var KF_AMS_FRAK_default;
|
|
65
|
+
var init_KF_AMS_FRAK = __esm({
|
|
66
|
+
"public/resource/KF_AMS_FRAK.woff"() {
|
|
67
|
+
KF_AMS_FRAK_default = "./KF_AMS_FRAK-CO33WWN4.woff";
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// public/resource/KF_AMS_MAIN.woff
|
|
72
|
+
var KF_AMS_MAIN_default;
|
|
73
|
+
var init_KF_AMS_MAIN = __esm({
|
|
74
|
+
"public/resource/KF_AMS_MAIN.woff"() {
|
|
75
|
+
KF_AMS_MAIN_default = "./KF_AMS_MAIN-25QJVAWY.woff";
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// public/resource/KF_AMS_ROMAN.woff
|
|
80
|
+
var KF_AMS_ROMAN_default;
|
|
81
|
+
var init_KF_AMS_ROMAN = __esm({
|
|
82
|
+
"public/resource/KF_AMS_ROMAN.woff"() {
|
|
83
|
+
KF_AMS_ROMAN_default = "./KF_AMS_ROMAN-243BR7HH.woff";
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// src/asset-manifest.ts
|
|
88
|
+
var kityFontAssets, kityToolbarAssets, kityStyleAssets, kityAssetManifest;
|
|
89
|
+
var init_asset_manifest = __esm({
|
|
90
|
+
"src/asset-manifest.ts"() {
|
|
91
|
+
"use strict";
|
|
92
|
+
init_btn();
|
|
93
|
+
init_other();
|
|
94
|
+
init_editor();
|
|
95
|
+
init_KF_AMS_BB();
|
|
96
|
+
init_KF_AMS_CAL();
|
|
97
|
+
init_KF_AMS_FRAK();
|
|
98
|
+
init_KF_AMS_MAIN();
|
|
99
|
+
init_KF_AMS_ROMAN();
|
|
100
|
+
kityFontAssets = {
|
|
101
|
+
KF_AMS_BB: KF_AMS_BB_default,
|
|
102
|
+
KF_AMS_CAL: KF_AMS_CAL_default,
|
|
103
|
+
KF_AMS_FRAK: KF_AMS_FRAK_default,
|
|
104
|
+
KF_AMS_MAIN: KF_AMS_MAIN_default,
|
|
105
|
+
KF_AMS_ROMAN: KF_AMS_ROMAN_default
|
|
106
|
+
};
|
|
107
|
+
kityToolbarAssets = {
|
|
108
|
+
btn: btn_default,
|
|
109
|
+
other: other_default
|
|
110
|
+
};
|
|
111
|
+
kityStyleAssets = {
|
|
112
|
+
editor: editor_default
|
|
113
|
+
};
|
|
114
|
+
kityAssetManifest = {
|
|
115
|
+
fonts: kityFontAssets,
|
|
116
|
+
toolbar: kityToolbarAssets,
|
|
117
|
+
styles: kityStyleAssets
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
|
|
23
122
|
// src/vendor/legacy-box-type.ts
|
|
24
123
|
var legacyBoxType;
|
|
25
124
|
var init_legacy_box_type = __esm({
|
|
@@ -927,28 +1026,30 @@ var init_dom_utils = __esm({
|
|
|
927
1026
|
|
|
928
1027
|
// src/vendor/legacy-ui-utils.ts
|
|
929
1028
|
function createLegacyUiUtils() {
|
|
930
|
-
return
|
|
931
|
-
ele: createElement,
|
|
932
|
-
getRectBox,
|
|
933
|
-
on(target, type, fn) {
|
|
934
|
-
addEvent(target, type, fn);
|
|
935
|
-
return this;
|
|
936
|
-
},
|
|
937
|
-
delegate(target, selector, type, fn) {
|
|
938
|
-
delegateEvent(target, selector, type, fn);
|
|
939
|
-
return this;
|
|
940
|
-
},
|
|
941
|
-
publish(topic, ...args) {
|
|
942
|
-
publish(topic, ...args);
|
|
943
|
-
},
|
|
944
|
-
subscribe,
|
|
945
|
-
getClassList
|
|
946
|
-
};
|
|
1029
|
+
return legacyUiUtils;
|
|
947
1030
|
}
|
|
1031
|
+
var legacyUiUtils;
|
|
948
1032
|
var init_legacy_ui_utils = __esm({
|
|
949
1033
|
"src/vendor/legacy-ui-utils.ts"() {
|
|
950
1034
|
"use strict";
|
|
951
1035
|
init_dom_utils();
|
|
1036
|
+
legacyUiUtils = {
|
|
1037
|
+
ele: createElement,
|
|
1038
|
+
getRectBox,
|
|
1039
|
+
on(target, type, fn) {
|
|
1040
|
+
addEvent(target, type, fn);
|
|
1041
|
+
return this;
|
|
1042
|
+
},
|
|
1043
|
+
delegate(target, selector, type, fn) {
|
|
1044
|
+
delegateEvent(target, selector, type, fn);
|
|
1045
|
+
return this;
|
|
1046
|
+
},
|
|
1047
|
+
publish(topic, ...args) {
|
|
1048
|
+
publish(topic, ...args);
|
|
1049
|
+
},
|
|
1050
|
+
subscribe,
|
|
1051
|
+
getClassList
|
|
1052
|
+
};
|
|
952
1053
|
}
|
|
953
1054
|
});
|
|
954
1055
|
|
|
@@ -971,7 +1072,11 @@ var toolbarAssetFileMap;
|
|
|
971
1072
|
var init_toolbar_assets = __esm({
|
|
972
1073
|
"src/toolbar-assets.ts"() {
|
|
973
1074
|
"use strict";
|
|
974
|
-
|
|
1075
|
+
init_asset_manifest();
|
|
1076
|
+
toolbarAssetFileMap = {
|
|
1077
|
+
"btn.png": kityToolbarAssets.btn,
|
|
1078
|
+
"other.png": kityToolbarAssets.other
|
|
1079
|
+
};
|
|
975
1080
|
}
|
|
976
1081
|
});
|
|
977
1082
|
|
|
@@ -1839,13 +1944,15 @@ var init_expression = __esm({
|
|
|
1839
1944
|
});
|
|
1840
1945
|
|
|
1841
1946
|
// src/vendor/kity-formula/font-installer.ts
|
|
1842
|
-
var FontInstallerModule, createFontInstallerClass;
|
|
1947
|
+
var MAIN_FONT_FAMILY, FontInstallerModule, createFontInstallerClass;
|
|
1843
1948
|
var init_font_installer = __esm({
|
|
1844
1949
|
"src/vendor/kity-formula/font-installer.ts"() {
|
|
1845
1950
|
"use strict";
|
|
1951
|
+
MAIN_FONT_FAMILY = "KF AMS MAIN";
|
|
1846
1952
|
FontInstallerModule = class {
|
|
1847
1953
|
static create(kity26, FontManager, fontConfig, checkerTemplate) {
|
|
1848
1954
|
let nodeList = [];
|
|
1955
|
+
let checkerNode = null;
|
|
1849
1956
|
return kity26.createClass("FontInstaller", {
|
|
1850
1957
|
constructor: function(doc, resource) {
|
|
1851
1958
|
const normalized = typeof resource === "string" ? { path: resource } : resource ?? {};
|
|
@@ -1855,36 +1962,30 @@ var init_font_installer = __esm({
|
|
|
1855
1962
|
},
|
|
1856
1963
|
mount: function(callback) {
|
|
1857
1964
|
const fontList = FontManager.getFontList();
|
|
1858
|
-
let count = 0;
|
|
1859
1965
|
kity26.Utils.each(fontList, (fontInfo) => {
|
|
1860
|
-
count += 1;
|
|
1861
1966
|
fontInfo.meta.src = resolveFontSource(this.fonts, this.resource, fontInfo.meta.src);
|
|
1862
1967
|
this.createFontStyle(fontInfo);
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
complete(this.doc, callback);
|
|
1869
|
-
}
|
|
1870
|
-
});
|
|
1968
|
+
if (fontInfo.meta.fontFamily === MAIN_FONT_FAMILY) {
|
|
1969
|
+
checkerNode = createFontCheckerNode(this.doc);
|
|
1970
|
+
return;
|
|
1971
|
+
}
|
|
1972
|
+
applyFonts(this.doc, fontInfo);
|
|
1871
1973
|
});
|
|
1974
|
+
complete(this.doc, callback);
|
|
1872
1975
|
},
|
|
1873
1976
|
createFontStyle: function(fontInfo) {
|
|
1977
|
+
const styleId = createFontStyleId(fontInfo);
|
|
1978
|
+
if (this.doc.getElementById(styleId)) {
|
|
1979
|
+
return;
|
|
1980
|
+
}
|
|
1874
1981
|
const stylesheet = this.doc.createElement("style");
|
|
1875
1982
|
const tpl = '@font-face{\nfont-family: "${fontFamily}";\nsrc: url("${src}");\n}';
|
|
1876
1983
|
stylesheet.setAttribute("type", "text/css");
|
|
1984
|
+
stylesheet.id = styleId;
|
|
1877
1985
|
stylesheet.innerHTML = tpl.replace("${fontFamily}", fontInfo.meta.fontFamily).replace("${src}", fontInfo.meta.src);
|
|
1878
1986
|
this.doc.head.appendChild(stylesheet);
|
|
1879
1987
|
}
|
|
1880
1988
|
});
|
|
1881
|
-
function preloadFont(doc, fontInfo) {
|
|
1882
|
-
const view = doc.defaultView ?? window;
|
|
1883
|
-
if (view.fetch) {
|
|
1884
|
-
return view.fetch(fontInfo.meta.src, { method: "GET" }).then(() => void 0);
|
|
1885
|
-
}
|
|
1886
|
-
return Promise.resolve();
|
|
1887
|
-
}
|
|
1888
1989
|
function resolveFontSource(fonts, resourceBase, originalSrc) {
|
|
1889
1990
|
const directMatch = fonts[originalSrc];
|
|
1890
1991
|
if (directMatch) {
|
|
@@ -1897,34 +1998,29 @@ var init_font_installer = __esm({
|
|
|
1897
1998
|
}
|
|
1898
1999
|
return resourceBase + originalSrc;
|
|
1899
2000
|
}
|
|
1900
|
-
function
|
|
2001
|
+
function createFontStyleId(fontInfo) {
|
|
2002
|
+
const raw = `${fontInfo.meta.fontFamily}::${fontInfo.meta.src}`;
|
|
2003
|
+
let hash = 0;
|
|
2004
|
+
for (let index = 0; index < raw.length; index += 1) {
|
|
2005
|
+
hash = (hash << 5) - hash + raw.charCodeAt(index) | 0;
|
|
2006
|
+
}
|
|
2007
|
+
return `formulax-kity-font-${Math.abs(hash).toString(36)}`;
|
|
2008
|
+
}
|
|
2009
|
+
function waitForFontsReady(doc) {
|
|
1901
2010
|
const view = doc.defaultView ?? window;
|
|
1902
2011
|
if (view.document.fonts) {
|
|
1903
|
-
|
|
1904
|
-
return view.document.fonts.load(`50px "${fontInfo.meta.fontFamily}"`);
|
|
1905
|
-
});
|
|
1906
|
-
return Promise.all(fontLoadPromises).then(() => view.document.fonts.ready).then(() => {
|
|
1907
|
-
return new Promise((resolve) => {
|
|
1908
|
-
requestAnimationFrame(() => {
|
|
1909
|
-
requestAnimationFrame(() => {
|
|
1910
|
-
resolve();
|
|
1911
|
-
});
|
|
1912
|
-
});
|
|
1913
|
-
});
|
|
1914
|
-
});
|
|
2012
|
+
return view.document.fonts.ready.then(() => void 0);
|
|
1915
2013
|
}
|
|
1916
2014
|
return Promise.resolve();
|
|
1917
2015
|
}
|
|
1918
2016
|
function complete(doc, callback) {
|
|
1919
2017
|
const view = doc.defaultView ?? window;
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
callback();
|
|
1927
|
-
}, 100);
|
|
2018
|
+
waitForFontsReady(doc).then(() => {
|
|
2019
|
+
return waitForNextFrames(view, 2);
|
|
2020
|
+
}).then(() => {
|
|
2021
|
+
initFontSystemInfo(doc);
|
|
2022
|
+
removeTmpNode();
|
|
2023
|
+
callback();
|
|
1928
2024
|
}).catch(() => {
|
|
1929
2025
|
view.setTimeout(() => {
|
|
1930
2026
|
initFontSystemInfo(doc);
|
|
@@ -1945,12 +2041,37 @@ var init_font_installer = __esm({
|
|
|
1945
2041
|
doc.body.appendChild(node);
|
|
1946
2042
|
nodeList.push(node);
|
|
1947
2043
|
}
|
|
2044
|
+
function createFontCheckerNode(doc) {
|
|
2045
|
+
if (checkerNode) {
|
|
2046
|
+
return checkerNode;
|
|
2047
|
+
}
|
|
2048
|
+
const node = doc.createElement("div");
|
|
2049
|
+
node.style.cssText = "position: absolute; top: 0; left: -100000px;";
|
|
2050
|
+
node.innerHTML = checkerTemplate.join("");
|
|
2051
|
+
doc.body.appendChild(node);
|
|
2052
|
+
checkerNode = node;
|
|
2053
|
+
return node;
|
|
2054
|
+
}
|
|
2055
|
+
function waitForNextFrames(view, frameCount) {
|
|
2056
|
+
if (typeof view.requestAnimationFrame !== "function") {
|
|
2057
|
+
return Promise.resolve();
|
|
2058
|
+
}
|
|
2059
|
+
return new Promise((resolve) => {
|
|
2060
|
+
const step = (remaining) => {
|
|
2061
|
+
if (remaining <= 0) {
|
|
2062
|
+
resolve();
|
|
2063
|
+
return;
|
|
2064
|
+
}
|
|
2065
|
+
view.requestAnimationFrame(() => {
|
|
2066
|
+
step(remaining - 1);
|
|
2067
|
+
});
|
|
2068
|
+
};
|
|
2069
|
+
step(frameCount);
|
|
2070
|
+
});
|
|
2071
|
+
}
|
|
1948
2072
|
function initFontSystemInfo(doc) {
|
|
1949
|
-
const
|
|
1950
|
-
|
|
1951
|
-
tmpNode.innerHTML = checkerTemplate.join("");
|
|
1952
|
-
doc.body.appendChild(tmpNode);
|
|
1953
|
-
const rectBox = tmpNode.getElementsByTagName("text")[0].getBBox();
|
|
2073
|
+
const activeCheckerNode = checkerNode ?? createFontCheckerNode(doc);
|
|
2074
|
+
const rectBox = activeCheckerNode.getElementsByTagName("text")[0].getBBox();
|
|
1954
2075
|
fontConfig.spaceHeight = rectBox.height;
|
|
1955
2076
|
fontConfig.topSpace = -rectBox.y - fontConfig.baseline;
|
|
1956
2077
|
fontConfig.bottomSpace = fontConfig.spaceHeight - fontConfig.topSpace - fontConfig.baseHeight;
|
|
@@ -1959,7 +2080,8 @@ var init_font_installer = __esm({
|
|
|
1959
2080
|
fontConfig.meanlinePosition = (fontConfig.topSpace + fontConfig.meanline) / fontConfig.spaceHeight;
|
|
1960
2081
|
fontConfig.ascenderPosition = fontConfig.topSpace / fontConfig.spaceHeight;
|
|
1961
2082
|
fontConfig.descenderPosition = (fontConfig.topSpace + fontConfig.baseHeight) / fontConfig.spaceHeight;
|
|
1962
|
-
|
|
2083
|
+
activeCheckerNode.parentNode?.removeChild(activeCheckerNode);
|
|
2084
|
+
checkerNode = null;
|
|
1963
2085
|
}
|
|
1964
2086
|
function removeTmpNode() {
|
|
1965
2087
|
kity26.Utils.each(nodeList, (node) => {
|
|
@@ -10878,8 +11000,8 @@ function getService(serviceName) {
|
|
|
10878
11000
|
}
|
|
10879
11001
|
return serviceObject;
|
|
10880
11002
|
}
|
|
10881
|
-
var defaultOptions, components, kity2, kf, KFEditor,
|
|
10882
|
-
var
|
|
11003
|
+
var defaultOptions, components, kity2, kf, KFEditor, editor_default2;
|
|
11004
|
+
var init_editor2 = __esm({
|
|
10883
11005
|
"src/legacy/editor.ts"() {
|
|
10884
11006
|
"use strict";
|
|
10885
11007
|
init_legacy_utils();
|
|
@@ -10990,7 +11112,7 @@ var init_editor = __esm({
|
|
|
10990
11112
|
components[name] = component;
|
|
10991
11113
|
}
|
|
10992
11114
|
});
|
|
10993
|
-
|
|
11115
|
+
editor_default2 = KFEditor;
|
|
10994
11116
|
}
|
|
10995
11117
|
});
|
|
10996
11118
|
|
|
@@ -10999,13 +11121,13 @@ var EditorWrapper, factory, factory_default;
|
|
|
10999
11121
|
var init_factory = __esm({
|
|
11000
11122
|
"src/legacy/factory.ts"() {
|
|
11001
11123
|
"use strict";
|
|
11002
|
-
|
|
11124
|
+
init_editor2();
|
|
11003
11125
|
init_runtime_interop();
|
|
11004
11126
|
EditorWrapper = class {
|
|
11005
11127
|
callbacks = [];
|
|
11006
11128
|
editor;
|
|
11007
11129
|
constructor(container, options) {
|
|
11008
|
-
this.editor = new
|
|
11130
|
+
this.editor = new editor_default2(container, options);
|
|
11009
11131
|
this.editor.ready(() => {
|
|
11010
11132
|
this.trigger();
|
|
11011
11133
|
});
|
|
@@ -15930,26 +16052,26 @@ var init_printer = __esm({
|
|
|
15930
16052
|
var start_exports = {};
|
|
15931
16053
|
__export(start_exports, {
|
|
15932
16054
|
Factory: () => factory_default,
|
|
15933
|
-
KFEditor: () =>
|
|
16055
|
+
KFEditor: () => editor_default2,
|
|
15934
16056
|
default: () => start_default,
|
|
15935
16057
|
installKityEditorStart: () => installKityEditorStart
|
|
15936
16058
|
});
|
|
15937
16059
|
function installKityEditorStart(target = window) {
|
|
15938
16060
|
const runtimeTarget = target;
|
|
15939
16061
|
if (!installed3) {
|
|
15940
|
-
|
|
15941
|
-
|
|
15942
|
-
|
|
15943
|
-
|
|
15944
|
-
|
|
15945
|
-
|
|
15946
|
-
|
|
16062
|
+
editor_default2.registerComponents("ui", ui_default);
|
|
16063
|
+
editor_default2.registerComponents("parser", parser_default);
|
|
16064
|
+
editor_default2.registerComponents("render", render_default);
|
|
16065
|
+
editor_default2.registerComponents("position", position_default);
|
|
16066
|
+
editor_default2.registerComponents("syntax", syntax_default);
|
|
16067
|
+
editor_default2.registerComponents("control", controller_default);
|
|
16068
|
+
editor_default2.registerComponents("print", printer_default);
|
|
15947
16069
|
installed3 = true;
|
|
15948
16070
|
}
|
|
15949
16071
|
runtimeTarget.kf = runtimeTarget.kf ?? {};
|
|
15950
16072
|
runtimeTarget.kf.EditorFactory = factory_default;
|
|
15951
16073
|
return {
|
|
15952
|
-
KFEditor:
|
|
16074
|
+
KFEditor: editor_default2,
|
|
15953
16075
|
Factory: factory_default
|
|
15954
16076
|
};
|
|
15955
16077
|
}
|
|
@@ -15957,7 +16079,7 @@ var installed3, start_default;
|
|
|
15957
16079
|
var init_start = __esm({
|
|
15958
16080
|
"src/boot/start.ts"() {
|
|
15959
16081
|
"use strict";
|
|
15960
|
-
|
|
16082
|
+
init_editor2();
|
|
15961
16083
|
init_factory();
|
|
15962
16084
|
init_ui();
|
|
15963
16085
|
init_parser();
|
|
@@ -15985,6 +16107,10 @@ __export(index_exports, {
|
|
|
15985
16107
|
getClassList: () => getClassList,
|
|
15986
16108
|
getRectBox: () => getRectBox,
|
|
15987
16109
|
installLegacyKityData: () => installLegacyKityData,
|
|
16110
|
+
kityAssetManifest: () => kityAssetManifest,
|
|
16111
|
+
kityFontAssets: () => kityFontAssets,
|
|
16112
|
+
kityStyleAssets: () => kityStyleAssets,
|
|
16113
|
+
kityToolbarAssets: () => kityToolbarAssets,
|
|
15988
16114
|
legacyBaseUtils: () => legacyBaseUtils,
|
|
15989
16115
|
legacyBoxType: () => legacyBoxType,
|
|
15990
16116
|
legacyCommonUtils: () => legacyCommonUtils,
|
|
@@ -15997,15 +16123,17 @@ __export(index_exports, {
|
|
|
15997
16123
|
legacyKfExtDef: () => legacyKfExtDef,
|
|
15998
16124
|
legacySysconf: () => legacySysconf,
|
|
15999
16125
|
legacyUiDef: () => legacyUiDef,
|
|
16126
|
+
legacyUiUtils: () => legacyUiUtils,
|
|
16000
16127
|
mountKityEditor: () => mountKityEditor,
|
|
16001
16128
|
normalizeMouseEvent: () => normalizeMouseEvent,
|
|
16002
16129
|
publish: () => publish,
|
|
16003
16130
|
subscribe: () => subscribe
|
|
16004
16131
|
});
|
|
16005
16132
|
module.exports = __toCommonJS(index_exports);
|
|
16133
|
+
init_asset_manifest();
|
|
16006
16134
|
|
|
16007
16135
|
// src/create-editor.ts
|
|
16008
|
-
|
|
16136
|
+
init_asset_manifest();
|
|
16009
16137
|
init_legacy_box_type();
|
|
16010
16138
|
|
|
16011
16139
|
// src/vendor/char-position.ts
|
|
@@ -19408,6 +19536,80 @@ function installKityRuntime(targetWindow = window) {
|
|
|
19408
19536
|
targetWindow.kity = kity;
|
|
19409
19537
|
}
|
|
19410
19538
|
|
|
19539
|
+
// src/perf.ts
|
|
19540
|
+
function getPerfHost() {
|
|
19541
|
+
return globalThis;
|
|
19542
|
+
}
|
|
19543
|
+
function getPerfState() {
|
|
19544
|
+
const host = getPerfHost();
|
|
19545
|
+
host.__FORMULAX_PERF_STATE__ ??= {
|
|
19546
|
+
reportedMeasureCount: 0,
|
|
19547
|
+
reportScheduled: false
|
|
19548
|
+
};
|
|
19549
|
+
return host.__FORMULAX_PERF_STATE__;
|
|
19550
|
+
}
|
|
19551
|
+
function hasPerfSupport() {
|
|
19552
|
+
return typeof performance !== "undefined" && typeof performance.mark === "function" && typeof performance.measure === "function" && typeof performance.getEntriesByType === "function";
|
|
19553
|
+
}
|
|
19554
|
+
function isPerfDebugEnabled() {
|
|
19555
|
+
return getPerfHost().__FORMULAX_PERF__ === true;
|
|
19556
|
+
}
|
|
19557
|
+
function schedulePerfReport() {
|
|
19558
|
+
if (!hasPerfSupport() || !isPerfDebugEnabled()) {
|
|
19559
|
+
return;
|
|
19560
|
+
}
|
|
19561
|
+
const state = getPerfState();
|
|
19562
|
+
if (state.reportScheduled) {
|
|
19563
|
+
return;
|
|
19564
|
+
}
|
|
19565
|
+
state.reportScheduled = true;
|
|
19566
|
+
queueMicrotask(() => {
|
|
19567
|
+
state.reportScheduled = false;
|
|
19568
|
+
const entries = performance.getEntriesByType("measure").filter((entry) => entry.name.startsWith("fx:")).sort((left, right) => left.startTime - right.startTime);
|
|
19569
|
+
const nextEntries = entries.slice(state.reportedMeasureCount);
|
|
19570
|
+
state.reportedMeasureCount = entries.length;
|
|
19571
|
+
if (!nextEntries.length) {
|
|
19572
|
+
return;
|
|
19573
|
+
}
|
|
19574
|
+
console.table(nextEntries.map((entry) => ({
|
|
19575
|
+
name: entry.name,
|
|
19576
|
+
duration: Number(entry.duration.toFixed(2)),
|
|
19577
|
+
startTime: Number(entry.startTime.toFixed(2))
|
|
19578
|
+
})));
|
|
19579
|
+
});
|
|
19580
|
+
}
|
|
19581
|
+
function markFormulaXPerf(name) {
|
|
19582
|
+
if (!hasPerfSupport()) {
|
|
19583
|
+
return null;
|
|
19584
|
+
}
|
|
19585
|
+
const markName = `${name}::${Date.now()}::${Math.random().toString(36).slice(2, 8)}`;
|
|
19586
|
+
performance.mark(markName);
|
|
19587
|
+
return markName;
|
|
19588
|
+
}
|
|
19589
|
+
function measureFormulaXPerf(name, startMark, endMark) {
|
|
19590
|
+
if (!hasPerfSupport() || !startMark) {
|
|
19591
|
+
return null;
|
|
19592
|
+
}
|
|
19593
|
+
const resolvedEndMark = endMark ?? markFormulaXPerf(`${name}:end`);
|
|
19594
|
+
if (!resolvedEndMark) {
|
|
19595
|
+
return null;
|
|
19596
|
+
}
|
|
19597
|
+
performance.measure(name, startMark, resolvedEndMark);
|
|
19598
|
+
schedulePerfReport();
|
|
19599
|
+
return resolvedEndMark;
|
|
19600
|
+
}
|
|
19601
|
+
function clearFormulaXPerfMarks(...marks) {
|
|
19602
|
+
if (!hasPerfSupport()) {
|
|
19603
|
+
return;
|
|
19604
|
+
}
|
|
19605
|
+
for (const mark of marks) {
|
|
19606
|
+
if (!mark) {
|
|
19607
|
+
continue;
|
|
19608
|
+
}
|
|
19609
|
+
performance.clearMarks(mark);
|
|
19610
|
+
}
|
|
19611
|
+
}
|
|
19612
|
+
|
|
19411
19613
|
// src/create-editor.ts
|
|
19412
19614
|
init_toolbar_assets();
|
|
19413
19615
|
var DEFAULT_LATEX = "x=\\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}";
|
|
@@ -19433,28 +19635,29 @@ function normalizeCssSize(value, fallback) {
|
|
|
19433
19635
|
function resolveEditorAssets(assets) {
|
|
19434
19636
|
return {
|
|
19435
19637
|
fonts: {
|
|
19436
|
-
...
|
|
19638
|
+
...kityAssetManifest.fonts,
|
|
19437
19639
|
...assets?.fonts
|
|
19438
19640
|
},
|
|
19439
19641
|
toolbar: {
|
|
19440
|
-
...
|
|
19642
|
+
...kityAssetManifest.toolbar,
|
|
19441
19643
|
...assets?.toolbar
|
|
19442
19644
|
},
|
|
19443
19645
|
styles: {
|
|
19444
|
-
...
|
|
19646
|
+
...kityAssetManifest.styles,
|
|
19445
19647
|
...assets?.styles
|
|
19446
19648
|
}
|
|
19447
19649
|
};
|
|
19448
19650
|
}
|
|
19449
19651
|
function ensureKityStylesheet(doc, href) {
|
|
19450
19652
|
if (doc.getElementById(KITY_STYLE_ID)) {
|
|
19451
|
-
return;
|
|
19653
|
+
return false;
|
|
19452
19654
|
}
|
|
19453
19655
|
const link = doc.createElement("link");
|
|
19454
19656
|
link.id = KITY_STYLE_ID;
|
|
19455
19657
|
link.rel = "stylesheet";
|
|
19456
19658
|
link.href = href;
|
|
19457
19659
|
doc.head.appendChild(link);
|
|
19660
|
+
return true;
|
|
19458
19661
|
}
|
|
19459
19662
|
function hydrateLegacyKf(runtimeWindow) {
|
|
19460
19663
|
const requireFormula = runtimeWindow.__kityFormulaRequire__;
|
|
@@ -19502,7 +19705,7 @@ function installLegacyRuntime(runtimeWindow) {
|
|
|
19502
19705
|
kity: runtimeWindow.kity,
|
|
19503
19706
|
otherPosition: legacyOtherPosition,
|
|
19504
19707
|
uiDef: legacyUiDef,
|
|
19505
|
-
uiUtils:
|
|
19708
|
+
uiUtils: legacyUiUtils
|
|
19506
19709
|
};
|
|
19507
19710
|
}
|
|
19508
19711
|
async function ensureKityRuntime() {
|
|
@@ -19510,64 +19713,114 @@ async function ensureKityRuntime() {
|
|
|
19510
19713
|
return runtimePromise;
|
|
19511
19714
|
}
|
|
19512
19715
|
runtimePromise = (async () => {
|
|
19716
|
+
const runtimeTotalStart = markFormulaXPerf("fx:kity-runtime:total");
|
|
19513
19717
|
const runtimeWindow = window;
|
|
19514
19718
|
runtimeWindow.kf = runtimeWindow.kf ?? {};
|
|
19515
19719
|
installKityRuntime(runtimeWindow);
|
|
19516
|
-
|
|
19517
|
-
|
|
19518
|
-
|
|
19519
|
-
|
|
19520
|
-
|
|
19521
|
-
|
|
19522
|
-
|
|
19523
|
-
|
|
19720
|
+
try {
|
|
19721
|
+
const formulaImportStart = markFormulaXPerf("fx:kity-runtime:formula-import");
|
|
19722
|
+
const { installLegacyKityFormulaRuntime: installLegacyKityFormulaRuntime2 } = await Promise.resolve().then(() => (init_install(), install_exports));
|
|
19723
|
+
const formulaImportEnd = markFormulaXPerf("fx:kity-runtime:formula-import:end");
|
|
19724
|
+
measureFormulaXPerf("fx:kity-runtime:formula-import", formulaImportStart, formulaImportEnd);
|
|
19725
|
+
clearFormulaXPerfMarks(formulaImportStart, formulaImportEnd);
|
|
19726
|
+
const formulaInstallStart = markFormulaXPerf("fx:kity-runtime:formula-install");
|
|
19727
|
+
installLegacyKityFormulaRuntime2(runtimeWindow);
|
|
19728
|
+
hydrateLegacyKf(runtimeWindow);
|
|
19729
|
+
const formulaInstallEnd = markFormulaXPerf("fx:kity-runtime:formula-install:end");
|
|
19730
|
+
measureFormulaXPerf("fx:kity-runtime:formula-install", formulaInstallStart, formulaInstallEnd);
|
|
19731
|
+
clearFormulaXPerfMarks(formulaInstallStart, formulaInstallEnd);
|
|
19732
|
+
const parserImportStart = markFormulaXPerf("fx:kity-runtime:parser-import");
|
|
19733
|
+
const { installLegacyParserRuntime: installLegacyParserRuntime2 } = await Promise.resolve().then(() => (init_install2(), install_exports2));
|
|
19734
|
+
const parserImportEnd = markFormulaXPerf("fx:kity-runtime:parser-import:end");
|
|
19735
|
+
measureFormulaXPerf("fx:kity-runtime:parser-import", parserImportStart, parserImportEnd);
|
|
19736
|
+
clearFormulaXPerfMarks(parserImportStart, parserImportEnd);
|
|
19737
|
+
const parserInstallStart = markFormulaXPerf("fx:kity-runtime:parser-install");
|
|
19738
|
+
installLegacyParserRuntime2(runtimeWindow);
|
|
19739
|
+
const parserInstallEnd = markFormulaXPerf("fx:kity-runtime:parser-install:end");
|
|
19740
|
+
measureFormulaXPerf("fx:kity-runtime:parser-install", parserInstallStart, parserInstallEnd);
|
|
19741
|
+
clearFormulaXPerfMarks(parserInstallStart, parserInstallEnd);
|
|
19742
|
+
installLegacyRuntime(runtimeWindow);
|
|
19743
|
+
const bootImportStart = markFormulaXPerf("fx:kity-runtime:boot-import");
|
|
19744
|
+
const { installKityEditorStart: installKityEditorStart2 } = await Promise.resolve().then(() => (init_start(), start_exports));
|
|
19745
|
+
const bootImportEnd = markFormulaXPerf("fx:kity-runtime:boot-import:end");
|
|
19746
|
+
measureFormulaXPerf("fx:kity-runtime:boot-import", bootImportStart, bootImportEnd);
|
|
19747
|
+
clearFormulaXPerfMarks(bootImportStart, bootImportEnd);
|
|
19748
|
+
const bootInstallStart = markFormulaXPerf("fx:kity-runtime:boot-install");
|
|
19749
|
+
installKityEditorStart2(runtimeWindow);
|
|
19750
|
+
const bootInstallEnd = markFormulaXPerf("fx:kity-runtime:boot-install:end");
|
|
19751
|
+
measureFormulaXPerf("fx:kity-runtime:boot-install", bootInstallStart, bootInstallEnd);
|
|
19752
|
+
clearFormulaXPerfMarks(bootInstallStart, bootInstallEnd);
|
|
19753
|
+
} finally {
|
|
19754
|
+
const runtimeTotalEnd = markFormulaXPerf("fx:kity-runtime:total:end");
|
|
19755
|
+
measureFormulaXPerf("fx:kity-runtime:total", runtimeTotalStart, runtimeTotalEnd);
|
|
19756
|
+
clearFormulaXPerfMarks(runtimeTotalStart, runtimeTotalEnd);
|
|
19757
|
+
}
|
|
19524
19758
|
})();
|
|
19525
19759
|
return runtimePromise;
|
|
19526
19760
|
}
|
|
19527
19761
|
async function createKityEditor(container, options = {}) {
|
|
19762
|
+
const createEditorStart = markFormulaXPerf("fx:create-kity-editor:total");
|
|
19528
19763
|
const fontsize = options.render?.fontsize ?? 40;
|
|
19529
19764
|
const editorHeight = normalizeCssSize(options.height, DEFAULT_EDITOR_HEIGHT);
|
|
19530
19765
|
const assets = resolveEditorAssets(options.assets);
|
|
19531
|
-
|
|
19532
|
-
|
|
19533
|
-
|
|
19534
|
-
|
|
19535
|
-
|
|
19536
|
-
|
|
19537
|
-
}
|
|
19538
|
-
container.innerHTML = "";
|
|
19539
|
-
const host = document.createElement("div");
|
|
19540
|
-
host.className = "kf-editor";
|
|
19541
|
-
host.style.width = "100%";
|
|
19542
|
-
host.style.height = editorHeight;
|
|
19543
|
-
container.appendChild(host);
|
|
19544
|
-
const factory2 = runtimeWindow.kf.EditorFactory.create(host, {
|
|
19545
|
-
render: {
|
|
19546
|
-
fontsize
|
|
19547
|
-
},
|
|
19548
|
-
resource: {
|
|
19549
|
-
path: "",
|
|
19550
|
-
fonts: assets.fonts
|
|
19766
|
+
try {
|
|
19767
|
+
const stylesheetInserted = ensureKityStylesheet(document, assets.styles.editor);
|
|
19768
|
+
if (stylesheetInserted) {
|
|
19769
|
+
const stylesheetInsertedMark = markFormulaXPerf("fx:kity-css:link-inserted");
|
|
19770
|
+
measureFormulaXPerf("fx:kity-css:link-inserted", createEditorStart, stylesheetInsertedMark);
|
|
19771
|
+
clearFormulaXPerfMarks(stylesheetInsertedMark);
|
|
19551
19772
|
}
|
|
19552
|
-
|
|
19553
|
-
|
|
19554
|
-
|
|
19555
|
-
|
|
19556
|
-
|
|
19557
|
-
|
|
19558
|
-
|
|
19559
|
-
|
|
19560
|
-
|
|
19561
|
-
|
|
19562
|
-
|
|
19563
|
-
|
|
19564
|
-
|
|
19565
|
-
|
|
19566
|
-
|
|
19567
|
-
|
|
19568
|
-
host,
|
|
19569
|
-
|
|
19570
|
-
|
|
19773
|
+
setToolbarAssetUrls(assets.toolbar);
|
|
19774
|
+
await ensureKityRuntime();
|
|
19775
|
+
const runtimeReadyMark = markFormulaXPerf("fx:kity-runtime:ready-for-editor");
|
|
19776
|
+
measureFormulaXPerf("fx:kity-runtime:ready-for-editor", createEditorStart, runtimeReadyMark);
|
|
19777
|
+
clearFormulaXPerfMarks(runtimeReadyMark);
|
|
19778
|
+
const runtimeWindow = window;
|
|
19779
|
+
if (!runtimeWindow.kf?.EditorFactory) {
|
|
19780
|
+
throw new Error("Kity editor runtime did not initialize");
|
|
19781
|
+
}
|
|
19782
|
+
container.innerHTML = "";
|
|
19783
|
+
const host = document.createElement("div");
|
|
19784
|
+
host.className = "kf-editor";
|
|
19785
|
+
host.style.width = "100%";
|
|
19786
|
+
host.style.height = editorHeight;
|
|
19787
|
+
container.appendChild(host);
|
|
19788
|
+
const factoryCreateStart = markFormulaXPerf("fx:kity-editor-factory:create");
|
|
19789
|
+
const factory2 = runtimeWindow.kf.EditorFactory.create(host, {
|
|
19790
|
+
render: {
|
|
19791
|
+
fontsize
|
|
19792
|
+
},
|
|
19793
|
+
resource: {
|
|
19794
|
+
path: "",
|
|
19795
|
+
fonts: assets.fonts
|
|
19796
|
+
}
|
|
19797
|
+
});
|
|
19798
|
+
const factoryCreateEnd = markFormulaXPerf("fx:kity-editor-factory:create:end");
|
|
19799
|
+
measureFormulaXPerf("fx:kity-editor-factory:create", factoryCreateStart, factoryCreateEnd);
|
|
19800
|
+
clearFormulaXPerfMarks(factoryCreateStart, factoryCreateEnd);
|
|
19801
|
+
return {
|
|
19802
|
+
ready: factory2.ready.bind(factory2),
|
|
19803
|
+
execCommand(name, value) {
|
|
19804
|
+
factory2.ready(function execWhenReady() {
|
|
19805
|
+
this.execCommand(name, value);
|
|
19806
|
+
});
|
|
19807
|
+
},
|
|
19808
|
+
focus() {
|
|
19809
|
+
factory2.ready(function focusWhenReady() {
|
|
19810
|
+
this.execCommand("focus");
|
|
19811
|
+
});
|
|
19812
|
+
},
|
|
19813
|
+
destroy() {
|
|
19814
|
+
container.innerHTML = "";
|
|
19815
|
+
},
|
|
19816
|
+
host,
|
|
19817
|
+
raw: factory2
|
|
19818
|
+
};
|
|
19819
|
+
} finally {
|
|
19820
|
+
const createEditorEnd = markFormulaXPerf("fx:create-kity-editor:total:end");
|
|
19821
|
+
measureFormulaXPerf("fx:create-kity-editor:total", createEditorStart, createEditorEnd);
|
|
19822
|
+
clearFormulaXPerfMarks(createEditorStart, createEditorEnd);
|
|
19823
|
+
}
|
|
19571
19824
|
}
|
|
19572
19825
|
async function mountKityEditor(container, options = {}) {
|
|
19573
19826
|
const editor = await createKityEditor(container, options);
|
|
@@ -19656,6 +19909,10 @@ init_legacy_utils();
|
|
|
19656
19909
|
getClassList,
|
|
19657
19910
|
getRectBox,
|
|
19658
19911
|
installLegacyKityData,
|
|
19912
|
+
kityAssetManifest,
|
|
19913
|
+
kityFontAssets,
|
|
19914
|
+
kityStyleAssets,
|
|
19915
|
+
kityToolbarAssets,
|
|
19659
19916
|
legacyBaseUtils,
|
|
19660
19917
|
legacyBoxType,
|
|
19661
19918
|
legacyCommonUtils,
|
|
@@ -19668,6 +19925,7 @@ init_legacy_utils();
|
|
|
19668
19925
|
legacyKfExtDef,
|
|
19669
19926
|
legacySysconf,
|
|
19670
19927
|
legacyUiDef,
|
|
19928
|
+
legacyUiUtils,
|
|
19671
19929
|
mountKityEditor,
|
|
19672
19930
|
normalizeMouseEvent,
|
|
19673
19931
|
publish,
|