@lynx-js/web-core 0.13.0 → 0.13.2

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 CHANGED
@@ -1,5 +1,76 @@
1
1
  # @lynx-js/web-core
2
2
 
3
+ ## 0.13.2
4
+
5
+ ### Patch Changes
6
+
7
+ - feat: allow lynx code to get JS engine provided properties on globalThis ([#786](https://github.com/lynx-family/lynx-stack/pull/786))
8
+
9
+ ```
10
+ globalThis.Reflect; // this will be the Reflect Object
11
+ ```
12
+
13
+ Note that `assigning to the globalThis` is still not allowed.
14
+
15
+ - perf: use v8 hint for generated javascript file ([#807](https://github.com/lynx-family/lynx-stack/pull/807))
16
+
17
+ https://v8.dev/blog/explicit-compile-hints
18
+
19
+ - feat: add new property `inject-style-rules` for LynxView ([#785](https://github.com/lynx-family/lynx-stack/pull/785))
20
+
21
+ This property allows developer to inject some style rules into the shadowroot.
22
+
23
+ It's a wrapper of https://developer.mozilla.org/docs/Web/API/CSSStyleSheet/insertRule
24
+
25
+ - fix: corrupt mainthread module cache ([#806](https://github.com/lynx-family/lynx-stack/pull/806))
26
+
27
+ - Updated dependencies [[`03a5f64`](https://github.com/lynx-family/lynx-stack/commit/03a5f64d7d09e38903f5d1c022f36f6e68b6432d), [`6d3d852`](https://github.com/lynx-family/lynx-stack/commit/6d3d8529d0d528419920102ca52da279bbe0f1e0), [`8cdd288`](https://github.com/lynx-family/lynx-stack/commit/8cdd28884288b9456aee3a919d6edbf72da1c67b), [`6d3d852`](https://github.com/lynx-family/lynx-stack/commit/6d3d8529d0d528419920102ca52da279bbe0f1e0)]:
28
+ - @lynx-js/web-mainthread-apis@0.13.2
29
+ - @lynx-js/web-worker-runtime@0.13.2
30
+ - @lynx-js/web-constants@0.13.2
31
+ - @lynx-js/offscreen-document@0.0.3
32
+ - @lynx-js/web-worker-rpc@0.13.2
33
+
34
+ ## 0.13.1
35
+
36
+ ### Patch Changes
37
+
38
+ - fix: some inline style properties cause crash ([#647](https://github.com/lynx-family/lynx-stack/pull/647))
39
+
40
+ add support for the following css properties
41
+
42
+ - mask
43
+ - mask-repeat
44
+ - mask-position
45
+ - mask-clip
46
+ - mask-origin
47
+ - mask-size
48
+ - gap
49
+ - column-gap
50
+ - row-gap
51
+ - image-rendering
52
+ - hyphens
53
+ - offset-path
54
+ - offset-distance
55
+
56
+ - feat: support touch events for MTS ([#641](https://github.com/lynx-family/lynx-stack/pull/641))
57
+
58
+ now we support
59
+
60
+ - main-thread:bindtouchstart
61
+ - main-thread:bindtouchend
62
+ - main-thread:bindtouchmove
63
+ - main-thread:bindtouchcancel
64
+
65
+ - feat: add SystemInfo.screenWidth and SystemInfo.screenHeight ([#641](https://github.com/lynx-family/lynx-stack/pull/641))
66
+
67
+ - Updated dependencies [[`c9ccad6`](https://github.com/lynx-family/lynx-stack/commit/c9ccad6b574c98121149d3e9d4a9a7e97af63d91), [`9ad394e`](https://github.com/lynx-family/lynx-stack/commit/9ad394ea9ef28688a3b810b4051868b2a28eb7de), [`f4cfb70`](https://github.com/lynx-family/lynx-stack/commit/f4cfb70606d46cd4017254c326095432f9c6bcb8), [`c9ccad6`](https://github.com/lynx-family/lynx-stack/commit/c9ccad6b574c98121149d3e9d4a9a7e97af63d91), [`839d61c`](https://github.com/lynx-family/lynx-stack/commit/839d61c8a329ed1e265fe2edc12a702e9592f743)]:
68
+ - @lynx-js/offscreen-document@0.0.2
69
+ - @lynx-js/web-mainthread-apis@0.13.1
70
+ - @lynx-js/web-worker-runtime@0.13.1
71
+ - @lynx-js/web-constants@0.13.1
72
+ - @lynx-js/web-worker-rpc@0.13.1
73
+
3
74
  ## 0.13.0
4
75
 
5
76
  ### Patch Changes
@@ -20,7 +20,8 @@ export type INapiModulesCall = (name: string, data: any, moduleName: string, lyn
20
20
  * @property {"auto" | null} width [optional] (attribute: "width") set it to "auto" for width auto-sizing
21
21
  * @property {NapiModulesMap} napiModulesMap [optional] the napiModule which is called in lynx-core. key is module-name, value is esm url.
22
22
  * @property {INapiModulesCall} onNapiModulesCall [optional] the NapiModule value handler.
23
- * @property {"false" | "true" | null} injectHeadLinks [optional] @default true set it to "false" to disable injecting the <link href="" ref="stylesheet"> styles into shadowroot
23
+ * @property {"false" | "true" | null} injectHeadLinks [optional] (attribute: "inject-head-links") @default true set it to "false" to disable injecting the <link href="" ref="stylesheet"> styles into shadowroot
24
+ * @property {string[]} injectStyleRules [optional] the css rules which will be injected into shadowroot. Each items will be inserted by `insertRule` method. @see https://developer.mozilla.org/docs/Web/API/CSSStyleSheet/insertRule
24
25
  * @property {number} lynxGroupId [optional] (attribute: "lynx-group-id") the background shared context id, which is used to share webworker between different lynx cards
25
26
  * @property {"all-on-ui" | "multi-thread"} threadStrategy [optional] @default "multi-thread" (attribute: "thread-strategy") controls the thread strategy for current lynx view
26
27
  * @property {(string)=>Promise<LynxTemplate>} customTemplateLoader [optional] the custom template loader, which is used to load the template
@@ -146,6 +147,9 @@ export declare class LynxView extends HTMLElement {
146
147
  */
147
148
  get threadStrategy(): 'all-on-ui' | 'multi-thread';
148
149
  set threadStrategy(val: 'all-on-ui' | 'multi-thread');
150
+ get injectHeadLinks(): boolean;
151
+ set injectHeadLinks(val: boolean);
152
+ injectStyleRules: string[];
149
153
  /**
150
154
  * @private
151
155
  */
@@ -2,8 +2,7 @@
2
2
  // Licensed under the Apache License Version 2.0 that can be found in the
3
3
  // LICENSE file in the root directory of this source tree.
4
4
  import { createLynxView, } from './createLynxView.js';
5
- import {} from '@lynx-js/web-constants';
6
- import { inShadowRootStyles } from './inShadowRootStyles.js';
5
+ import { inShadowRootStyles, } from '@lynx-js/web-constants';
7
6
  /**
8
7
  * Based on our experiences, these elements are almost used in all lynx cards.
9
8
  */
@@ -18,7 +17,8 @@ import { inShadowRootStyles } from './inShadowRootStyles.js';
18
17
  * @property {"auto" | null} width [optional] (attribute: "width") set it to "auto" for width auto-sizing
19
18
  * @property {NapiModulesMap} napiModulesMap [optional] the napiModule which is called in lynx-core. key is module-name, value is esm url.
20
19
  * @property {INapiModulesCall} onNapiModulesCall [optional] the NapiModule value handler.
21
- * @property {"false" | "true" | null} injectHeadLinks [optional] @default true set it to "false" to disable injecting the <link href="" ref="stylesheet"> styles into shadowroot
20
+ * @property {"false" | "true" | null} injectHeadLinks [optional] (attribute: "inject-head-links") @default true set it to "false" to disable injecting the <link href="" ref="stylesheet"> styles into shadowroot
21
+ * @property {string[]} injectStyleRules [optional] the css rules which will be injected into shadowroot. Each items will be inserted by `insertRule` method. @see https://developer.mozilla.org/docs/Web/API/CSSStyleSheet/insertRule
22
22
  * @property {number} lynxGroupId [optional] (attribute: "lynx-group-id") the background shared context id, which is used to share webworker between different lynx cards
23
23
  * @property {"all-on-ui" | "multi-thread"} threadStrategy [optional] @default "multi-thread" (attribute: "thread-strategy") controls the thread strategy for current lynx view
24
24
  * @property {(string)=>Promise<LynxTemplate>} customTemplateLoader [optional] the custom template loader, which is used to load the template
@@ -260,6 +260,18 @@ export class LynxView extends HTMLElement {
260
260
  this.removeAttribute('thread-strategy');
261
261
  }
262
262
  }
263
+ get injectHeadLinks() {
264
+ return this.getAttribute('inject-head-links') !== 'false';
265
+ }
266
+ set injectHeadLinks(val) {
267
+ if (val) {
268
+ this.setAttribute('inject-head-links', 'true');
269
+ }
270
+ else {
271
+ this.removeAttribute('inject-head-links');
272
+ }
273
+ }
274
+ injectStyleRules = [];
263
275
  /**
264
276
  * @private
265
277
  */
@@ -344,6 +356,9 @@ export class LynxView extends HTMLElement {
344
356
  for (const rule of inShadowRootStyles) {
345
357
  styleSheet.insertRule(rule);
346
358
  }
359
+ for (const rule of this.injectStyleRules) {
360
+ styleSheet.insertRule(rule);
361
+ }
347
362
  const injectHeadLinks = this.getAttribute('inject-head-links') !== 'false';
348
363
  if (injectHeadLinks) {
349
364
  document.head.querySelectorAll('link[rel="stylesheet"]').forEach((linkElement) => {
@@ -2,6 +2,9 @@
2
2
  // Licensed under the Apache License Version 2.0 that can be found in the
3
3
  // LICENSE file in the root directory of this source tree.
4
4
  import { startUIThread, } from '../uiThread/startUIThread.js';
5
+ const pixelRatio = window.devicePixelRatio;
6
+ const screenWidth = window.screen.availWidth * pixelRatio;
7
+ const screenHeight = window.screen.availHeight * pixelRatio;
5
8
  export function createLynxView(configs) {
6
9
  const { shadowRoot, callbacks, templateUrl, globalProps, initData, nativeModulesMap, napiModulesMap, tagMap, lynxGroupId, threadStrategy = 'multi-thread', } = configs;
7
10
  return startUIThread(templateUrl, {
@@ -12,6 +15,8 @@ export function createLynxView(configs) {
12
15
  napiModulesMap,
13
16
  browserConfig: {
14
17
  pixelRatio: window.devicePixelRatio,
18
+ pixelWidth: screenWidth,
19
+ pixelHeight: screenHeight,
15
20
  },
16
21
  }, shadowRoot, lynxGroupId, threadStrategy, callbacks);
17
22
  }
@@ -9,6 +9,7 @@ function generateJavascriptUrl(obj, injectVars, injectWithBind, muteableVars) {
9
9
  return [
10
10
  name,
11
11
  createJsModuleUrl([
12
+ '//# allFunctionsCalledOnLoad\n',
12
13
  'globalThis.module.exports = function(lynx_runtime) {',
13
14
  'const module= {exports:{}};let exports = module.exports;',
14
15
  'var {',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/web-core",
3
- "version": "0.13.0",
3
+ "version": "0.13.2",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [],
@@ -24,15 +24,15 @@
24
24
  "**/*.css"
25
25
  ],
26
26
  "dependencies": {
27
- "@lynx-js/offscreen-document": "0.0.1",
28
- "@lynx-js/web-constants": "0.13.0",
29
- "@lynx-js/web-mainthread-apis": "0.13.0",
30
- "@lynx-js/web-worker-rpc": "0.13.0",
31
- "@lynx-js/web-worker-runtime": "0.13.0"
27
+ "@lynx-js/offscreen-document": "0.0.3",
28
+ "@lynx-js/web-constants": "0.13.2",
29
+ "@lynx-js/web-mainthread-apis": "0.13.2",
30
+ "@lynx-js/web-worker-rpc": "0.13.2",
31
+ "@lynx-js/web-worker-runtime": "0.13.2"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@lynx-js/lynx-core": "0.1.2",
35
- "@lynx-js/web-elements": "0.7.0"
35
+ "@lynx-js/web-elements": "0.7.2"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "@lynx-js/lynx-core": "0.1.2",
@@ -1 +0,0 @@
1
- export declare const inShadowRootStyles: string[];
@@ -1,10 +0,0 @@
1
- export const inShadowRootStyles = [
2
- ` [lynx-default-display-linear="false"] * {
3
- --lynx-display: flex;
4
- --lynx-display-toggle: var(--lynx-display-flex);
5
- }`,
6
- `[lynx-default-overflow-visible="true"] x-view{
7
- overflow: visible;
8
- }`,
9
- ];
10
- //# sourceMappingURL=inShadowRootStyles.js.map