@weapp-vite/web 1.3.15 → 1.3.17
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/README.md +2 -2
- package/dist/_virtual/_rolldown/runtime.mjs +18 -0
- package/dist/compiler/wxml/attributes.mjs +93 -0
- package/dist/compiler/wxml/attributes.mjs.map +1 -0
- package/dist/compiler/wxml/compile.mjs +158 -0
- package/dist/compiler/wxml/compile.mjs.map +1 -0
- package/dist/compiler/wxml/dependency.mjs +31 -0
- package/dist/compiler/wxml/dependency.mjs.map +1 -0
- package/dist/compiler/wxml/interpolation.mjs +142 -0
- package/dist/compiler/wxml/interpolation.mjs.map +1 -0
- package/dist/compiler/wxml/navigation.mjs +85 -0
- package/dist/compiler/wxml/navigation.mjs.map +1 -0
- package/dist/compiler/wxml/parser.mjs +41 -0
- package/dist/compiler/wxml/parser.mjs.map +1 -0
- package/dist/compiler/wxml/renderer.mjs +114 -0
- package/dist/compiler/wxml/renderer.mjs.map +1 -0
- package/dist/compiler/wxml/specialNodes.mjs +85 -0
- package/dist/compiler/wxml/specialNodes.mjs.map +1 -0
- package/dist/compiler/wxs.mjs +83 -0
- package/dist/compiler/wxs.mjs.map +1 -0
- package/dist/css/wxss.d.mts +25 -0
- package/dist/css/wxss.mjs +17 -0
- package/dist/css/wxss.mjs.map +1 -0
- package/dist/index.d.mts +18 -2
- package/dist/index.mjs +18 -3
- package/dist/plugin/constants.mjs +43 -0
- package/dist/plugin/constants.mjs.map +1 -0
- package/dist/plugin/entry.mjs +29 -0
- package/dist/plugin/entry.mjs.map +1 -0
- package/dist/plugin/files.mjs +58 -0
- package/dist/plugin/files.mjs.map +1 -0
- package/dist/plugin/index.d.mts +33 -0
- package/dist/plugin/index.mjs +188 -0
- package/dist/plugin/index.mjs.map +1 -0
- package/dist/plugin/navigation.mjs +20 -0
- package/dist/plugin/navigation.mjs.map +1 -0
- package/dist/plugin/path.mjs +85 -0
- package/dist/plugin/path.mjs.map +1 -0
- package/dist/plugin/register.mjs +83 -0
- package/dist/plugin/register.mjs.map +1 -0
- package/dist/plugin/scan.mjs +195 -0
- package/dist/plugin/scan.mjs.map +1 -0
- package/dist/plugin/scanConfig.mjs +45 -0
- package/dist/plugin/scanConfig.mjs.map +1 -0
- package/dist/plugin/state.mjs +22 -0
- package/dist/plugin/state.mjs.map +1 -0
- package/dist/plugin/types.d.mts +46 -0
- package/dist/plugin.d.mts +3 -2
- package/dist/plugin.mjs +3 -2
- package/dist/runtime/button/helpers.mjs +92 -0
- package/dist/runtime/button/helpers.mjs.map +1 -0
- package/dist/runtime/button/index.d.mts +9 -0
- package/dist/runtime/button/index.mjs +198 -0
- package/dist/runtime/button/index.mjs.map +1 -0
- package/dist/runtime/button/style.mjs +168 -0
- package/dist/runtime/button/style.mjs.map +1 -0
- package/dist/runtime/component/behavior.mjs +98 -0
- package/dist/runtime/component/behavior.mjs.map +1 -0
- package/dist/runtime/component/constants.mjs +13 -0
- package/dist/runtime/component/constants.mjs.map +1 -0
- package/dist/runtime/component/dom.mjs +32 -0
- package/dist/runtime/component/dom.mjs.map +1 -0
- package/dist/runtime/component/element.mjs +208 -0
- package/dist/runtime/component/element.mjs.map +1 -0
- package/dist/runtime/component/events.mjs +49 -0
- package/dist/runtime/component/events.mjs.map +1 -0
- package/dist/runtime/component/index.d.mts +7 -0
- package/dist/runtime/component/index.mjs +44 -0
- package/dist/runtime/component/index.mjs.map +1 -0
- package/dist/runtime/component/state.mjs +63 -0
- package/dist/runtime/component/state.mjs.map +1 -0
- package/dist/runtime/component/types.d.mts +49 -0
- package/dist/runtime/component/utils.mjs +39 -0
- package/dist/runtime/component/utils.mjs.map +1 -0
- package/dist/runtime/execution.d.mts +7 -0
- package/dist/runtime/execution.mjs +37 -0
- package/dist/runtime/execution.mjs.map +1 -0
- package/dist/runtime/index.d.mts +16 -2
- package/dist/runtime/index.mjs +16 -2
- package/dist/runtime/legacyTemplate/dom.mjs +76 -0
- package/dist/runtime/legacyTemplate/dom.mjs.map +1 -0
- package/dist/runtime/legacyTemplate/expression.mjs +113 -0
- package/dist/runtime/legacyTemplate/expression.mjs.map +1 -0
- package/dist/runtime/legacyTemplate/index.d.mts +9 -0
- package/dist/runtime/legacyTemplate/index.mjs +132 -0
- package/dist/runtime/legacyTemplate/index.mjs.map +1 -0
- package/dist/runtime/legacyTemplate/types.d.mts +6 -0
- package/dist/runtime/navigationBar/index.d.mts +10 -0
- package/dist/runtime/navigationBar/index.mjs +162 -0
- package/dist/runtime/navigationBar/index.mjs.map +1 -0
- package/dist/runtime/navigationBar/style.mjs +108 -0
- package/dist/runtime/navigationBar/style.mjs.map +1 -0
- package/dist/runtime/polyfill/ad.mjs +150 -0
- package/dist/runtime/polyfill/ad.mjs.map +1 -0
- package/dist/runtime/polyfill/appState.mjs +31 -0
- package/dist/runtime/polyfill/appState.mjs.map +1 -0
- package/dist/runtime/polyfill/async.mjs +31 -0
- package/dist/runtime/polyfill/async.mjs.map +1 -0
- package/dist/runtime/polyfill/auth.mjs +120 -0
- package/dist/runtime/polyfill/auth.mjs.map +1 -0
- package/dist/runtime/polyfill/authApi.mjs +101 -0
- package/dist/runtime/polyfill/authApi.mjs.map +1 -0
- package/dist/runtime/polyfill/background.mjs +31 -0
- package/dist/runtime/polyfill/background.mjs.map +1 -0
- package/dist/runtime/polyfill/canvasContext.mjs +115 -0
- package/dist/runtime/polyfill/canvasContext.mjs.map +1 -0
- package/dist/runtime/polyfill/capability.mjs +20 -0
- package/dist/runtime/polyfill/capability.mjs.map +1 -0
- package/dist/runtime/polyfill/cloud.mjs +39 -0
- package/dist/runtime/polyfill/cloud.mjs.map +1 -0
- package/dist/runtime/polyfill/device.mjs +44 -0
- package/dist/runtime/polyfill/device.mjs.map +1 -0
- package/dist/runtime/polyfill/deviceApi.mjs +31 -0
- package/dist/runtime/polyfill/deviceApi.mjs.map +1 -0
- package/dist/runtime/polyfill/deviceAuthSystemApi.d.mts +102 -0
- package/dist/runtime/polyfill/deviceAuthSystemApi.mjs +144 -0
- package/dist/runtime/polyfill/deviceAuthSystemApi.mjs.map +1 -0
- package/dist/runtime/polyfill/filePicker.mjs +158 -0
- package/dist/runtime/polyfill/filePicker.mjs.map +1 -0
- package/dist/runtime/polyfill/fileSystemManager.mjs +45 -0
- package/dist/runtime/polyfill/fileSystemManager.mjs.map +1 -0
- package/dist/runtime/polyfill/files.mjs +118 -0
- package/dist/runtime/polyfill/files.mjs.map +1 -0
- package/dist/runtime/polyfill/index.d.mts +40 -0
- package/dist/runtime/polyfill/index.mjs +110 -0
- package/dist/runtime/polyfill/index.mjs.map +1 -0
- package/dist/runtime/polyfill/interaction.mjs +38 -0
- package/dist/runtime/polyfill/interaction.mjs.map +1 -0
- package/dist/runtime/polyfill/interactionApi.mjs +54 -0
- package/dist/runtime/polyfill/interactionApi.mjs.map +1 -0
- package/dist/runtime/polyfill/location.mjs +106 -0
- package/dist/runtime/polyfill/location.mjs.map +1 -0
- package/dist/runtime/polyfill/locationApi.mjs +120 -0
- package/dist/runtime/polyfill/locationApi.mjs.map +1 -0
- package/dist/runtime/polyfill/mediaActions.mjs +52 -0
- package/dist/runtime/polyfill/mediaActions.mjs.map +1 -0
- package/dist/runtime/polyfill/mediaApi/file.mjs +63 -0
- package/dist/runtime/polyfill/mediaApi/file.mjs.map +1 -0
- package/dist/runtime/polyfill/mediaApi/info.mjs +59 -0
- package/dist/runtime/polyfill/mediaApi/info.mjs.map +1 -0
- package/dist/runtime/polyfill/mediaApi/picker.mjs +82 -0
- package/dist/runtime/polyfill/mediaApi/picker.mjs.map +1 -0
- package/dist/runtime/polyfill/mediaApi/preview.mjs +39 -0
- package/dist/runtime/polyfill/mediaApi/preview.mjs.map +1 -0
- package/dist/runtime/polyfill/mediaApi/process.mjs +46 -0
- package/dist/runtime/polyfill/mediaApi/process.mjs.map +1 -0
- package/dist/runtime/polyfill/mediaInfo.mjs +136 -0
- package/dist/runtime/polyfill/mediaInfo.mjs.map +1 -0
- package/dist/runtime/polyfill/mediaPicker.mjs +213 -0
- package/dist/runtime/polyfill/mediaPicker.mjs.map +1 -0
- package/dist/runtime/polyfill/mediaProcess.mjs +65 -0
- package/dist/runtime/polyfill/mediaProcess.mjs.map +1 -0
- package/dist/runtime/polyfill/menuApi.mjs +70 -0
- package/dist/runtime/polyfill/menuApi.mjs.map +1 -0
- package/dist/runtime/polyfill/navigationBarRuntime.mjs +66 -0
- package/dist/runtime/polyfill/navigationBarRuntime.mjs.map +1 -0
- package/dist/runtime/polyfill/network/request.mjs +162 -0
- package/dist/runtime/polyfill/network/request.mjs.map +1 -0
- package/dist/runtime/polyfill/network/requestBridge.mjs +49 -0
- package/dist/runtime/polyfill/network/requestBridge.mjs.map +1 -0
- package/dist/runtime/polyfill/network/status.mjs +55 -0
- package/dist/runtime/polyfill/network/status.mjs.map +1 -0
- package/dist/runtime/polyfill/platformApi.mjs +33 -0
- package/dist/runtime/polyfill/platformApi.mjs.map +1 -0
- package/dist/runtime/polyfill/platformRuntime.mjs +120 -0
- package/dist/runtime/polyfill/platformRuntime.mjs.map +1 -0
- package/dist/runtime/polyfill/routeRuntime/dom.mjs +36 -0
- package/dist/runtime/polyfill/routeRuntime/dom.mjs.map +1 -0
- package/dist/runtime/polyfill/routeRuntime/lifecycle.mjs +83 -0
- package/dist/runtime/polyfill/routeRuntime/lifecycle.mjs.map +1 -0
- package/dist/runtime/polyfill/routeRuntime/options.d.mts +33 -0
- package/dist/runtime/polyfill/routeRuntime/options.mjs +76 -0
- package/dist/runtime/polyfill/routeRuntime/options.mjs.map +1 -0
- package/dist/runtime/polyfill/routeRuntime/url.mjs +35 -0
- package/dist/runtime/polyfill/routeRuntime/url.mjs.map +1 -0
- package/dist/runtime/polyfill/routeRuntime.d.mts +43 -0
- package/dist/runtime/polyfill/routeRuntime.mjs +202 -0
- package/dist/runtime/polyfill/routeRuntime.mjs.map +1 -0
- package/dist/runtime/polyfill/runtimeCapabilityApi.mjs +26 -0
- package/dist/runtime/polyfill/runtimeCapabilityApi.mjs.map +1 -0
- package/dist/runtime/polyfill/runtimeDataApi.d.mts +79 -0
- package/dist/runtime/polyfill/runtimeDataApi.mjs +134 -0
- package/dist/runtime/polyfill/runtimeDataApi.mjs.map +1 -0
- package/dist/runtime/polyfill/runtimeInfra.mjs +40 -0
- package/dist/runtime/polyfill/runtimeInfra.mjs.map +1 -0
- package/dist/runtime/polyfill/runtimeOps.mjs +62 -0
- package/dist/runtime/polyfill/runtimeOps.mjs.map +1 -0
- package/dist/runtime/polyfill/selectorQuery.mjs +204 -0
- package/dist/runtime/polyfill/selectorQuery.mjs.map +1 -0
- package/dist/runtime/polyfill/storage.mjs +103 -0
- package/dist/runtime/polyfill/storage.mjs.map +1 -0
- package/dist/runtime/polyfill/storageAsync.mjs +62 -0
- package/dist/runtime/polyfill/storageAsync.mjs.map +1 -0
- package/dist/runtime/polyfill/subscribe.mjs +30 -0
- package/dist/runtime/polyfill/subscribe.mjs.map +1 -0
- package/dist/runtime/polyfill/system.mjs +111 -0
- package/dist/runtime/polyfill/system.mjs.map +1 -0
- package/dist/runtime/polyfill/systemApi.mjs +65 -0
- package/dist/runtime/polyfill/systemApi.mjs.map +1 -0
- package/dist/runtime/polyfill/types/base.d.mts +12 -0
- package/dist/runtime/polyfill/types/common.d.mts +126 -0
- package/dist/runtime/polyfill/types/locationRuntime.d.mts +151 -0
- package/dist/runtime/polyfill/types/mediaAuth.d.mts +152 -0
- package/dist/runtime/polyfill/types/platformRuntime.d.mts +141 -0
- package/dist/runtime/polyfill/types/systemAuth.d.mts +122 -0
- package/dist/runtime/polyfill/ui.mjs +135 -0
- package/dist/runtime/polyfill/ui.mjs.map +1 -0
- package/dist/runtime/polyfill/uiFeedback.mjs +35 -0
- package/dist/runtime/polyfill/uiFeedback.mjs.map +1 -0
- package/dist/runtime/polyfill/uiMediaApi.d.mts +172 -0
- package/dist/runtime/polyfill/uiMediaApi.mjs +162 -0
- package/dist/runtime/polyfill/uiMediaApi.mjs.map +1 -0
- package/dist/runtime/polyfill/videoContext.mjs +56 -0
- package/dist/runtime/polyfill/videoContext.mjs.map +1 -0
- package/dist/runtime/polyfill/vkSession.mjs +58 -0
- package/dist/runtime/polyfill/vkSession.mjs.map +1 -0
- package/dist/runtime/polyfill/windowResize.mjs +39 -0
- package/dist/runtime/polyfill/windowResize.mjs.map +1 -0
- package/dist/runtime/polyfill/worker.mjs +77 -0
- package/dist/runtime/polyfill/worker.mjs.map +1 -0
- package/dist/runtime/polyfill.d.mts +5 -0
- package/dist/runtime/renderContext.d.mts +21 -0
- package/dist/runtime/renderContext.mjs +147 -0
- package/dist/runtime/renderContext.mjs.map +1 -0
- package/dist/runtime/rpx.d.mts +9 -0
- package/dist/runtime/rpx.mjs +27 -0
- package/dist/runtime/rpx.mjs.map +1 -0
- package/dist/runtime/style.d.mts +6 -0
- package/dist/runtime/style.mjs +37 -0
- package/dist/runtime/style.mjs.map +1 -0
- package/dist/runtime/template.d.mts +10 -0
- package/dist/runtime/warning.d.mts +10 -0
- package/dist/runtime/warning.mjs +43 -0
- package/dist/runtime/warning.mjs.map +1 -0
- package/dist/{slugify-B4l45KNs.mjs → shared/slugify.mjs} +3 -1
- package/dist/shared/slugify.mjs.map +1 -0
- package/dist/shared/wxml.mjs +83 -0
- package/dist/shared/wxml.mjs.map +1 -0
- package/package.json +2 -2
- package/dist/index-w9xxIH-l.d.mts +0 -1229
- package/dist/plugin-BARxSPO8.mjs +0 -1567
- package/dist/plugin-DP2iPVmw.d.mts +0 -96
- package/dist/runtime-D6j2_x_N.mjs +0 -6251
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
//#region src/runtime/navigationBar/style.ts
|
|
2
|
+
const NAVBAR_STYLE = `
|
|
3
|
+
:host {
|
|
4
|
+
--weapp-status-bar-height: 20px;
|
|
5
|
+
--weapp-nav-content-height: 44px;
|
|
6
|
+
--weapp-nav-height: calc(var(--weapp-status-bar-height) + var(--weapp-nav-content-height));
|
|
7
|
+
--weapp-nav-bg: #ffffff;
|
|
8
|
+
--weapp-nav-color: #000000;
|
|
9
|
+
--weapp-nav-transition-duration: 0ms;
|
|
10
|
+
--weapp-nav-transition-easing: ease;
|
|
11
|
+
display: block;
|
|
12
|
+
position: relative;
|
|
13
|
+
z-index: 999;
|
|
14
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.weapp-nav__spacer {
|
|
18
|
+
height: var(--weapp-nav-height);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.weapp-nav {
|
|
22
|
+
position: fixed;
|
|
23
|
+
top: 0;
|
|
24
|
+
left: 0;
|
|
25
|
+
right: 0;
|
|
26
|
+
height: var(--weapp-nav-height);
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
background: var(--weapp-nav-bg);
|
|
30
|
+
color: var(--weapp-nav-color);
|
|
31
|
+
box-shadow: 0 0.5px 0 rgba(0, 0, 0, 0.1);
|
|
32
|
+
transition:
|
|
33
|
+
background-color var(--weapp-nav-transition-duration) var(--weapp-nav-transition-easing),
|
|
34
|
+
color var(--weapp-nav-transition-duration) var(--weapp-nav-transition-easing);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.weapp-nav--transparent {
|
|
38
|
+
box-shadow: none;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.weapp-nav__status {
|
|
42
|
+
height: var(--weapp-status-bar-height);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.weapp-nav__content {
|
|
46
|
+
height: var(--weapp-nav-content-height);
|
|
47
|
+
display: flex;
|
|
48
|
+
align-items: center;
|
|
49
|
+
justify-content: center;
|
|
50
|
+
position: relative;
|
|
51
|
+
padding: 0 12px;
|
|
52
|
+
box-sizing: border-box;
|
|
53
|
+
font-size: 17px;
|
|
54
|
+
font-weight: 500;
|
|
55
|
+
line-height: 1;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.weapp-nav__left,
|
|
59
|
+
.weapp-nav__right {
|
|
60
|
+
position: absolute;
|
|
61
|
+
top: 0;
|
|
62
|
+
bottom: 0;
|
|
63
|
+
width: 88px;
|
|
64
|
+
display: flex;
|
|
65
|
+
align-items: center;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.weapp-nav__left {
|
|
69
|
+
left: 12px;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.weapp-nav__right {
|
|
73
|
+
right: 12px;
|
|
74
|
+
justify-content: flex-end;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.weapp-nav__title {
|
|
78
|
+
display: inline-flex;
|
|
79
|
+
align-items: center;
|
|
80
|
+
gap: 6px;
|
|
81
|
+
max-width: 70%;
|
|
82
|
+
overflow: hidden;
|
|
83
|
+
text-overflow: ellipsis;
|
|
84
|
+
white-space: nowrap;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.weapp-nav__loading {
|
|
88
|
+
width: 12px;
|
|
89
|
+
height: 12px;
|
|
90
|
+
border-radius: 50%;
|
|
91
|
+
border: 2px solid currentColor;
|
|
92
|
+
border-top-color: transparent;
|
|
93
|
+
animation: weapp-nav-spin 0.8s linear infinite;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.weapp-nav__loading[hidden] {
|
|
97
|
+
display: none;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
@keyframes weapp-nav-spin {
|
|
101
|
+
from { transform: rotate(0deg); }
|
|
102
|
+
to { transform: rotate(360deg); }
|
|
103
|
+
}
|
|
104
|
+
`;
|
|
105
|
+
|
|
106
|
+
//#endregion
|
|
107
|
+
export { NAVBAR_STYLE };
|
|
108
|
+
//# sourceMappingURL=style.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.mjs","names":[],"sources":["../../../src/runtime/navigationBar/style.ts"],"sourcesContent":["export const NAVBAR_STYLE = `\n:host {\n --weapp-status-bar-height: 20px;\n --weapp-nav-content-height: 44px;\n --weapp-nav-height: calc(var(--weapp-status-bar-height) + var(--weapp-nav-content-height));\n --weapp-nav-bg: #ffffff;\n --weapp-nav-color: #000000;\n --weapp-nav-transition-duration: 0ms;\n --weapp-nav-transition-easing: ease;\n display: block;\n position: relative;\n z-index: 999;\n font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;\n}\n\n.weapp-nav__spacer {\n height: var(--weapp-nav-height);\n}\n\n.weapp-nav {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n height: var(--weapp-nav-height);\n display: flex;\n flex-direction: column;\n background: var(--weapp-nav-bg);\n color: var(--weapp-nav-color);\n box-shadow: 0 0.5px 0 rgba(0, 0, 0, 0.1);\n transition:\n background-color var(--weapp-nav-transition-duration) var(--weapp-nav-transition-easing),\n color var(--weapp-nav-transition-duration) var(--weapp-nav-transition-easing);\n}\n\n.weapp-nav--transparent {\n box-shadow: none;\n}\n\n.weapp-nav__status {\n height: var(--weapp-status-bar-height);\n}\n\n.weapp-nav__content {\n height: var(--weapp-nav-content-height);\n display: flex;\n align-items: center;\n justify-content: center;\n position: relative;\n padding: 0 12px;\n box-sizing: border-box;\n font-size: 17px;\n font-weight: 500;\n line-height: 1;\n}\n\n.weapp-nav__left,\n.weapp-nav__right {\n position: absolute;\n top: 0;\n bottom: 0;\n width: 88px;\n display: flex;\n align-items: center;\n}\n\n.weapp-nav__left {\n left: 12px;\n}\n\n.weapp-nav__right {\n right: 12px;\n justify-content: flex-end;\n}\n\n.weapp-nav__title {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n max-width: 70%;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.weapp-nav__loading {\n width: 12px;\n height: 12px;\n border-radius: 50%;\n border: 2px solid currentColor;\n border-top-color: transparent;\n animation: weapp-nav-spin 0.8s linear infinite;\n}\n\n.weapp-nav__loading[hidden] {\n display: none;\n}\n\n@keyframes weapp-nav-spin {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n}\n`\n"],"mappings":";AAAA,MAAa,eAAe"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
//#region src/runtime/polyfill/ad.ts
|
|
2
|
+
function createAdError(errMsg) {
|
|
3
|
+
return {
|
|
4
|
+
errMsg,
|
|
5
|
+
errCode: -1
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
function normalizeAdUnitId(options) {
|
|
9
|
+
if (typeof options?.adUnitId !== "string") return "";
|
|
10
|
+
return options.adUnitId.trim();
|
|
11
|
+
}
|
|
12
|
+
function createRewardedVideoAdImpl(options) {
|
|
13
|
+
let loaded = false;
|
|
14
|
+
let destroyed = false;
|
|
15
|
+
const loadCallbacks = /* @__PURE__ */ new Set();
|
|
16
|
+
const errorCallbacks = /* @__PURE__ */ new Set();
|
|
17
|
+
const closeCallbacks = /* @__PURE__ */ new Set();
|
|
18
|
+
const adUnitId = normalizeAdUnitId(options);
|
|
19
|
+
const emitError = (error) => {
|
|
20
|
+
for (const callback of errorCallbacks) callback(error);
|
|
21
|
+
};
|
|
22
|
+
const fail = (message) => {
|
|
23
|
+
const error = createAdError(message);
|
|
24
|
+
emitError(error);
|
|
25
|
+
return Promise.reject(error);
|
|
26
|
+
};
|
|
27
|
+
return {
|
|
28
|
+
load() {
|
|
29
|
+
if (destroyed) return fail("RewardedVideoAd.load:fail ad is destroyed");
|
|
30
|
+
if (!adUnitId) return fail("RewardedVideoAd.load:fail invalid adUnitId");
|
|
31
|
+
loaded = true;
|
|
32
|
+
for (const callback of loadCallbacks) callback();
|
|
33
|
+
return Promise.resolve({ errMsg: "RewardedVideoAd.load:ok" });
|
|
34
|
+
},
|
|
35
|
+
show() {
|
|
36
|
+
if (destroyed) return fail("RewardedVideoAd.show:fail ad is destroyed");
|
|
37
|
+
if (!loaded) return this.load().then(() => this.show());
|
|
38
|
+
const result = { isEnded: true };
|
|
39
|
+
for (const callback of closeCallbacks) callback(result);
|
|
40
|
+
return Promise.resolve({ errMsg: "RewardedVideoAd.show:ok" });
|
|
41
|
+
},
|
|
42
|
+
destroy() {
|
|
43
|
+
destroyed = true;
|
|
44
|
+
loadCallbacks.clear();
|
|
45
|
+
errorCallbacks.clear();
|
|
46
|
+
closeCallbacks.clear();
|
|
47
|
+
},
|
|
48
|
+
onLoad(callback) {
|
|
49
|
+
if (typeof callback === "function") loadCallbacks.add(callback);
|
|
50
|
+
},
|
|
51
|
+
offLoad(callback) {
|
|
52
|
+
if (typeof callback !== "function") {
|
|
53
|
+
loadCallbacks.clear();
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
loadCallbacks.delete(callback);
|
|
57
|
+
},
|
|
58
|
+
onError(callback) {
|
|
59
|
+
if (typeof callback === "function") errorCallbacks.add(callback);
|
|
60
|
+
},
|
|
61
|
+
offError(callback) {
|
|
62
|
+
if (typeof callback !== "function") {
|
|
63
|
+
errorCallbacks.clear();
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
errorCallbacks.delete(callback);
|
|
67
|
+
},
|
|
68
|
+
onClose(callback) {
|
|
69
|
+
if (typeof callback === "function") closeCallbacks.add(callback);
|
|
70
|
+
},
|
|
71
|
+
offClose(callback) {
|
|
72
|
+
if (typeof callback !== "function") {
|
|
73
|
+
closeCallbacks.clear();
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
closeCallbacks.delete(callback);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function createInterstitialAdImpl(options) {
|
|
81
|
+
let loaded = false;
|
|
82
|
+
let destroyed = false;
|
|
83
|
+
const loadCallbacks = /* @__PURE__ */ new Set();
|
|
84
|
+
const errorCallbacks = /* @__PURE__ */ new Set();
|
|
85
|
+
const closeCallbacks = /* @__PURE__ */ new Set();
|
|
86
|
+
const adUnitId = normalizeAdUnitId(options);
|
|
87
|
+
const emitError = (error) => {
|
|
88
|
+
for (const callback of errorCallbacks) callback(error);
|
|
89
|
+
};
|
|
90
|
+
const fail = (message) => {
|
|
91
|
+
const error = createAdError(message);
|
|
92
|
+
emitError(error);
|
|
93
|
+
return Promise.reject(error);
|
|
94
|
+
};
|
|
95
|
+
return {
|
|
96
|
+
load() {
|
|
97
|
+
if (destroyed) return fail("InterstitialAd.load:fail ad is destroyed");
|
|
98
|
+
if (!adUnitId) return fail("InterstitialAd.load:fail invalid adUnitId");
|
|
99
|
+
loaded = true;
|
|
100
|
+
for (const callback of loadCallbacks) callback();
|
|
101
|
+
return Promise.resolve({ errMsg: "InterstitialAd.load:ok" });
|
|
102
|
+
},
|
|
103
|
+
show() {
|
|
104
|
+
if (destroyed) return fail("InterstitialAd.show:fail ad is destroyed");
|
|
105
|
+
if (!loaded) return this.load().then(() => this.show());
|
|
106
|
+
for (const callback of closeCallbacks) callback();
|
|
107
|
+
return Promise.resolve({ errMsg: "InterstitialAd.show:ok" });
|
|
108
|
+
},
|
|
109
|
+
destroy() {
|
|
110
|
+
destroyed = true;
|
|
111
|
+
loadCallbacks.clear();
|
|
112
|
+
errorCallbacks.clear();
|
|
113
|
+
closeCallbacks.clear();
|
|
114
|
+
},
|
|
115
|
+
onLoad(callback) {
|
|
116
|
+
if (typeof callback === "function") loadCallbacks.add(callback);
|
|
117
|
+
},
|
|
118
|
+
offLoad(callback) {
|
|
119
|
+
if (typeof callback !== "function") {
|
|
120
|
+
loadCallbacks.clear();
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
loadCallbacks.delete(callback);
|
|
124
|
+
},
|
|
125
|
+
onError(callback) {
|
|
126
|
+
if (typeof callback === "function") errorCallbacks.add(callback);
|
|
127
|
+
},
|
|
128
|
+
offError(callback) {
|
|
129
|
+
if (typeof callback !== "function") {
|
|
130
|
+
errorCallbacks.clear();
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
errorCallbacks.delete(callback);
|
|
134
|
+
},
|
|
135
|
+
onClose(callback) {
|
|
136
|
+
if (typeof callback === "function") closeCallbacks.add(callback);
|
|
137
|
+
},
|
|
138
|
+
offClose(callback) {
|
|
139
|
+
if (typeof callback !== "function") {
|
|
140
|
+
closeCallbacks.clear();
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
closeCallbacks.delete(callback);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
//#endregion
|
|
149
|
+
export { createInterstitialAdImpl, createRewardedVideoAdImpl };
|
|
150
|
+
//# sourceMappingURL=ad.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ad.mjs","names":[],"sources":["../../../src/runtime/polyfill/ad.ts"],"sourcesContent":["interface AdBaseOptions {\n adUnitId?: string\n}\n\ninterface AdError {\n errMsg: string\n errCode: number\n}\n\ninterface RewardedVideoAdCloseResult {\n isEnded: boolean\n}\n\ninterface RewardedVideoAd {\n load: () => Promise<{ errMsg: string }>\n show: () => Promise<{ errMsg: string }>\n destroy: () => void\n onLoad: (callback: () => void) => void\n offLoad: (callback?: () => void) => void\n onError: (callback: (error: AdError) => void) => void\n offError: (callback?: (error: AdError) => void) => void\n onClose: (callback: (result: RewardedVideoAdCloseResult) => void) => void\n offClose: (callback?: (result: RewardedVideoAdCloseResult) => void) => void\n}\n\ninterface InterstitialAd {\n load: () => Promise<{ errMsg: string }>\n show: () => Promise<{ errMsg: string }>\n destroy: () => void\n onLoad: (callback: () => void) => void\n offLoad: (callback?: () => void) => void\n onError: (callback: (error: AdError) => void) => void\n offError: (callback?: (error: AdError) => void) => void\n onClose: (callback: () => void) => void\n offClose: (callback?: () => void) => void\n}\n\nfunction createAdError(errMsg: string): AdError {\n return {\n errMsg,\n errCode: -1,\n }\n}\n\nfunction normalizeAdUnitId(options?: AdBaseOptions) {\n if (typeof options?.adUnitId !== 'string') {\n return ''\n }\n return options.adUnitId.trim()\n}\n\nexport function createRewardedVideoAdImpl(options?: AdBaseOptions): RewardedVideoAd {\n let loaded = false\n let destroyed = false\n const loadCallbacks = new Set<() => void>()\n const errorCallbacks = new Set<(error: AdError) => void>()\n const closeCallbacks = new Set<(result: RewardedVideoAdCloseResult) => void>()\n const adUnitId = normalizeAdUnitId(options)\n\n const emitError = (error: AdError) => {\n for (const callback of errorCallbacks) {\n callback(error)\n }\n }\n\n const fail = (message: string) => {\n const error = createAdError(message)\n emitError(error)\n return Promise.reject(error)\n }\n\n return {\n load() {\n if (destroyed) {\n return fail('RewardedVideoAd.load:fail ad is destroyed')\n }\n if (!adUnitId) {\n return fail('RewardedVideoAd.load:fail invalid adUnitId')\n }\n loaded = true\n for (const callback of loadCallbacks) {\n callback()\n }\n return Promise.resolve({ errMsg: 'RewardedVideoAd.load:ok' })\n },\n show() {\n if (destroyed) {\n return fail('RewardedVideoAd.show:fail ad is destroyed')\n }\n if (!loaded) {\n return this.load().then(() => this.show())\n }\n const result: RewardedVideoAdCloseResult = { isEnded: true }\n for (const callback of closeCallbacks) {\n callback(result)\n }\n return Promise.resolve({ errMsg: 'RewardedVideoAd.show:ok' })\n },\n destroy() {\n destroyed = true\n loadCallbacks.clear()\n errorCallbacks.clear()\n closeCallbacks.clear()\n },\n onLoad(callback: () => void) {\n if (typeof callback === 'function') {\n loadCallbacks.add(callback)\n }\n },\n offLoad(callback?: () => void) {\n if (typeof callback !== 'function') {\n loadCallbacks.clear()\n return\n }\n loadCallbacks.delete(callback)\n },\n onError(callback: (error: AdError) => void) {\n if (typeof callback === 'function') {\n errorCallbacks.add(callback)\n }\n },\n offError(callback?: (error: AdError) => void) {\n if (typeof callback !== 'function') {\n errorCallbacks.clear()\n return\n }\n errorCallbacks.delete(callback)\n },\n onClose(callback: (result: RewardedVideoAdCloseResult) => void) {\n if (typeof callback === 'function') {\n closeCallbacks.add(callback)\n }\n },\n offClose(callback?: (result: RewardedVideoAdCloseResult) => void) {\n if (typeof callback !== 'function') {\n closeCallbacks.clear()\n return\n }\n closeCallbacks.delete(callback)\n },\n }\n}\n\nexport function createInterstitialAdImpl(options?: AdBaseOptions): InterstitialAd {\n let loaded = false\n let destroyed = false\n const loadCallbacks = new Set<() => void>()\n const errorCallbacks = new Set<(error: AdError) => void>()\n const closeCallbacks = new Set<() => void>()\n const adUnitId = normalizeAdUnitId(options)\n\n const emitError = (error: AdError) => {\n for (const callback of errorCallbacks) {\n callback(error)\n }\n }\n\n const fail = (message: string) => {\n const error = createAdError(message)\n emitError(error)\n return Promise.reject(error)\n }\n\n return {\n load() {\n if (destroyed) {\n return fail('InterstitialAd.load:fail ad is destroyed')\n }\n if (!adUnitId) {\n return fail('InterstitialAd.load:fail invalid adUnitId')\n }\n loaded = true\n for (const callback of loadCallbacks) {\n callback()\n }\n return Promise.resolve({ errMsg: 'InterstitialAd.load:ok' })\n },\n show() {\n if (destroyed) {\n return fail('InterstitialAd.show:fail ad is destroyed')\n }\n if (!loaded) {\n return this.load().then(() => this.show())\n }\n for (const callback of closeCallbacks) {\n callback()\n }\n return Promise.resolve({ errMsg: 'InterstitialAd.show:ok' })\n },\n destroy() {\n destroyed = true\n loadCallbacks.clear()\n errorCallbacks.clear()\n closeCallbacks.clear()\n },\n onLoad(callback: () => void) {\n if (typeof callback === 'function') {\n loadCallbacks.add(callback)\n }\n },\n offLoad(callback?: () => void) {\n if (typeof callback !== 'function') {\n loadCallbacks.clear()\n return\n }\n loadCallbacks.delete(callback)\n },\n onError(callback: (error: AdError) => void) {\n if (typeof callback === 'function') {\n errorCallbacks.add(callback)\n }\n },\n offError(callback?: (error: AdError) => void) {\n if (typeof callback !== 'function') {\n errorCallbacks.clear()\n return\n }\n errorCallbacks.delete(callback)\n },\n onClose(callback: () => void) {\n if (typeof callback === 'function') {\n closeCallbacks.add(callback)\n }\n },\n offClose(callback?: () => void) {\n if (typeof callback !== 'function') {\n closeCallbacks.clear()\n return\n }\n closeCallbacks.delete(callback)\n },\n }\n}\n"],"mappings":";AAqCA,SAAS,cAAc,QAAyB;AAC9C,QAAO;EACL;EACA,SAAS;EACV;;AAGH,SAAS,kBAAkB,SAAyB;AAClD,KAAI,OAAO,SAAS,aAAa,SAC/B,QAAO;AA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B,QAAQ,UAAuB;AAC7B,OAAI,OAAO,aAAa,YAAY;AAClC,kBAAc,OAAO;AACrB;;AAEF,iBAAc,OAAO,SAAS;;EAEhC,QAAQ,UAAoC;AAC1C,OAAI,OAAO,aAAa,WACtB,gBAAe,IAAI,SAAS;;EAGhC,SAAS,UAAqC;AAC5C,OAAI,OAAO,aAAa,YAAY;AAClC,mBAAe,OAAO;AACtB;;AAEF,kBAAe,OAAO,SAAS;;EAEjC,QAAQ,UAAsB;AAC5B,OAAI,OAAO,aAAa,WACtB,gBAAe,IAAI,SAAS;;EAGhC,SAAS,UAAuB;AAC9B,OAAI,OAAO,aAAa,YAAY;AAClC,mBAAe,OAAO;AACtB;;AAEF,kBAAe,OAAO,SAAS;;EAElC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
//#region src/runtime/polyfill/appState.ts
|
|
2
|
+
function resolveCurrentPages(navigationHistory) {
|
|
3
|
+
return navigationHistory.map((entry) => entry.instance).filter((instance) => Boolean(instance));
|
|
4
|
+
}
|
|
5
|
+
function cloneLaunchOptions(options) {
|
|
6
|
+
return {
|
|
7
|
+
path: options.path,
|
|
8
|
+
scene: options.scene,
|
|
9
|
+
query: { ...options.query },
|
|
10
|
+
referrerInfo: { ...options.referrerInfo }
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function resolveFallbackLaunchOptions(navigationHistory) {
|
|
14
|
+
const entry = navigationHistory[navigationHistory.length - 1] ?? navigationHistory[0];
|
|
15
|
+
if (!entry) return {
|
|
16
|
+
path: "",
|
|
17
|
+
scene: 0,
|
|
18
|
+
query: {},
|
|
19
|
+
referrerInfo: {}
|
|
20
|
+
};
|
|
21
|
+
return {
|
|
22
|
+
path: entry.id,
|
|
23
|
+
scene: 0,
|
|
24
|
+
query: { ...entry.query },
|
|
25
|
+
referrerInfo: {}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
export { cloneLaunchOptions, resolveCurrentPages, resolveFallbackLaunchOptions };
|
|
31
|
+
//# sourceMappingURL=appState.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appState.mjs","names":[],"sources":["../../../src/runtime/polyfill/appState.ts"],"sourcesContent":["import type { AppLaunchOptions } from './routeRuntime/options'\n\nexport function resolveCurrentPages<T>(navigationHistory: Array<{ instance?: T }>) {\n return navigationHistory\n .map(entry => entry.instance)\n .filter((instance): instance is T => Boolean(instance))\n}\n\nexport function cloneLaunchOptions(options: AppLaunchOptions): AppLaunchOptions {\n return {\n path: options.path,\n scene: options.scene,\n query: { ...options.query },\n referrerInfo: { ...options.referrerInfo },\n }\n}\n\nexport function resolveFallbackLaunchOptions(\n navigationHistory: Array<{ id: string, query: Record<string, string> }>,\n): AppLaunchOptions {\n const entry = navigationHistory[navigationHistory.length - 1] ?? navigationHistory[0]\n if (!entry) {\n return {\n path: '',\n scene: 0,\n query: {},\n referrerInfo: {},\n }\n }\n return {\n path: entry.id,\n scene: 0,\n query: { ...entry.query },\n referrerInfo: {},\n }\n}\n"],"mappings":";AAEA,SAAgB,oBAAuB,mBAA4C;AACjF,QAAO,kBACJ,KAAI,UAAS,MAAM,SAAS,CAC5B,QAAQ,aAA4B,QAAQ,SAAS,CAAC;;AAG3D,SAAgB,mBAAmB,SAA6C;AAC9E,QAAO;EACL,MAAM,QAAQ;EACd,OAAO,QAAQ;EACf,OAAO,EAAE,GAAG,QAAQ,OAAO;EAC3B,cAAc,EAAE,GAAG,QAAQ,cAAc;EAC1C;;AAGH,SAAgB,6BACd,mBACkB;CAClB,MAAM,QAAQ,kBAAkB,kBAAkB,SAAS,MAAM,kBAAkB;AACnF,KAAI,CAAC,MACH,QAAO;EACL,MAAM;EACN,OAAO;EACP,OAAO,EAAE;EACT,cAAc,EAAE;EACjB;AAEH,QAAO;EACL,MAAM,MAAM;EACZ,OAAO;EACP,OAAO,EAAE,GAAG,MAAM,OAAO;EACzB,cAAc,EAAE;EACjB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
//#region src/runtime/polyfill/async.ts
|
|
2
|
+
function callMiniProgramAsyncSuccess(options, result) {
|
|
3
|
+
options?.success?.(result);
|
|
4
|
+
options?.complete?.(result);
|
|
5
|
+
return result;
|
|
6
|
+
}
|
|
7
|
+
function callMiniProgramAsyncFailure(options, errMsg) {
|
|
8
|
+
const result = { errMsg };
|
|
9
|
+
options?.fail?.(result);
|
|
10
|
+
options?.complete?.(result);
|
|
11
|
+
return result;
|
|
12
|
+
}
|
|
13
|
+
function normalizeDuration(duration, fallback) {
|
|
14
|
+
if (typeof duration !== "number" || Number.isNaN(duration)) return fallback;
|
|
15
|
+
return Math.max(0, duration);
|
|
16
|
+
}
|
|
17
|
+
function scheduleMicrotask(task) {
|
|
18
|
+
if (typeof queueMicrotask === "function") {
|
|
19
|
+
queueMicrotask(task);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
Promise.resolve().then(task).catch((error) => {
|
|
23
|
+
setTimeout(() => {
|
|
24
|
+
throw error;
|
|
25
|
+
}, 0);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
export { callMiniProgramAsyncFailure, callMiniProgramAsyncSuccess, normalizeDuration, scheduleMicrotask };
|
|
31
|
+
//# sourceMappingURL=async.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async.mjs","names":[],"sources":["../../../src/runtime/polyfill/async.ts"],"sourcesContent":["interface MiniProgramBaseResultLike {\n errMsg: string\n}\n\ninterface MiniProgramAsyncOptionsLike<SuccessResult extends MiniProgramBaseResultLike> {\n success?: (result: SuccessResult) => void\n fail?: (result: MiniProgramBaseResultLike) => void\n complete?: (result: SuccessResult | MiniProgramBaseResultLike) => void\n}\n\nexport function callMiniProgramAsyncSuccess<SuccessResult extends MiniProgramBaseResultLike>(\n options: MiniProgramAsyncOptionsLike<SuccessResult> | undefined,\n result: SuccessResult,\n) {\n options?.success?.(result)\n options?.complete?.(result)\n return result\n}\n\nexport function callMiniProgramAsyncFailure<SuccessResult extends MiniProgramBaseResultLike>(\n options: MiniProgramAsyncOptionsLike<SuccessResult> | undefined,\n errMsg: string,\n) {\n const result: MiniProgramBaseResultLike = { errMsg }\n options?.fail?.(result)\n options?.complete?.(result)\n return result\n}\n\nexport const callWxAsyncSuccess = callMiniProgramAsyncSuccess\nexport const callWxAsyncFailure = callMiniProgramAsyncFailure\n\nexport function normalizeDuration(duration: number | undefined, fallback: number) {\n if (typeof duration !== 'number' || Number.isNaN(duration)) {\n return fallback\n }\n return Math.max(0, duration)\n}\n\nexport function scheduleMicrotask(task: () => void) {\n if (typeof queueMicrotask === 'function') {\n queueMicrotask(task)\n return\n }\n Promise.resolve()\n .then(task)\n .catch((error) => {\n setTimeout(() => {\n throw error\n }, 0)\n })\n}\n"],"mappings":";AAUA,SAAgB,4BACd,SACA,QACA;AACA,UAAS,UAAU,OAAO;AAC1B,UAAS,WAAW,OAAO;AAC3B,QAAO;;AAGT,SAAgB,4BACd,SACA,QACA;CACA,MAAM,SAAoC,EAAE,QAAQ;AACpD,UAAS,OAAO,OAAO;AACvB,UAAS,WAAW,OAAO;AAC3B,QAAO;;AAMT,SAAgB,kBAAkB,UAA8B,UAAkB;AAChF,KAAI,OAAO,aAAa,YAAY,OAAO,MAAM,SAAS,CACxD,QAAO;AAET,QAAO,KAAK,IAAI,GAAG,SAAS;;AAG9B,SAAgB,kBAAkB,MAAkB;AAClD,KAAI,OAAO,mBAAmB,YAAY;AACxC,iBAAe,KAAK;AACpB;;AAEF,SAAQ,SAAS,CACd,KAAK,KAAK,CACV,OAAO,UAAU;AAChB,mBAAiB;AACf,SAAM;KACL,EAAE;GACL"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { WEAPP_VITE_WEB_AUTHORIZE_DECISION_KEY, WEAPP_VITE_WEB_CHECK_SESSION_KEY, WEAPP_VITE_WEB_GET_USER_PROFILE_DECISION_KEY, WEAPP_VITE_WEB_OPEN_APP_AUTHORIZE_SETTING_KEY, WEAPP_VITE_WEB_OPEN_SETTING_AUTH_KEY, WEAPP_VITE_WEB_USER_INFO_KEY, WEAPP_VITE_WEB_USER_PROFILE_KEY } from "@weapp-core/constants";
|
|
2
|
+
|
|
3
|
+
//#region src/runtime/polyfill/auth.ts
|
|
4
|
+
function normalizeAuthScope(scope) {
|
|
5
|
+
if (typeof scope !== "string") return "";
|
|
6
|
+
return scope.trim();
|
|
7
|
+
}
|
|
8
|
+
function buildAuthSettingSnapshot(authorizeState) {
|
|
9
|
+
const authSetting = {};
|
|
10
|
+
for (const [scope, status] of authorizeState.entries()) authSetting[scope] = status === "authorized";
|
|
11
|
+
return authSetting;
|
|
12
|
+
}
|
|
13
|
+
function normalizeAuthorizeDecision(decision) {
|
|
14
|
+
if (decision === true) return "authorized";
|
|
15
|
+
if (decision === false) return "denied";
|
|
16
|
+
if (decision === "authorized" || decision === "denied" || decision === "not determined") return decision;
|
|
17
|
+
return "authorized";
|
|
18
|
+
}
|
|
19
|
+
function resolveAuthorizeDecision(scope) {
|
|
20
|
+
const decisionSource = globalThis[WEAPP_VITE_WEB_AUTHORIZE_DECISION_KEY];
|
|
21
|
+
if (typeof decisionSource === "function") try {
|
|
22
|
+
return normalizeAuthorizeDecision(decisionSource(scope));
|
|
23
|
+
} catch {
|
|
24
|
+
return "authorized";
|
|
25
|
+
}
|
|
26
|
+
if (decisionSource && typeof decisionSource === "object") return normalizeAuthorizeDecision(decisionSource[scope]);
|
|
27
|
+
return "authorized";
|
|
28
|
+
}
|
|
29
|
+
function syncOpenSettingPreset(authorizeState, supportedAuthScopes) {
|
|
30
|
+
const preset = globalThis[WEAPP_VITE_WEB_OPEN_SETTING_AUTH_KEY];
|
|
31
|
+
if (!preset || typeof preset !== "object") return;
|
|
32
|
+
for (const [scope, value] of Object.entries(preset)) {
|
|
33
|
+
if (!supportedAuthScopes.has(scope)) continue;
|
|
34
|
+
authorizeState.set(scope, value ? "authorized" : "denied");
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function normalizeAppAuthorizeStatus(value) {
|
|
38
|
+
if (value === true) return "authorized";
|
|
39
|
+
if (value === false) return "denied";
|
|
40
|
+
if (value === "authorized" || value === "denied" || value === "not determined") return value;
|
|
41
|
+
return "not determined";
|
|
42
|
+
}
|
|
43
|
+
function syncOpenAppAuthorizeSettingPreset(authorizeState, scopeMap) {
|
|
44
|
+
const preset = globalThis[WEAPP_VITE_WEB_OPEN_APP_AUTHORIZE_SETTING_KEY];
|
|
45
|
+
if (!preset || typeof preset !== "object") return;
|
|
46
|
+
for (const [key, scope] of Object.entries(scopeMap)) {
|
|
47
|
+
if (!scope) continue;
|
|
48
|
+
const status = normalizeAppAuthorizeStatus(preset[key]);
|
|
49
|
+
authorizeState.set(scope, status);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function generateLoginCode() {
|
|
53
|
+
return `web_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;
|
|
54
|
+
}
|
|
55
|
+
function normalizeUserLanguage(value) {
|
|
56
|
+
if (value === "en" || value === "zh_CN" || value === "zh_TW") return value;
|
|
57
|
+
const language = (typeof navigator !== "undefined" ? navigator : void 0)?.language?.toLowerCase() ?? "";
|
|
58
|
+
if (language.startsWith("zh-tw") || language.startsWith("zh-hk")) return "zh_TW";
|
|
59
|
+
if (language.startsWith("zh")) return "zh_CN";
|
|
60
|
+
return "en";
|
|
61
|
+
}
|
|
62
|
+
function normalizeUserGender(value) {
|
|
63
|
+
if (value === 1 || value === 2) return value;
|
|
64
|
+
return 0;
|
|
65
|
+
}
|
|
66
|
+
function normalizeUserInfoValue(value, lang) {
|
|
67
|
+
if (!value || typeof value !== "object") return null;
|
|
68
|
+
const info = value;
|
|
69
|
+
return {
|
|
70
|
+
nickName: typeof info.nickName === "string" && info.nickName.trim() ? info.nickName : "Web User",
|
|
71
|
+
avatarUrl: typeof info.avatarUrl === "string" ? info.avatarUrl : "",
|
|
72
|
+
gender: normalizeUserGender(info.gender),
|
|
73
|
+
country: typeof info.country === "string" ? info.country : "",
|
|
74
|
+
province: typeof info.province === "string" ? info.province : "",
|
|
75
|
+
city: typeof info.city === "string" ? info.city : "",
|
|
76
|
+
language: normalizeUserLanguage(info.language ?? lang)
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function resolveUserInfoPreset(source, lang) {
|
|
80
|
+
const preset = globalThis[source];
|
|
81
|
+
if (typeof preset === "function") return normalizeUserInfoValue(preset(), lang);
|
|
82
|
+
return normalizeUserInfoValue(preset, lang);
|
|
83
|
+
}
|
|
84
|
+
function buildUserProfilePayload(errMsg, optionsLang) {
|
|
85
|
+
const language = normalizeUserLanguage(optionsLang);
|
|
86
|
+
const userInfo = resolveUserInfoPreset(WEAPP_VITE_WEB_USER_PROFILE_KEY, language) ?? resolveUserInfoPreset(WEAPP_VITE_WEB_USER_INFO_KEY, language) ?? {
|
|
87
|
+
nickName: "Web User",
|
|
88
|
+
avatarUrl: "",
|
|
89
|
+
gender: 0,
|
|
90
|
+
country: "",
|
|
91
|
+
province: "",
|
|
92
|
+
city: "",
|
|
93
|
+
language
|
|
94
|
+
};
|
|
95
|
+
const rawData = JSON.stringify(userInfo);
|
|
96
|
+
return {
|
|
97
|
+
errMsg,
|
|
98
|
+
userInfo,
|
|
99
|
+
rawData,
|
|
100
|
+
signature: `web-signature-${rawData.length}`,
|
|
101
|
+
encryptedData: "",
|
|
102
|
+
iv: ""
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function resolveCheckSessionState() {
|
|
106
|
+
const preset = globalThis[WEAPP_VITE_WEB_CHECK_SESSION_KEY];
|
|
107
|
+
if (typeof preset === "boolean") return preset;
|
|
108
|
+
if (typeof preset === "string") return preset.trim() !== "fail";
|
|
109
|
+
if (preset && typeof preset === "object" && "valid" in preset) return Boolean(preset.valid);
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
function resolveUserProfileDecision() {
|
|
113
|
+
const preset = globalThis[WEAPP_VITE_WEB_GET_USER_PROFILE_DECISION_KEY];
|
|
114
|
+
if (typeof preset === "function") return normalizeAuthorizeDecision(preset());
|
|
115
|
+
return normalizeAuthorizeDecision(preset);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
//#endregion
|
|
119
|
+
export { buildAuthSettingSnapshot, buildUserProfilePayload, generateLoginCode, normalizeAuthScope, resolveAuthorizeDecision, resolveCheckSessionState, resolveUserProfileDecision, syncOpenAppAuthorizeSettingPreset, syncOpenSettingPreset };
|
|
120
|
+
//# sourceMappingURL=auth.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.mjs","names":[],"sources":["../../../src/runtime/polyfill/auth.ts"],"sourcesContent":["import {\n WEAPP_VITE_WEB_AUTHORIZE_DECISION_KEY,\n WEAPP_VITE_WEB_CHECK_SESSION_KEY,\n WEAPP_VITE_WEB_GET_USER_PROFILE_DECISION_KEY,\n WEAPP_VITE_WEB_OPEN_APP_AUTHORIZE_SETTING_KEY,\n WEAPP_VITE_WEB_OPEN_SETTING_AUTH_KEY,\n WEAPP_VITE_WEB_USER_INFO_KEY,\n WEAPP_VITE_WEB_USER_PROFILE_KEY,\n} from '@weapp-core/constants'\n\nexport type AppAuthorizeStatusLike = 'authorized' | 'denied' | 'not determined'\n\ntype UserLanguageLike = 'en' | 'zh_CN' | 'zh_TW'\n\ninterface UserInfoLike {\n nickName: string\n avatarUrl: string\n gender: 0 | 1 | 2\n country: string\n province: string\n city: string\n language: UserLanguageLike\n}\n\nexport function normalizeAuthScope(scope: unknown) {\n if (typeof scope !== 'string') {\n return ''\n }\n return scope.trim()\n}\n\nexport function buildAuthSettingSnapshot(authorizeState: Map<string, AppAuthorizeStatusLike>) {\n const authSetting: Record<string, boolean> = {}\n for (const [scope, status] of authorizeState.entries()) {\n authSetting[scope] = status === 'authorized'\n }\n return authSetting\n}\n\nexport function normalizeAuthorizeDecision(decision: unknown): AppAuthorizeStatusLike {\n if (decision === true) {\n return 'authorized'\n }\n if (decision === false) {\n return 'denied'\n }\n if (decision === 'authorized' || decision === 'denied' || decision === 'not determined') {\n return decision\n }\n return 'authorized'\n}\n\nexport function resolveAuthorizeDecision(scope: string): AppAuthorizeStatusLike {\n const runtimeGlobal = globalThis as Record<string, unknown>\n const decisionSource = runtimeGlobal[WEAPP_VITE_WEB_AUTHORIZE_DECISION_KEY]\n if (typeof decisionSource === 'function') {\n try {\n return normalizeAuthorizeDecision((decisionSource as (value: string) => unknown)(scope))\n }\n catch {\n return 'authorized'\n }\n }\n if (decisionSource && typeof decisionSource === 'object') {\n return normalizeAuthorizeDecision((decisionSource as Record<string, unknown>)[scope])\n }\n return 'authorized'\n}\n\nexport function syncOpenSettingPreset(\n authorizeState: Map<string, AppAuthorizeStatusLike>,\n supportedAuthScopes: Set<string>,\n) {\n const runtimeGlobal = globalThis as Record<string, unknown>\n const preset = runtimeGlobal[WEAPP_VITE_WEB_OPEN_SETTING_AUTH_KEY]\n if (!preset || typeof preset !== 'object') {\n return\n }\n for (const [scope, value] of Object.entries(preset as Record<string, unknown>)) {\n if (!supportedAuthScopes.has(scope)) {\n continue\n }\n authorizeState.set(scope, value ? 'authorized' : 'denied')\n }\n}\n\nexport function normalizeAppAuthorizeStatus(value: unknown): AppAuthorizeStatusLike {\n if (value === true) {\n return 'authorized'\n }\n if (value === false) {\n return 'denied'\n }\n if (value === 'authorized' || value === 'denied' || value === 'not determined') {\n return value\n }\n return 'not determined'\n}\n\nexport function syncOpenAppAuthorizeSettingPreset(\n authorizeState: Map<string, AppAuthorizeStatusLike>,\n scopeMap: Partial<Record<string, string>>,\n) {\n const runtimeGlobal = globalThis as Record<string, unknown>\n const preset = runtimeGlobal[WEAPP_VITE_WEB_OPEN_APP_AUTHORIZE_SETTING_KEY]\n if (!preset || typeof preset !== 'object') {\n return\n }\n for (const [key, scope] of Object.entries(scopeMap)) {\n if (!scope) {\n continue\n }\n const status = normalizeAppAuthorizeStatus((preset as Record<string, unknown>)[key])\n authorizeState.set(scope, status)\n }\n}\n\nexport function generateLoginCode() {\n const now = Date.now().toString(36)\n const random = Math.random().toString(36).slice(2, 10)\n return `web_${now}_${random}`\n}\n\nexport function normalizeUserLanguage(value: unknown): UserLanguageLike {\n if (value === 'en' || value === 'zh_CN' || value === 'zh_TW') {\n return value\n }\n const runtimeNavigator = typeof navigator !== 'undefined' ? navigator : undefined\n const language = runtimeNavigator?.language?.toLowerCase() ?? ''\n if (language.startsWith('zh-tw') || language.startsWith('zh-hk')) {\n return 'zh_TW'\n }\n if (language.startsWith('zh')) {\n return 'zh_CN'\n }\n return 'en'\n}\n\nfunction normalizeUserGender(value: unknown): UserInfoLike['gender'] {\n if (value === 1 || value === 2) {\n return value\n }\n return 0\n}\n\nfunction normalizeUserInfoValue(value: unknown, lang: UserLanguageLike) {\n if (!value || typeof value !== 'object') {\n return null\n }\n const info = value as Record<string, unknown>\n return {\n nickName: typeof info.nickName === 'string' && info.nickName.trim() ? info.nickName : 'Web User',\n avatarUrl: typeof info.avatarUrl === 'string' ? info.avatarUrl : '',\n gender: normalizeUserGender(info.gender),\n country: typeof info.country === 'string' ? info.country : '',\n province: typeof info.province === 'string' ? info.province : '',\n city: typeof info.city === 'string' ? info.city : '',\n language: normalizeUserLanguage(info.language ?? lang),\n } satisfies UserInfoLike\n}\n\nfunction resolveUserInfoPreset(\n source: typeof WEAPP_VITE_WEB_USER_INFO_KEY | typeof WEAPP_VITE_WEB_USER_PROFILE_KEY,\n lang: UserLanguageLike,\n) {\n const runtimeGlobal = globalThis as Record<string, unknown>\n const preset = runtimeGlobal[source]\n if (typeof preset === 'function') {\n return normalizeUserInfoValue((preset as () => unknown)(), lang)\n }\n return normalizeUserInfoValue(preset, lang)\n}\n\nexport function buildUserProfilePayload(errMsg: 'getUserInfo:ok' | 'getUserProfile:ok', optionsLang?: unknown) {\n const language = normalizeUserLanguage(optionsLang)\n const userInfo = resolveUserInfoPreset(WEAPP_VITE_WEB_USER_PROFILE_KEY, language)\n ?? resolveUserInfoPreset(WEAPP_VITE_WEB_USER_INFO_KEY, language)\n ?? {\n nickName: 'Web User',\n avatarUrl: '',\n gender: 0 as const,\n country: '',\n province: '',\n city: '',\n language,\n }\n const rawData = JSON.stringify(userInfo)\n return {\n errMsg,\n userInfo,\n rawData,\n signature: `web-signature-${rawData.length}`,\n encryptedData: '',\n iv: '',\n }\n}\n\nexport function resolveCheckSessionState() {\n const runtimeGlobal = globalThis as Record<string, unknown>\n const preset = runtimeGlobal[WEAPP_VITE_WEB_CHECK_SESSION_KEY]\n if (typeof preset === 'boolean') {\n return preset\n }\n if (typeof preset === 'string') {\n return preset.trim() !== 'fail'\n }\n if (preset && typeof preset === 'object' && 'valid' in preset) {\n return Boolean((preset as { valid?: unknown }).valid)\n }\n return true\n}\n\nexport function resolveUserProfileDecision(): AppAuthorizeStatusLike {\n const runtimeGlobal = globalThis as Record<string, unknown>\n const preset = runtimeGlobal[WEAPP_VITE_WEB_GET_USER_PROFILE_DECISION_KEY]\n if (typeof preset === 'function') {\n return normalizeAuthorizeDecision((preset as () => unknown)())\n }\n return normalizeAuthorizeDecision(preset)\n}\n"],"mappings":";;;AAwBA,SAAgB,mBAAmB,OAAgB;AACjD,KAAI,OAAO,UAAU,SACnB,QAAO;AAET,QAAO,MAAM,MAAM;;AAGrB,SAAgB,yBAAyB,gBAAqD;CAC5F,MAAM,cAAuC,EAAE;AAC/C,MAAK,MAAM,CAAC,OAAO,WAAW,eAAe,SAAS,CACpD,aAAY,SAAS,WAAW;AAElC,QAAO;;AAGT,SAAgB,2BAA2B,UAA2C;AACpF,KAAI,aAAa,KACf,QAAO;AAET,KAAI,aAAa,MACf,QAAO;AAET,KAAI,aAAa,gBAAgB,aAAa,YAAY,aAAa,iBACrE,QAAO;AAET,QAAO;;AAGT,SAAgB,yBAAyB,OAAuC;CAE9E,MAAM,iBADgB,WACe;AACrC,KAAI,OAAO,mBAAmB,WAC5B,KAAI;AACF,SAAO,2BAA4B,eAA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AGT,SAAgB,6BAAqD;CAEnE,MAAM,SADgB,WACO;AAC7B,KAAI,OAAO,WAAW,WACpB,QAAO,2BAA4B,QAA0B,CAAC;AAEhE,QAAO,2BAA2B,OAAO"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { callMiniProgramAsyncFailure, callMiniProgramAsyncSuccess } from "./async.mjs";
|
|
2
|
+
import { buildAuthSettingSnapshot, buildUserProfilePayload, generateLoginCode, normalizeAuthScope, resolveAuthorizeDecision, resolveCheckSessionState, resolveUserProfileDecision, syncOpenAppAuthorizeSettingPreset, syncOpenSettingPreset } from "./auth.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/runtime/polyfill/authApi.ts
|
|
5
|
+
function getSettingBridge(options, authState) {
|
|
6
|
+
return Promise.resolve(callMiniProgramAsyncSuccess(options, {
|
|
7
|
+
errMsg: "getSetting:ok",
|
|
8
|
+
authSetting: buildAuthSettingSnapshot(authState)
|
|
9
|
+
}));
|
|
10
|
+
}
|
|
11
|
+
function authorizeBridge(options, authState, supportedScopes) {
|
|
12
|
+
const scope = normalizeAuthScope(options?.scope);
|
|
13
|
+
if (!scope) {
|
|
14
|
+
const failure = callMiniProgramAsyncFailure(options, "authorize:fail invalid scope");
|
|
15
|
+
return Promise.reject(failure);
|
|
16
|
+
}
|
|
17
|
+
if (!supportedScopes.has(scope)) {
|
|
18
|
+
const failure = callMiniProgramAsyncFailure(options, "authorize:fail unsupported scope");
|
|
19
|
+
return Promise.reject(failure);
|
|
20
|
+
}
|
|
21
|
+
const decision = resolveAuthorizeDecision(scope);
|
|
22
|
+
authState.set(scope, decision);
|
|
23
|
+
if (decision !== "authorized") {
|
|
24
|
+
const failure = callMiniProgramAsyncFailure(options, `authorize:fail ${decision === "denied" ? "auth deny" : "auth canceled"}`);
|
|
25
|
+
return Promise.reject(failure);
|
|
26
|
+
}
|
|
27
|
+
return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: "authorize:ok" }));
|
|
28
|
+
}
|
|
29
|
+
function openSettingBridge(options, authState, supportedScopes) {
|
|
30
|
+
syncOpenSettingPreset(authState, supportedScopes);
|
|
31
|
+
return Promise.resolve(callMiniProgramAsyncSuccess(options, {
|
|
32
|
+
errMsg: "openSetting:ok",
|
|
33
|
+
authSetting: buildAuthSettingSnapshot(authState)
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
36
|
+
function openAppAuthorizeSettingBridge(options, authState, scopeMap, resolveAppAuthorizeSetting) {
|
|
37
|
+
syncOpenAppAuthorizeSettingPreset(authState, scopeMap);
|
|
38
|
+
return Promise.resolve(callMiniProgramAsyncSuccess(options, {
|
|
39
|
+
errMsg: "openAppAuthorizeSetting:ok",
|
|
40
|
+
...resolveAppAuthorizeSetting()
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
function getSystemSettingBridge(authState, resolveOrientation) {
|
|
44
|
+
return {
|
|
45
|
+
bluetoothEnabled: false,
|
|
46
|
+
wifiEnabled: true,
|
|
47
|
+
locationEnabled: authState.get("scope.userLocation") === "authorized",
|
|
48
|
+
locationReducedAccuracy: false,
|
|
49
|
+
deviceOrientation: resolveOrientation()
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function getAppAuthorizeSettingBridge(authState) {
|
|
53
|
+
const resolveStatus = (scope) => authState.get(scope) ?? "not determined";
|
|
54
|
+
return {
|
|
55
|
+
albumAuthorized: resolveStatus("scope.writePhotosAlbum"),
|
|
56
|
+
bluetoothAuthorized: "not determined",
|
|
57
|
+
cameraAuthorized: resolveStatus("scope.camera"),
|
|
58
|
+
locationAuthorized: resolveStatus("scope.userLocation"),
|
|
59
|
+
microphoneAuthorized: resolveStatus("scope.record"),
|
|
60
|
+
notificationAuthorized: "not determined",
|
|
61
|
+
phoneCalendarAuthorized: "not determined"
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function loginBridge(options) {
|
|
65
|
+
return Promise.resolve(callMiniProgramAsyncSuccess(options, {
|
|
66
|
+
errMsg: "login:ok",
|
|
67
|
+
code: generateLoginCode()
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
function checkSessionBridge(options) {
|
|
71
|
+
if (!resolveCheckSessionState()) {
|
|
72
|
+
const failure = callMiniProgramAsyncFailure(options, "checkSession:fail session expired");
|
|
73
|
+
return Promise.reject(failure);
|
|
74
|
+
}
|
|
75
|
+
return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: "checkSession:ok" }));
|
|
76
|
+
}
|
|
77
|
+
function getUserInfoBridge(options, authState) {
|
|
78
|
+
if (authState.get("scope.userInfo") === "denied") {
|
|
79
|
+
const failure = callMiniProgramAsyncFailure(options, "getUserInfo:fail auth deny");
|
|
80
|
+
return Promise.reject(failure);
|
|
81
|
+
}
|
|
82
|
+
authState.set("scope.userInfo", "authorized");
|
|
83
|
+
return Promise.resolve(callMiniProgramAsyncSuccess(options, buildUserProfilePayload("getUserInfo:ok", options?.lang)));
|
|
84
|
+
}
|
|
85
|
+
function getUserProfileBridge(options, authState) {
|
|
86
|
+
if (!(typeof options?.desc === "string" ? options.desc.trim() : "")) {
|
|
87
|
+
const failure = callMiniProgramAsyncFailure(options, "getUserProfile:fail invalid desc");
|
|
88
|
+
return Promise.reject(failure);
|
|
89
|
+
}
|
|
90
|
+
const decision = resolveUserProfileDecision();
|
|
91
|
+
authState.set("scope.userInfo", decision);
|
|
92
|
+
if (decision !== "authorized") {
|
|
93
|
+
const failure = callMiniProgramAsyncFailure(options, `getUserProfile:fail ${decision === "denied" ? "auth deny" : "auth canceled"}`);
|
|
94
|
+
return Promise.reject(failure);
|
|
95
|
+
}
|
|
96
|
+
return Promise.resolve(callMiniProgramAsyncSuccess(options, buildUserProfilePayload("getUserProfile:ok", options?.lang)));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
//#endregion
|
|
100
|
+
export { authorizeBridge, checkSessionBridge, getAppAuthorizeSettingBridge, getSettingBridge, getSystemSettingBridge, getUserInfoBridge, getUserProfileBridge, loginBridge, openAppAuthorizeSettingBridge, openSettingBridge };
|
|
101
|
+
//# sourceMappingURL=authApi.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authApi.mjs","names":[],"sources":["../../../src/runtime/polyfill/authApi.ts"],"sourcesContent":["import type { AppAuthorizeStatusLike } from './auth'\nimport {\n callMiniProgramAsyncFailure,\n callMiniProgramAsyncSuccess,\n} from './async'\nimport {\n buildAuthSettingSnapshot,\n buildUserProfilePayload,\n generateLoginCode,\n normalizeAuthScope,\n resolveAuthorizeDecision,\n resolveCheckSessionState,\n resolveUserProfileDecision,\n syncOpenAppAuthorizeSettingPreset,\n syncOpenSettingPreset,\n} from './auth'\n\ntype AuthState = Map<string, AppAuthorizeStatusLike>\n\nexport function getSettingBridge(options: any, authState: AuthState) {\n return Promise.resolve(callMiniProgramAsyncSuccess(options, {\n errMsg: 'getSetting:ok',\n authSetting: buildAuthSettingSnapshot(authState),\n }))\n}\n\nexport function authorizeBridge(options: any, authState: AuthState, supportedScopes: Set<string>) {\n const scope = normalizeAuthScope(options?.scope)\n if (!scope) {\n const failure = callMiniProgramAsyncFailure(options, 'authorize:fail invalid scope')\n return Promise.reject(failure)\n }\n if (!supportedScopes.has(scope)) {\n const failure = callMiniProgramAsyncFailure(options, 'authorize:fail unsupported scope')\n return Promise.reject(failure)\n }\n const decision = resolveAuthorizeDecision(scope)\n authState.set(scope, decision)\n if (decision !== 'authorized') {\n const reason = decision === 'denied' ? 'auth deny' : 'auth canceled'\n const failure = callMiniProgramAsyncFailure(options, `authorize:fail ${reason}`)\n return Promise.reject(failure)\n }\n return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: 'authorize:ok' }))\n}\n\nexport function openSettingBridge(options: any, authState: AuthState, supportedScopes: Set<string>) {\n syncOpenSettingPreset(authState, supportedScopes)\n return Promise.resolve(callMiniProgramAsyncSuccess(options, {\n errMsg: 'openSetting:ok',\n authSetting: buildAuthSettingSnapshot(authState),\n }))\n}\n\nexport function openAppAuthorizeSettingBridge(\n options: any,\n authState: AuthState,\n scopeMap: Record<string, string>,\n resolveAppAuthorizeSetting: () => object,\n) {\n syncOpenAppAuthorizeSettingPreset(authState, scopeMap)\n return Promise.resolve(callMiniProgramAsyncSuccess(options, {\n errMsg: 'openAppAuthorizeSetting:ok',\n ...resolveAppAuthorizeSetting(),\n }))\n}\n\nexport function getSystemSettingBridge(authState: AuthState, resolveOrientation: () => 'portrait' | 'landscape') {\n const locationAuthorized = authState.get('scope.userLocation') === 'authorized'\n return {\n bluetoothEnabled: false,\n wifiEnabled: true,\n locationEnabled: locationAuthorized,\n locationReducedAccuracy: false,\n deviceOrientation: resolveOrientation(),\n }\n}\n\nexport function getAppAuthorizeSettingBridge(authState: AuthState) {\n const resolveStatus = (scope: string) => authState.get(scope) ?? 'not determined'\n return {\n albumAuthorized: resolveStatus('scope.writePhotosAlbum'),\n bluetoothAuthorized: 'not determined',\n cameraAuthorized: resolveStatus('scope.camera'),\n locationAuthorized: resolveStatus('scope.userLocation'),\n microphoneAuthorized: resolveStatus('scope.record'),\n notificationAuthorized: 'not determined',\n phoneCalendarAuthorized: 'not determined',\n }\n}\n\nexport function loginBridge(options: any) {\n return Promise.resolve(callMiniProgramAsyncSuccess(options, {\n errMsg: 'login:ok',\n code: generateLoginCode(),\n }))\n}\n\nexport function checkSessionBridge(options: any) {\n if (!resolveCheckSessionState()) {\n const failure = callMiniProgramAsyncFailure(options, 'checkSession:fail session expired')\n return Promise.reject(failure)\n }\n return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: 'checkSession:ok' }))\n}\n\nexport function getUserInfoBridge(options: any, authState: AuthState) {\n if (authState.get('scope.userInfo') === 'denied') {\n const failure = callMiniProgramAsyncFailure(options, 'getUserInfo:fail auth deny')\n return Promise.reject(failure)\n }\n authState.set('scope.userInfo', 'authorized')\n return Promise.resolve(callMiniProgramAsyncSuccess(options, buildUserProfilePayload('getUserInfo:ok', options?.lang)))\n}\n\nexport function getUserProfileBridge(options: any, authState: AuthState) {\n const desc = typeof options?.desc === 'string' ? options.desc.trim() : ''\n if (!desc) {\n const failure = callMiniProgramAsyncFailure(options, 'getUserProfile:fail invalid desc')\n return Promise.reject(failure)\n }\n const decision = resolveUserProfileDecision()\n authState.set('scope.userInfo', decision)\n if (decision !== 'authorized') {\n const reason = decision === 'denied' ? 'auth deny' : 'auth canceled'\n const failure = callMiniProgramAsyncFailure(options, `getUserProfile:fail ${reason}`)\n return Promise.reject(failure)\n }\n return Promise.resolve(callMiniProgramAsyncSuccess(options, buildUserProfilePayload('getUserProfile:ok', options?.lang)))\n}\n"],"mappings":";;;;AAmBA,SAAgB,iBAAiB,SAAc,WAAsB;AACnE,QAAO,QAAQ,QAAQ,4BAA4B,SAAS;EAC1D,QAAQ;EACR,aAAa,yBAAyB,UAAU;EACjD,CAAC,CAAC;;AAGL,SAAgB,gBAAgB,SAAc,WAAsB,iBAA8B;CAChG,MAAM,QAAQ,mBAAmB,SAAS,MAAM;AAChD,KAAI,CAAC,OAAO;EACV,MAAM,UAAU,4BAA4B,SAAS,+BAA+B;AACpF,SAAO,QAAQ,OAAO,QAAQ;;AAEhC,KAAI,CAAC,gBAAgB,IAAI,MAAM,EAAE;EAC/B,MAAM,UAAU,4BAA4B,SAAS,mCAAmC;AACxF,SAAO,QAAQ,OAAO,QAAQ;;CAEhC,MAAM,WAAW,yBAAyB,MAAM;AAChD,WAAU,IAAI,OAAO,SAAS;AAC9B,KAAI,aAAa,cAAc;EAE7B,MAAM,UAAU,4BAA4B,SAAS,kBADtC,aAAa,WAAW,cAAc,kBAC2B;AAChF,SAAO,QAAQ,OAAO,QAAQ;;AAEhC,QAAO,QAAQ,QAAQ,4BAA4B,SAAS,EAAE,QAAQ,gBAAgB,CAAC,CAAC;;AAG1F,SAAgB,kBAAkB,SAAc,WAAsB,iBAA8B;AAClG,uBAAsB,WAAW,gBAAgB;AACjD,QAAO,QAAQ,QAAQ,4BAA4B,SAAS;EAC1D,QAAQ;EACR,aAAa,yBAAyB,UA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c,WAAsB;AAEvE,KAAI,EADS,OAAO,SAAS,SAAS,WAAW,QAAQ,KAAK,MAAM,GAAG,KAC5D;EACT,MAAM,UAAU,4BAA4B,SAAS,mCAAmC;AACxF,SAAO,QAAQ,OAAO,QAAQ;;CAEhC,MAAM,WAAW,4BAA4B;AAC7C,WAAU,IAAI,kBAAkB,SAAS;AACzC,KAAI,aAAa,cAAc;EAE7B,MAAM,UAAU,4BAA4B,SAAS,uBADtC,aAAa,WAAW,cAAc,kBACgC;AACrF,SAAO,QAAQ,OAAO,QAAQ;;AAEhC,QAAO,QAAQ,QAAQ,4BAA4B,SAAS,wBAAwB,qBAAqB,SAAS,KAAK,CAAC,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { callMiniProgramAsyncFailure, callMiniProgramAsyncSuccess } from "./async.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/runtime/polyfill/background.ts
|
|
4
|
+
function normalizeBackgroundColorValue(color) {
|
|
5
|
+
if (typeof color !== "string") return "";
|
|
6
|
+
return color.trim();
|
|
7
|
+
}
|
|
8
|
+
function setBackgroundColorBridge(options) {
|
|
9
|
+
const backgroundColor = normalizeBackgroundColorValue(options?.backgroundColor);
|
|
10
|
+
const backgroundColorTop = normalizeBackgroundColorValue(options?.backgroundColorTop);
|
|
11
|
+
const backgroundColorBottom = normalizeBackgroundColorValue(options?.backgroundColorBottom);
|
|
12
|
+
const runtimeDocument = typeof document !== "undefined" ? document : void 0;
|
|
13
|
+
const rootElement = runtimeDocument?.documentElement;
|
|
14
|
+
const body = runtimeDocument?.body;
|
|
15
|
+
if (body && backgroundColor) body.style.backgroundColor = backgroundColor;
|
|
16
|
+
if (rootElement && backgroundColorTop && backgroundColorBottom) rootElement.style.setProperty("--weapp-web-background-gradient", `linear-gradient(${backgroundColorTop}, ${backgroundColorBottom})`);
|
|
17
|
+
return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: "setBackgroundColor:ok" }));
|
|
18
|
+
}
|
|
19
|
+
function setBackgroundTextStyleBridge(options) {
|
|
20
|
+
const textStyle = options?.textStyle;
|
|
21
|
+
if (textStyle !== void 0 && textStyle !== "dark" && textStyle !== "light") {
|
|
22
|
+
const failure = callMiniProgramAsyncFailure(options, "setBackgroundTextStyle:fail invalid textStyle");
|
|
23
|
+
return Promise.reject(failure);
|
|
24
|
+
}
|
|
25
|
+
if (typeof document !== "undefined" && document.documentElement && textStyle) document.documentElement.setAttribute("data-weapp-background-text-style", textStyle);
|
|
26
|
+
return Promise.resolve(callMiniProgramAsyncSuccess(options, { errMsg: "setBackgroundTextStyle:ok" }));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
export { setBackgroundColorBridge, setBackgroundTextStyleBridge };
|
|
31
|
+
//# sourceMappingURL=background.mjs.map
|