@lynx-js/web-constants 0.15.5 → 0.15.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/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # @lynx-js/web-constants
2
2
 
3
+ ## 0.15.7
4
+
5
+ ### Patch Changes
6
+
7
+ - fix: globalThis is never accessible in MTS ([#1531](https://github.com/lynx-family/lynx-stack/pull/1531))
8
+
9
+ - Updated dependencies []:
10
+ - @lynx-js/web-worker-rpc@0.15.7
11
+
12
+ ## 0.15.6
13
+
14
+ ### Patch Changes
15
+
16
+ - fix: systeminfo in mts function ([#1537](https://github.com/lynx-family/lynx-stack/pull/1537))
17
+
18
+ - feat: add MTS API: \_\_UpdateComponentInfo ([#1485](https://github.com/lynx-family/lynx-stack/pull/1485))
19
+
20
+ - fix: `__ElementFromBinary` needs to correctly apply the dataset in elementTemplate to the Element ([#1487](https://github.com/lynx-family/lynx-stack/pull/1487))
21
+
22
+ - fix: all attributes except `id` and `type` under ElementTemplateData are optional. ([#1483](https://github.com/lynx-family/lynx-stack/pull/1483))
23
+
24
+ - feat: add MTS API \_\_GetAttributeByName ([#1486](https://github.com/lynx-family/lynx-stack/pull/1486))
25
+
26
+ - Updated dependencies []:
27
+ - @lynx-js/web-worker-rpc@0.15.6
28
+
3
29
  ## 0.15.5
4
30
 
5
31
  ### Patch Changes
@@ -14,3 +14,4 @@ export declare const __lynx_timing_flag: "__lynx_timing_flag";
14
14
  export declare const globalMuteableVars: readonly ["registerDataProcessor", "registerWorkletInternal", "lynxWorkletImpl", "runWorklet"];
15
15
  export declare const systemInfo: Record<string, string | number>;
16
16
  export declare const inShadowRootStyles: string[];
17
+ export declare const globalDisallowedVars: string[];
package/dist/constants.js CHANGED
@@ -33,4 +33,5 @@ export const inShadowRootStyles = [
33
33
  overflow: visible;
34
34
  }`,
35
35
  ];
36
+ export const globalDisallowedVars = ['navigator', 'postMessage'];
36
37
  //# sourceMappingURL=constants.js.map
@@ -5,16 +5,17 @@ import type { StyleInfo } from './StyleInfo.js';
5
5
  export type ElementTemplateData = {
6
6
  id: string;
7
7
  type: string;
8
- class: string[];
9
- idSelector: string;
10
- attributes: Record<string, string>;
11
- builtinAttributes: Record<string, string>;
12
- children: ElementTemplateData[];
13
- events: {
8
+ idSelector?: string;
9
+ class?: string[];
10
+ attributes?: Record<string, string>;
11
+ builtinAttributes?: Record<string, string>;
12
+ children?: ElementTemplateData[];
13
+ events?: {
14
14
  type: LynxEventType;
15
15
  name: string;
16
16
  value: string;
17
17
  }[];
18
+ dataset?: Record<string, string>;
18
19
  };
19
20
  export interface LynxTemplate {
20
21
  styleInfo: StyleInfo;
@@ -47,6 +47,13 @@ export type SetConfigPAPI = (element: WebFiberElementImpl, config: Record<string
47
47
  export type SetDatasetPAPI = (element: WebFiberElementImpl, dataset: Record<string, Cloneable>) => void;
48
48
  export type SetIDPAPI = (element: WebFiberElementImpl, id: string | null) => void;
49
49
  export type UpdateComponentIDPAPI = (element: WebFiberElementImpl, componentID: string) => void;
50
+ export type UpdateComponentInfoPAPI = (element: WebFiberElementImpl, params: {
51
+ componentID?: string;
52
+ name?: string;
53
+ path?: string;
54
+ entry?: string;
55
+ cssID?: number;
56
+ }) => void;
50
57
  export type GetClassesPAPI = (element: WebFiberElementImpl) => string[];
51
58
  export type CreateViewPAPI = (parentComponentUniqueID: number) => WebFiberElementImpl;
52
59
  export type SwapElementPAPI = (childA: WebFiberElementImpl, childB: WebFiberElementImpl) => void;
@@ -82,6 +89,7 @@ interface JSErrorInfo {
82
89
  release: string;
83
90
  }
84
91
  export type ElementFromBinaryPAPI = (templateId: string, parentComponentUniId: number) => WebFiberElementImpl[];
92
+ export type GetAttributeByNamePAPI = (element: WebFiberElementImpl, name: string) => string | null;
85
93
  export interface MainThreadGlobalThis {
86
94
  __ElementFromBinary: ElementFromBinaryPAPI;
87
95
  __GetTemplateParts?: GetTemplatePartsPAPI;
@@ -117,6 +125,7 @@ export interface MainThreadGlobalThis {
117
125
  __SetDataset: SetDatasetPAPI;
118
126
  __SetID: SetIDPAPI;
119
127
  __UpdateComponentID: UpdateComponentIDPAPI;
128
+ __UpdateComponentInfo: UpdateComponentInfoPAPI;
120
129
  __GetClasses: GetClassesPAPI;
121
130
  __CreateView: CreateViewPAPI;
122
131
  __SwapElement: SwapElementPAPI;
@@ -137,6 +146,7 @@ export interface MainThreadGlobalThis {
137
146
  __SetInlineStyles: SetInlineStylesPAPI;
138
147
  __SetCSSId: SetCSSIdPAPI;
139
148
  __GetPageElement: GetPageElementPAPI;
149
+ __GetAttributeByName: GetAttributeByNamePAPI;
140
150
  __globalProps: unknown;
141
151
  SystemInfo: typeof systemInfo;
142
152
  globalThis?: MainThreadGlobalThis;
@@ -1,3 +1,4 @@
1
+ import type { systemInfo } from '../constants.js';
1
2
  import type { Cloneable } from './Cloneable.js';
2
3
  import type { LynxContextEventTarget } from './LynxContextEventTarget.js';
3
4
  export interface MainThreadLynx {
@@ -7,4 +8,5 @@ export interface MainThreadLynx {
7
8
  __globalProps: unknown;
8
9
  getCustomSectionSync: (key: string) => Cloneable;
9
10
  markPipelineTiming: (pipelineId: string, timingKey: string) => void;
11
+ SystemInfo: typeof systemInfo;
10
12
  }
@@ -1,7 +1,7 @@
1
1
  // Copyright 2023 The Lynx Authors. All rights reserved.
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
- import { globalMuteableVars } from '../constants.js';
4
+ import { globalDisallowedVars, globalMuteableVars } from '../constants.js';
5
5
  const mainThreadInjectVars = [
6
6
  'lynx',
7
7
  'globalThis',
@@ -22,7 +22,9 @@ const mainThreadInjectVars = [
22
22
  '__SetDataset',
23
23
  '__SetID',
24
24
  '__UpdateComponentID',
25
+ '__UpdateComponentInfo',
25
26
  '__GetConfig',
27
+ '__GetAttributeByName',
26
28
  '__UpdateListCallbacks',
27
29
  '__AppendElement',
28
30
  '__ElementIsEqual',
@@ -79,7 +81,7 @@ const backgroundInjectWithBind = [
79
81
  'Card',
80
82
  'Component',
81
83
  ];
82
- const generateModuleContent = (content, injectVars, injectWithBind, muteableVars, isESM) => [
84
+ const generateModuleContent = (content, injectVars, injectWithBind, muteableVars, globalDisallowedVars, isESM) => [
83
85
  '//# allFunctionsCalledOnLoad\n',
84
86
  isESM ? 'export default ' : 'globalThis.module.exports =',
85
87
  'function(lynx_runtime) {',
@@ -89,6 +91,9 @@ const generateModuleContent = (content, injectVars, injectWithBind, muteableVars
89
91
  '} = lynx_runtime;',
90
92
  ...injectWithBind.map(nm => `const ${nm} = lynx_runtime.${nm}?.bind(lynx_runtime);`),
91
93
  ';var globDynamicComponentEntry = \'__Card__\';',
94
+ globalDisallowedVars.length !== 0
95
+ ? `var ${globalDisallowedVars.join('=')}=undefined;`
96
+ : '',
92
97
  'var {__globalProps} = lynx;',
93
98
  'lynx_runtime._updateVars=()=>{',
94
99
  ...muteableVars.map(nm => `${nm} = lynx_runtime.__lynxGlobalBindingValues.${nm};`),
@@ -96,18 +101,18 @@ const generateModuleContent = (content, injectVars, injectWithBind, muteableVars
96
101
  content,
97
102
  '\n return module.exports;}',
98
103
  ].join('');
99
- async function generateJavascriptUrl(obj, injectVars, injectWithBind, muteableVars, createJsModuleUrl, isESM, templateName) {
104
+ async function generateJavascriptUrl(obj, injectVars, injectWithBind, muteableVars, globalDisallowedVars, createJsModuleUrl, isESM, templateName) {
100
105
  const processEntry = async ([name, content]) => [
101
106
  name,
102
- await createJsModuleUrl(generateModuleContent(content, injectVars.concat(muteableVars), injectWithBind, muteableVars, isESM), `${templateName}-${name.replaceAll('/', '')}.js`),
107
+ await createJsModuleUrl(generateModuleContent(content, injectVars.concat(muteableVars), injectWithBind, muteableVars, globalDisallowedVars, isESM), `${templateName}-${name.replaceAll('/', '')}.js`),
103
108
  ];
104
109
  return Promise.all(Object.entries(obj).filter(([_, content]) => typeof content === 'string').map(processEntry)).then(Object.fromEntries);
105
110
  }
106
111
  export async function generateTemplate(template, createJsModuleUrl, templateName) {
107
112
  return {
108
113
  ...template,
109
- lepusCode: await generateJavascriptUrl(template.lepusCode, mainThreadInjectVars, [], globalMuteableVars, createJsModuleUrl, true, templateName),
110
- manifest: await generateJavascriptUrl(template.manifest, backgroundInjectVars, backgroundInjectWithBind, [], createJsModuleUrl, false, templateName),
114
+ lepusCode: await generateJavascriptUrl(template.lepusCode, mainThreadInjectVars, [], globalMuteableVars, templateName ? [] : globalDisallowedVars, createJsModuleUrl, true, templateName),
115
+ manifest: await generateJavascriptUrl(template.manifest, backgroundInjectVars, backgroundInjectWithBind, [], templateName ? [] : globalDisallowedVars, createJsModuleUrl, false, templateName),
111
116
  };
112
117
  }
113
118
  //# sourceMappingURL=generateTemplate.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/web-constants",
3
- "version": "0.15.5",
3
+ "version": "0.15.7",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [],
@@ -23,7 +23,7 @@
23
23
  "**/*.css"
24
24
  ],
25
25
  "dependencies": {
26
- "@lynx-js/web-worker-rpc": "0.15.5"
26
+ "@lynx-js/web-worker-rpc": "0.15.7"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@lynx-js/offscreen-document": "0.1.3"