@weapp-vite/web 0.0.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/LICENSE +21 -0
- package/README.md +51 -0
- package/dist/index.cjs +15772 -0
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.mjs +15747 -0
- package/dist/plugin-D_a0z32j.d.cts +24 -0
- package/dist/plugin-D_a0z32j.d.ts +24 -0
- package/dist/plugin.cjs +14634 -0
- package/dist/plugin.d.cts +2 -0
- package/dist/plugin.d.ts +2 -0
- package/dist/plugin.mjs +14624 -0
- package/dist/runtime/index.cjs +1155 -0
- package/dist/runtime/index.d.cts +89 -0
- package/dist/runtime/index.d.ts +89 -0
- package/dist/runtime/index.mjs +1115 -0
- package/package.json +58 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { ChildNode } from 'domhandler';
|
|
2
|
+
|
|
3
|
+
type TemplateScope = Record<string, any>;
|
|
4
|
+
type TemplateRenderer = (scope?: TemplateScope) => string;
|
|
5
|
+
declare function renderTemplate(nodes: ChildNode[], scope?: TemplateScope): string;
|
|
6
|
+
declare function createTemplate(source: string): TemplateRenderer;
|
|
7
|
+
|
|
8
|
+
type DataRecord = Record<string, any>;
|
|
9
|
+
interface PropertyOption {
|
|
10
|
+
type?: StringConstructor | NumberConstructor | BooleanConstructor | ObjectConstructor | ArrayConstructor | null;
|
|
11
|
+
value?: any;
|
|
12
|
+
observer?: (this: ComponentPublicInstance, newValue: any, oldValue: any) => void;
|
|
13
|
+
}
|
|
14
|
+
interface LifeTimeHooks {
|
|
15
|
+
created?: (this: ComponentPublicInstance) => void;
|
|
16
|
+
attached?: (this: ComponentPublicInstance) => void;
|
|
17
|
+
ready?: (this: ComponentPublicInstance) => void;
|
|
18
|
+
detached?: (this: ComponentPublicInstance) => void;
|
|
19
|
+
}
|
|
20
|
+
interface ComponentOptions {
|
|
21
|
+
properties?: Record<string, PropertyOption>;
|
|
22
|
+
data?: DataRecord | (() => DataRecord);
|
|
23
|
+
methods?: Record<string, (this: ComponentPublicInstance, event: any) => any>;
|
|
24
|
+
lifetimes?: LifeTimeHooks;
|
|
25
|
+
}
|
|
26
|
+
interface DefineComponentOptions {
|
|
27
|
+
template: TemplateRenderer;
|
|
28
|
+
style?: string;
|
|
29
|
+
component?: ComponentOptions;
|
|
30
|
+
}
|
|
31
|
+
interface ComponentPublicInstance extends HTMLElement {
|
|
32
|
+
readonly data: DataRecord;
|
|
33
|
+
readonly properties: DataRecord;
|
|
34
|
+
setData: (patch: DataRecord) => void;
|
|
35
|
+
triggerEvent: (name: string, detail?: any) => void;
|
|
36
|
+
}
|
|
37
|
+
declare function defineComponent(tagName: string, options: DefineComponentOptions): CustomElementConstructor;
|
|
38
|
+
|
|
39
|
+
interface RegisterMeta {
|
|
40
|
+
id: string;
|
|
41
|
+
template?: TemplateRenderer;
|
|
42
|
+
style?: string;
|
|
43
|
+
}
|
|
44
|
+
interface PageHooks {
|
|
45
|
+
onLoad?: (this: ComponentPublicInstance, query: Record<string, string>) => void;
|
|
46
|
+
onReady?: (this: ComponentPublicInstance) => void;
|
|
47
|
+
onShow?: (this: ComponentPublicInstance) => void;
|
|
48
|
+
onHide?: (this: ComponentPublicInstance) => void;
|
|
49
|
+
onUnload?: (this: ComponentPublicInstance) => void;
|
|
50
|
+
}
|
|
51
|
+
interface AppLifecycleHooks {
|
|
52
|
+
onLaunch?: (this: AppRuntime, options: AppLaunchOptions) => void;
|
|
53
|
+
onShow?: (this: AppRuntime, options: AppLaunchOptions) => void;
|
|
54
|
+
}
|
|
55
|
+
type AppRuntime = Record<string, unknown> & Partial<AppLifecycleHooks> & {
|
|
56
|
+
globalData?: Record<string, unknown>;
|
|
57
|
+
};
|
|
58
|
+
interface AppLaunchOptions {
|
|
59
|
+
path: string;
|
|
60
|
+
scene: number;
|
|
61
|
+
query: Record<string, string>;
|
|
62
|
+
referrerInfo: Record<string, unknown>;
|
|
63
|
+
}
|
|
64
|
+
type PageRawOptions = ComponentOptions & PageHooks & Record<string, unknown>;
|
|
65
|
+
type ComponentRawOptions = ComponentOptions & Record<string, unknown>;
|
|
66
|
+
declare function initializePageRoutes(ids: string[]): void;
|
|
67
|
+
declare function registerPage<T extends PageRawOptions | undefined>(options: T, meta: RegisterMeta): T;
|
|
68
|
+
declare function registerComponent<T extends ComponentRawOptions | undefined>(options: T, meta: RegisterMeta): T;
|
|
69
|
+
declare function registerApp<T extends AppRuntime | undefined>(options: T, _meta?: RegisterMeta): T;
|
|
70
|
+
declare function navigateTo(options: {
|
|
71
|
+
url: string;
|
|
72
|
+
}): Promise<void>;
|
|
73
|
+
declare function redirectTo(options: {
|
|
74
|
+
url: string;
|
|
75
|
+
}): Promise<void>;
|
|
76
|
+
declare function reLaunch(options: {
|
|
77
|
+
url: string;
|
|
78
|
+
}): Promise<void>;
|
|
79
|
+
declare function switchTab(options: {
|
|
80
|
+
url: string;
|
|
81
|
+
}): Promise<void>;
|
|
82
|
+
declare function navigateBack(options?: {
|
|
83
|
+
delta?: number;
|
|
84
|
+
}): Promise<void>;
|
|
85
|
+
|
|
86
|
+
declare function removeStyle(id: string): void;
|
|
87
|
+
declare function injectStyle(css: string, id?: string): () => void;
|
|
88
|
+
|
|
89
|
+
export { type TemplateRenderer, type TemplateScope, createTemplate, defineComponent, initializePageRoutes, injectStyle, navigateBack, navigateTo, reLaunch, redirectTo, registerApp, registerComponent, registerPage, removeStyle, renderTemplate, switchTab };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { ChildNode } from 'domhandler';
|
|
2
|
+
|
|
3
|
+
type TemplateScope = Record<string, any>;
|
|
4
|
+
type TemplateRenderer = (scope?: TemplateScope) => string;
|
|
5
|
+
declare function renderTemplate(nodes: ChildNode[], scope?: TemplateScope): string;
|
|
6
|
+
declare function createTemplate(source: string): TemplateRenderer;
|
|
7
|
+
|
|
8
|
+
type DataRecord = Record<string, any>;
|
|
9
|
+
interface PropertyOption {
|
|
10
|
+
type?: StringConstructor | NumberConstructor | BooleanConstructor | ObjectConstructor | ArrayConstructor | null;
|
|
11
|
+
value?: any;
|
|
12
|
+
observer?: (this: ComponentPublicInstance, newValue: any, oldValue: any) => void;
|
|
13
|
+
}
|
|
14
|
+
interface LifeTimeHooks {
|
|
15
|
+
created?: (this: ComponentPublicInstance) => void;
|
|
16
|
+
attached?: (this: ComponentPublicInstance) => void;
|
|
17
|
+
ready?: (this: ComponentPublicInstance) => void;
|
|
18
|
+
detached?: (this: ComponentPublicInstance) => void;
|
|
19
|
+
}
|
|
20
|
+
interface ComponentOptions {
|
|
21
|
+
properties?: Record<string, PropertyOption>;
|
|
22
|
+
data?: DataRecord | (() => DataRecord);
|
|
23
|
+
methods?: Record<string, (this: ComponentPublicInstance, event: any) => any>;
|
|
24
|
+
lifetimes?: LifeTimeHooks;
|
|
25
|
+
}
|
|
26
|
+
interface DefineComponentOptions {
|
|
27
|
+
template: TemplateRenderer;
|
|
28
|
+
style?: string;
|
|
29
|
+
component?: ComponentOptions;
|
|
30
|
+
}
|
|
31
|
+
interface ComponentPublicInstance extends HTMLElement {
|
|
32
|
+
readonly data: DataRecord;
|
|
33
|
+
readonly properties: DataRecord;
|
|
34
|
+
setData: (patch: DataRecord) => void;
|
|
35
|
+
triggerEvent: (name: string, detail?: any) => void;
|
|
36
|
+
}
|
|
37
|
+
declare function defineComponent(tagName: string, options: DefineComponentOptions): CustomElementConstructor;
|
|
38
|
+
|
|
39
|
+
interface RegisterMeta {
|
|
40
|
+
id: string;
|
|
41
|
+
template?: TemplateRenderer;
|
|
42
|
+
style?: string;
|
|
43
|
+
}
|
|
44
|
+
interface PageHooks {
|
|
45
|
+
onLoad?: (this: ComponentPublicInstance, query: Record<string, string>) => void;
|
|
46
|
+
onReady?: (this: ComponentPublicInstance) => void;
|
|
47
|
+
onShow?: (this: ComponentPublicInstance) => void;
|
|
48
|
+
onHide?: (this: ComponentPublicInstance) => void;
|
|
49
|
+
onUnload?: (this: ComponentPublicInstance) => void;
|
|
50
|
+
}
|
|
51
|
+
interface AppLifecycleHooks {
|
|
52
|
+
onLaunch?: (this: AppRuntime, options: AppLaunchOptions) => void;
|
|
53
|
+
onShow?: (this: AppRuntime, options: AppLaunchOptions) => void;
|
|
54
|
+
}
|
|
55
|
+
type AppRuntime = Record<string, unknown> & Partial<AppLifecycleHooks> & {
|
|
56
|
+
globalData?: Record<string, unknown>;
|
|
57
|
+
};
|
|
58
|
+
interface AppLaunchOptions {
|
|
59
|
+
path: string;
|
|
60
|
+
scene: number;
|
|
61
|
+
query: Record<string, string>;
|
|
62
|
+
referrerInfo: Record<string, unknown>;
|
|
63
|
+
}
|
|
64
|
+
type PageRawOptions = ComponentOptions & PageHooks & Record<string, unknown>;
|
|
65
|
+
type ComponentRawOptions = ComponentOptions & Record<string, unknown>;
|
|
66
|
+
declare function initializePageRoutes(ids: string[]): void;
|
|
67
|
+
declare function registerPage<T extends PageRawOptions | undefined>(options: T, meta: RegisterMeta): T;
|
|
68
|
+
declare function registerComponent<T extends ComponentRawOptions | undefined>(options: T, meta: RegisterMeta): T;
|
|
69
|
+
declare function registerApp<T extends AppRuntime | undefined>(options: T, _meta?: RegisterMeta): T;
|
|
70
|
+
declare function navigateTo(options: {
|
|
71
|
+
url: string;
|
|
72
|
+
}): Promise<void>;
|
|
73
|
+
declare function redirectTo(options: {
|
|
74
|
+
url: string;
|
|
75
|
+
}): Promise<void>;
|
|
76
|
+
declare function reLaunch(options: {
|
|
77
|
+
url: string;
|
|
78
|
+
}): Promise<void>;
|
|
79
|
+
declare function switchTab(options: {
|
|
80
|
+
url: string;
|
|
81
|
+
}): Promise<void>;
|
|
82
|
+
declare function navigateBack(options?: {
|
|
83
|
+
delta?: number;
|
|
84
|
+
}): Promise<void>;
|
|
85
|
+
|
|
86
|
+
declare function removeStyle(id: string): void;
|
|
87
|
+
declare function injectStyle(css: string, id?: string): () => void;
|
|
88
|
+
|
|
89
|
+
export { type TemplateRenderer, type TemplateScope, createTemplate, defineComponent, initializePageRoutes, injectStyle, navigateBack, navigateTo, reLaunch, redirectTo, registerApp, registerComponent, registerPage, removeStyle, renderTemplate, switchTab };
|