@lingxia/html 0.10.0 → 0.12.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/dist/global.es2020.js +69 -0
- package/dist/global.es5.js +83 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -1
- package/package.json +5 -3
package/dist/global.es2020.js
CHANGED
|
@@ -156,11 +156,80 @@ var LingXiaPage = (function(exports) {
|
|
|
156
156
|
if (clean.length > 1) throw new Error(`Page action '${name}' accepts at most one payload argument`);
|
|
157
157
|
return clean[0];
|
|
158
158
|
}
|
|
159
|
+
const initialLayout = Object.freeze({
|
|
160
|
+
revision: 0,
|
|
161
|
+
topInset: 0,
|
|
162
|
+
bottomInset: 0,
|
|
163
|
+
capsuleRect: null,
|
|
164
|
+
capsuleInlineEndInset: 0
|
|
165
|
+
});
|
|
166
|
+
function shouldApplyPageChromeRevision(currentRevision, nextRevision) {
|
|
167
|
+
return nextRevision >= currentRevision;
|
|
168
|
+
}
|
|
169
|
+
function projectPageChromeLayout(layout) {
|
|
170
|
+
const root = document.documentElement;
|
|
171
|
+
root?.style.setProperty("--lx-page-chrome-top-inset", `${layout.topInset}px`);
|
|
172
|
+
root?.style.setProperty("--lx-page-chrome-bottom-inset", `${layout.bottomInset}px`);
|
|
173
|
+
root?.style.setProperty("--lx-page-chrome-capsule-inline-end-inset", `${layout.capsuleInlineEndInset}px`);
|
|
174
|
+
}
|
|
175
|
+
/** Read the latest realized page-chrome layout synchronously. */
|
|
176
|
+
function getPageChromeLayout() {
|
|
177
|
+
if (typeof window === "undefined") return initialLayout;
|
|
178
|
+
return installPageChromeRuntime()?.layout ?? initialLayout;
|
|
179
|
+
}
|
|
180
|
+
/** Subscribe to realized page-chrome layout changes. */
|
|
181
|
+
function subscribePageChromeLayout(listener) {
|
|
182
|
+
if (typeof window === "undefined") return () => {};
|
|
183
|
+
installPageChromeRuntime();
|
|
184
|
+
const handleChange = (event) => {
|
|
185
|
+
listener(event.detail);
|
|
186
|
+
};
|
|
187
|
+
window.addEventListener("lxpagechromechange", handleChange);
|
|
188
|
+
return () => window.removeEventListener("lxpagechromechange", handleChange);
|
|
189
|
+
}
|
|
190
|
+
/** Ensure browser previews have the same synchronous contract as native pages. */
|
|
191
|
+
function installPageChromeRuntime() {
|
|
192
|
+
if (typeof window === "undefined") return void 0;
|
|
193
|
+
if (window.lxPageChrome) return window.lxPageChrome;
|
|
194
|
+
let layout = initialLayout;
|
|
195
|
+
const api = Object.freeze({ get layout() {
|
|
196
|
+
return layout;
|
|
197
|
+
} });
|
|
198
|
+
Object.defineProperty(window, "lxPageChrome", {
|
|
199
|
+
configurable: false,
|
|
200
|
+
enumerable: true,
|
|
201
|
+
value: api
|
|
202
|
+
});
|
|
203
|
+
Object.defineProperty(window, "__lingxiaApplyPageChrome", {
|
|
204
|
+
configurable: false,
|
|
205
|
+
enumerable: false,
|
|
206
|
+
value(next, scheme) {
|
|
207
|
+
if (!shouldApplyPageChromeRevision(layout.revision, next.revision)) return;
|
|
208
|
+
const capsuleRect = next.capsuleRect ? Object.freeze({ ...next.capsuleRect }) : null;
|
|
209
|
+
layout = Object.freeze({
|
|
210
|
+
...next,
|
|
211
|
+
capsuleRect
|
|
212
|
+
});
|
|
213
|
+
projectPageChromeLayout(layout);
|
|
214
|
+
const root = document.documentElement;
|
|
215
|
+
if (root) {
|
|
216
|
+
root.style.colorScheme = scheme;
|
|
217
|
+
root.setAttribute("data-theme", scheme);
|
|
218
|
+
}
|
|
219
|
+
window.dispatchEvent(new CustomEvent("lxpagechromechange", { detail: layout }));
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
projectPageChromeLayout(initialLayout);
|
|
223
|
+
return api;
|
|
224
|
+
}
|
|
225
|
+
installPageChromeRuntime();
|
|
159
226
|
//#endregion
|
|
160
227
|
exports.getActions = getPageActions;
|
|
228
|
+
exports.getPageChromeLayout = getPageChromeLayout;
|
|
161
229
|
exports.getSnapshot = getPageSnapshot;
|
|
162
230
|
exports.getStateInfo = getPageStateInfo;
|
|
163
231
|
exports.subscribe = subscribePageData;
|
|
232
|
+
exports.subscribePageChromeLayout = subscribePageChromeLayout;
|
|
164
233
|
exports.subscribeSnapshot = subscribePageSnapshot;
|
|
165
234
|
return exports;
|
|
166
235
|
})({});
|
package/dist/global.es5.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
1
12
|
var LingXiaPage = (function (exports) {
|
|
2
13
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
14
|
//#region dist/__page_runtime_runtime__.js
|
|
@@ -182,11 +193,83 @@ var LingXiaPage = (function (exports) {
|
|
|
182
193
|
throw new Error("Page action '".concat(name, "' accepts at most one payload argument"));
|
|
183
194
|
return clean[0];
|
|
184
195
|
}
|
|
196
|
+
var initialLayout = Object.freeze({
|
|
197
|
+
revision: 0,
|
|
198
|
+
topInset: 0,
|
|
199
|
+
bottomInset: 0,
|
|
200
|
+
capsuleRect: null,
|
|
201
|
+
capsuleInlineEndInset: 0
|
|
202
|
+
});
|
|
203
|
+
function shouldApplyPageChromeRevision(currentRevision, nextRevision) {
|
|
204
|
+
return nextRevision >= currentRevision;
|
|
205
|
+
}
|
|
206
|
+
function projectPageChromeLayout(layout) {
|
|
207
|
+
var root = document.documentElement;
|
|
208
|
+
root === null || root === void 0 ? void 0 : root.style.setProperty("--lx-page-chrome-top-inset", "".concat(layout.topInset, "px"));
|
|
209
|
+
root === null || root === void 0 ? void 0 : root.style.setProperty("--lx-page-chrome-bottom-inset", "".concat(layout.bottomInset, "px"));
|
|
210
|
+
root === null || root === void 0 ? void 0 : root.style.setProperty("--lx-page-chrome-capsule-inline-end-inset", "".concat(layout.capsuleInlineEndInset, "px"));
|
|
211
|
+
}
|
|
212
|
+
/** Read the latest realized page-chrome layout synchronously. */
|
|
213
|
+
function getPageChromeLayout() {
|
|
214
|
+
var _a, _b;
|
|
215
|
+
if (typeof window === "undefined")
|
|
216
|
+
return initialLayout;
|
|
217
|
+
return (_b = (_a = installPageChromeRuntime()) === null || _a === void 0 ? void 0 : _a.layout) !== null && _b !== void 0 ? _b : initialLayout;
|
|
218
|
+
}
|
|
219
|
+
/** Subscribe to realized page-chrome layout changes. */
|
|
220
|
+
function subscribePageChromeLayout(listener) {
|
|
221
|
+
if (typeof window === "undefined")
|
|
222
|
+
return function () { };
|
|
223
|
+
installPageChromeRuntime();
|
|
224
|
+
var handleChange = function (event) {
|
|
225
|
+
listener(event.detail);
|
|
226
|
+
};
|
|
227
|
+
window.addEventListener("lxpagechromechange", handleChange);
|
|
228
|
+
return function () { return window.removeEventListener("lxpagechromechange", handleChange); };
|
|
229
|
+
}
|
|
230
|
+
/** Ensure browser previews have the same synchronous contract as native pages. */
|
|
231
|
+
function installPageChromeRuntime() {
|
|
232
|
+
if (typeof window === "undefined")
|
|
233
|
+
return void 0;
|
|
234
|
+
if (window.lxPageChrome)
|
|
235
|
+
return window.lxPageChrome;
|
|
236
|
+
var layout = initialLayout;
|
|
237
|
+
var api = Object.freeze({ get layout() {
|
|
238
|
+
return layout;
|
|
239
|
+
} });
|
|
240
|
+
Object.defineProperty(window, "lxPageChrome", {
|
|
241
|
+
configurable: false,
|
|
242
|
+
enumerable: true,
|
|
243
|
+
value: api
|
|
244
|
+
});
|
|
245
|
+
Object.defineProperty(window, "__lingxiaApplyPageChrome", {
|
|
246
|
+
configurable: false,
|
|
247
|
+
enumerable: false,
|
|
248
|
+
value: function (next, scheme) {
|
|
249
|
+
if (!shouldApplyPageChromeRevision(layout.revision, next.revision))
|
|
250
|
+
return;
|
|
251
|
+
var capsuleRect = next.capsuleRect ? Object.freeze(__assign({}, next.capsuleRect)) : null;
|
|
252
|
+
layout = Object.freeze(__assign(__assign({}, next), { capsuleRect: capsuleRect }));
|
|
253
|
+
projectPageChromeLayout(layout);
|
|
254
|
+
var root = document.documentElement;
|
|
255
|
+
if (root) {
|
|
256
|
+
root.style.colorScheme = scheme;
|
|
257
|
+
root.setAttribute("data-theme", scheme);
|
|
258
|
+
}
|
|
259
|
+
window.dispatchEvent(new CustomEvent("lxpagechromechange", { detail: layout }));
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
projectPageChromeLayout(initialLayout);
|
|
263
|
+
return api;
|
|
264
|
+
}
|
|
265
|
+
installPageChromeRuntime();
|
|
185
266
|
//#endregion
|
|
186
267
|
exports.getActions = getPageActions;
|
|
268
|
+
exports.getPageChromeLayout = getPageChromeLayout;
|
|
187
269
|
exports.getSnapshot = getPageSnapshot;
|
|
188
270
|
exports.getStateInfo = getPageStateInfo;
|
|
189
271
|
exports.subscribe = subscribePageData;
|
|
272
|
+
exports.subscribePageChromeLayout = subscribePageChromeLayout;
|
|
190
273
|
exports.subscribeSnapshot = subscribePageSnapshot;
|
|
191
274
|
return exports;
|
|
192
275
|
})({});
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
export { getPageActions as getActions, getPageSnapshot as getSnapshot, getPageStateInfo as getStateInfo, subscribePageData as subscribe, subscribePageSnapshot as subscribeSnapshot, type ActionMap, type Snapshot, } from "@lingxia/page-runtime";
|
|
1
|
+
export { getPageChromeLayout, getPageActions as getActions, getPageSnapshot as getSnapshot, getPageStateInfo as getStateInfo, subscribePageData as subscribe, subscribePageChromeLayout, subscribePageSnapshot as subscribeSnapshot, type ActionMap, type Snapshot, } from "@lingxia/page-runtime";
|
|
2
|
+
export type { LxPageChrome, PageChromeLayoutListener, PageChromeLayoutSnapshot, PageChromeRect, } from "@lingxia/page-runtime";
|
|
3
|
+
export { getDisplayLanguage, subscribeDisplayLanguage, } from "@lingxia/bridge";
|
package/dist/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { getPageActions as getActions, getPageSnapshot as getSnapshot, getPageStateInfo as getStateInfo, subscribePageData as subscribe, subscribePageSnapshot as subscribeSnapshot, } from "@lingxia/page-runtime";
|
|
1
|
+
export { getPageChromeLayout, getPageActions as getActions, getPageSnapshot as getSnapshot, getPageStateInfo as getStateInfo, subscribePageData as subscribe, subscribePageChromeLayout, subscribePageSnapshot as subscribeSnapshot, } from "@lingxia/page-runtime";
|
|
2
|
+
export { getDisplayLanguage, subscribeDisplayLanguage, } from "@lingxia/bridge";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingxia/html",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "LingXia HTML runtime for lxapp pages",
|
|
6
6
|
"type": "module",
|
|
@@ -21,11 +21,13 @@
|
|
|
21
21
|
"prepublishOnly": "npm run build"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@lingxia/
|
|
24
|
+
"@lingxia/bridge": "~0.12.0",
|
|
25
|
+
"@lingxia/page-runtime": "~0.12.0"
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|
|
28
|
+
"@lingxia/bridge": "file:../lingxia-bridge",
|
|
27
29
|
"@lingxia/page-runtime": "file:../lingxia-page-runtime",
|
|
28
|
-
"rolldown": "^1.
|
|
30
|
+
"rolldown": "^1.2.4",
|
|
29
31
|
"typescript": "^5.7.2"
|
|
30
32
|
},
|
|
31
33
|
"files": [
|