@lynx-js/web-core-server 0.17.2 → 0.18.1
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/CHANGELOG.md +4 -0
- package/dist/index.js +46 -38
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -383,17 +383,14 @@ __webpack_require__.m = __webpack_modules__;
|
|
|
383
383
|
}
|
|
384
384
|
};
|
|
385
385
|
})();
|
|
386
|
-
const lynxUniqueIdAttribute = 'l-uid';
|
|
387
386
|
const cssIdAttribute = 'l-css-id';
|
|
388
387
|
const componentIdAttribute = 'l-comp-id';
|
|
389
388
|
const parentComponentUniqueIdAttribute = 'l-p-comp-uid';
|
|
390
389
|
const lynxEntryNameAttribute = 'l-e-name';
|
|
391
390
|
const lynxTagAttribute = 'lynx-tag';
|
|
392
|
-
const lynxDatasetAttribute = 'l-dset';
|
|
393
391
|
const lynxComponentConfigAttribute = 'l-comp-cfg';
|
|
394
392
|
const lynxDisposedAttribute = 'l-disposed';
|
|
395
393
|
const lynxElementTemplateMarkerAttribute = 'l-template';
|
|
396
|
-
const lynxPartIdAttribute = 'l-part';
|
|
397
394
|
const lynxDefaultDisplayLinearAttribute = 'lynx-default-display-linear';
|
|
398
395
|
const __lynx_timing_flag = '__lynx_timing_flag';
|
|
399
396
|
const systemInfo = {
|
|
@@ -620,7 +617,7 @@ const publishEventEndpoint = createRpcEndpoint('publishEvent', false, false);
|
|
|
620
617
|
createRpcEndpoint('postOffscreenEventEndpoint', false, false);
|
|
621
618
|
const switchExposureServiceEndpoint = createRpcEndpoint('switchExposureServiceEndpoint', false, false);
|
|
622
619
|
createRpcEndpoint('mainThreadStart', false, false);
|
|
623
|
-
createRpcEndpoint('updateData', false, true);
|
|
620
|
+
const updateDataEndpoint = createRpcEndpoint('updateData', false, true);
|
|
624
621
|
createRpcEndpoint('sendGlobalEventEndpoint', false, false);
|
|
625
622
|
createRpcEndpoint('dispose', false, true);
|
|
626
623
|
const BackgroundThreadStartEndpoint = createRpcEndpoint('start', false, true);
|
|
@@ -671,17 +668,6 @@ var UpdateDataOptions_NativeUpdateDataType;
|
|
|
671
668
|
NativeUpdateDataType[NativeUpdateDataType["UPDATE"] = 0] = "UPDATE";
|
|
672
669
|
NativeUpdateDataType[NativeUpdateDataType["RESET"] = 1] = "RESET";
|
|
673
670
|
})(UpdateDataOptions_NativeUpdateDataType || (UpdateDataOptions_NativeUpdateDataType = {}));
|
|
674
|
-
var UpdateDataOptions_UpdateDataType;
|
|
675
|
-
(function(UpdateDataType) {
|
|
676
|
-
UpdateDataType[UpdateDataType["Unknown"] = 0] = "Unknown";
|
|
677
|
-
UpdateDataType[UpdateDataType["UpdateExplicitByUser"] = 1] = "UpdateExplicitByUser";
|
|
678
|
-
UpdateDataType[UpdateDataType["UpdateByKernelFromCtor"] = 2] = "UpdateByKernelFromCtor";
|
|
679
|
-
UpdateDataType[UpdateDataType["UpdateByKernelFromRender"] = 4] = "UpdateByKernelFromRender";
|
|
680
|
-
UpdateDataType[UpdateDataType["UpdateByKernelFromHydrate"] = 8] = "UpdateByKernelFromHydrate";
|
|
681
|
-
UpdateDataType[UpdateDataType["UpdateByKernelFromGetDerived"] = 16] = "UpdateByKernelFromGetDerived";
|
|
682
|
-
UpdateDataType[UpdateDataType["UpdateByKernelFromConflict"] = 32] = "UpdateByKernelFromConflict";
|
|
683
|
-
UpdateDataType[UpdateDataType["UpdateByKernelFromHMR"] = 64] = "UpdateByKernelFromHMR";
|
|
684
|
-
})(UpdateDataOptions_UpdateDataType || (UpdateDataOptions_UpdateDataType = {}));
|
|
685
671
|
const DispatchEventResult = {
|
|
686
672
|
NotCanceled: 0,
|
|
687
673
|
CanceledByEventHandler: 1,
|
|
@@ -1152,11 +1138,11 @@ const __AddConfig = /*#__PURE__*/ (element, type, value)=>{
|
|
|
1152
1138
|
const __AddDataset = /*#__PURE__*/ (element, key, value)=>{
|
|
1153
1139
|
const currentDataset = __GetDataset(element);
|
|
1154
1140
|
currentDataset[key] = value;
|
|
1155
|
-
element.setAttribute(
|
|
1141
|
+
element.setAttribute("l-dset", encodeURIComponent(JSON.stringify(currentDataset)));
|
|
1156
1142
|
value ? element.setAttribute('data-' + key, value.toString()) : element.removeAttribute('data-' + key);
|
|
1157
1143
|
};
|
|
1158
1144
|
const __GetDataset = /*#__PURE__*/ (element)=>{
|
|
1159
|
-
const datasetString = element.getAttribute(
|
|
1145
|
+
const datasetString = element.getAttribute("l-dset");
|
|
1160
1146
|
const currentDataset = datasetString ? JSON.parse(decodeURIComponent(datasetString)) : {};
|
|
1161
1147
|
return currentDataset;
|
|
1162
1148
|
};
|
|
@@ -1174,7 +1160,7 @@ const __GetElementConfig = /*#__PURE__*/ (element)=>{
|
|
|
1174
1160
|
return currentComponentConfigString ? JSON.parse(decodeURIComponent(currentComponentConfigString)) : {};
|
|
1175
1161
|
};
|
|
1176
1162
|
const __GetAttributeByName = /*#__PURE__*/ (element, name)=>element.getAttribute(name);
|
|
1177
|
-
const __GetElementUniqueID = /*#__PURE__*/ (element)=>element && element.getAttribute ? Number(element.getAttribute(
|
|
1163
|
+
const __GetElementUniqueID = /*#__PURE__*/ (element)=>element && element.getAttribute ? Number(element.getAttribute("l-uid")) : -1;
|
|
1178
1164
|
const __GetID = /*#__PURE__*/ (element)=>element.getAttribute('id');
|
|
1179
1165
|
const __SetID = /*#__PURE__*/ (element, id)=>id ? element.setAttribute('id', id) : element.removeAttribute('id');
|
|
1180
1166
|
const __GetTag = /*#__PURE__*/ (element)=>element.getAttribute(lynxTagAttribute);
|
|
@@ -1182,7 +1168,7 @@ const __SetConfig = /*#__PURE__*/ (element, config)=>{
|
|
|
1182
1168
|
element.setAttribute(lynxComponentConfigAttribute, encodeURIComponent(JSON.stringify(config)));
|
|
1183
1169
|
};
|
|
1184
1170
|
const __SetDataset = /*#__PURE__*/ (element, dataset)=>{
|
|
1185
|
-
element.setAttribute(
|
|
1171
|
+
element.setAttribute("l-dset", encodeURIComponent(JSON.stringify(dataset)));
|
|
1186
1172
|
for (const [key, value] of Object.entries(dataset))element.setAttribute('data-' + key, value.toString());
|
|
1187
1173
|
};
|
|
1188
1174
|
const __UpdateComponentID = /*#__PURE__*/ (element, componentID)=>element.setAttribute(componentIdAttribute, componentID);
|
|
@@ -1240,9 +1226,9 @@ const __GetTemplateParts = (templateElement)=>{
|
|
|
1240
1226
|
if (!isTemplate) return {};
|
|
1241
1227
|
const templateUniqueId = __GetElementUniqueID(templateElement);
|
|
1242
1228
|
const parts = {};
|
|
1243
|
-
const partElements = templateElement.querySelectorAll(`[
|
|
1229
|
+
const partElements = templateElement.querySelectorAll(`[l-uid="${templateUniqueId}"] [l-part]:not([l-uid="${templateUniqueId}"] [${lynxElementTemplateMarkerAttribute}] [l-part])`);
|
|
1244
1230
|
for (const partElement of partElements){
|
|
1245
|
-
const partId = partElement.getAttribute(
|
|
1231
|
+
const partId = partElement.getAttribute("l-part");
|
|
1246
1232
|
if (partId) parts[partId] = partElement;
|
|
1247
1233
|
}
|
|
1248
1234
|
return parts;
|
|
@@ -1251,7 +1237,7 @@ const __MarkTemplateElement = (element)=>{
|
|
|
1251
1237
|
element.setAttribute(lynxElementTemplateMarkerAttribute, '');
|
|
1252
1238
|
};
|
|
1253
1239
|
const __MarkPartElement = (element, partId)=>{
|
|
1254
|
-
element.setAttribute(
|
|
1240
|
+
element.setAttribute("l-part", partId);
|
|
1255
1241
|
};
|
|
1256
1242
|
function toCloneableObject(obj) {
|
|
1257
1243
|
const cloneableObj = {};
|
|
@@ -1294,10 +1280,22 @@ function createCrossThreadEvent(domEvent, eventName) {
|
|
|
1294
1280
|
targetTouches: isTrusted ? targetTouches.map(toCloneableObject) : targetTouches,
|
|
1295
1281
|
changedTouches: isTrusted ? changedTouches.map(toCloneableObject) : changedTouches
|
|
1296
1282
|
});
|
|
1283
|
+
} else if (type.startsWith('mouse')) {
|
|
1284
|
+
const mouseEvent = domEvent;
|
|
1285
|
+
Object.assign(otherProperties, {
|
|
1286
|
+
button: mouseEvent.button,
|
|
1287
|
+
buttons: mouseEvent.buttons,
|
|
1288
|
+
x: mouseEvent.x,
|
|
1289
|
+
y: mouseEvent.y,
|
|
1290
|
+
pageX: mouseEvent.pageX,
|
|
1291
|
+
pageY: mouseEvent.pageY,
|
|
1292
|
+
clientX: mouseEvent.clientX,
|
|
1293
|
+
clientY: mouseEvent.clientY
|
|
1294
|
+
});
|
|
1297
1295
|
}
|
|
1298
|
-
const currentTargetDatasetString = currentTargetElement?.getAttribute(
|
|
1296
|
+
const currentTargetDatasetString = currentTargetElement?.getAttribute("l-dset");
|
|
1299
1297
|
const currentTargetDataset = currentTargetDatasetString ? JSON.parse(decodeURIComponent(currentTargetDatasetString)) : {};
|
|
1300
|
-
const targetDatasetString = targetElement.getAttribute(
|
|
1298
|
+
const targetDatasetString = targetElement.getAttribute("l-dset");
|
|
1301
1299
|
const targetDataset = targetDatasetString ? JSON.parse(decodeURIComponent(targetDatasetString)) : {};
|
|
1302
1300
|
return {
|
|
1303
1301
|
type: eventName,
|
|
@@ -1305,12 +1303,12 @@ function createCrossThreadEvent(domEvent, eventName) {
|
|
|
1305
1303
|
target: {
|
|
1306
1304
|
id: targetElement.getAttribute('id'),
|
|
1307
1305
|
dataset: targetDataset,
|
|
1308
|
-
uniqueId: Number(targetElement.getAttribute(
|
|
1306
|
+
uniqueId: Number(targetElement.getAttribute("l-uid"))
|
|
1309
1307
|
},
|
|
1310
1308
|
currentTarget: currentTargetElement ? {
|
|
1311
1309
|
id: currentTargetElement.getAttribute('id'),
|
|
1312
1310
|
dataset: currentTargetDataset,
|
|
1313
|
-
uniqueId: Number(currentTargetElement.getAttribute(
|
|
1311
|
+
uniqueId: Number(currentTargetElement.getAttribute("l-uid"))
|
|
1314
1312
|
} : null,
|
|
1315
1313
|
detail: domEvent.detail ?? {},
|
|
1316
1314
|
params,
|
|
@@ -1447,7 +1445,7 @@ function createMainThreadGlobalThis(config) {
|
|
|
1447
1445
|
const parentComponentCssID = lynxUniqueIdToElement[parentComponentUniqueId]?.deref()?.getAttribute(cssIdAttribute);
|
|
1448
1446
|
parentComponentCssID && '0' !== parentComponentCssID && element.setAttribute(cssIdAttribute, parentComponentCssID);
|
|
1449
1447
|
element.setAttribute(lynxTagAttribute, tag);
|
|
1450
|
-
element.setAttribute(
|
|
1448
|
+
element.setAttribute("l-uid", uniqueId + '');
|
|
1451
1449
|
element.setAttribute(parentComponentUniqueIdAttribute, parentComponentUniqueId + '');
|
|
1452
1450
|
return element;
|
|
1453
1451
|
};
|
|
@@ -1540,14 +1538,14 @@ function createMainThreadGlobalThis(config) {
|
|
|
1540
1538
|
const newClassName = ((element.getAttribute('class') ?? '') + ' ' + className).trim();
|
|
1541
1539
|
element.setAttribute('class', newClassName);
|
|
1542
1540
|
const cssId = element.getAttribute(cssIdAttribute);
|
|
1543
|
-
const uniqueId = Number(element.getAttribute(
|
|
1541
|
+
const uniqueId = Number(element.getAttribute("l-uid"));
|
|
1544
1542
|
const entryName = element.getAttribute(lynxEntryNameAttribute);
|
|
1545
1543
|
callbacks.updateCssOGStyle(uniqueId, newClassName, cssId, entryName);
|
|
1546
1544
|
};
|
|
1547
1545
|
const __SetClassesForCSSOG = (element, classNames)=>{
|
|
1548
1546
|
__SetClasses(element, classNames);
|
|
1549
1547
|
const cssId = element.getAttribute(cssIdAttribute);
|
|
1550
|
-
const uniqueId = Number(element.getAttribute(
|
|
1548
|
+
const uniqueId = Number(element.getAttribute("l-uid"));
|
|
1551
1549
|
const entryName = element.getAttribute(lynxEntryNameAttribute);
|
|
1552
1550
|
callbacks.updateCssOGStyle(uniqueId, classNames ?? '', cssId, entryName);
|
|
1553
1551
|
};
|
|
@@ -1586,7 +1584,7 @@ function createMainThreadGlobalThis(config) {
|
|
|
1586
1584
|
};
|
|
1587
1585
|
const applyEventsForElementTemplate = (data, element)=>{
|
|
1588
1586
|
const uniqueId = uniqueIdInc++;
|
|
1589
|
-
element.setAttribute(
|
|
1587
|
+
element.setAttribute("l-uid", uniqueId + '');
|
|
1590
1588
|
for (const event of data.events || []){
|
|
1591
1589
|
const { type, name, value } = event;
|
|
1592
1590
|
__AddEvent(element, type, name, value);
|
|
@@ -1720,7 +1718,7 @@ function createExposureService(rootDom, postExposure) {
|
|
|
1720
1718
|
const onScreen = new Map();
|
|
1721
1719
|
function exposureEventHandler(ev) {
|
|
1722
1720
|
const exposureEvent = createCrossThreadEvent(ev, ev.type);
|
|
1723
|
-
exposureEvent.detail['unique-id'] = parseFloat(ev.target.getAttribute(
|
|
1721
|
+
exposureEvent.detail['unique-id'] = parseFloat(ev.target.getAttribute("l-uid"));
|
|
1724
1722
|
const exposureID = exposureEvent.detail.exposureID;
|
|
1725
1723
|
if ('exposure' === ev.type) {
|
|
1726
1724
|
exposureCache.push(exposureEvent);
|
|
@@ -1928,7 +1926,7 @@ function appendStyleElement(styleInfo, pageConfig, rootDom, document, ssrHydrate
|
|
|
1928
1926
|
const rule = cardStyleElementSheet.cssRules[lynxUniqueIdToStyleRulesIndex[uniqueId]];
|
|
1929
1927
|
rule.style.cssText = newStyles;
|
|
1930
1928
|
} else {
|
|
1931
|
-
const index = cardStyleElementSheet.insertRule(`[
|
|
1929
|
+
const index = cardStyleElementSheet.insertRule(`[l-uid="${uniqueId}"]{${newStyles}}`, cardStyleElementSheet.cssRules.length);
|
|
1932
1930
|
lynxUniqueIdToStyleRulesIndex[uniqueId] = index;
|
|
1933
1931
|
}
|
|
1934
1932
|
};
|
|
@@ -1996,18 +1994,20 @@ function createQueryComponent(loadTemplate, updateLazyComponentStyle, background
|
|
|
1996
1994
|
return __QueryComponentImpl;
|
|
1997
1995
|
}
|
|
1998
1996
|
const initWasmPromise = initWasm();
|
|
1999
|
-
function prepareMainThreadAPIs(backgroundThreadRpc, rootDom, document,
|
|
1997
|
+
function prepareMainThreadAPIs(backgroundThreadRpc, rootDom, document, mtsRealmPromise, commitDocument, markTimingInternal, flushMarkTimingInternal, reportError, triggerI18nResourceFallback, initialI18nResources, loadTemplate, ssrHooks) {
|
|
2000
1998
|
const postTimingFlags = backgroundThreadRpc.createCall(postTimingFlagsEndpoint);
|
|
2001
1999
|
const backgroundStart = backgroundThreadRpc.createCall(BackgroundThreadStartEndpoint);
|
|
2002
2000
|
const publishEvent = backgroundThreadRpc.createCall(publishEventEndpoint);
|
|
2003
2001
|
const publicComponentEvent = backgroundThreadRpc.createCall(publicComponentEventEndpoint);
|
|
2004
2002
|
const postExposure = backgroundThreadRpc.createCall(postExposureEndpoint);
|
|
2005
2003
|
const dispatchI18nResource = backgroundThreadRpc.createCall(dispatchI18nResourceEndpoint);
|
|
2004
|
+
const updateDataBackground = backgroundThreadRpc.createCall(updateDataEndpoint);
|
|
2006
2005
|
markTimingInternal('lepus_execute_start');
|
|
2007
2006
|
async function startMainThread(config, ssrHydrateInfo) {
|
|
2008
2007
|
let isFp = true;
|
|
2009
2008
|
const { globalProps, template, browserConfig, nativeModulesMap, napiModulesMap, tagMap, initI18nResources } = config;
|
|
2010
2009
|
const { styleInfo, pageConfig, customSections, cardType } = template;
|
|
2010
|
+
const mtsRealm = await mtsRealmPromise;
|
|
2011
2011
|
markTimingInternal('decode_start');
|
|
2012
2012
|
await initWasmPromise;
|
|
2013
2013
|
const jsContext = new LynxCrossThreadContext({
|
|
@@ -2113,8 +2113,16 @@ function prepareMainThreadAPIs(backgroundThreadRpc, rootDom, document, mtsRealm,
|
|
|
2113
2113
|
await mtsRealm.loadScript(template.lepusCode.root);
|
|
2114
2114
|
jsContext.__start();
|
|
2115
2115
|
}
|
|
2116
|
+
async function handleUpdatedData(newData, options) {
|
|
2117
|
+
const mtsRealm = await mtsRealmPromise;
|
|
2118
|
+
const runtime = mtsRealm.globalWindow;
|
|
2119
|
+
const processedData = runtime.processData ? runtime.processData(newData, options?.processorName) : newData;
|
|
2120
|
+
runtime.updatePage?.(processedData, options);
|
|
2121
|
+
return updateDataBackground(processedData, options);
|
|
2122
|
+
}
|
|
2116
2123
|
return {
|
|
2117
|
-
startMainThread
|
|
2124
|
+
startMainThread,
|
|
2125
|
+
handleUpdatedData
|
|
2118
2126
|
};
|
|
2119
2127
|
}
|
|
2120
2128
|
const templateCache = new Map();
|
|
@@ -2790,8 +2798,8 @@ function getTextContentImpl(buffer, element, shadowrootTemplates) {
|
|
|
2790
2798
|
buffer.push('"');
|
|
2791
2799
|
}
|
|
2792
2800
|
}
|
|
2793
|
-
const partId = element[_attributes].get(
|
|
2794
|
-
buffer.push(' ',
|
|
2801
|
+
const partId = element[_attributes].get("l-part") ?? element[_attributes].get("l-uid");
|
|
2802
|
+
buffer.push(' ', "l-part", '="', partId, '"');
|
|
2795
2803
|
buffer.push('>');
|
|
2796
2804
|
const templateImpl = shadowrootTemplates[localName];
|
|
2797
2805
|
if (templateImpl) {
|
|
@@ -2833,7 +2841,7 @@ const builtinTagTransformMap = {
|
|
|
2833
2841
|
};
|
|
2834
2842
|
OffscreenElement.prototype.toJSON = function() {
|
|
2835
2843
|
return {
|
|
2836
|
-
ssrID: this[_attributes].get(
|
|
2844
|
+
ssrID: this[_attributes].get("l-part") ?? this[_attributes].get("l-uid")
|
|
2837
2845
|
};
|
|
2838
2846
|
};
|
|
2839
2847
|
async function createLynxView(config) {
|
|
@@ -2902,7 +2910,7 @@ async function createLynxView(config) {
|
|
|
2902
2910
|
}, ()=>{}, {
|
|
2903
2911
|
__AddEvent (element, eventName, eventData, eventOptions) {
|
|
2904
2912
|
events.push([
|
|
2905
|
-
Number(element.getAttribute(
|
|
2913
|
+
Number(element.getAttribute("l-uid")),
|
|
2906
2914
|
eventName,
|
|
2907
2915
|
eventData,
|
|
2908
2916
|
eventOptions
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/web-core-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [],
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"rsbuild-plugin-arethetypeswrong": "0.1.1",
|
|
27
27
|
"rsbuild-plugin-publint": "0.3.3",
|
|
28
28
|
"@lynx-js/offscreen-document": "0.1.4",
|
|
29
|
-
"@lynx-js/web-constants": "0.
|
|
30
|
-
"@lynx-js/web-elements-template": "0.8.
|
|
31
|
-
"@lynx-js/web-mainthread-apis": "0.
|
|
32
|
-
"@lynx-js/web-worker-rpc": "0.
|
|
29
|
+
"@lynx-js/web-constants": "0.18.1",
|
|
30
|
+
"@lynx-js/web-elements-template": "0.8.9",
|
|
31
|
+
"@lynx-js/web-mainthread-apis": "0.18.1",
|
|
32
|
+
"@lynx-js/web-worker-rpc": "0.18.1"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"build": "rslib build",
|