@formulaxjs/kity-runtime 0.2.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 +2 -3
- package/dist/{chunk-EKIJQ64F.js → chunk-AOMNUFFB.js} +73 -19
- package/dist/chunk-AOMNUFFB.js.map +1 -0
- package/dist/index.cjs +366 -160
- package/dist/index.cjs.map +1 -1
- package/dist/index.global.js +365 -160
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +182 -96
- 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 +1 -1
- 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) => {
|
|
@@ -10879,7 +11001,7 @@ function getService(serviceName) {
|
|
|
10879
11001
|
return serviceObject;
|
|
10880
11002
|
}
|
|
10881
11003
|
var defaultOptions, components, kity2, kf, KFEditor, editor_default2;
|
|
10882
|
-
var
|
|
11004
|
+
var init_editor2 = __esm({
|
|
10883
11005
|
"src/legacy/editor.ts"() {
|
|
10884
11006
|
"use strict";
|
|
10885
11007
|
init_legacy_utils();
|
|
@@ -10999,7 +11121,7 @@ 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 = [];
|
|
@@ -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();
|
|
@@ -16001,59 +16123,17 @@ __export(index_exports, {
|
|
|
16001
16123
|
legacyKfExtDef: () => legacyKfExtDef,
|
|
16002
16124
|
legacySysconf: () => legacySysconf,
|
|
16003
16125
|
legacyUiDef: () => legacyUiDef,
|
|
16126
|
+
legacyUiUtils: () => legacyUiUtils,
|
|
16004
16127
|
mountKityEditor: () => mountKityEditor,
|
|
16005
16128
|
normalizeMouseEvent: () => normalizeMouseEvent,
|
|
16006
16129
|
publish: () => publish,
|
|
16007
16130
|
subscribe: () => subscribe
|
|
16008
16131
|
});
|
|
16009
16132
|
module.exports = __toCommonJS(index_exports);
|
|
16010
|
-
|
|
16011
|
-
// public/assets/images/toolbar/btn.png
|
|
16012
|
-
var btn_default = "./btn-5DANP6JY.png";
|
|
16013
|
-
|
|
16014
|
-
// public/assets/images/toolbar/other.png
|
|
16015
|
-
var other_default = "./other-OMWJFGL5.png";
|
|
16016
|
-
|
|
16017
|
-
// public/assets/styles/editor.css?url
|
|
16018
|
-
var editor_default = "./editor-JT5KLVXX.css?url";
|
|
16019
|
-
|
|
16020
|
-
// public/resource/KF_AMS_BB.woff
|
|
16021
|
-
var KF_AMS_BB_default = "./KF_AMS_BB-5QF7FUSO.woff";
|
|
16022
|
-
|
|
16023
|
-
// public/resource/KF_AMS_CAL.woff
|
|
16024
|
-
var KF_AMS_CAL_default = "./KF_AMS_CAL-NXRNLAZN.woff";
|
|
16025
|
-
|
|
16026
|
-
// public/resource/KF_AMS_FRAK.woff
|
|
16027
|
-
var KF_AMS_FRAK_default = "./KF_AMS_FRAK-CO33WWN4.woff";
|
|
16028
|
-
|
|
16029
|
-
// public/resource/KF_AMS_MAIN.woff
|
|
16030
|
-
var KF_AMS_MAIN_default = "./KF_AMS_MAIN-25QJVAWY.woff";
|
|
16031
|
-
|
|
16032
|
-
// public/resource/KF_AMS_ROMAN.woff
|
|
16033
|
-
var KF_AMS_ROMAN_default = "./KF_AMS_ROMAN-243BR7HH.woff";
|
|
16034
|
-
|
|
16035
|
-
// src/asset-manifest.ts
|
|
16036
|
-
var kityFontAssets = {
|
|
16037
|
-
KF_AMS_BB: KF_AMS_BB_default,
|
|
16038
|
-
KF_AMS_CAL: KF_AMS_CAL_default,
|
|
16039
|
-
KF_AMS_FRAK: KF_AMS_FRAK_default,
|
|
16040
|
-
KF_AMS_MAIN: KF_AMS_MAIN_default,
|
|
16041
|
-
KF_AMS_ROMAN: KF_AMS_ROMAN_default
|
|
16042
|
-
};
|
|
16043
|
-
var kityToolbarAssets = {
|
|
16044
|
-
btn: btn_default,
|
|
16045
|
-
other: other_default
|
|
16046
|
-
};
|
|
16047
|
-
var kityStyleAssets = {
|
|
16048
|
-
editor: editor_default
|
|
16049
|
-
};
|
|
16050
|
-
var kityAssetManifest = {
|
|
16051
|
-
fonts: kityFontAssets,
|
|
16052
|
-
toolbar: kityToolbarAssets,
|
|
16053
|
-
styles: kityStyleAssets
|
|
16054
|
-
};
|
|
16133
|
+
init_asset_manifest();
|
|
16055
16134
|
|
|
16056
16135
|
// src/create-editor.ts
|
|
16136
|
+
init_asset_manifest();
|
|
16057
16137
|
init_legacy_box_type();
|
|
16058
16138
|
|
|
16059
16139
|
// src/vendor/char-position.ts
|
|
@@ -19456,6 +19536,80 @@ function installKityRuntime(targetWindow = window) {
|
|
|
19456
19536
|
targetWindow.kity = kity;
|
|
19457
19537
|
}
|
|
19458
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
|
+
|
|
19459
19613
|
// src/create-editor.ts
|
|
19460
19614
|
init_toolbar_assets();
|
|
19461
19615
|
var DEFAULT_LATEX = "x=\\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}";
|
|
@@ -19496,13 +19650,14 @@ function resolveEditorAssets(assets) {
|
|
|
19496
19650
|
}
|
|
19497
19651
|
function ensureKityStylesheet(doc, href) {
|
|
19498
19652
|
if (doc.getElementById(KITY_STYLE_ID)) {
|
|
19499
|
-
return;
|
|
19653
|
+
return false;
|
|
19500
19654
|
}
|
|
19501
19655
|
const link = doc.createElement("link");
|
|
19502
19656
|
link.id = KITY_STYLE_ID;
|
|
19503
19657
|
link.rel = "stylesheet";
|
|
19504
19658
|
link.href = href;
|
|
19505
19659
|
doc.head.appendChild(link);
|
|
19660
|
+
return true;
|
|
19506
19661
|
}
|
|
19507
19662
|
function hydrateLegacyKf(runtimeWindow) {
|
|
19508
19663
|
const requireFormula = runtimeWindow.__kityFormulaRequire__;
|
|
@@ -19550,7 +19705,7 @@ function installLegacyRuntime(runtimeWindow) {
|
|
|
19550
19705
|
kity: runtimeWindow.kity,
|
|
19551
19706
|
otherPosition: legacyOtherPosition,
|
|
19552
19707
|
uiDef: legacyUiDef,
|
|
19553
|
-
uiUtils:
|
|
19708
|
+
uiUtils: legacyUiUtils
|
|
19554
19709
|
};
|
|
19555
19710
|
}
|
|
19556
19711
|
async function ensureKityRuntime() {
|
|
@@ -19558,64 +19713,114 @@ async function ensureKityRuntime() {
|
|
|
19558
19713
|
return runtimePromise;
|
|
19559
19714
|
}
|
|
19560
19715
|
runtimePromise = (async () => {
|
|
19716
|
+
const runtimeTotalStart = markFormulaXPerf("fx:kity-runtime:total");
|
|
19561
19717
|
const runtimeWindow = window;
|
|
19562
19718
|
runtimeWindow.kf = runtimeWindow.kf ?? {};
|
|
19563
19719
|
installKityRuntime(runtimeWindow);
|
|
19564
|
-
|
|
19565
|
-
|
|
19566
|
-
|
|
19567
|
-
|
|
19568
|
-
|
|
19569
|
-
|
|
19570
|
-
|
|
19571
|
-
|
|
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
|
+
}
|
|
19572
19758
|
})();
|
|
19573
19759
|
return runtimePromise;
|
|
19574
19760
|
}
|
|
19575
19761
|
async function createKityEditor(container, options = {}) {
|
|
19762
|
+
const createEditorStart = markFormulaXPerf("fx:create-kity-editor:total");
|
|
19576
19763
|
const fontsize = options.render?.fontsize ?? 40;
|
|
19577
19764
|
const editorHeight = normalizeCssSize(options.height, DEFAULT_EDITOR_HEIGHT);
|
|
19578
19765
|
const assets = resolveEditorAssets(options.assets);
|
|
19579
|
-
|
|
19580
|
-
|
|
19581
|
-
|
|
19582
|
-
|
|
19583
|
-
|
|
19584
|
-
|
|
19585
|
-
}
|
|
19586
|
-
container.innerHTML = "";
|
|
19587
|
-
const host = document.createElement("div");
|
|
19588
|
-
host.className = "kf-editor";
|
|
19589
|
-
host.style.width = "100%";
|
|
19590
|
-
host.style.height = editorHeight;
|
|
19591
|
-
container.appendChild(host);
|
|
19592
|
-
const factory2 = runtimeWindow.kf.EditorFactory.create(host, {
|
|
19593
|
-
render: {
|
|
19594
|
-
fontsize
|
|
19595
|
-
},
|
|
19596
|
-
resource: {
|
|
19597
|
-
path: "",
|
|
19598
|
-
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);
|
|
19599
19772
|
}
|
|
19600
|
-
|
|
19601
|
-
|
|
19602
|
-
|
|
19603
|
-
|
|
19604
|
-
|
|
19605
|
-
|
|
19606
|
-
|
|
19607
|
-
|
|
19608
|
-
|
|
19609
|
-
|
|
19610
|
-
|
|
19611
|
-
|
|
19612
|
-
|
|
19613
|
-
|
|
19614
|
-
|
|
19615
|
-
|
|
19616
|
-
host,
|
|
19617
|
-
|
|
19618
|
-
|
|
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
|
+
}
|
|
19619
19824
|
}
|
|
19620
19825
|
async function mountKityEditor(container, options = {}) {
|
|
19621
19826
|
const editor = await createKityEditor(container, options);
|
|
@@ -19720,6 +19925,7 @@ init_legacy_utils();
|
|
|
19720
19925
|
legacyKfExtDef,
|
|
19721
19926
|
legacySysconf,
|
|
19722
19927
|
legacyUiDef,
|
|
19928
|
+
legacyUiUtils,
|
|
19723
19929
|
mountKityEditor,
|
|
19724
19930
|
normalizeMouseEvent,
|
|
19725
19931
|
publish,
|