@blueking/bk-weweb 0.0.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/dist/collect-source.js +2139 -0
- package/dist/collect-source.js.map +1 -0
- package/dist/index.esm.js +2106 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.min.js +2 -0
- package/dist/index.min.js.map +1 -0
- package/dist/index.umd.js +2 -0
- package/dist/index.umd.js.map +1 -0
- package/package.json +82 -0
- package/readme.md +33 -0
- package/typings/base-app/base-element.d.ts +6 -0
- package/typings/base-app/collect-source.d.ts +1 -0
- package/typings/cache/app-cache.d.ts +19 -0
- package/typings/common/index.d.ts +1 -0
- package/typings/common/state.d.ts +11 -0
- package/typings/component/web-compnent.d.ts +26 -0
- package/typings/context/document.d.ts +2 -0
- package/typings/context/element.d.ts +2 -0
- package/typings/context/function.d.ts +1 -0
- package/typings/context/memory.d.ts +10 -0
- package/typings/context/sandbox.d.ts +17 -0
- package/typings/context/window.d.ts +9 -0
- package/typings/entry/entry.d.ts +28 -0
- package/typings/entry/script.d.ts +22 -0
- package/typings/entry/style.d.ts +22 -0
- package/typings/index.d.ts +19 -0
- package/typings/lifecircle/activated.d.ts +2 -0
- package/typings/lifecircle/before-load.d.ts +1 -0
- package/typings/lifecircle/deactivated.d.ts +1 -0
- package/typings/lifecircle/load.d.ts +6 -0
- package/typings/lifecircle/mount.d.ts +2 -0
- package/typings/lifecircle/unload.d.ts +1 -0
- package/typings/lifecircle/unmount.d.ts +1 -0
- package/typings/mode/app.d.ts +37 -0
- package/typings/mode/instance.d.ts +32 -0
- package/typings/preload/preload.d.ts +5 -0
- package/typings/typings/global.d.ts +17 -0
- package/typings/typings/index.d.ts +10 -0
- package/typings/typings/model.d.ts +64 -0
- package/typings/typings/sandbox.d.ts +18 -0
- package/typings/typings/source.d.ts +23 -0
- package/typings/utils/common.d.ts +18 -0
- package/typings/utils/element-event.d.ts +2 -0
- package/typings/utils/element.d.ts +6 -0
- package/typings/utils/fetch.d.ts +1 -0
- package/typings/utils/index.d.ts +4 -0
- package/typings/utils/load-source.d.ts +12 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BaseModel, IScriptOption } from '../typings';
|
|
2
|
+
export declare class Script {
|
|
3
|
+
code: string;
|
|
4
|
+
async: boolean;
|
|
5
|
+
defer: boolean;
|
|
6
|
+
isModule: boolean;
|
|
7
|
+
url: string | undefined;
|
|
8
|
+
exportInstance?: any;
|
|
9
|
+
scoped: boolean;
|
|
10
|
+
fromHtml: boolean;
|
|
11
|
+
initial: boolean;
|
|
12
|
+
constructor({ code, async, defer, isModule, url, fromHtml, initial }: IScriptOption);
|
|
13
|
+
getCode(app?: BaseModel): Promise<string>;
|
|
14
|
+
excuteCode(app: BaseModel, needRelaceScriptElement?: boolean): Promise<HTMLScriptElement | Comment | undefined>;
|
|
15
|
+
transformCode(app: BaseModel): string;
|
|
16
|
+
executeSourceScript(scriptElement: HTMLScriptElement, scopedCode: string): void;
|
|
17
|
+
executeMemoryScript(app: BaseModel, scopedCode: string): void;
|
|
18
|
+
}
|
|
19
|
+
export declare function shouldSkipProperty(global: Window, p: any): boolean;
|
|
20
|
+
export declare function getGlobalProp(global: Window, useFirstGlobalProp?: boolean): string | undefined;
|
|
21
|
+
export declare function noteGlobalProps(global: Window): string | undefined;
|
|
22
|
+
export declare function execAppScripts(app: BaseModel): Promise<void>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BaseModel, IStyleOption } from '../typings';
|
|
2
|
+
export declare class Style {
|
|
3
|
+
scopedCode: string;
|
|
4
|
+
code: string;
|
|
5
|
+
prefetch: boolean;
|
|
6
|
+
preload: boolean;
|
|
7
|
+
url: string | undefined;
|
|
8
|
+
scoped: boolean;
|
|
9
|
+
fromHtml: boolean;
|
|
10
|
+
initial: boolean;
|
|
11
|
+
constructor({ code, prefetch, preload, url, fromHtml, initial }: IStyleOption);
|
|
12
|
+
getCode(app?: BaseModel): Promise<string>;
|
|
13
|
+
excuteCode(app: BaseModel): Promise<HTMLStyleElement>;
|
|
14
|
+
scopedStyleCSS(app: BaseModel, styleElement: HTMLStyleElement): HTMLStyleElement;
|
|
15
|
+
scopedLinkCSS(app: BaseModel, linkElement: HTMLLinkElement): HTMLStyleElement;
|
|
16
|
+
commonScoped(templateStyle: HTMLStyleElement, styleElement: HTMLStyleElement, app: BaseModel): void;
|
|
17
|
+
scopeRule(rules: CSSRule[], cssPrefix: string): string;
|
|
18
|
+
resetPackRule(rule: CSSMediaRule | CSSSupportsRule, prefix: string, packName: string): string;
|
|
19
|
+
resetUrlHost(cssText: string, baseURI: string, linkpath?: string): string;
|
|
20
|
+
scopeStyleRule(rule: CSSStyleRule, prefix: string): string;
|
|
21
|
+
}
|
|
22
|
+
export declare function excuteAppStyles(app: BaseModel, container?: Element | ShadowRoot): Promise<void>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import './context/memory';
|
|
2
|
+
import { FetchSourceType, IStartOption } from './typings';
|
|
3
|
+
export * from './lifecircle/before-load';
|
|
4
|
+
export * from './lifecircle/load';
|
|
5
|
+
export * from './lifecircle/mount';
|
|
6
|
+
export * from './lifecircle/unload';
|
|
7
|
+
export * from './lifecircle/unmount';
|
|
8
|
+
export * from './lifecircle/activated';
|
|
9
|
+
export * from './lifecircle/deactivated';
|
|
10
|
+
export * from './preload/preload';
|
|
11
|
+
export declare class IframeApp {
|
|
12
|
+
fetchSource?: FetchSourceType;
|
|
13
|
+
webcomponentTag: string;
|
|
14
|
+
constructor();
|
|
15
|
+
start(option?: IStartOption): void;
|
|
16
|
+
setWebComponentTag(): void;
|
|
17
|
+
}
|
|
18
|
+
declare const iframeApp: IframeApp;
|
|
19
|
+
export default iframeApp;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function beforeLoad(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function deactivated(appKey: string): void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { MicroAppModel } from '../mode/app';
|
|
2
|
+
import { BaseModel, IAppModleProps, IBaseModelProps, IJsModelProps } from '../typings';
|
|
3
|
+
import { MicroInstanceModel } from '../mode/instance';
|
|
4
|
+
export declare function load(props: IBaseModelProps): Promise<BaseModel>;
|
|
5
|
+
export declare function loadApp(props: IAppModleProps): Promise<MicroAppModel>;
|
|
6
|
+
export declare function loadInstance(props: IJsModelProps): Promise<MicroInstanceModel>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function unload(url: string): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function unmount(appKey: string): void;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { AppState } from '../common';
|
|
2
|
+
import { EntrySource } from '../entry/entry';
|
|
3
|
+
import { AppMode, BaseModel, IAppModleProps } from '../typings';
|
|
4
|
+
import SandBox from '../context/sandbox';
|
|
5
|
+
import { SourceType } from '../utils/load-source';
|
|
6
|
+
export declare class MicroAppModel implements BaseModel {
|
|
7
|
+
private state;
|
|
8
|
+
isPreLoad: boolean;
|
|
9
|
+
mode: AppMode;
|
|
10
|
+
name: string;
|
|
11
|
+
url: string;
|
|
12
|
+
container?: HTMLElement | ShadowRoot;
|
|
13
|
+
showSourceCode: boolean;
|
|
14
|
+
scopeCss: boolean;
|
|
15
|
+
scopeJs: boolean;
|
|
16
|
+
source?: EntrySource;
|
|
17
|
+
sandBox?: SandBox;
|
|
18
|
+
scopeLocation: boolean;
|
|
19
|
+
keepAlive: boolean;
|
|
20
|
+
initSource: SourceType;
|
|
21
|
+
iframe: HTMLIFrameElement | null;
|
|
22
|
+
data: Record<string, unknown>;
|
|
23
|
+
constructor(props: IAppModleProps);
|
|
24
|
+
get appCacheKey(): string;
|
|
25
|
+
get status(): AppState;
|
|
26
|
+
set status(v: AppState);
|
|
27
|
+
start(): Promise<void>;
|
|
28
|
+
onMount(): void;
|
|
29
|
+
onError(): void;
|
|
30
|
+
mount(container?: HTMLElement | ShadowRoot, callback?: (app: BaseModel) => void): void;
|
|
31
|
+
activated(container: HTMLElement | ShadowRoot, callback?: (app: BaseModel) => void): void;
|
|
32
|
+
deactivated(): void;
|
|
33
|
+
unmount(needDestroy?: boolean): void;
|
|
34
|
+
createIframe(): Promise<HTMLIFrameElement>;
|
|
35
|
+
registerRunningApp(): void;
|
|
36
|
+
}
|
|
37
|
+
export declare const createApp: (props: IAppModleProps) => void;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { AppState } from '../common';
|
|
2
|
+
import SandBox from '../context/sandbox';
|
|
3
|
+
import { EntrySource } from '../entry/entry';
|
|
4
|
+
import { BaseModel, IJsModelProps } from '../typings';
|
|
5
|
+
import { SourceType } from '../utils/load-source';
|
|
6
|
+
export declare class MicroInstanceModel implements BaseModel {
|
|
7
|
+
private state;
|
|
8
|
+
isPreLoad: boolean;
|
|
9
|
+
appCacheKey: string;
|
|
10
|
+
url: string;
|
|
11
|
+
container?: HTMLElement | ShadowRoot;
|
|
12
|
+
scopeJs: boolean;
|
|
13
|
+
source?: EntrySource;
|
|
14
|
+
sandBox?: SandBox;
|
|
15
|
+
name: string;
|
|
16
|
+
showSourceCode: boolean;
|
|
17
|
+
scopeCss: boolean;
|
|
18
|
+
keepAlive: boolean;
|
|
19
|
+
initSource: SourceType;
|
|
20
|
+
data: Record<string, unknown>;
|
|
21
|
+
constructor(props: IJsModelProps);
|
|
22
|
+
get status(): AppState;
|
|
23
|
+
set status(v: AppState);
|
|
24
|
+
start(): Promise<void>;
|
|
25
|
+
onMount(): void;
|
|
26
|
+
onError(): void;
|
|
27
|
+
mount<T>(container?: HTMLElement | ShadowRoot, callback?: (instance: MicroInstanceModel, exportInstance: T) => void): void;
|
|
28
|
+
activated<T>(container: HTMLElement | ShadowRoot, callback?: (instance: BaseModel, exportInstance?: T) => void): void;
|
|
29
|
+
deactivated(): void;
|
|
30
|
+
unmount(needDestroy?: boolean): void;
|
|
31
|
+
registerRunningApp(): void;
|
|
32
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { IAppModleProps, IJsModelProps } from '../typings';
|
|
2
|
+
import { SourceType } from '../utils/load-source';
|
|
3
|
+
export declare function preLoadInstance(options: IJsModelProps): void;
|
|
4
|
+
export declare function preLoadApp(options: IAppModleProps): void;
|
|
5
|
+
export declare function preLoadSource(sourceList: SourceType): void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AppCache } from '../cache/app-cache';
|
|
2
|
+
import { BaseModel } from './model';
|
|
3
|
+
export {};
|
|
4
|
+
declare global {
|
|
5
|
+
interface Window {
|
|
6
|
+
__POWERED_BY_BK_WEWEB__?: boolean;
|
|
7
|
+
__BK_WEWEB_APP_KEY__?: string;
|
|
8
|
+
__getAppOrInstance__(id?: string): AppCache | BaseModel | undefined;
|
|
9
|
+
Zone?: Function;
|
|
10
|
+
requestIdleCallback(callback: Function, options?: unknown | undefined): number;
|
|
11
|
+
}
|
|
12
|
+
interface Node {
|
|
13
|
+
__BK_WEWEB_APP_KEY__?: string;
|
|
14
|
+
__KEEP_ALIVE__?: string;
|
|
15
|
+
data?: any;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './global';
|
|
2
|
+
export * from './source';
|
|
3
|
+
export * from './sandbox';
|
|
4
|
+
export * from './model';
|
|
5
|
+
export declare type AppMode = 'app' | 'config' | 'js';
|
|
6
|
+
export declare type FetchSourceType = (url: string, options: Record<string, unknown>) => Promise<string>;
|
|
7
|
+
export interface IStartOption {
|
|
8
|
+
fetchSource?: FetchSourceType;
|
|
9
|
+
webcomponentTag?: string;
|
|
10
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { AppMode } from '.';
|
|
2
|
+
import { AppState } from '../common';
|
|
3
|
+
import { ObserveAttrs } from '../component/web-compnent';
|
|
4
|
+
import SandBox from '../context/sandbox';
|
|
5
|
+
import { EntrySource } from '../entry/entry';
|
|
6
|
+
import { SourceType } from '../utils/load-source';
|
|
7
|
+
export interface IComponentProps {
|
|
8
|
+
[ObserveAttrs.URL]: string;
|
|
9
|
+
[ObserveAttrs.showSourceCode]?: boolean;
|
|
10
|
+
[ObserveAttrs.scopeLocation]?: boolean;
|
|
11
|
+
[ObserveAttrs.setShodowDom]?: boolean;
|
|
12
|
+
[ObserveAttrs.mode]?: AppMode;
|
|
13
|
+
[ObserveAttrs.data]?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface IBaseModelProps {
|
|
16
|
+
[ObserveAttrs.mode]?: AppMode;
|
|
17
|
+
[ObserveAttrs.URL]: string;
|
|
18
|
+
isPreLoad?: boolean;
|
|
19
|
+
id?: string | null;
|
|
20
|
+
}
|
|
21
|
+
export interface IAppModleProps extends IBaseModelProps {
|
|
22
|
+
container?: HTMLElement | ShadowRoot | null;
|
|
23
|
+
scopeCss?: boolean;
|
|
24
|
+
scopeJs?: boolean;
|
|
25
|
+
keepAlive?: boolean;
|
|
26
|
+
[ObserveAttrs.showSourceCode]?: boolean;
|
|
27
|
+
[ObserveAttrs.scopeLocation]?: boolean;
|
|
28
|
+
[ObserveAttrs.setShodowDom]?: boolean;
|
|
29
|
+
[ObserveAttrs.data]?: Record<string, unknown>;
|
|
30
|
+
initSource?: SourceType;
|
|
31
|
+
}
|
|
32
|
+
export interface IJsModelProps extends IBaseModelProps {
|
|
33
|
+
container?: HTMLElement | ShadowRoot | null;
|
|
34
|
+
scopeJs?: boolean;
|
|
35
|
+
scopeCss?: boolean;
|
|
36
|
+
keepAlive?: boolean;
|
|
37
|
+
[ObserveAttrs.showSourceCode]?: boolean;
|
|
38
|
+
[ObserveAttrs.data]?: Record<string, unknown>;
|
|
39
|
+
initSource?: SourceType;
|
|
40
|
+
}
|
|
41
|
+
export interface BaseModel {
|
|
42
|
+
url: string;
|
|
43
|
+
container?: HTMLElement | ShadowRoot;
|
|
44
|
+
source?: EntrySource;
|
|
45
|
+
sandBox?: SandBox;
|
|
46
|
+
isPreLoad: boolean;
|
|
47
|
+
showSourceCode?: boolean;
|
|
48
|
+
name: string;
|
|
49
|
+
scopeCss?: boolean;
|
|
50
|
+
scopeJs: boolean;
|
|
51
|
+
keepAlive?: boolean;
|
|
52
|
+
initSource?: SourceType;
|
|
53
|
+
get appCacheKey(): string;
|
|
54
|
+
get status(): AppState;
|
|
55
|
+
set status(v: AppState);
|
|
56
|
+
start(): Promise<void>;
|
|
57
|
+
onMount(): void;
|
|
58
|
+
onError(): void;
|
|
59
|
+
mount<T>(container?: HTMLElement | ShadowRoot, callback?: (instance: BaseModel, exportInstance?: T) => void): void;
|
|
60
|
+
activated<T>(container: HTMLElement | ShadowRoot, callback?: (instance: BaseModel, exportInstance?: T) => void): void;
|
|
61
|
+
deactivated(): void;
|
|
62
|
+
unmount(needDestroy?: boolean): void;
|
|
63
|
+
registerRunningApp(): void;
|
|
64
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface IInjectWindowAttrs {
|
|
2
|
+
__POWERED_BY_BK_WEWEB__: boolean;
|
|
3
|
+
__BK_WEWEB_APP_KEY__: string;
|
|
4
|
+
__BK_WEWEB_DATA__: Record<string, unknown>;
|
|
5
|
+
rawWindow: Window;
|
|
6
|
+
rawDocument: Document;
|
|
7
|
+
}
|
|
8
|
+
export declare const commonEScapeKeyList: PropertyKey[];
|
|
9
|
+
export declare const escapeSetterKeyList: PropertyKey[];
|
|
10
|
+
export declare const scopeWindowKeyList: PropertyKey[];
|
|
11
|
+
export declare const scopedLocationKeyList: PropertyKey[];
|
|
12
|
+
export declare enum DescriptorMapValue {
|
|
13
|
+
'TARGET' = "TARGET",
|
|
14
|
+
'WINDOW' = "WINDOW"
|
|
15
|
+
}
|
|
16
|
+
export declare const commonRawWindowKeyMap: any;
|
|
17
|
+
export declare const commonFakeWindowKeyMap: any;
|
|
18
|
+
export declare const commonWindowNameMap: any;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface IStyleOption {
|
|
2
|
+
code: string;
|
|
3
|
+
prefetch?: boolean;
|
|
4
|
+
preload?: boolean;
|
|
5
|
+
url?: string;
|
|
6
|
+
fromHtml: boolean;
|
|
7
|
+
initial?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface IScriptOption {
|
|
10
|
+
code: string;
|
|
11
|
+
async: boolean;
|
|
12
|
+
defer: boolean;
|
|
13
|
+
isModule: boolean;
|
|
14
|
+
url?: string;
|
|
15
|
+
fromHtml: boolean;
|
|
16
|
+
initial?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare const CSS_ATTRIBUTE_KEY = "id";
|
|
19
|
+
export declare enum CSS_RULE_TYPE {
|
|
20
|
+
STYLE_RULE = 1,
|
|
21
|
+
MEDIA_RULE = 4,
|
|
22
|
+
SUPPORTS_RULE = 12
|
|
23
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare function isFunction(target: unknown): boolean;
|
|
2
|
+
export declare const nextTask: (cb: () => void) => any;
|
|
3
|
+
export declare function nextTick(cb: () => void): void;
|
|
4
|
+
export declare function addUrlProtocol(url: string): string;
|
|
5
|
+
export declare function getUrlDir(url: string): string;
|
|
6
|
+
export declare function fillUpPath(path: string, baseURI: string): string;
|
|
7
|
+
export declare function getFileDir(linkpath: string): string;
|
|
8
|
+
export declare const isIE11: boolean;
|
|
9
|
+
export declare function randomUrl(): string;
|
|
10
|
+
export declare function arrayUnique(array: any[]): any[];
|
|
11
|
+
export declare const requestIdleCallback: {
|
|
12
|
+
(callback: IdleRequestCallback, options?: IdleRequestOptions | undefined): number;
|
|
13
|
+
(callback: Function, options?: unknown): number;
|
|
14
|
+
} & typeof globalThis.requestIdleCallback;
|
|
15
|
+
export declare function isSafari(): boolean;
|
|
16
|
+
export declare function createElement<K extends keyof HTMLElementTagNameMap>(tagName: K, options?: ElementCreationOptions): HTMLElementTagNameMap[K];
|
|
17
|
+
export declare function isBodyElement(key: string): boolean;
|
|
18
|
+
export declare const random: (n: number, str?: string) => string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { BaseModel } from '../typings';
|
|
2
|
+
export declare function resetNewElement(parent: Node, child: Node, app: BaseModel): Node;
|
|
3
|
+
export declare function isSepcailElement(node: Node): boolean;
|
|
4
|
+
export declare function elmentAppendHandler(parent: Node, newChild: Node, rawMethod: Function): any;
|
|
5
|
+
export declare function elementInsertHandler(parent: Node, newChild: Node, passiveChild: Node | null, rawMethod: Function): any;
|
|
6
|
+
export declare function setMarkElement<T extends Element>(element: T, app: BaseModel, keepAlive: boolean): T;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function fetchSource(url: string, options?: {}): Promise<string>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Script } from '../entry/script';
|
|
2
|
+
import { Style } from '../entry/style';
|
|
3
|
+
export declare type SourceFuncType = () => Promise<string[]>;
|
|
4
|
+
export declare type SourceType = string[] | SourceFuncType;
|
|
5
|
+
export declare function collectSource(soruceList: SourceType): Promise<{
|
|
6
|
+
collectScript?: undefined;
|
|
7
|
+
collectStyle?: undefined;
|
|
8
|
+
} | {
|
|
9
|
+
collectScript: Map<string, Script>;
|
|
10
|
+
collectStyle: Map<string, Style>;
|
|
11
|
+
}>;
|
|
12
|
+
export declare function LoadGlobalSource(soruceList: SourceType): Promise<void>;
|