@lark.js/mvc 0.0.5 → 0.0.7
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 +608 -721
- package/dist/{chunk-IIIY575B.js → chunk-3HSA7OHB.js} +6 -6
- package/dist/index.cjs +226 -924
- package/dist/index.d.cts +106 -182
- package/dist/index.d.ts +106 -182
- package/dist/index.js +222 -907
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.js +1 -1
- package/dist/vite.cjs +6 -6
- package/dist/vite.js +1 -1
- package/dist/webpack.cjs +6 -6
- package/dist/webpack.js +1 -1
- package/package.json +22 -21
- package/src/client.d.ts +1 -0
package/dist/index.cjs
CHANGED
|
@@ -31,7 +31,6 @@ __export(index_exports, {
|
|
|
31
31
|
Framework: () => Framework,
|
|
32
32
|
LARK_VIEW: () => LARK_VIEW,
|
|
33
33
|
Payload: () => Payload,
|
|
34
|
-
Platform: () => Platform,
|
|
35
34
|
ROUTER_EVENTS: () => RouterEvents,
|
|
36
35
|
Router: () => Router,
|
|
37
36
|
SPLITTER: () => SPLITTER,
|
|
@@ -45,16 +44,13 @@ __export(index_exports, {
|
|
|
45
44
|
applyStyle: () => applyStyle,
|
|
46
45
|
applyVdomOps: () => applyVdomOps,
|
|
47
46
|
assign: () => assign,
|
|
48
|
-
|
|
49
|
-
cloneData: () => cloneData,
|
|
50
|
-
cloneStore: () => cloneStore,
|
|
47
|
+
bindStore: () => bindStore,
|
|
51
48
|
compileTemplate: () => compileTemplate,
|
|
52
49
|
computed: () => computed,
|
|
53
|
-
|
|
50
|
+
create: () => create,
|
|
54
51
|
createVdomRef: () => createVdomRef,
|
|
55
52
|
defineStore: () => defineStore,
|
|
56
53
|
defineView: () => defineView,
|
|
57
|
-
delStore: () => delStore,
|
|
58
54
|
encodeHTML: () => encodeHTML,
|
|
59
55
|
encodeQ: () => encodeQ,
|
|
60
56
|
encodeSafe: () => encodeSafe,
|
|
@@ -66,43 +62,34 @@ __export(index_exports, {
|
|
|
66
62
|
generateId: () => generateId,
|
|
67
63
|
getAttribute: () => getAttribute,
|
|
68
64
|
getById: () => getById,
|
|
69
|
-
|
|
70
|
-
getStore: () => getStore,
|
|
71
|
-
getUseStore: () => getUseStore,
|
|
65
|
+
getRouteMode: () => getRouteMode,
|
|
72
66
|
hasOwnProperty: () => hasOwnProperty,
|
|
73
67
|
installFrameVisualizerBridge: () => installFrameVisualizerBridge,
|
|
74
68
|
invalidateViewClass: () => invalidateViewClass,
|
|
75
69
|
isPlainObject: () => isPlainObject,
|
|
76
70
|
isPrimitive: () => isPrimitive,
|
|
77
71
|
isPrimitiveOrFunc: () => isPrimitiveOrFunc,
|
|
78
|
-
isState: () => isState,
|
|
79
|
-
isStoreActive: () => isStoreActive,
|
|
80
72
|
keys: () => keys,
|
|
81
|
-
lazySet: () => lazySet,
|
|
82
73
|
mark: () => mark,
|
|
83
74
|
markBooted: () => markBooted,
|
|
84
75
|
markRouterBooted: () => markRouterBooted,
|
|
85
|
-
multi: () => multi,
|
|
86
76
|
nextCounter: () => nextCounter,
|
|
87
77
|
nodeInside: () => nodeInside,
|
|
88
78
|
noop: () => noop,
|
|
89
79
|
now: () => now,
|
|
90
|
-
observeCell: () => observeCell,
|
|
91
80
|
parseUri: () => parseUri,
|
|
92
81
|
registerViewClass: () => registerViewClass,
|
|
93
82
|
resetProjectsMap: () => resetProjectsMap,
|
|
94
83
|
safeguard: () => safeguard,
|
|
95
84
|
serializeFrameTree: () => serializeFrameTree,
|
|
96
85
|
setData: () => setData,
|
|
97
|
-
shallowSet: () => shallowSet,
|
|
98
|
-
storeMark: () => mark2,
|
|
99
|
-
storeUnmark: () => unmark2,
|
|
100
86
|
syncCounter: () => syncCounter,
|
|
101
87
|
toMap: () => toMap,
|
|
102
88
|
toUri: () => toUri,
|
|
103
89
|
translateData: () => translateData,
|
|
104
90
|
unmark: () => unmark,
|
|
105
91
|
use: () => use,
|
|
92
|
+
useUrlState: () => useUrlState,
|
|
106
93
|
vdomGetCompareKey: () => vdomGetCompareKey,
|
|
107
94
|
vdomGetNode: () => vdomGetNode,
|
|
108
95
|
vdomSetAttributes: () => vdomSetAttributes,
|
|
@@ -115,7 +102,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
115
102
|
|
|
116
103
|
// src/constants.ts
|
|
117
104
|
var globalCounter = 0;
|
|
118
|
-
var SPLITTER =
|
|
105
|
+
var SPLITTER = String.fromCharCode(30);
|
|
119
106
|
var RouterEvents = {
|
|
120
107
|
CHANGE: "change",
|
|
121
108
|
CHANGED: "changed",
|
|
@@ -420,7 +407,7 @@ function safeguard(data, getter, setter, isRoot) {
|
|
|
420
407
|
set(target, property, value) {
|
|
421
408
|
if (!setter && !prefix) {
|
|
422
409
|
throw new Error(
|
|
423
|
-
"Avoid write back, key: " + prefix + property + " value:" + value + " more: https://github.com/hangtiancheng/
|
|
410
|
+
"Avoid write back, key: " + prefix + property + " value:" + value + " more: https://github.com/hangtiancheng/lark"
|
|
424
411
|
);
|
|
425
412
|
}
|
|
426
413
|
Reflect.set(target, property, value);
|
|
@@ -882,6 +869,7 @@ var cachedDefaultPath;
|
|
|
882
869
|
var cachedRewrite;
|
|
883
870
|
var defaultTitle;
|
|
884
871
|
var frameworkConfig;
|
|
872
|
+
var routeMode = "history";
|
|
885
873
|
var beforeEachGuards = [];
|
|
886
874
|
function createEmptyLocation() {
|
|
887
875
|
return {
|
|
@@ -907,7 +895,8 @@ function attachViewAndPath(loc) {
|
|
|
907
895
|
cachedRewrite = frameworkConfig.rewrite;
|
|
908
896
|
}
|
|
909
897
|
if (!loc.view) {
|
|
910
|
-
|
|
898
|
+
const rawPath = routeMode === "history" ? loc.query["path"] || loc.hash["path"] : loc.hash["path"];
|
|
899
|
+
let path = rawPath || cachedDefaultPath || "/";
|
|
911
900
|
if (cachedRewrite) {
|
|
912
901
|
path = cachedRewrite(
|
|
913
902
|
path,
|
|
@@ -973,7 +962,16 @@ function getChanged(oldLoc, newLoc) {
|
|
|
973
962
|
changedCache.set(tKey, finalResult);
|
|
974
963
|
return finalResult;
|
|
975
964
|
}
|
|
976
|
-
function
|
|
965
|
+
function updateBrowserUrl(path, replace) {
|
|
966
|
+
if (routeMode === "history") {
|
|
967
|
+
const url = path || "/";
|
|
968
|
+
if (replace) {
|
|
969
|
+
window.history.replaceState(null, "", url);
|
|
970
|
+
} else {
|
|
971
|
+
window.history.pushState(null, "", url);
|
|
972
|
+
}
|
|
973
|
+
return;
|
|
974
|
+
}
|
|
977
975
|
const hashbang = frameworkConfig?.hashbang || "#!";
|
|
978
976
|
const fullPath = path === "" ? "" : hashbang + path;
|
|
979
977
|
if (replace) {
|
|
@@ -984,9 +982,10 @@ function updateHash(path, replace) {
|
|
|
984
982
|
}
|
|
985
983
|
function updateUrl(path, params, loc, replace, silentFlag, lQuery) {
|
|
986
984
|
path = toUri(path, params, lQuery);
|
|
987
|
-
|
|
985
|
+
const currentSrc = routeMode === "history" ? loc.srcQuery : loc.srcHash;
|
|
986
|
+
if (path !== currentSrc) {
|
|
988
987
|
silent = silentFlag ? 1 : 0;
|
|
989
|
-
|
|
988
|
+
updateBrowserUrl(path, replace);
|
|
990
989
|
}
|
|
991
990
|
}
|
|
992
991
|
var Router = {
|
|
@@ -1000,10 +999,29 @@ var Router = {
|
|
|
1000
999
|
if (cached) {
|
|
1001
1000
|
return cached;
|
|
1002
1001
|
}
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1002
|
+
let srcQuery;
|
|
1003
|
+
let srcHash;
|
|
1004
|
+
let query;
|
|
1005
|
+
let hash;
|
|
1006
|
+
if (routeMode === "history") {
|
|
1007
|
+
try {
|
|
1008
|
+
const urlObj = new URL(href, window.location.origin);
|
|
1009
|
+
srcQuery = urlObj.pathname + urlObj.search;
|
|
1010
|
+
srcHash = urlObj.hash ? urlObj.hash.replace(/^#!?/, "") : "";
|
|
1011
|
+
query = parseUri(srcQuery);
|
|
1012
|
+
hash = srcHash ? parseUri(srcHash) : { path: "", params: {} };
|
|
1013
|
+
} catch {
|
|
1014
|
+
srcQuery = href.replace(URL_TRIM_HASH_REGEXP, "");
|
|
1015
|
+
srcHash = href.replace(URL_TRIM_QUERY_REGEXP, "");
|
|
1016
|
+
query = parseUri(srcQuery);
|
|
1017
|
+
hash = parseUri(srcHash);
|
|
1018
|
+
}
|
|
1019
|
+
} else {
|
|
1020
|
+
srcQuery = href.replace(URL_TRIM_HASH_REGEXP, "");
|
|
1021
|
+
srcHash = href.replace(URL_TRIM_QUERY_REGEXP, "");
|
|
1022
|
+
query = parseUri(srcQuery);
|
|
1023
|
+
hash = parseUri(srcHash);
|
|
1024
|
+
}
|
|
1007
1025
|
const params = assign({}, query["params"], hash["params"]);
|
|
1008
1026
|
const location = {
|
|
1009
1027
|
href,
|
|
@@ -1077,7 +1095,7 @@ var Router = {
|
|
|
1077
1095
|
}
|
|
1078
1096
|
}
|
|
1079
1097
|
if (tPath) {
|
|
1080
|
-
if (!hasOwnProperty(window, "history")) {
|
|
1098
|
+
if (routeMode === "hash" && !hasOwnProperty(window, "history")) {
|
|
1081
1099
|
for (const qKey of lQuery) {
|
|
1082
1100
|
if (!hasOwnProperty(tParams, qKey)) {
|
|
1083
1101
|
tParams[qKey] = "";
|
|
@@ -1129,32 +1147,41 @@ var Router = {
|
|
|
1129
1147
|
return Router;
|
|
1130
1148
|
},
|
|
1131
1149
|
/**
|
|
1132
|
-
* Internal: bind
|
|
1150
|
+
* Internal: bind routing events and beforeunload.
|
|
1133
1151
|
* Called by Framework.boot().
|
|
1152
|
+
* In hash mode, listens to hashchange + popstate.
|
|
1153
|
+
* In history mode, listens to popstate only.
|
|
1134
1154
|
*/
|
|
1135
1155
|
_bind() {
|
|
1136
1156
|
defaultTitle = document.title;
|
|
1137
|
-
|
|
1157
|
+
const getLocationKey = () => {
|
|
1158
|
+
if (routeMode === "history") {
|
|
1159
|
+
return window.location.pathname + window.location.search;
|
|
1160
|
+
}
|
|
1161
|
+
return Router.parse().srcHash;
|
|
1162
|
+
};
|
|
1163
|
+
let lastKey = getLocationKey();
|
|
1138
1164
|
let suspend;
|
|
1139
1165
|
const watchChange = () => {
|
|
1140
1166
|
if (suspend) {
|
|
1141
1167
|
return;
|
|
1142
1168
|
}
|
|
1169
|
+
hrefCache.clear();
|
|
1143
1170
|
const loc = Router.parse();
|
|
1144
|
-
const
|
|
1145
|
-
if (
|
|
1171
|
+
const newKey = routeMode === "history" ? loc.srcQuery : loc.srcHash;
|
|
1172
|
+
if (newKey !== lastKey) {
|
|
1146
1173
|
const changeEvent = {
|
|
1147
1174
|
p: 0,
|
|
1148
1175
|
reject: () => {
|
|
1149
1176
|
changeEvent.p = 1;
|
|
1150
1177
|
suspend = "";
|
|
1151
|
-
|
|
1178
|
+
updateBrowserUrl(lastKey);
|
|
1152
1179
|
},
|
|
1153
1180
|
resolve: () => {
|
|
1154
1181
|
changeEvent.p = 1;
|
|
1155
|
-
|
|
1182
|
+
lastKey = newKey;
|
|
1156
1183
|
suspend = "";
|
|
1157
|
-
|
|
1184
|
+
updateBrowserUrl(newKey);
|
|
1158
1185
|
Router.diff();
|
|
1159
1186
|
},
|
|
1160
1187
|
prevent: () => {
|
|
@@ -1198,8 +1225,12 @@ var Router = {
|
|
|
1198
1225
|
}
|
|
1199
1226
|
};
|
|
1200
1227
|
Router.notify = watchChange;
|
|
1201
|
-
|
|
1202
|
-
|
|
1228
|
+
if (routeMode === "history") {
|
|
1229
|
+
window.addEventListener("popstate", watchChange);
|
|
1230
|
+
} else {
|
|
1231
|
+
window.addEventListener("hashchange", watchChange);
|
|
1232
|
+
window.addEventListener("popstate", watchChange);
|
|
1233
|
+
}
|
|
1203
1234
|
window.addEventListener("beforeunload", (domEvent) => {
|
|
1204
1235
|
const data = {};
|
|
1205
1236
|
Router.fire(RouterEvents.PAGE_UNLOAD, data);
|
|
@@ -1215,11 +1246,15 @@ var Router = {
|
|
|
1215
1246
|
*/
|
|
1216
1247
|
_setConfig(cfg) {
|
|
1217
1248
|
frameworkConfig = cfg;
|
|
1249
|
+
routeMode = cfg.routeMode || "history";
|
|
1218
1250
|
}
|
|
1219
1251
|
};
|
|
1220
1252
|
function markRouterBooted() {
|
|
1221
1253
|
booted2 = true;
|
|
1222
1254
|
}
|
|
1255
|
+
function getRouteMode() {
|
|
1256
|
+
return routeMode;
|
|
1257
|
+
}
|
|
1223
1258
|
|
|
1224
1259
|
// src/event-delegator.ts
|
|
1225
1260
|
var rootEvents = {};
|
|
@@ -2558,6 +2593,7 @@ function defineView(props, statics) {
|
|
|
2558
2593
|
// src/module-loader.ts
|
|
2559
2594
|
var config = {
|
|
2560
2595
|
rootId: "root",
|
|
2596
|
+
routeMode: "history",
|
|
2561
2597
|
hashbang: "#!",
|
|
2562
2598
|
error: (error) => {
|
|
2563
2599
|
throw error;
|
|
@@ -3630,6 +3666,7 @@ function serviceSend(service, attrs, done, flag, save) {
|
|
|
3630
3666
|
const payloadInfo = service.type.get(attrObj, save);
|
|
3631
3667
|
const payloadEntity = payloadInfo.entity;
|
|
3632
3668
|
const cacheKey = payloadEntity.cacheInfo?.key || "";
|
|
3669
|
+
doneArr[requestCount + 1] = payloadEntity;
|
|
3633
3670
|
const complete = remoteComplete.bind(null, requestCount++);
|
|
3634
3671
|
if (cacheKey && pendingCacheKeys[cacheKey]) {
|
|
3635
3672
|
pendingCacheKeys[cacheKey].push(complete);
|
|
@@ -3669,6 +3706,23 @@ var FrameVisualBridge = {
|
|
|
3669
3706
|
MSG_TREE_DELTA: "LARK_VIS_TREE_DELTA"
|
|
3670
3707
|
};
|
|
3671
3708
|
function serializeView(view) {
|
|
3709
|
+
const evtMap = view.eventObjectMap;
|
|
3710
|
+
const eventMethodKeys = evtMap ? Object.keys(evtMap) : [];
|
|
3711
|
+
const resourceKeys = view.resources ? Object.keys(view.resources) : [];
|
|
3712
|
+
const lookup = view;
|
|
3713
|
+
const hasAssign = typeof lookup["assign"] === "function";
|
|
3714
|
+
let updaterData = null;
|
|
3715
|
+
try {
|
|
3716
|
+
const ref = view.updater?.refData;
|
|
3717
|
+
if (ref && typeof ref === "object") {
|
|
3718
|
+
updaterData = {};
|
|
3719
|
+
for (const k of Object.keys(ref)) {
|
|
3720
|
+
const v = ref[k];
|
|
3721
|
+
updaterData[k] = v === null || typeof v !== "object" ? v : `[${typeof v}]`;
|
|
3722
|
+
}
|
|
3723
|
+
}
|
|
3724
|
+
} catch {
|
|
3725
|
+
}
|
|
3672
3726
|
return {
|
|
3673
3727
|
id: view.id,
|
|
3674
3728
|
rendered: !!view.rendered,
|
|
@@ -3679,7 +3733,11 @@ function serializeView(view) {
|
|
|
3679
3733
|
keys: view.locationObserved.keys,
|
|
3680
3734
|
observePath: view.locationObserved.observePath
|
|
3681
3735
|
},
|
|
3682
|
-
hasTemplate: !!view.template
|
|
3736
|
+
hasTemplate: !!view.template,
|
|
3737
|
+
eventMethodKeys,
|
|
3738
|
+
resourceKeys,
|
|
3739
|
+
hasAssign,
|
|
3740
|
+
updaterData
|
|
3683
3741
|
};
|
|
3684
3742
|
}
|
|
3685
3743
|
function serializeFrame(frameId) {
|
|
@@ -4118,904 +4176,161 @@ if (typeof window !== "undefined") {
|
|
|
4118
4176
|
window.__lark_registerViewClass = registerViewClass;
|
|
4119
4177
|
}
|
|
4120
4178
|
|
|
4121
|
-
// src/
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
var hasStructuredClone = typeof globalThis !== "undefined" && typeof globalThis.structuredClone === "function";
|
|
4134
|
-
var deepCloneFallback = (obj) => {
|
|
4135
|
-
if (!obj || !isObject(obj)) return {};
|
|
4136
|
-
const newData = Array.isArray(obj) ? [] : {};
|
|
4137
|
-
for (const key in obj) {
|
|
4138
|
-
if (hasOwnProperty2(obj, key)) {
|
|
4139
|
-
const value = obj[key];
|
|
4140
|
-
newData[key] = isObject(value) ? deepCloneFallback(value) : value;
|
|
4141
|
-
}
|
|
4142
|
-
}
|
|
4143
|
-
return newData;
|
|
4144
|
-
};
|
|
4145
|
-
var deepClone = (obj) => {
|
|
4146
|
-
if (hasStructuredClone) {
|
|
4147
|
-
try {
|
|
4148
|
-
return structuredClone(obj);
|
|
4149
|
-
} catch {
|
|
4150
|
-
return deepCloneFallback(obj);
|
|
4151
|
-
}
|
|
4152
|
-
}
|
|
4153
|
-
return deepCloneFallback(obj);
|
|
4154
|
-
};
|
|
4155
|
-
var cloneData = (data) => isObject(data) ? deepClone(data) : data;
|
|
4156
|
-
var getDataByKey = (target, key) => {
|
|
4157
|
-
if (!key.includes(".")) {
|
|
4158
|
-
return target[key];
|
|
4159
|
-
}
|
|
4160
|
-
let data = target;
|
|
4161
|
-
for (const k of key.split(".")) {
|
|
4162
|
-
if (!isObject(data)) return void 0;
|
|
4163
|
-
data = data[k];
|
|
4164
|
-
}
|
|
4165
|
-
return data;
|
|
4166
|
-
};
|
|
4167
|
-
var Queue = class {
|
|
4168
|
-
pendingTasks = /* @__PURE__ */ new Set();
|
|
4169
|
-
queue = [];
|
|
4170
|
-
flushTasks() {
|
|
4171
|
-
const { pendingTasks, queue } = this;
|
|
4172
|
-
const flushTickTask = () => {
|
|
4173
|
-
while (queue.length > 0) {
|
|
4174
|
-
const task2 = queue.shift();
|
|
4175
|
-
if (task2) {
|
|
4176
|
-
pendingTasks.delete(task2);
|
|
4177
|
-
runTask(task2);
|
|
4178
|
-
}
|
|
4179
|
-
}
|
|
4180
|
-
};
|
|
4181
|
-
Promise.resolve().then(flushTickTask);
|
|
4182
|
-
}
|
|
4183
|
-
add(tasks) {
|
|
4184
|
-
const isQueueEmpty = this.queue.length === 0;
|
|
4185
|
-
for (const { cb, params } of tasks) {
|
|
4186
|
-
addParams2Callback(cb, params);
|
|
4187
|
-
if (!this.pendingTasks.has(cb)) {
|
|
4188
|
-
this.queue.push(cb);
|
|
4189
|
-
this.pendingTasks.add(cb);
|
|
4190
|
-
}
|
|
4191
|
-
}
|
|
4192
|
-
if (isQueueEmpty) this.flushTasks();
|
|
4193
|
-
}
|
|
4194
|
-
delete(tasks) {
|
|
4195
|
-
if (this.pendingTasks.size === 0) return;
|
|
4196
|
-
for (const { cb } of tasks) {
|
|
4197
|
-
if (this.pendingTasks.has(cb)) {
|
|
4198
|
-
this.pendingTasks.delete(cb);
|
|
4199
|
-
const index = this.queue.findIndex((item) => item === cb);
|
|
4200
|
-
if (index !== -1) this.queue.splice(index, 1);
|
|
4201
|
-
}
|
|
4202
|
-
}
|
|
4203
|
-
}
|
|
4204
|
-
clear() {
|
|
4205
|
-
this.queue = [];
|
|
4206
|
-
this.pendingTasks.clear();
|
|
4207
|
-
}
|
|
4208
|
-
};
|
|
4209
|
-
var addParams2Callback = (cb, params) => {
|
|
4210
|
-
if (!cb || !params) return;
|
|
4211
|
-
const tagged = cb;
|
|
4212
|
-
const existing = tagged.params;
|
|
4213
|
-
if (isObject(existing)) {
|
|
4214
|
-
Object.assign(existing, params);
|
|
4215
|
-
} else {
|
|
4216
|
-
tagged.params = params;
|
|
4217
|
-
}
|
|
4218
|
-
};
|
|
4219
|
-
var runTask = (cb) => {
|
|
4220
|
-
const tagged = cb;
|
|
4221
|
-
const params = tagged.params;
|
|
4222
|
-
delete tagged.params;
|
|
4223
|
-
try {
|
|
4224
|
-
cb(params);
|
|
4225
|
-
} catch {
|
|
4226
|
-
}
|
|
4227
|
-
};
|
|
4228
|
-
var getDefScheduler = () => new Queue();
|
|
4229
|
-
var run = (tasks, scheduler) => {
|
|
4230
|
-
if (scheduler) {
|
|
4231
|
-
if (isFunction(scheduler)) {
|
|
4232
|
-
for (const { cb, params } of tasks) scheduler(cb, params);
|
|
4233
|
-
} else {
|
|
4234
|
-
scheduler.add(tasks);
|
|
4179
|
+
// src/url-state.ts
|
|
4180
|
+
function useUrlState(view, initialState) {
|
|
4181
|
+
const keys2 = initialState ? Object.keys(initialState) : [];
|
|
4182
|
+
if (keys2.length > 0) {
|
|
4183
|
+
view.observeLocation(keys2);
|
|
4184
|
+
}
|
|
4185
|
+
const getState = () => {
|
|
4186
|
+
const loc = Router.parse();
|
|
4187
|
+
const result = { ...initialState || {} };
|
|
4188
|
+
for (const key of keys2) {
|
|
4189
|
+
const val = loc.get(key);
|
|
4190
|
+
if (val) result[key] = val;
|
|
4235
4191
|
}
|
|
4236
|
-
} else {
|
|
4237
|
-
for (const { cb, params } of tasks) cb(params);
|
|
4238
|
-
}
|
|
4239
|
-
};
|
|
4240
|
-
var ArrMethods = {};
|
|
4241
|
-
["indexOf", "lastIndexOf", "includes"].forEach((key) => {
|
|
4242
|
-
const rawMethod = Array.prototype[key];
|
|
4243
|
-
ArrMethods[key] = function(...args) {
|
|
4244
|
-
let res = rawMethod.apply(this, args);
|
|
4245
|
-
if (res === -1 || res === false) {
|
|
4246
|
-
res = rawMethod.apply(
|
|
4247
|
-
this,
|
|
4248
|
-
args.map(
|
|
4249
|
-
(item) => isObject(item) ? ProxyCache.get(item) ?? item : item
|
|
4250
|
-
)
|
|
4251
|
-
);
|
|
4252
|
-
}
|
|
4253
|
-
return res;
|
|
4254
|
-
};
|
|
4255
|
-
});
|
|
4256
|
-
var inArrUpdate = false;
|
|
4257
|
-
["unshift", "shift", "push", "pop", "splice"].forEach((key) => {
|
|
4258
|
-
const rawMethod = Array.prototype[key];
|
|
4259
|
-
ArrMethods[key] = function(...args) {
|
|
4260
|
-
inArrUpdate = true;
|
|
4261
|
-
const result = rawMethod.apply(this, args);
|
|
4262
|
-
inArrUpdate = false;
|
|
4263
4192
|
return result;
|
|
4264
4193
|
};
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
return getLinkKeys(newVal) === createLinkKeys(target, key);
|
|
4270
|
-
}
|
|
4271
|
-
var defStateConfig = {
|
|
4272
|
-
belong: LARK_GLOBAL,
|
|
4273
|
-
linkKeys: "",
|
|
4274
|
-
shallow: false
|
|
4275
|
-
};
|
|
4276
|
-
var StateConfigMap = /* @__PURE__ */ new WeakMap();
|
|
4277
|
-
var setStateConfig = (target, config2) => {
|
|
4278
|
-
if (target && isObject(config2)) StateConfigMap.set(target, config2);
|
|
4279
|
-
};
|
|
4280
|
-
function getStateConfig(target, key) {
|
|
4281
|
-
if (!StateConfigMap.has(target)) {
|
|
4282
|
-
return void 0;
|
|
4283
|
-
}
|
|
4284
|
-
const config2 = StateConfigMap.get(target);
|
|
4285
|
-
return key ? config2?.[key] : config2;
|
|
4286
|
-
}
|
|
4287
|
-
var isState = (target) => isObject(target) && StateConfigMap.has(target);
|
|
4288
|
-
var createLinkKeys = (target, property) => {
|
|
4289
|
-
if (!hasLinkKeys(target)) return property;
|
|
4290
|
-
if (Array.isArray(target)) return getLinkKeys(target) ?? property;
|
|
4291
|
-
return `${getLinkKeys(target)}.${property}`;
|
|
4292
|
-
};
|
|
4293
|
-
var formatLinkKeys = (target, key) => {
|
|
4294
|
-
const originKeysStr = getLinkKeys(target);
|
|
4295
|
-
if (!originKeysStr) return null;
|
|
4296
|
-
const linkKeys = [];
|
|
4297
|
-
const originKeys = originKeysStr.split(".");
|
|
4298
|
-
let pre = "";
|
|
4299
|
-
for (const k of originKeys) {
|
|
4300
|
-
const curr = pre ? `${pre}.${k}` : k;
|
|
4301
|
-
linkKeys.push(curr);
|
|
4302
|
-
pre = curr;
|
|
4303
|
-
}
|
|
4304
|
-
linkKeys.push(`${originKeysStr}.${key}`);
|
|
4305
|
-
return linkKeys;
|
|
4306
|
-
};
|
|
4307
|
-
var getLinkKeys = (target) => getStateConfig(target, "linkKeys");
|
|
4308
|
-
var hasLinkKeys = (target) => !!getLinkKeys(target);
|
|
4309
|
-
var ProxyCache = /* @__PURE__ */ new WeakMap();
|
|
4310
|
-
var keepKey = null;
|
|
4311
|
-
var keep = (key) => {
|
|
4312
|
-
if (keepKey) throw new Error("[lark-store] keepKey is not null");
|
|
4313
|
-
keepKey = key;
|
|
4314
|
-
};
|
|
4315
|
-
var needKeep = (key) => {
|
|
4316
|
-
if (keepKey === key) {
|
|
4317
|
-
keepKey = null;
|
|
4318
|
-
return true;
|
|
4319
|
-
}
|
|
4320
|
-
return false;
|
|
4321
|
-
};
|
|
4322
|
-
var canSetNewVal = (params) => {
|
|
4323
|
-
const { property, newVal, oldVal } = params;
|
|
4324
|
-
if (hasOwnProperty2(params.target, property) && newVal === oldVal)
|
|
4325
|
-
return false;
|
|
4326
|
-
return true;
|
|
4327
|
-
};
|
|
4328
|
-
var getNewVal = (params) => {
|
|
4329
|
-
const { target, newVal, property, needKeepVal = false } = params;
|
|
4330
|
-
const config2 = getStateConfig(target);
|
|
4331
|
-
if (!isObject(newVal)) return newVal;
|
|
4332
|
-
if (needKeepArrItem(target, newVal, property)) return newVal;
|
|
4333
|
-
if (config2?.shallow) return newVal;
|
|
4334
|
-
if (needKeepVal) return newVal;
|
|
4335
|
-
const linkKeys = createLinkKeys(target, property);
|
|
4336
|
-
const newState = createState(newVal, { ...config2, linkKeys });
|
|
4337
|
-
if (isPromise(newVal)) handlePromise(newVal, target, property);
|
|
4338
|
-
return newState;
|
|
4339
|
-
};
|
|
4340
|
-
var genPayload = (params) => {
|
|
4341
|
-
const { target, property, newVal, oldVal } = params;
|
|
4342
|
-
const config2 = getStateConfig(target) ?? defStateConfig;
|
|
4343
|
-
return {
|
|
4344
|
-
belong: config2.belong || LARK_GLOBAL,
|
|
4345
|
-
target,
|
|
4346
|
-
keys: formatLinkKeys(target, property) || [property],
|
|
4347
|
-
newVal,
|
|
4348
|
-
oldVal
|
|
4194
|
+
const setState = (patch) => {
|
|
4195
|
+
const current = getState();
|
|
4196
|
+
const resolved = typeof patch === "function" ? patch(current) : patch;
|
|
4197
|
+
Router.to(resolved);
|
|
4349
4198
|
};
|
|
4350
|
-
|
|
4351
|
-
var handlePromise = (child, parent, key) => {
|
|
4352
|
-
const childObj = child;
|
|
4353
|
-
child.then((res) => {
|
|
4354
|
-
const parentProxy = ProxyCache.get(parent);
|
|
4355
|
-
if (parentProxy) {
|
|
4356
|
-
const oldVal = parentProxy[key];
|
|
4357
|
-
if (ProxyCache.get(childObj) === oldVal) {
|
|
4358
|
-
parentProxy[key] = res;
|
|
4359
|
-
}
|
|
4360
|
-
}
|
|
4361
|
-
}).catch((err) => {
|
|
4362
|
-
const parentProxy = ProxyCache.get(parent);
|
|
4363
|
-
if (parentProxy) {
|
|
4364
|
-
const oldVal = parentProxy[key];
|
|
4365
|
-
if (ProxyCache.get(childObj) === oldVal) {
|
|
4366
|
-
parentProxy[key] = err;
|
|
4367
|
-
}
|
|
4368
|
-
}
|
|
4369
|
-
});
|
|
4370
|
-
};
|
|
4371
|
-
var _deleteKey = "_delete";
|
|
4372
|
-
var _markObjKey = "_markObj";
|
|
4373
|
-
var mark2 = (host, key) => {
|
|
4374
|
-
let sign;
|
|
4375
|
-
if (!host[_deleteKey]) {
|
|
4376
|
-
const markHost = host[_markObjKey] || (host[_markObjKey] = {});
|
|
4377
|
-
if (!hasOwnProperty2(markHost, key)) {
|
|
4378
|
-
markHost[key] = 0;
|
|
4379
|
-
}
|
|
4380
|
-
sign = ++markHost[key];
|
|
4381
|
-
}
|
|
4382
|
-
return () => {
|
|
4383
|
-
const temp = host[_markObjKey];
|
|
4384
|
-
return !!temp && sign === temp[key];
|
|
4385
|
-
};
|
|
4386
|
-
};
|
|
4387
|
-
var unmark2 = (host) => {
|
|
4388
|
-
host[_deleteKey] = 1;
|
|
4389
|
-
host[_markObjKey] = 0;
|
|
4390
|
-
};
|
|
4391
|
-
function createState(initialData, config2) {
|
|
4392
|
-
if (!isObject(initialData)) return initialData;
|
|
4393
|
-
const mergedConfig = Object.assign({ ...defStateConfig }, config2);
|
|
4394
|
-
const data = Array.isArray(initialData) ? [] : Object.create(Object.getPrototypeOf(initialData));
|
|
4395
|
-
const handler = {
|
|
4396
|
-
get(target, property, _receiver) {
|
|
4397
|
-
if (Array.isArray(target) && property in ArrMethods) {
|
|
4398
|
-
return ArrMethods[property];
|
|
4399
|
-
}
|
|
4400
|
-
return Reflect.get(target, property);
|
|
4401
|
-
},
|
|
4402
|
-
set(target, property, newVal, receiver) {
|
|
4403
|
-
const strProp = property;
|
|
4404
|
-
const oldVal = Reflect.get(target, property);
|
|
4405
|
-
const preventTrigger = isLazySet(strProp);
|
|
4406
|
-
const needKeepVal = needKeep(strProp);
|
|
4407
|
-
const canSet = canSetNewVal({
|
|
4408
|
-
target,
|
|
4409
|
-
property: strProp,
|
|
4410
|
-
newVal,
|
|
4411
|
-
oldVal
|
|
4412
|
-
});
|
|
4413
|
-
if (!canSet) return true;
|
|
4414
|
-
const proxyTarget = isObject(receiver) && receiver !== null ? receiver : state;
|
|
4415
|
-
newVal = getNewVal({
|
|
4416
|
-
target: proxyTarget,
|
|
4417
|
-
property: strProp,
|
|
4418
|
-
newVal,
|
|
4419
|
-
needKeepVal
|
|
4420
|
-
});
|
|
4421
|
-
Reflect.set(target, property, newVal, receiver);
|
|
4422
|
-
if (preventTrigger) return true;
|
|
4423
|
-
const payload = genPayload({
|
|
4424
|
-
target: proxyTarget,
|
|
4425
|
-
property: strProp,
|
|
4426
|
-
newVal,
|
|
4427
|
-
oldVal
|
|
4428
|
-
});
|
|
4429
|
-
trigger(payload);
|
|
4430
|
-
return true;
|
|
4431
|
-
},
|
|
4432
|
-
deleteProperty(target, property) {
|
|
4433
|
-
const strProp = property;
|
|
4434
|
-
if (!hasOwnProperty2(target, strProp)) return true;
|
|
4435
|
-
const oldVal = Reflect.get(target, property);
|
|
4436
|
-
Reflect.deleteProperty(target, property);
|
|
4437
|
-
const payload = genPayload({
|
|
4438
|
-
target: state,
|
|
4439
|
-
property: strProp,
|
|
4440
|
-
newVal: null,
|
|
4441
|
-
oldVal
|
|
4442
|
-
});
|
|
4443
|
-
trigger(payload);
|
|
4444
|
-
return true;
|
|
4445
|
-
}
|
|
4446
|
-
};
|
|
4447
|
-
const state = new Proxy(data, handler);
|
|
4448
|
-
ProxyCache.set(initialData, state);
|
|
4449
|
-
setStateConfig(state, mergedConfig);
|
|
4450
|
-
lazySet(state, initialData);
|
|
4451
|
-
return state;
|
|
4452
|
-
}
|
|
4453
|
-
var curLazySetKey = null;
|
|
4454
|
-
function lazySet(target, data) {
|
|
4455
|
-
if (isObject(data)) {
|
|
4456
|
-
Reflect.ownKeys(data).forEach((key) => {
|
|
4457
|
-
const strKey = key;
|
|
4458
|
-
if (curLazySetKey) throw new Error("[lark-store] lazy set key conflict");
|
|
4459
|
-
curLazySetKey = strKey;
|
|
4460
|
-
target[strKey] = data[strKey];
|
|
4461
|
-
});
|
|
4462
|
-
}
|
|
4463
|
-
}
|
|
4464
|
-
function isLazySet(property) {
|
|
4465
|
-
if (curLazySetKey === property) {
|
|
4466
|
-
curLazySetKey = "";
|
|
4467
|
-
return true;
|
|
4468
|
-
}
|
|
4469
|
-
return false;
|
|
4470
|
-
}
|
|
4471
|
-
function shallowSet(target, key, data) {
|
|
4472
|
-
if (!isState(target))
|
|
4473
|
-
throw new Error("[lark-store] shallowSet only supports state objects");
|
|
4474
|
-
if (!isObject(data)) return target[key] = data;
|
|
4475
|
-
keep(key);
|
|
4476
|
-
const config2 = getStateConfig(target);
|
|
4477
|
-
const linkKeys = createLinkKeys(target, key);
|
|
4478
|
-
target[key] = createState(data, { ...config2, linkKeys, shallow: true });
|
|
4479
|
-
return target[key];
|
|
4199
|
+
return [getState(), setState];
|
|
4480
4200
|
}
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
for (const { key, cb } of trackList) {
|
|
4487
|
-
if (isFunction(cb)) {
|
|
4488
|
-
let callbacks = deps.get(key);
|
|
4489
|
-
if (!callbacks) deps.set(key, callbacks = /* @__PURE__ */ new Set());
|
|
4490
|
-
callbacks.add(cb);
|
|
4491
|
-
}
|
|
4492
|
-
}
|
|
4493
|
-
}
|
|
4494
|
-
function trigger(payload) {
|
|
4495
|
-
const { belong, keys: keys2 } = payload;
|
|
4496
|
-
const store = getStore(belong);
|
|
4497
|
-
if (store && store.status !== 2 /* ACTIVE */ && belong !== LARK_GLOBAL)
|
|
4498
|
-
return;
|
|
4499
|
-
const deps = GlobalDeps.get(belong);
|
|
4500
|
-
if (!deps) return;
|
|
4501
|
-
const tasks = /* @__PURE__ */ new Set();
|
|
4502
|
-
for (const key of keys2) {
|
|
4503
|
-
const callbacks = deps.get(key);
|
|
4504
|
-
if (callbacks) {
|
|
4505
|
-
for (const cb of callbacks) {
|
|
4506
|
-
tasks.add({ cb, params: { [key]: true } });
|
|
4507
|
-
}
|
|
4508
|
-
}
|
|
4509
|
-
}
|
|
4510
|
-
if (tasks.size === 0) return;
|
|
4511
|
-
const scheduler = store?.scheduler;
|
|
4512
|
-
run(Array.from(tasks), scheduler);
|
|
4201
|
+
|
|
4202
|
+
// src/store.ts
|
|
4203
|
+
var COMPUTED_BRAND = /* @__PURE__ */ Symbol("lark-store-computed");
|
|
4204
|
+
function isComputedMarker(val) {
|
|
4205
|
+
return val !== null && typeof val === "object" && val[COMPUTED_BRAND] === true;
|
|
4513
4206
|
}
|
|
4514
|
-
function
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
const
|
|
4520
|
-
const
|
|
4521
|
-
|
|
4522
|
-
const
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
|
|
4535
|
-
|
|
4207
|
+
function computed(deps, fn) {
|
|
4208
|
+
return { [COMPUTED_BRAND]: true, deps, fn };
|
|
4209
|
+
}
|
|
4210
|
+
var storeRegistry = /* @__PURE__ */ new Map();
|
|
4211
|
+
function create(name, creator) {
|
|
4212
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
4213
|
+
const computedDefs = /* @__PURE__ */ new Map();
|
|
4214
|
+
const computedKeys = /* @__PURE__ */ new Set();
|
|
4215
|
+
const actionKeys = /* @__PURE__ */ new Set();
|
|
4216
|
+
let state;
|
|
4217
|
+
let destroyed = false;
|
|
4218
|
+
const getState = () => state;
|
|
4219
|
+
const setState = (partial) => {
|
|
4220
|
+
if (destroyed) return;
|
|
4221
|
+
const prevState = state;
|
|
4222
|
+
const resolved = typeof partial === "function" ? partial(prevState) : partial;
|
|
4223
|
+
const nextState = { ...prevState };
|
|
4224
|
+
let changed = false;
|
|
4225
|
+
for (const key in resolved) {
|
|
4226
|
+
if (Object.prototype.hasOwnProperty.call(resolved, key) && !computedKeys.has(key) && !actionKeys.has(key)) {
|
|
4227
|
+
const newVal = resolved[key];
|
|
4228
|
+
if (!Object.is(prevState[key], newVal)) {
|
|
4229
|
+
nextState[key] = newVal;
|
|
4230
|
+
changed = true;
|
|
4536
4231
|
}
|
|
4537
4232
|
}
|
|
4538
4233
|
}
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4234
|
+
if (!changed) return;
|
|
4235
|
+
state = nextState;
|
|
4236
|
+
recomputeIfNeeded(prevState);
|
|
4237
|
+
for (const listener of listeners) {
|
|
4238
|
+
listener(state, prevState);
|
|
4544
4239
|
}
|
|
4545
|
-
}
|
|
4546
|
-
}
|
|
4547
|
-
var _storeName = /* @__PURE__ */ Symbol("store-name");
|
|
4548
|
-
var _storeStatus = /* @__PURE__ */ Symbol("store-status");
|
|
4549
|
-
var _storeScheduler = /* @__PURE__ */ Symbol("store-scheduler");
|
|
4550
|
-
var _storeCreate = /* @__PURE__ */ Symbol("fn:store-create");
|
|
4551
|
-
var _storeBoot = /* @__PURE__ */ Symbol("fn:store-boot");
|
|
4552
|
-
var _storeDestroy = /* @__PURE__ */ Symbol("fn:store-destroy");
|
|
4553
|
-
var _innerStore = /* @__PURE__ */ Symbol("inner-store");
|
|
4554
|
-
var _outerStore = /* @__PURE__ */ Symbol("outer-store");
|
|
4555
|
-
var _originState = /* @__PURE__ */ Symbol("origin-state");
|
|
4556
|
-
var _stateKeys = /* @__PURE__ */ Symbol("state-keys");
|
|
4557
|
-
var _storeState = /* @__PURE__ */ Symbol("store-state");
|
|
4558
|
-
var _storeDefScheduler = /* @__PURE__ */ Symbol("store-def-scheduler");
|
|
4559
|
-
var _storeProxy = /* @__PURE__ */ Symbol("fn:store-proxy");
|
|
4560
|
-
var _computedKeys = /* @__PURE__ */ Symbol("store-computed-keys");
|
|
4561
|
-
var COMPUTED_BRAND = /* @__PURE__ */ Symbol("store-computed-brand");
|
|
4562
|
-
function computed(deps, fn) {
|
|
4563
|
-
const marker = {
|
|
4564
|
-
[COMPUTED_BRAND]: true,
|
|
4565
|
-
deps,
|
|
4566
|
-
fn
|
|
4567
4240
|
};
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
this[_storeStatus] = 3 /* DESTROYED */;
|
|
4587
|
-
}
|
|
4588
|
-
/**
|
|
4589
|
-
*
|
|
4590
|
-
* @param body - The object returned by the creator function
|
|
4591
|
-
* @param excludeFns - Function keys to exclude from handlers (e.g. ['observe'])
|
|
4592
|
-
*/
|
|
4593
|
-
[_storeCreate](body, excludeFns = ["observe"]) {
|
|
4594
|
-
this[_storeStatus] = 1 /* CREATED */;
|
|
4595
|
-
if (isObject(body)) {
|
|
4596
|
-
const state = {};
|
|
4597
|
-
const handlers = {};
|
|
4598
|
-
const computedDefs = {};
|
|
4599
|
-
const computedKeys = this[_computedKeys];
|
|
4600
|
-
Reflect.ownKeys(body).forEach((key) => {
|
|
4601
|
-
const strKey = key;
|
|
4602
|
-
const val = body[strKey];
|
|
4603
|
-
if (isComputedMarker(val)) {
|
|
4604
|
-
computedDefs[strKey] = val;
|
|
4605
|
-
state[strKey] = void 0;
|
|
4606
|
-
computedKeys.add(strKey);
|
|
4607
|
-
} else if (isFunction(val)) {
|
|
4608
|
-
if (!excludeFns.includes(strKey)) handlers[strKey] = val;
|
|
4609
|
-
} else {
|
|
4610
|
-
state[strKey] = val;
|
|
4611
|
-
}
|
|
4612
|
-
});
|
|
4613
|
-
Object.assign(this, handlers);
|
|
4614
|
-
this[_originState] = cloneData(state);
|
|
4615
|
-
this[_stateKeys] = Object.keys(state);
|
|
4616
|
-
this[_storeState] = createState(state, { belong: this[_storeName] });
|
|
4617
|
-
if (Object.keys(computedDefs).length > 0) {
|
|
4618
|
-
const belong = this[_storeName];
|
|
4619
|
-
const storeState = this[_storeState];
|
|
4620
|
-
for (const key of Object.keys(computedDefs)) {
|
|
4621
|
-
const def = computedDefs[key];
|
|
4622
|
-
const recompute = () => {
|
|
4623
|
-
storeState[key] = def.fn();
|
|
4624
|
-
};
|
|
4625
|
-
recompute();
|
|
4626
|
-
const trackList = def.deps.map((depKey) => ({
|
|
4627
|
-
key: depKey,
|
|
4628
|
-
cb: recompute
|
|
4629
|
-
}));
|
|
4630
|
-
if (trackList.length > 0) track({ belong, trackList });
|
|
4241
|
+
const recomputeIfNeeded = (prevState) => {
|
|
4242
|
+
if (computedDefs.size === 0) return;
|
|
4243
|
+
const changedKeys2 = /* @__PURE__ */ new Set();
|
|
4244
|
+
for (const key of Object.keys(state)) {
|
|
4245
|
+
if (!Object.is(
|
|
4246
|
+
state[key],
|
|
4247
|
+
prevState[key]
|
|
4248
|
+
)) {
|
|
4249
|
+
changedKeys2.add(key);
|
|
4250
|
+
}
|
|
4251
|
+
}
|
|
4252
|
+
let recomputed = false;
|
|
4253
|
+
for (const [key, def] of computedDefs) {
|
|
4254
|
+
if (def.deps.some((dep) => changedKeys2.has(dep))) {
|
|
4255
|
+
const newVal = def.fn();
|
|
4256
|
+
if (!Object.is(state[key], newVal)) {
|
|
4257
|
+
state[key] = newVal;
|
|
4258
|
+
recomputed = true;
|
|
4631
4259
|
}
|
|
4632
4260
|
}
|
|
4633
4261
|
}
|
|
4634
|
-
|
|
4635
|
-
constructor(name, config2) {
|
|
4636
|
-
this[_storeName] = name;
|
|
4637
|
-
this[_storeScheduler] = config2?.scheduler || this[_storeDefScheduler]();
|
|
4638
|
-
this[_outerStore] = this[_storeProxy](true);
|
|
4639
|
-
}
|
|
4640
|
-
[_innerStore]() {
|
|
4641
|
-
return this[_storeProxy]();
|
|
4642
|
-
}
|
|
4643
|
-
get status() {
|
|
4644
|
-
return this[_storeStatus];
|
|
4645
|
-
}
|
|
4646
|
-
get storeName() {
|
|
4647
|
-
return this[_storeName];
|
|
4648
|
-
}
|
|
4649
|
-
get scheduler() {
|
|
4650
|
-
return this[_storeScheduler];
|
|
4651
|
-
}
|
|
4652
|
-
[_storeProxy](toOut = false) {
|
|
4653
|
-
const self = this;
|
|
4654
|
-
const proxy = new Proxy(self, {
|
|
4655
|
-
get(target, property) {
|
|
4656
|
-
const strProp = property;
|
|
4657
|
-
if (self[_stateKeys].includes(strProp)) {
|
|
4658
|
-
const val = self[_storeState][strProp];
|
|
4659
|
-
return toOut ? cloneData(val) : val;
|
|
4660
|
-
}
|
|
4661
|
-
return Reflect.get(target, property);
|
|
4662
|
-
},
|
|
4663
|
-
set(_target, property, val) {
|
|
4664
|
-
if (toOut) return true;
|
|
4665
|
-
const strProp = property;
|
|
4666
|
-
if (self[_computedKeys].has(strProp)) return true;
|
|
4667
|
-
if (self[_stateKeys].includes(strProp)) {
|
|
4668
|
-
self[_storeState][strProp] = val;
|
|
4669
|
-
}
|
|
4670
|
-
return true;
|
|
4671
|
-
},
|
|
4672
|
-
has(target, property) {
|
|
4673
|
-
return Reflect.has(target, property) || self[_stateKeys].includes(property);
|
|
4674
|
-
}
|
|
4675
|
-
});
|
|
4676
|
-
return proxy;
|
|
4677
|
-
}
|
|
4678
|
-
};
|
|
4679
|
-
var LarkUtils = {
|
|
4680
|
-
isLarkView(instance) {
|
|
4681
|
-
if (!isObject(instance)) return false;
|
|
4682
|
-
const updater = instance["updater"];
|
|
4683
|
-
return isObject(updater) && isFunction(updater["set"]) && isFunction(updater["digest"]);
|
|
4684
|
-
},
|
|
4685
|
-
getRender(view) {
|
|
4686
|
-
return view.updater.digest.bind(view.updater);
|
|
4687
|
-
},
|
|
4688
|
-
getDataSetter(view) {
|
|
4689
|
-
return view.updater.set.bind(view.updater);
|
|
4690
|
-
},
|
|
4691
|
-
onDestroy(view, cb) {
|
|
4692
|
-
view.on("destroy", cb);
|
|
4693
|
-
}
|
|
4694
|
-
};
|
|
4695
|
-
var getLarkAdapter = (storeName) => ({
|
|
4696
|
-
Store: LarkStore,
|
|
4697
|
-
useStore: ((view) => {
|
|
4698
|
-
const store = getStore(storeName);
|
|
4699
|
-
if (!(store instanceof LarkStore)) return {};
|
|
4700
|
-
return store[_storeBoot](view);
|
|
4701
|
-
})
|
|
4702
|
-
});
|
|
4703
|
-
var _innerObserveFlags = /* @__PURE__ */ Symbol("store-inner-observe-flags");
|
|
4704
|
-
var _boundViews = /* @__PURE__ */ Symbol("store-bound-views");
|
|
4705
|
-
var LarkStore = class extends BaseStore {
|
|
4706
|
-
[_boundViews] = /* @__PURE__ */ new Set();
|
|
4707
|
-
[_innerObserveFlags] = /* @__PURE__ */ new Set();
|
|
4708
|
-
[_storeBoot](view) {
|
|
4709
|
-
if (view && LarkUtils.isLarkView(view) && !this[_boundViews].has(view)) {
|
|
4710
|
-
this[_boundViews].add(view);
|
|
4711
|
-
LarkUtils.onDestroy(view, () => {
|
|
4712
|
-
this[_boundViews].delete(view);
|
|
4713
|
-
});
|
|
4714
|
-
}
|
|
4715
|
-
return super[_storeBoot]();
|
|
4716
|
-
}
|
|
4717
|
-
[_storeDestroy]() {
|
|
4718
|
-
this[_boundViews].clear();
|
|
4719
|
-
this[_innerObserveFlags].clear();
|
|
4720
|
-
super[_storeDestroy]();
|
|
4721
|
-
}
|
|
4722
|
-
observe(view, keys2, defCallback) {
|
|
4723
|
-
if (this[_storeStatus] !== 2 /* ACTIVE */) return noop;
|
|
4724
|
-
let observeKeys = Array.isArray(keys2) ? keys2 : [];
|
|
4725
|
-
const _view = view;
|
|
4726
|
-
const renderFn = _view ? LarkUtils.getRender(_view) : noop;
|
|
4727
|
-
const dateSetterFn = _view ? LarkUtils.getDataSetter(_view) : noop;
|
|
4728
|
-
const isInnerObserve = !view;
|
|
4729
|
-
const innerFlags = /* @__PURE__ */ new Set();
|
|
4730
|
-
const storeInnerObserveFlags = this[_innerObserveFlags];
|
|
4731
|
-
if (isFunction(keys2)) {
|
|
4732
|
-
const res = keys2();
|
|
4733
|
-
if (Array.isArray(res)) observeKeys = res;
|
|
4734
|
-
}
|
|
4735
|
-
if (keys2 === void 0 && _view && observeKeys.length === 0 && Array.isArray(this[_stateKeys])) {
|
|
4736
|
-
observeKeys = this[_stateKeys].slice();
|
|
4737
|
-
}
|
|
4738
|
-
const defSetter = (immediate, key, alias, transform) => () => {
|
|
4739
|
-
const stateVal = getDataByKey(this, key);
|
|
4740
|
-
let data = { [alias || key]: stateVal };
|
|
4741
|
-
if (transform && isFunction(transform)) {
|
|
4742
|
-
const newData = transform(stateVal);
|
|
4743
|
-
if (isObject(newData)) data = newData;
|
|
4744
|
-
}
|
|
4745
|
-
if (immediate) dateSetterFn(data);
|
|
4746
|
-
else renderFn(data);
|
|
4747
|
-
};
|
|
4748
|
-
const getList = (immediate = false) => {
|
|
4749
|
-
const list = [];
|
|
4750
|
-
for (const item of observeKeys) {
|
|
4751
|
-
if (!item) continue;
|
|
4752
|
-
const payload = typeof item === "string" ? { key: item } : item;
|
|
4753
|
-
const { cb: cbDefault = defCallback, key } = payload;
|
|
4754
|
-
let cb = cbDefault;
|
|
4755
|
-
const { alias, lazy = true, transform } = payload;
|
|
4756
|
-
if (!key) continue;
|
|
4757
|
-
const c1 = !immediate;
|
|
4758
|
-
const c2 = !cb && !!_view;
|
|
4759
|
-
const c3 = !!cb && String(lazy) === "false";
|
|
4760
|
-
if (!(c1 || c2 || c3)) continue;
|
|
4761
|
-
if (isInnerObserve && cb) {
|
|
4762
|
-
const flag = `storeInner_${key}_${observeKeys.join("-")}_${cb.toString()}`;
|
|
4763
|
-
if (!storeInnerObserveFlags.has(flag)) {
|
|
4764
|
-
storeInnerObserveFlags.add(flag);
|
|
4765
|
-
innerFlags.add(flag);
|
|
4766
|
-
}
|
|
4767
|
-
}
|
|
4768
|
-
if (c2) cb = defSetter(immediate, key, alias, transform);
|
|
4769
|
-
if (cb) list.push({ key, cb });
|
|
4770
|
-
}
|
|
4771
|
-
return list;
|
|
4772
|
-
};
|
|
4773
|
-
const trackList = getList();
|
|
4774
|
-
track({ belong: this[_storeName], trackList });
|
|
4775
|
-
if (_view) {
|
|
4776
|
-
LarkUtils.onDestroy(
|
|
4777
|
-
_view,
|
|
4778
|
-
() => clear({ belong: this[_storeName], clearList: trackList })
|
|
4779
|
-
);
|
|
4262
|
+
if (recomputed) {
|
|
4780
4263
|
}
|
|
4781
|
-
|
|
4264
|
+
};
|
|
4265
|
+
const subscribe = (listener) => {
|
|
4266
|
+
listeners.add(listener);
|
|
4782
4267
|
return () => {
|
|
4783
|
-
|
|
4784
|
-
innerFlags.forEach((flag) => storeInnerObserveFlags.delete(flag));
|
|
4268
|
+
listeners.delete(listener);
|
|
4785
4269
|
};
|
|
4786
|
-
}
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
}
|
|
4795
|
-
}
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
scheduler: (cb, params) => cb(params)
|
|
4806
|
-
} : config2;
|
|
4807
|
-
super(name, effectiveConfig);
|
|
4808
|
-
}
|
|
4809
|
-
[_storeCreate](body) {
|
|
4810
|
-
super[_storeCreate](body);
|
|
4811
|
-
this[_observe](() => {
|
|
4812
|
-
this.stateChangeCount += 1;
|
|
4813
|
-
});
|
|
4814
|
-
}
|
|
4815
|
-
isStateChanged() {
|
|
4816
|
-
const currCount = this.stateChangeCount;
|
|
4817
|
-
const changed = this.lastCount !== currCount;
|
|
4818
|
-
this.lastCount = currCount;
|
|
4819
|
-
return changed;
|
|
4820
|
-
}
|
|
4821
|
-
[_getLastState](handlers) {
|
|
4822
|
-
if (this.isStateChanged() || !this.lastState) {
|
|
4823
|
-
const state = this[_storeState];
|
|
4824
|
-
const immutableState = freezeData(state);
|
|
4825
|
-
this.lastState = Object.assign({}, handlers, immutableState);
|
|
4826
|
-
}
|
|
4827
|
-
return this.lastState;
|
|
4828
|
-
}
|
|
4829
|
-
[_observe](cb) {
|
|
4830
|
-
const tasks = this[_stateKeys].map((key) => ({ key, cb }));
|
|
4831
|
-
track({ belong: this[_storeName], trackList: tasks });
|
|
4832
|
-
return () => clear({ belong: this[_storeName], clearList: tasks });
|
|
4833
|
-
}
|
|
4834
|
-
};
|
|
4835
|
-
var freezeData = (target) => {
|
|
4836
|
-
const data = {};
|
|
4837
|
-
const keys2 = Object.keys(target);
|
|
4838
|
-
for (const key of keys2) {
|
|
4839
|
-
const value = target[key];
|
|
4840
|
-
if (Array.isArray(value)) {
|
|
4841
|
-
data[key] = value.map(
|
|
4842
|
-
(item) => isObject(item) ? freezeData(item) : item
|
|
4843
|
-
);
|
|
4844
|
-
} else if (isObject(value)) {
|
|
4845
|
-
data[key] = freezeData(value);
|
|
4270
|
+
};
|
|
4271
|
+
const destroy = () => {
|
|
4272
|
+
destroyed = true;
|
|
4273
|
+
listeners.clear();
|
|
4274
|
+
storeRegistry.delete(name);
|
|
4275
|
+
};
|
|
4276
|
+
const api = { getState, setState, subscribe, destroy };
|
|
4277
|
+
const body = creator(setState, getState);
|
|
4278
|
+
const initialState = {};
|
|
4279
|
+
const actions = {};
|
|
4280
|
+
for (const key of Object.keys(body)) {
|
|
4281
|
+
const val = body[key];
|
|
4282
|
+
if (isComputedMarker(val)) {
|
|
4283
|
+
computedDefs.set(key, val);
|
|
4284
|
+
computedKeys.add(key);
|
|
4285
|
+
initialState[key] = void 0;
|
|
4286
|
+
} else if (typeof val === "function") {
|
|
4287
|
+
actions[key] = val;
|
|
4288
|
+
actionKeys.add(key);
|
|
4846
4289
|
} else {
|
|
4847
|
-
|
|
4290
|
+
initialState[key] = val;
|
|
4848
4291
|
}
|
|
4849
4292
|
}
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
Store: NodeStore,
|
|
4854
|
-
useStore: (() => {
|
|
4855
|
-
const store = getStore(storeName);
|
|
4856
|
-
if (!(store instanceof NodeStore)) return {};
|
|
4857
|
-
return store[_storeBoot]();
|
|
4858
|
-
})
|
|
4859
|
-
});
|
|
4860
|
-
var NodeStore = class extends BaseStore {
|
|
4861
|
-
observe(key, callback, immediate = true) {
|
|
4862
|
-
const tasks = [{ key, cb: callback }];
|
|
4863
|
-
track({ belong: this[_storeName], trackList: tasks });
|
|
4864
|
-
if (immediate) run(tasks);
|
|
4865
|
-
return () => clear({ belong: this[_storeName], clearList: tasks });
|
|
4293
|
+
state = { ...initialState, ...actions };
|
|
4294
|
+
for (const [key, def] of computedDefs) {
|
|
4295
|
+
state[key] = def.fn();
|
|
4866
4296
|
}
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
switch (platform) {
|
|
4870
|
-
case "react" /* React */:
|
|
4871
|
-
return getReactAdapter(storeName);
|
|
4872
|
-
case "node" /* Node */:
|
|
4873
|
-
return getNodeAdapter(storeName);
|
|
4874
|
-
case "lark" /* Lark */:
|
|
4875
|
-
default:
|
|
4876
|
-
return getLarkAdapter(storeName);
|
|
4877
|
-
}
|
|
4878
|
-
};
|
|
4879
|
-
var getPlatform = (comp) => {
|
|
4880
|
-
if (LarkUtils.isLarkView(comp)) return "lark" /* Lark */;
|
|
4881
|
-
return void 0;
|
|
4882
|
-
};
|
|
4883
|
-
var extendApis = { lazySet, shallowSet, computed };
|
|
4884
|
-
var StoreCache = /* @__PURE__ */ new Map();
|
|
4885
|
-
function defineStore(name, creator, config2) {
|
|
4886
|
-
if (StoreCache.has(name)) {
|
|
4887
|
-
name = name + "_copy";
|
|
4888
|
-
}
|
|
4889
|
-
const { platform = "lark" /* Lark */ } = config2 || {};
|
|
4890
|
-
const adapter = getAdapter(platform, name);
|
|
4891
|
-
const StoreClass = adapter.Store;
|
|
4892
|
-
const useStore = adapter.useStore;
|
|
4893
|
-
const store = new StoreClass(name, config2);
|
|
4894
|
-
const innerProxy = store[_innerStore]();
|
|
4895
|
-
const body = creator(innerProxy, extendApis);
|
|
4896
|
-
store[_storeCreate](body);
|
|
4897
|
-
Object.defineProperties(useStore, {
|
|
4898
|
-
$storeName: { value: name, configurable: true },
|
|
4899
|
-
$destroyFn: { value: () => store[_storeDestroy](), configurable: true }
|
|
4900
|
-
});
|
|
4901
|
-
if (!StoreCache.has(name)) {
|
|
4902
|
-
StoreCache.set(name, {
|
|
4903
|
-
store,
|
|
4904
|
-
creator,
|
|
4905
|
-
config: config2,
|
|
4906
|
-
useStore
|
|
4907
|
-
});
|
|
4908
|
-
}
|
|
4909
|
-
return useStore;
|
|
4297
|
+
storeRegistry.set(name, api);
|
|
4298
|
+
return api;
|
|
4910
4299
|
}
|
|
4911
|
-
function
|
|
4912
|
-
if (
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
return void 0;
|
|
4917
|
-
}
|
|
4918
|
-
function delStore(name) {
|
|
4919
|
-
if (name && StoreCache.has(name)) StoreCache.delete(name);
|
|
4920
|
-
}
|
|
4921
|
-
function getUseStore(name) {
|
|
4922
|
-
if (name && StoreCache.has(name)) {
|
|
4923
|
-
const entry = StoreCache.get(name);
|
|
4924
|
-
return entry ? entry.useStore : void 0;
|
|
4925
|
-
}
|
|
4926
|
-
return void 0;
|
|
4927
|
-
}
|
|
4928
|
-
function cloneStore(name, useStore, config2) {
|
|
4929
|
-
const oldStoreName = useStore.$storeName ?? "";
|
|
4930
|
-
const cached = StoreCache.get(oldStoreName);
|
|
4931
|
-
const oldStoreCreator = cached?.creator;
|
|
4932
|
-
const oldConfig = cached?.config || {};
|
|
4933
|
-
if (!name || !oldStoreCreator) return;
|
|
4934
|
-
const mergedConfig = { ...oldConfig, ...config2 || {} };
|
|
4935
|
-
return defineStore(
|
|
4936
|
-
name,
|
|
4937
|
-
oldStoreCreator,
|
|
4938
|
-
mergedConfig
|
|
4939
|
-
);
|
|
4300
|
+
function isLarkView(instance) {
|
|
4301
|
+
if (!instance || typeof instance !== "object") return false;
|
|
4302
|
+
const obj = instance;
|
|
4303
|
+
const updater = obj["updater"];
|
|
4304
|
+
return updater !== null && typeof updater === "object" && typeof updater["set"] === "function" && typeof updater["digest"] === "function";
|
|
4940
4305
|
}
|
|
4941
|
-
function
|
|
4942
|
-
if (
|
|
4943
|
-
const entry = StoreCache.get(name);
|
|
4944
|
-
return entry ? entry.store.status === 2 /* ACTIVE */ : false;
|
|
4945
|
-
}
|
|
4946
|
-
return false;
|
|
4947
|
-
}
|
|
4948
|
-
var cellCount = 0;
|
|
4949
|
-
function cell(data) {
|
|
4950
|
-
const linkKeys = `${LARK_GLOBAL}_${cellCount++}`;
|
|
4951
|
-
return createState(data, { belong: LARK_GLOBAL, linkKeys });
|
|
4952
|
-
}
|
|
4953
|
-
function observeCell(state, cb, immediate = true) {
|
|
4954
|
-
const linkKeys = getLinkKeys(state);
|
|
4955
|
-
if (!linkKeys) return noop;
|
|
4956
|
-
const keys2 = linkKeys.split(".");
|
|
4957
|
-
const key = keys2[keys2.length - 1];
|
|
4958
|
-
const list = [{ key, cb }];
|
|
4959
|
-
track({ belong: LARK_GLOBAL, trackList: list });
|
|
4960
|
-
if (immediate) cb();
|
|
4961
|
-
return () => clear({ belong: LARK_GLOBAL, clearList: list });
|
|
4962
|
-
}
|
|
4963
|
-
function multi(useStore) {
|
|
4964
|
-
const storeName = useStore.$storeName ?? "";
|
|
4965
|
-
const flagSym = `lark-comp-${storeName}`;
|
|
4966
|
-
const map = /* @__PURE__ */ new Map();
|
|
4967
|
-
let rootViewPath;
|
|
4968
|
-
const getFlag = (viewContext) => {
|
|
4969
|
-
const owner = viewContext.owner;
|
|
4970
|
-
const viewPath = owner?.path ?? "";
|
|
4971
|
-
const viewId = owner?.id ?? "";
|
|
4972
|
-
let flag;
|
|
4973
|
-
if (viewPath === rootViewPath) {
|
|
4974
|
-
flag = `${flagSym}-${viewId}`;
|
|
4975
|
-
} else {
|
|
4976
|
-
const initParams = owner?.viewInitParams;
|
|
4977
|
-
const candidate = initParams?.[flagSym];
|
|
4978
|
-
flag = typeof candidate === "string" ? candidate : void 0;
|
|
4979
|
-
}
|
|
4980
|
-
if (owner && isFunction(owner.mountFrame)) {
|
|
4981
|
-
const rawMountFrame = owner.mountFrame;
|
|
4982
|
-
owner.mountFrame = (frameId, viewPath2, viewInitParams = {}) => rawMountFrame.call(
|
|
4983
|
-
owner,
|
|
4984
|
-
frameId,
|
|
4985
|
-
viewPath2,
|
|
4986
|
-
Object.assign(viewInitParams, { [flagSym]: flag })
|
|
4987
|
-
);
|
|
4988
|
-
}
|
|
4989
|
-
return flag ?? "";
|
|
4306
|
+
function bindStore(view, store, selector) {
|
|
4307
|
+
if (!isLarkView(view)) return () => {
|
|
4990
4308
|
};
|
|
4991
|
-
const
|
|
4992
|
-
if (
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
)
|
|
4996
|
-
|
|
4997
|
-
const tag = viewCtx[flagSym];
|
|
4998
|
-
const flag = typeof tag === "string" ? tag : "";
|
|
4999
|
-
if (map.has(flag)) return map.get(flag);
|
|
5000
|
-
const newFn = cloneStore(flag, useStore);
|
|
5001
|
-
map.set(flag, newFn);
|
|
5002
|
-
return useFn(view);
|
|
5003
|
-
});
|
|
5004
|
-
const mixinObj = {
|
|
5005
|
-
make() {
|
|
5006
|
-
if (!rootViewPath) {
|
|
5007
|
-
rootViewPath = this.owner?.path ?? "";
|
|
4309
|
+
const extract = (s) => {
|
|
4310
|
+
if (selector) return selector(s);
|
|
4311
|
+
const result = {};
|
|
4312
|
+
for (const key in s) {
|
|
4313
|
+
if (Object.prototype.hasOwnProperty.call(s, key) && typeof s[key] !== "function") {
|
|
4314
|
+
result[key] = s[key];
|
|
5008
4315
|
}
|
|
5009
|
-
this[flagSym] = getFlag(this);
|
|
5010
4316
|
}
|
|
4317
|
+
return result;
|
|
5011
4318
|
};
|
|
5012
|
-
|
|
4319
|
+
view.updater.set(extract(store.getState()));
|
|
4320
|
+
view.updater.digest();
|
|
4321
|
+
const off = store.subscribe((state) => {
|
|
4322
|
+
view.updater.set(extract(state));
|
|
4323
|
+
view.updater.digest();
|
|
4324
|
+
});
|
|
4325
|
+
view.on("destroy", off);
|
|
4326
|
+
return off;
|
|
5013
4327
|
}
|
|
4328
|
+
var defineStore = create;
|
|
5014
4329
|
|
|
5015
4330
|
// src/compiler.ts
|
|
5016
4331
|
var import_parser = require("@babel/parser");
|
|
5017
|
-
var SPLITTER2 =
|
|
5018
|
-
var VIEW_ID_PLACEHOLDER =
|
|
4332
|
+
var SPLITTER2 = String.fromCharCode(30);
|
|
4333
|
+
var VIEW_ID_PLACEHOLDER = String.fromCharCode(31);
|
|
5019
4334
|
function jsObjectToUrlParams(paramsStr) {
|
|
5020
4335
|
const trimmed = paramsStr.trim();
|
|
5021
4336
|
if (!/^[{[]/.test(trimmed) && /=/.test(trimmed)) {
|
|
@@ -5075,7 +4390,7 @@ function addLineMarkers(source) {
|
|
|
5075
4390
|
if (parts.length > 1) {
|
|
5076
4391
|
const reconstructed = parts.map((part, i) => {
|
|
5077
4392
|
if (i === 0) return part;
|
|
5078
|
-
return openTag + SPLITTER2 + ++lineNo;
|
|
4393
|
+
return openTag + SPLITTER2 + ++lineNo + part;
|
|
5079
4394
|
}).join("");
|
|
5080
4395
|
result.push(reconstructed);
|
|
5081
4396
|
} else {
|
|
@@ -5468,7 +4783,7 @@ function extractGlobalVars(source) {
|
|
|
5468
4783
|
const htmlStore = {};
|
|
5469
4784
|
let htmlIndex = 0;
|
|
5470
4785
|
let lastIndex = 0;
|
|
5471
|
-
const htmlKey =
|
|
4786
|
+
const htmlKey = String.fromCharCode(5);
|
|
5472
4787
|
template.replace(
|
|
5473
4788
|
templateCmdRegExp,
|
|
5474
4789
|
(match, operate, content, offset) => {
|
|
@@ -5773,7 +5088,6 @@ var BUILTIN_GLOBAL_SET = new Set(Object.keys(BUILTIN_GLOBALS));
|
|
|
5773
5088
|
Framework,
|
|
5774
5089
|
LARK_VIEW,
|
|
5775
5090
|
Payload,
|
|
5776
|
-
Platform,
|
|
5777
5091
|
ROUTER_EVENTS,
|
|
5778
5092
|
Router,
|
|
5779
5093
|
SPLITTER,
|
|
@@ -5787,16 +5101,13 @@ var BUILTIN_GLOBAL_SET = new Set(Object.keys(BUILTIN_GLOBALS));
|
|
|
5787
5101
|
applyStyle,
|
|
5788
5102
|
applyVdomOps,
|
|
5789
5103
|
assign,
|
|
5790
|
-
|
|
5791
|
-
cloneData,
|
|
5792
|
-
cloneStore,
|
|
5104
|
+
bindStore,
|
|
5793
5105
|
compileTemplate,
|
|
5794
5106
|
computed,
|
|
5795
|
-
|
|
5107
|
+
create,
|
|
5796
5108
|
createVdomRef,
|
|
5797
5109
|
defineStore,
|
|
5798
5110
|
defineView,
|
|
5799
|
-
delStore,
|
|
5800
5111
|
encodeHTML,
|
|
5801
5112
|
encodeQ,
|
|
5802
5113
|
encodeSafe,
|
|
@@ -5808,43 +5119,34 @@ var BUILTIN_GLOBAL_SET = new Set(Object.keys(BUILTIN_GLOBALS));
|
|
|
5808
5119
|
generateId,
|
|
5809
5120
|
getAttribute,
|
|
5810
5121
|
getById,
|
|
5811
|
-
|
|
5812
|
-
getStore,
|
|
5813
|
-
getUseStore,
|
|
5122
|
+
getRouteMode,
|
|
5814
5123
|
hasOwnProperty,
|
|
5815
5124
|
installFrameVisualizerBridge,
|
|
5816
5125
|
invalidateViewClass,
|
|
5817
5126
|
isPlainObject,
|
|
5818
5127
|
isPrimitive,
|
|
5819
5128
|
isPrimitiveOrFunc,
|
|
5820
|
-
isState,
|
|
5821
|
-
isStoreActive,
|
|
5822
5129
|
keys,
|
|
5823
|
-
lazySet,
|
|
5824
5130
|
mark,
|
|
5825
5131
|
markBooted,
|
|
5826
5132
|
markRouterBooted,
|
|
5827
|
-
multi,
|
|
5828
5133
|
nextCounter,
|
|
5829
5134
|
nodeInside,
|
|
5830
5135
|
noop,
|
|
5831
5136
|
now,
|
|
5832
|
-
observeCell,
|
|
5833
5137
|
parseUri,
|
|
5834
5138
|
registerViewClass,
|
|
5835
5139
|
resetProjectsMap,
|
|
5836
5140
|
safeguard,
|
|
5837
5141
|
serializeFrameTree,
|
|
5838
5142
|
setData,
|
|
5839
|
-
shallowSet,
|
|
5840
|
-
storeMark,
|
|
5841
|
-
storeUnmark,
|
|
5842
5143
|
syncCounter,
|
|
5843
5144
|
toMap,
|
|
5844
5145
|
toUri,
|
|
5845
5146
|
translateData,
|
|
5846
5147
|
unmark,
|
|
5847
5148
|
use,
|
|
5149
|
+
useUrlState,
|
|
5848
5150
|
vdomGetCompareKey,
|
|
5849
5151
|
vdomGetNode,
|
|
5850
5152
|
vdomSetAttributes,
|