miaoda-expo-devkit 0.1.1-beta.60 → 0.1.1-beta.61
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.
|
@@ -1,30 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var import_react_native = require("react-native");
|
|
3
|
-
var import_expo = require("expo");
|
|
4
3
|
var import_web_stub_dialog = require("./web-stub-dialog");
|
|
5
|
-
if (import_react_native.Platform.OS !== "web"
|
|
4
|
+
if (import_react_native.Platform.OS !== "web") {
|
|
6
5
|
module.exports = require("expo-calendar");
|
|
7
6
|
} else {
|
|
8
7
|
let showCalendarAlert = function(title, lines, isValid, errors) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
});
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
const statusLine = isValid ? "\u2705 \u53C2\u6570\u5408\u89C4" : "\u274C \u53C2\u6570\u6709\u8BEF";
|
|
18
|
-
const parts = ["\u79D2\u54D2\u626B\u7801\u9884\u89C8\u4E0D\u652F\u6301\u8BBF\u95EE\u624B\u673A\u65E5\u5386", "", ...lines, "", statusLine];
|
|
19
|
-
if (!isValid && errors && errors.length > 0) {
|
|
20
|
-
parts.push(`\u95EE\u9898: ${errors.join(" / ")}`);
|
|
21
|
-
parts.push("");
|
|
22
|
-
parts.push("\u8BF7\u622A\u56FE\u53D1\u7ED9\u79D2\u54D2 Agent \u4FEE\u590D");
|
|
23
|
-
} else {
|
|
24
|
-
parts.push("");
|
|
25
|
-
parts.push("\u53D1\u5E03\u4E3A\u6B63\u5F0F App \u540E\u53EF\u6B63\u5E38\u4F7F\u7528");
|
|
26
|
-
}
|
|
27
|
-
import_react_native.Alert.alert(title, parts.join("\n"), [{ text: "\u77E5\u9053\u4E86" }]);
|
|
8
|
+
(0, import_web_stub_dialog.showWebStubDialog)({
|
|
9
|
+
title,
|
|
10
|
+
details: lines,
|
|
11
|
+
errors: !isValid && errors && errors.length > 0 ? errors : void 0
|
|
12
|
+
});
|
|
28
13
|
}, validateId = function(id, label = "id") {
|
|
29
14
|
const errors = [];
|
|
30
15
|
if (typeof id !== "string" || id.trim().length === 0) {
|
|
@@ -46,71 +31,47 @@ if (import_react_native.Platform.OS !== "web" && !(0, import_expo.isRunningInExp
|
|
|
46
31
|
if (typeof value === "string") return value;
|
|
47
32
|
return String(value);
|
|
48
33
|
}, useCalendarPermissions = function() {
|
|
49
|
-
const [permission
|
|
50
|
-
const requestPermission = useCallback(async () =>
|
|
51
|
-
|
|
52
|
-
"\u8BF7\u6C42\u65E5\u5386\u6743\u9650",
|
|
53
|
-
["\u64CD\u4F5C: \u8BF7\u6C42\u8BBF\u95EE\u624B\u673A\u65E5\u5386\u6743\u9650", "\u79D2\u54D2\u9884\u89C8\u6A21\u5F0F\u4E0B\u6A21\u62DF\u8FD4\u56DE\u672A\u6388\u6743", "\u53D1\u5E03\u6B63\u5F0F App \u540E\u4F1A\u5F39\u51FA\u7CFB\u7EDF\u6388\u6743\u5F39\u7A97"],
|
|
54
|
-
true
|
|
55
|
-
);
|
|
56
|
-
setPermission(DENIED_PERMISSION);
|
|
57
|
-
return DENIED_PERMISSION;
|
|
58
|
-
}, []);
|
|
59
|
-
const getPermission = useCallback(async () => permission, [permission]);
|
|
34
|
+
const [permission] = useState(GRANTED_PERMISSION);
|
|
35
|
+
const requestPermission = useCallback(async () => GRANTED_PERMISSION, []);
|
|
36
|
+
const getPermission = useCallback(async () => GRANTED_PERMISSION, []);
|
|
60
37
|
return [permission, requestPermission, getPermission];
|
|
61
38
|
}, useRemindersPermissions = function() {
|
|
62
|
-
const [permission
|
|
63
|
-
const requestPermission = useCallback(async () =>
|
|
64
|
-
|
|
65
|
-
"\u8BF7\u6C42\u63D0\u9192\u4E8B\u9879\u6743\u9650",
|
|
66
|
-
["\u64CD\u4F5C: \u8BF7\u6C42\u8BBF\u95EE\u624B\u673A\u63D0\u9192\u4E8B\u9879\u6743\u9650\uFF08iOS \u4E13\u5C5E\uFF09", "\u79D2\u54D2\u9884\u89C8\u6A21\u5F0F\u4E0B\u6A21\u62DF\u8FD4\u56DE\u672A\u6388\u6743", "\u53D1\u5E03\u6B63\u5F0F App \u540E\u4F1A\u5F39\u51FA\u7CFB\u7EDF\u6388\u6743\u5F39\u7A97"],
|
|
67
|
-
true
|
|
68
|
-
);
|
|
69
|
-
setPermission(DENIED_PERMISSION);
|
|
70
|
-
return DENIED_PERMISSION;
|
|
71
|
-
}, []);
|
|
72
|
-
const getPermission = useCallback(async () => permission, [permission]);
|
|
39
|
+
const [permission] = useState(GRANTED_PERMISSION);
|
|
40
|
+
const requestPermission = useCallback(async () => GRANTED_PERMISSION, []);
|
|
41
|
+
const getPermission = useCallback(async () => GRANTED_PERMISSION, []);
|
|
73
42
|
return [permission, requestPermission, getPermission];
|
|
74
43
|
};
|
|
75
44
|
var showCalendarAlert2 = showCalendarAlert, validateId2 = validateId, validateDate2 = validateDate, formatDateArg2 = formatDateArg, useCalendarPermissions2 = useCalendarPermissions, useRemindersPermissions2 = useRemindersPermissions;
|
|
76
|
-
const
|
|
77
|
-
status: "
|
|
78
|
-
granted:
|
|
45
|
+
const GRANTED_PERMISSION = {
|
|
46
|
+
status: "granted",
|
|
47
|
+
granted: true,
|
|
79
48
|
canAskAgain: true,
|
|
80
49
|
expires: "never"
|
|
81
50
|
};
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
51
|
+
const STUB_CALENDAR = {
|
|
52
|
+
id: "stub-calendar",
|
|
53
|
+
title: "\u9884\u89C8\u65E5\u5386\uFF08Web\uFF09",
|
|
54
|
+
color: "#1677FF",
|
|
55
|
+
entityType: "event",
|
|
56
|
+
source: { id: "stub", type: "local", name: "\u672C\u5730" },
|
|
57
|
+
type: "local",
|
|
58
|
+
allowsModifications: true,
|
|
59
|
+
allowedAvailabilities: [],
|
|
60
|
+
allowedReminders: [],
|
|
61
|
+
allowedAttendeeTypes: [],
|
|
62
|
+
accessLevel: "owner"
|
|
87
63
|
};
|
|
88
64
|
const { useState, useCallback } = require("react");
|
|
89
|
-
const requestCalendarPermissionsAsync = async () =>
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
true
|
|
94
|
-
);
|
|
95
|
-
return DENIED_PERMISSION;
|
|
96
|
-
};
|
|
97
|
-
const getCalendarPermissionsAsync = async () => DENIED_PERMISSION;
|
|
98
|
-
const requestRemindersPermissionsAsync = async () => {
|
|
99
|
-
showCalendarAlert(
|
|
100
|
-
"\u8BF7\u6C42\u63D0\u9192\u4E8B\u9879\u6743\u9650",
|
|
101
|
-
["\u64CD\u4F5C: \u8BF7\u6C42\u8BBF\u95EE\u624B\u673A\u63D0\u9192\u4E8B\u9879\u6743\u9650\uFF08iOS \u4E13\u5C5E\uFF09", "\u79D2\u54D2\u9884\u89C8\u6A21\u5F0F\u4E0B\u6A21\u62DF\u8FD4\u56DE\u672A\u6388\u6743"],
|
|
102
|
-
true
|
|
103
|
-
);
|
|
104
|
-
return DENIED_PERMISSION;
|
|
105
|
-
};
|
|
106
|
-
const getRemindersPermissionsAsync = async () => DENIED_PERMISSION;
|
|
65
|
+
const requestCalendarPermissionsAsync = async () => GRANTED_PERMISSION;
|
|
66
|
+
const getCalendarPermissionsAsync = async () => GRANTED_PERMISSION;
|
|
67
|
+
const requestRemindersPermissionsAsync = async () => GRANTED_PERMISSION;
|
|
68
|
+
const getRemindersPermissionsAsync = async () => GRANTED_PERMISSION;
|
|
107
69
|
const requestPermissionsAsync = requestCalendarPermissionsAsync;
|
|
108
70
|
const getPermissionsAsync = getCalendarPermissionsAsync;
|
|
109
|
-
const isAvailableAsync = async () =>
|
|
71
|
+
const isAvailableAsync = async () => true;
|
|
110
72
|
const getCalendarsAsync = async (entityType) => {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
return [];
|
|
73
|
+
void entityType;
|
|
74
|
+
return [STUB_CALENDAR];
|
|
114
75
|
};
|
|
115
76
|
const getDefaultCalendarAsync = async () => {
|
|
116
77
|
showCalendarAlert("\u83B7\u53D6\u9ED8\u8BA4\u65E5\u5386", ["\u64CD\u4F5C: \u83B7\u53D6\u7CFB\u7EDF\u9ED8\u8BA4\u65E5\u5386", "\u79D2\u54D2\u9884\u89C8\u6A21\u5F0F\u4E0D\u652F\u6301"], false, ["\u65E0\u6CD5\u8BBF\u95EE\u7CFB\u7EDF\u65E5\u5386"]);
|
|
@@ -339,7 +300,7 @@ if (import_react_native.Platform.OS !== "web" && !(0, import_expo.isRunningInExp
|
|
|
339
300
|
updateEventAsync,
|
|
340
301
|
deleteEventAsync
|
|
341
302
|
};
|
|
342
|
-
const noopPermission = async () =>
|
|
303
|
+
const noopPermission = async () => GRANTED_PERMISSION;
|
|
343
304
|
const noop = async () => void 0;
|
|
344
305
|
module.exports = new Proxy(enums, {
|
|
345
306
|
get(target, key) {
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var import_entry_inject = require("./entry-inject");
|
|
3
3
|
var import_entry_classic = require("expo-router/entry-classic");
|
|
4
|
+
var import_navigation_guard_spy = require("./navigation-guard-spy");
|
|
5
|
+
(0, import_navigation_guard_spy.setupNavigationGuardSpy)(
|
|
6
|
+
require("expo-router"),
|
|
7
|
+
require("expo-router/build/global-state/router-store").store
|
|
8
|
+
);
|
|
4
9
|
//# sourceMappingURL=expo-router-entry-stub.js.map
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var navigation_guard_spy_exports = {};
|
|
20
|
+
__export(navigation_guard_spy_exports, {
|
|
21
|
+
checkHrefAgainstStore: () => checkHrefAgainstStore,
|
|
22
|
+
extractHrefString: () => extractHrefString,
|
|
23
|
+
setupNavigationGuardSpy: () => setupNavigationGuardSpy
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(navigation_guard_spy_exports);
|
|
26
|
+
var import_navigation_guard_detector = require("../utils/navigation-guard-detector");
|
|
27
|
+
function extractHrefString(href) {
|
|
28
|
+
if (typeof href === "string") return href;
|
|
29
|
+
if (typeof href === "object" && href !== null) {
|
|
30
|
+
const p = href.pathname;
|
|
31
|
+
if (typeof p === "string") return p;
|
|
32
|
+
}
|
|
33
|
+
return String(href);
|
|
34
|
+
}
|
|
35
|
+
function checkHrefAgainstStore(href, store) {
|
|
36
|
+
const navigationRef = store?.navigationRef?.current;
|
|
37
|
+
const rawScreens = store?.linking?.config?.screens;
|
|
38
|
+
if (!navigationRef || !rawScreens) return;
|
|
39
|
+
const rootSlot = rawScreens["__root"];
|
|
40
|
+
const allScreens = rootSlot?.screens ?? rawScreens;
|
|
41
|
+
let rootState;
|
|
42
|
+
try {
|
|
43
|
+
rootState = navigationRef.getRootState?.();
|
|
44
|
+
} catch {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const activeRouteNames = rootState?.routeNames ?? [];
|
|
48
|
+
const hrefStr = extractHrefString(href);
|
|
49
|
+
const result = (0, import_navigation_guard_detector.detectNavigationFailure)(hrefStr, allScreens, activeRouteNames);
|
|
50
|
+
if (result.type === "blocked_by_guard") {
|
|
51
|
+
throw new Error(
|
|
52
|
+
`[NavigationGuard] \u5BFC\u822A\u5230 "${hrefStr}" \u5931\u8D25\uFF1A\u8DEF\u7531 "${result.route}" \u88AB Stack.Protected guard \u5C4F\u853D\uFF0C\u5F53\u524D\u6D3B\u8DC3\u8DEF\u7531\uFF1A[${activeRouteNames.join(", ")}]\u3002\u8BF7\u68C0\u67E5\u8BA4\u8BC1\u72B6\u6001\u662F\u5426\u5DF2\u5C31\u7EEA\u518D\u6267\u884C\u5BFC\u822A\u3002`
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
if (result.type === "route_not_found") {
|
|
56
|
+
throw new Error(
|
|
57
|
+
`[NavigationGuard] \u5BFC\u822A\u5230 "${hrefStr}" \u5931\u8D25\uFF1A\u8DEF\u7531 "${result.route}" \u5728\u6587\u4EF6\u7CFB\u7EDF\u4E2D\u4E0D\u5B58\u5728\uFF0C\u8BF7\u68C0\u67E5\u8DEF\u7531\u8DEF\u5F84\u62FC\u5199\u3002`
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const METHODS = ["replace", "push", "navigate"];
|
|
62
|
+
const GUARD_MARKER = /* @__PURE__ */ Symbol("__devkit_guard__");
|
|
63
|
+
function setupNavigationGuardSpy(expoRouter, store) {
|
|
64
|
+
if (typeof __DEV__ === "undefined" || !__DEV__) return;
|
|
65
|
+
const router = expoRouter?.router;
|
|
66
|
+
if (!router || typeof router !== "object") return;
|
|
67
|
+
for (const method of METHODS) {
|
|
68
|
+
let guardedNavigate2 = function(href, ...rest) {
|
|
69
|
+
checkHrefAgainstStore(href, store);
|
|
70
|
+
return original.call(this, href, ...rest);
|
|
71
|
+
};
|
|
72
|
+
var guardedNavigate = guardedNavigate2;
|
|
73
|
+
const original = router[method];
|
|
74
|
+
if (typeof original !== "function") continue;
|
|
75
|
+
if (original[GUARD_MARKER]) continue;
|
|
76
|
+
guardedNavigate2[GUARD_MARKER] = true;
|
|
77
|
+
router[method] = guardedNavigate2;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
81
|
+
0 && (module.exports = {
|
|
82
|
+
checkHrefAgainstStore,
|
|
83
|
+
extractHrefString,
|
|
84
|
+
setupNavigationGuardSpy
|
|
85
|
+
});
|
|
86
|
+
//# sourceMappingURL=navigation-guard-spy.js.map
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var navigation_guard_detector_exports = {};
|
|
20
|
+
__export(navigation_guard_detector_exports, {
|
|
21
|
+
detectNavigationFailure: () => detectNavigationFailure,
|
|
22
|
+
flattenScreenNames: () => flattenScreenNames
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(navigation_guard_detector_exports);
|
|
25
|
+
function flattenScreenNames(screens, prefix = "") {
|
|
26
|
+
const result = /* @__PURE__ */ new Set();
|
|
27
|
+
for (const [key, value] of Object.entries(screens)) {
|
|
28
|
+
const full = prefix ? `${prefix}/${key}` : key;
|
|
29
|
+
result.add(full);
|
|
30
|
+
const nested = value?.screens;
|
|
31
|
+
if (nested && typeof nested === "object") {
|
|
32
|
+
for (const r of flattenScreenNames(nested, full)) {
|
|
33
|
+
result.add(r);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
function detectNavigationFailure(href, allScreens, activeRouteNames) {
|
|
40
|
+
const segment = String(href).replace(/^\//, "").split("/")[0];
|
|
41
|
+
if (!segment) return { type: "ok" };
|
|
42
|
+
const allRoutes = flattenScreenNames(allScreens);
|
|
43
|
+
const activeRoutes = new Set(activeRouteNames);
|
|
44
|
+
if (allRoutes.has(segment) && !activeRoutes.has(segment)) {
|
|
45
|
+
return { type: "blocked_by_guard", route: segment };
|
|
46
|
+
}
|
|
47
|
+
if (!allRoutes.has(segment)) {
|
|
48
|
+
return { type: "route_not_found", route: segment };
|
|
49
|
+
}
|
|
50
|
+
return { type: "ok" };
|
|
51
|
+
}
|
|
52
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
53
|
+
0 && (module.exports = {
|
|
54
|
+
detectNavigationFailure,
|
|
55
|
+
flattenScreenNames
|
|
56
|
+
});
|
|
57
|
+
//# sourceMappingURL=navigation-guard-detector.js.map
|