@lynx-js/web-constants 0.15.7 → 0.16.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 +32 -0
- package/dist/constants.d.ts +1 -2
- package/dist/constants.js +1 -7
- package/dist/endpoints.d.ts +9 -1
- package/dist/endpoints.js +3 -0
- package/dist/types/BackThreadStartConfigs.d.ts +0 -2
- package/dist/types/Element.d.ts +1 -1
- package/dist/types/JSRealm.d.ts +5 -0
- package/dist/types/JSRealm.js +2 -0
- package/dist/types/LynxModule.d.ts +2 -0
- package/dist/types/MainThreadGlobalThis.d.ts +10 -6
- package/dist/types/MainThreadLynx.d.ts +4 -0
- package/dist/types/MarkTiming.d.ts +1 -0
- package/dist/types/NativeApp.d.ts +10 -1
- package/dist/types/TemplateLoader.d.ts +2 -0
- package/dist/types/TemplateLoader.js +2 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +2 -0
- package/dist/utils/generateTemplate.js +85 -101
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# @lynx-js/web-constants
|
|
2
2
|
|
|
3
|
+
## 0.16.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- feat: supports lazy bundle. (This feature requires `@lynx-js/lynx-core >= 0.1.3`) ([#1235](https://github.com/lynx-family/lynx-stack/pull/1235))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies []:
|
|
10
|
+
- @lynx-js/web-worker-rpc@0.16.1
|
|
11
|
+
|
|
12
|
+
## 0.16.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- refactor: provide the mts a real globalThis ([#1589](https://github.com/lynx-family/lynx-stack/pull/1589))
|
|
17
|
+
|
|
18
|
+
Before this change, We create a function wrapper and a fake globalThis for Javascript code.
|
|
19
|
+
|
|
20
|
+
This caused some issues.
|
|
21
|
+
|
|
22
|
+
After this change, we will create an iframe for createing an isolated Javascript context.
|
|
23
|
+
|
|
24
|
+
This means the globalThis will be the real one.
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- refactor: add `:not([l-e-name])` at the end of selector for lazy component ([#1622](https://github.com/lynx-family/lynx-stack/pull/1622))
|
|
29
|
+
|
|
30
|
+
- fix: the SystemInfo in bts should be assigned to the globalThis ([#1599](https://github.com/lynx-family/lynx-stack/pull/1599))
|
|
31
|
+
|
|
32
|
+
- Updated dependencies [[`c1f8715`](https://github.com/lynx-family/lynx-stack/commit/c1f8715a81b2e69ff46fc363013626db4468c209)]:
|
|
33
|
+
- @lynx-js/web-worker-rpc@0.16.0
|
|
34
|
+
|
|
3
35
|
## 0.15.7
|
|
4
36
|
|
|
5
37
|
### Patch Changes
|
package/dist/constants.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export declare const lynxUniqueIdAttribute: "l-uid";
|
|
|
2
2
|
export declare const cssIdAttribute: "l-css-id";
|
|
3
3
|
export declare const componentIdAttribute: "l-comp-id";
|
|
4
4
|
export declare const parentComponentUniqueIdAttribute: "l-p-comp-uid";
|
|
5
|
+
export declare const lynxEntryNameAttribute: "l-e-name";
|
|
5
6
|
export declare const lynxTagAttribute: "lynx-tag";
|
|
6
7
|
export declare const lynxDatasetAttribute: "l-dset";
|
|
7
8
|
export declare const lynxComponentConfigAttribute: "l-comp-cfg";
|
|
@@ -11,7 +12,5 @@ export declare const lynxPartIdAttribute: "l-part";
|
|
|
11
12
|
export declare const lynxDefaultDisplayLinearAttribute: "lynx-default-display-linear";
|
|
12
13
|
export declare const lynxDefaultOverflowVisibleAttribute: "lynx-default-overflow-visible";
|
|
13
14
|
export declare const __lynx_timing_flag: "__lynx_timing_flag";
|
|
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
|
@@ -5,6 +5,7 @@ export const lynxUniqueIdAttribute = 'l-uid';
|
|
|
5
5
|
export const cssIdAttribute = 'l-css-id';
|
|
6
6
|
export const componentIdAttribute = 'l-comp-id';
|
|
7
7
|
export const parentComponentUniqueIdAttribute = 'l-p-comp-uid';
|
|
8
|
+
export const lynxEntryNameAttribute = 'l-e-name';
|
|
8
9
|
export const lynxTagAttribute = 'lynx-tag';
|
|
9
10
|
export const lynxDatasetAttribute = 'l-dset';
|
|
10
11
|
export const lynxComponentConfigAttribute = 'l-comp-cfg';
|
|
@@ -14,12 +15,6 @@ export const lynxPartIdAttribute = 'l-part';
|
|
|
14
15
|
export const lynxDefaultDisplayLinearAttribute = 'lynx-default-display-linear';
|
|
15
16
|
export const lynxDefaultOverflowVisibleAttribute = 'lynx-default-overflow-visible';
|
|
16
17
|
export const __lynx_timing_flag = '__lynx_timing_flag';
|
|
17
|
-
export const globalMuteableVars = [
|
|
18
|
-
'registerDataProcessor',
|
|
19
|
-
'registerWorkletInternal',
|
|
20
|
-
'lynxWorkletImpl',
|
|
21
|
-
'runWorklet',
|
|
22
|
-
];
|
|
23
18
|
export const systemInfo = {
|
|
24
19
|
platform: 'web',
|
|
25
20
|
lynxSdkVersion: '3.0',
|
|
@@ -33,5 +28,4 @@ export const inShadowRootStyles = [
|
|
|
33
28
|
overflow: visible;
|
|
34
29
|
}`,
|
|
35
30
|
];
|
|
36
|
-
export const globalDisallowedVars = ['navigator', 'postMessage'];
|
|
37
31
|
//# sourceMappingURL=constants.js.map
|
package/dist/endpoints.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { Cloneable, CloneableObject } from './types/Cloneable.js';
|
|
|
3
3
|
import type { StartMainThreadContextConfig } from './types/MainThreadStartConfigs.js';
|
|
4
4
|
import type { IdentifierType, InvokeCallbackRes } from './types/NativeApp.js';
|
|
5
5
|
import type { ElementAnimationOptions } from './types/Element.js';
|
|
6
|
-
import type { BackMainThreadContextConfig, MarkTiming } from './types/index.js';
|
|
6
|
+
import type { BackMainThreadContextConfig, LynxTemplate, MarkTiming } from './types/index.js';
|
|
7
7
|
export declare const postExposureEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[{
|
|
8
8
|
exposures: ExposureWorkerEvent[];
|
|
9
9
|
disExposures: ExposureWorkerEvent[];
|
|
@@ -57,3 +57,11 @@ export declare const updateGlobalPropsEndpoint: import("@lynx-js/web-worker-rpc/
|
|
|
57
57
|
export declare const updateI18nResourcesEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[Cloneable]>;
|
|
58
58
|
export declare const updateI18nResourceEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[Cloneable]>;
|
|
59
59
|
export declare const dispatchI18nResourceEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[Cloneable]>;
|
|
60
|
+
export declare const queryComponentEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsync<[string], {
|
|
61
|
+
code: number;
|
|
62
|
+
detail: {
|
|
63
|
+
schema: string;
|
|
64
|
+
};
|
|
65
|
+
}>;
|
|
66
|
+
export declare const updateBTSTemplateCacheEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsync<[string, LynxTemplate], void>;
|
|
67
|
+
export declare const loadTemplateMultiThread: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsync<[string], LynxTemplate>;
|
package/dist/endpoints.js
CHANGED
|
@@ -38,4 +38,7 @@ export const updateGlobalPropsEndpoint = createRpcEndpoint('updateGlobalProps',
|
|
|
38
38
|
export const updateI18nResourcesEndpoint = createRpcEndpoint('updateI18nResources', false, false);
|
|
39
39
|
export const updateI18nResourceEndpoint = createRpcEndpoint('updateI18nResource', false, false);
|
|
40
40
|
export const dispatchI18nResourceEndpoint = createRpcEndpoint('dispatchI18nResource', false, false);
|
|
41
|
+
export const queryComponentEndpoint = createRpcEndpoint('queryComponent', false, true);
|
|
42
|
+
export const updateBTSTemplateCacheEndpoint = createRpcEndpoint('updateBTSTemplateCacheEndpoint', false, true);
|
|
43
|
+
export const loadTemplateMultiThread = createRpcEndpoint('loadTemplateMultiThread', false, true);
|
|
41
44
|
//# sourceMappingURL=endpoints.js.map
|
|
@@ -2,7 +2,6 @@ import type { Cloneable } from './Cloneable.js';
|
|
|
2
2
|
import type { LynxTemplate } from './LynxModule.js';
|
|
3
3
|
import type { NapiModulesMap } from './NapiModules.js';
|
|
4
4
|
import type { NativeModulesMap } from './NativeModules.js';
|
|
5
|
-
import type { BrowserConfig } from './PageConfig.js';
|
|
6
5
|
export interface BackMainThreadContextConfig {
|
|
7
6
|
initData: unknown;
|
|
8
7
|
globalProps: unknown;
|
|
@@ -11,5 +10,4 @@ export interface BackMainThreadContextConfig {
|
|
|
11
10
|
customSections: Record<string, Cloneable>;
|
|
12
11
|
nativeModulesMap: NativeModulesMap;
|
|
13
12
|
napiModulesMap: NapiModulesMap;
|
|
14
|
-
browserConfig: BrowserConfig;
|
|
15
13
|
}
|
package/dist/types/Element.d.ts
CHANGED
|
@@ -52,7 +52,7 @@ export interface WebFiberElementImpl {
|
|
|
52
52
|
removeEventListener: (type: string, handler: (ev: Event) => void, options?: {
|
|
53
53
|
capture?: boolean;
|
|
54
54
|
}) => void;
|
|
55
|
-
|
|
55
|
+
textContent: string;
|
|
56
56
|
readonly tagName: string;
|
|
57
57
|
readonly firstElementChild: WebFiberElementImpl | null;
|
|
58
58
|
readonly children: WebFiberElementImpl[];
|
|
@@ -80,7 +80,7 @@ export type AddClassPAPI = (element: WebFiberElementImpl, className: string) =>
|
|
|
80
80
|
export type SetClassesPAPI = (element: WebFiberElementImpl, classNames: string | null) => void;
|
|
81
81
|
export type AddInlineStylePAPI = (element: WebFiberElementImpl, key: number | string, value: string | number | null | undefined) => void;
|
|
82
82
|
export type SetInlineStylesPAPI = (element: WebFiberElementImpl, value: string | Record<string, string> | undefined) => void;
|
|
83
|
-
export type SetCSSIdPAPI = (elements: WebFiberElementImpl[], cssId: number | null) => void;
|
|
83
|
+
export type SetCSSIdPAPI = (elements: WebFiberElementImpl[], cssId: number | null, entryName: string | undefined) => void;
|
|
84
84
|
export type GetPageElementPAPI = () => WebFiberElementImpl | undefined;
|
|
85
85
|
export type MarkTemplateElementPAPI = (element: WebFiberElementImpl) => void;
|
|
86
86
|
export type MarkPartElementPAPI = (element: WebFiberElementImpl, partId: string) => void;
|
|
@@ -90,6 +90,13 @@ interface JSErrorInfo {
|
|
|
90
90
|
}
|
|
91
91
|
export type ElementFromBinaryPAPI = (templateId: string, parentComponentUniId: number) => WebFiberElementImpl[];
|
|
92
92
|
export type GetAttributeByNamePAPI = (element: WebFiberElementImpl, name: string) => string | null;
|
|
93
|
+
export type QueryComponentPAPI = (source: string, resultCallback?: (result: {
|
|
94
|
+
code: number;
|
|
95
|
+
data?: {
|
|
96
|
+
url: string;
|
|
97
|
+
evalResult: unknown;
|
|
98
|
+
};
|
|
99
|
+
}) => void) => null;
|
|
93
100
|
export interface MainThreadGlobalThis {
|
|
94
101
|
__ElementFromBinary: ElementFromBinaryPAPI;
|
|
95
102
|
__GetTemplateParts?: GetTemplatePartsPAPI;
|
|
@@ -161,11 +168,8 @@ export interface MainThreadGlobalThis {
|
|
|
161
168
|
__FlushElementTree: (_subTree: unknown, options: FlushElementTreeOptions) => void;
|
|
162
169
|
_I18nResourceTranslation: (options: I18nResourceTranslationOptions) => unknown | undefined;
|
|
163
170
|
_AddEventListener: (...args: unknown[]) => void;
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
*/
|
|
167
|
-
_updateVars: () => void;
|
|
168
|
-
__lynxGlobalBindingValues: Record<string, unknown>;
|
|
171
|
+
__QueryComponent: QueryComponentPAPI;
|
|
172
|
+
processEvalResult?: (exports: unknown, schema: string) => unknown;
|
|
169
173
|
renderPage: ((data: unknown) => void) | undefined;
|
|
170
174
|
updatePage?: (data: Cloneable, options?: Record<string, string>) => void;
|
|
171
175
|
runWorklet?: (obj: unknown, event: unknown) => void;
|
|
@@ -9,4 +9,8 @@ export interface MainThreadLynx {
|
|
|
9
9
|
getCustomSectionSync: (key: string) => Cloneable;
|
|
10
10
|
markPipelineTiming: (pipelineId: string, timingKey: string) => void;
|
|
11
11
|
SystemInfo: typeof systemInfo;
|
|
12
|
+
setTimeout: typeof setTimeout;
|
|
13
|
+
clearTimeout: typeof clearTimeout;
|
|
14
|
+
setInterval: typeof setInterval;
|
|
15
|
+
clearInterval: typeof clearInterval;
|
|
12
16
|
}
|
|
@@ -82,7 +82,7 @@ export interface NativeApp {
|
|
|
82
82
|
clearInterval: typeof clearInterval;
|
|
83
83
|
requestAnimationFrame: (cb: () => void) => void;
|
|
84
84
|
cancelAnimationFrame: (id: number) => void;
|
|
85
|
-
loadScript: (sourceURL: string) => BundleInitReturnObj;
|
|
85
|
+
loadScript: (sourceURL: string, entryName?: string) => BundleInitReturnObj;
|
|
86
86
|
loadScriptAsync(sourceURL: string, callback: (message: string | null, exports?: BundleInitReturnObj) => void): void;
|
|
87
87
|
nativeModuleProxy: Record<string, any>;
|
|
88
88
|
setNativeProps: (type: IdentifierType, identifier: string, component_id: string, first_only: boolean, native_props: Record<string, unknown>, root_unique_id: number | undefined) => void;
|
|
@@ -125,4 +125,13 @@ export interface NativeApp {
|
|
|
125
125
|
i18nResource: I18nResource;
|
|
126
126
|
reportException: (error: Error, _: unknown) => void;
|
|
127
127
|
__SetSourceMapRelease: (err: Error) => void;
|
|
128
|
+
queryComponent: (source: string, callback: (ret: {
|
|
129
|
+
__hasReady: boolean;
|
|
130
|
+
} | {
|
|
131
|
+
code: number;
|
|
132
|
+
detail?: {
|
|
133
|
+
schema: string;
|
|
134
|
+
};
|
|
135
|
+
}) => void) => void;
|
|
136
|
+
tt: NativeTTObject | null;
|
|
128
137
|
}
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js
CHANGED
|
@@ -1,118 +1,102 @@
|
|
|
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
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
'__AddInlineStyle',
|
|
59
|
-
'__SetInlineStyles',
|
|
60
|
-
'__SetCSSId',
|
|
61
|
-
'__OnLifecycleEvent',
|
|
62
|
-
'__FlushElementTree',
|
|
63
|
-
'__LoadLepusChunk',
|
|
64
|
-
'SystemInfo',
|
|
65
|
-
'_I18nResourceTranslation',
|
|
66
|
-
'_AddEventListener',
|
|
67
|
-
'__GetTemplateParts',
|
|
68
|
-
'__MarkPartElement',
|
|
69
|
-
'__MarkTemplateElement',
|
|
70
|
-
'__GetPageElement',
|
|
71
|
-
'__ElementFromBinary',
|
|
4
|
+
const currentSupportedTemplateVersion = 2;
|
|
5
|
+
const globalDisallowedVars = ['navigator', 'postMessage'];
|
|
6
|
+
const templateUpgraders = [
|
|
7
|
+
(template) => {
|
|
8
|
+
const defaultInjectStr = [
|
|
9
|
+
'Card',
|
|
10
|
+
'setTimeout',
|
|
11
|
+
'setInterval',
|
|
12
|
+
'clearInterval',
|
|
13
|
+
'clearTimeout',
|
|
14
|
+
'NativeModules',
|
|
15
|
+
'Component',
|
|
16
|
+
'ReactLynx',
|
|
17
|
+
'nativeAppId',
|
|
18
|
+
'Behavior',
|
|
19
|
+
'LynxJSBI',
|
|
20
|
+
'lynx',
|
|
21
|
+
// BOM API
|
|
22
|
+
'window',
|
|
23
|
+
'document',
|
|
24
|
+
'frames',
|
|
25
|
+
'location',
|
|
26
|
+
'navigator',
|
|
27
|
+
'localStorage',
|
|
28
|
+
'history',
|
|
29
|
+
'Caches',
|
|
30
|
+
'screen',
|
|
31
|
+
'alert',
|
|
32
|
+
'confirm',
|
|
33
|
+
'prompt',
|
|
34
|
+
'fetch',
|
|
35
|
+
'XMLHttpRequest',
|
|
36
|
+
'__WebSocket__', // We would provide `WebSocket` using `ProvidePlugin`
|
|
37
|
+
'webkit',
|
|
38
|
+
'Reporter',
|
|
39
|
+
'print',
|
|
40
|
+
'global',
|
|
41
|
+
// Lynx API
|
|
42
|
+
'requestAnimationFrame',
|
|
43
|
+
'cancelAnimationFrame',
|
|
44
|
+
].join(',');
|
|
45
|
+
template.appType = template.lepusCode.root.startsWith('(function (globDynamicComponentEntry')
|
|
46
|
+
? 'lazy'
|
|
47
|
+
: 'card';
|
|
48
|
+
/**
|
|
49
|
+
* The template version 1 has no module wrapper for bts code
|
|
50
|
+
*/
|
|
51
|
+
template.manifest = Object.fromEntries(Object.entries(template.manifest).map(([key, value]) => [
|
|
52
|
+
key,
|
|
53
|
+
`module.exports={init: (lynxCoreInject) => { var {${defaultInjectStr}} = lynxCoreInject.tt; var module = {exports:{}}; var exports=module.exports; ${value}\n return module.exports; } }`,
|
|
54
|
+
]));
|
|
55
|
+
template.version = 2;
|
|
56
|
+
return template;
|
|
57
|
+
},
|
|
72
58
|
];
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
'//# allFunctionsCalledOnLoad
|
|
86
|
-
|
|
87
|
-
'
|
|
88
|
-
'
|
|
89
|
-
'
|
|
90
|
-
injectVars.join(','),
|
|
91
|
-
'} = lynx_runtime;',
|
|
92
|
-
...injectWithBind.map(nm => `const ${nm} = lynx_runtime.${nm}?.bind(lynx_runtime);`),
|
|
93
|
-
';var globDynamicComponentEntry = \'__Card__\';',
|
|
94
|
-
globalDisallowedVars.length !== 0
|
|
95
|
-
? `var ${globalDisallowedVars.join('=')}=undefined;`
|
|
96
|
-
: '',
|
|
97
|
-
'var {__globalProps} = lynx;',
|
|
98
|
-
'lynx_runtime._updateVars=()=>{',
|
|
99
|
-
...muteableVars.map(nm => `${nm} = lynx_runtime.__lynxGlobalBindingValues.${nm};`),
|
|
100
|
-
'};\n',
|
|
59
|
+
const generateModuleContent = (content, eager, appType) =>
|
|
60
|
+
/**
|
|
61
|
+
* About the `allFunctionsCalledOnLoad` directive:
|
|
62
|
+
* https://v8.dev/blog/preparser#pife
|
|
63
|
+
* https://github.com/WICG/explicit-javascript-compile-hints-file-based?tab=readme-ov-file
|
|
64
|
+
* https://v8.dev/blog/explicit-compile-hints
|
|
65
|
+
* We should ensure the MTS code is parsed eagerly to avoid runtime parse delay.
|
|
66
|
+
* But for BTS code, we should not do this as it would increase the memory usage.
|
|
67
|
+
* JavaScript Engines, like V8, already had optimizations for code starts with "(function"
|
|
68
|
+
* to be parsed eagerly.
|
|
69
|
+
*/
|
|
70
|
+
[
|
|
71
|
+
eager ? '//# allFunctionsCalledOnLoad' : '',
|
|
72
|
+
'\n(function() { "use strict"; const ',
|
|
73
|
+
globalDisallowedVars.join('=void 0,'),
|
|
74
|
+
'=void 0;\n',
|
|
75
|
+
appType === 'lazy' ? 'module.exports=\n' : '',
|
|
101
76
|
content,
|
|
102
|
-
'\n
|
|
77
|
+
'\n})()',
|
|
103
78
|
].join('');
|
|
104
|
-
async function generateJavascriptUrl(obj,
|
|
79
|
+
async function generateJavascriptUrl(obj, createJsModuleUrl, eager, appType, templateName) {
|
|
105
80
|
const processEntry = async ([name, content]) => [
|
|
106
81
|
name,
|
|
107
|
-
await createJsModuleUrl(generateModuleContent(content,
|
|
82
|
+
await createJsModuleUrl(generateModuleContent(content, eager, appType), `${templateName}-${name.replaceAll('/', '')}.js`),
|
|
108
83
|
];
|
|
109
84
|
return Promise.all(Object.entries(obj).filter(([_, content]) => typeof content === 'string').map(processEntry)).then(Object.fromEntries);
|
|
110
85
|
}
|
|
111
86
|
export async function generateTemplate(template, createJsModuleUrl, templateName) {
|
|
87
|
+
template.version = template.version ?? 1;
|
|
88
|
+
if (template.version > currentSupportedTemplateVersion) {
|
|
89
|
+
throw new Error(`Unsupported template, please upgrade your web-platform dependencies`);
|
|
90
|
+
}
|
|
91
|
+
let upgrader;
|
|
92
|
+
while (template.version < currentSupportedTemplateVersion
|
|
93
|
+
&& (upgrader = templateUpgraders[template.version - 1])) {
|
|
94
|
+
template = upgrader(template);
|
|
95
|
+
}
|
|
112
96
|
return {
|
|
113
97
|
...template,
|
|
114
|
-
lepusCode: await generateJavascriptUrl(template.lepusCode,
|
|
115
|
-
manifest: await generateJavascriptUrl(template.manifest,
|
|
98
|
+
lepusCode: await generateJavascriptUrl(template.lepusCode, createJsModuleUrl, true, template.appType, templateName),
|
|
99
|
+
manifest: await generateJavascriptUrl(template.manifest, createJsModuleUrl, false, template.appType, templateName),
|
|
116
100
|
};
|
|
117
101
|
}
|
|
118
102
|
//# sourceMappingURL=generateTemplate.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/web-constants",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [],
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"**/*.css"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@lynx-js/web-worker-rpc": "0.
|
|
26
|
+
"@lynx-js/web-worker-rpc": "0.16.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@lynx-js/offscreen-document": "0.1.
|
|
29
|
+
"@lynx-js/offscreen-document": "0.1.4"
|
|
30
30
|
}
|
|
31
31
|
}
|