miaoda-expo-devkit 0.1.1-beta.83 → 0.1.1-beta.84
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/metro.d.mts +5 -0
- package/dist/metro.d.ts +5 -0
- package/dist/metro.js +4 -1
- package/dist/metro.mjs +4 -1
- package/dist/stubs/expo-calendar-stub.js +53 -51
- package/dist/stubs/expo-contacts-stub.js +46 -45
- package/dist/stubs/expo-file-system-next-stub.js +11 -10
- package/dist/stubs/expo-file-system-stub.js +19 -18
- package/dist/stubs/expo-haptics-stub.js +9 -8
- package/dist/stubs/expo-image-picker-stub.js +9 -8
- package/dist/stubs/expo-media-library-stub.js +12 -11
- package/dist/stubs/expo-notifications-stub.js +36 -35
- package/dist/stubs/i18n/en.js +195 -0
- package/dist/stubs/i18n/index.js +66 -0
- package/dist/stubs/i18n/zh.js +198 -0
- package/dist/stubs/web-stub-dialog.js +7 -6
- package/package.json +1 -1
package/dist/metro.d.mts
CHANGED
|
@@ -141,6 +141,11 @@ interface DevkitOptions {
|
|
|
141
141
|
* 默认:'./src/global.css'
|
|
142
142
|
*/
|
|
143
143
|
input?: string;
|
|
144
|
+
/**
|
|
145
|
+
* stub 弹窗/提示文案的语言。
|
|
146
|
+
* 不设置时运行时自动检测(navigator.language / NativeModules)。
|
|
147
|
+
*/
|
|
148
|
+
locale?: 'zh' | 'en';
|
|
144
149
|
}
|
|
145
150
|
/**
|
|
146
151
|
* 一站式应用所有 devkit Metro wrapper。
|
package/dist/metro.d.ts
CHANGED
|
@@ -141,6 +141,11 @@ interface DevkitOptions {
|
|
|
141
141
|
* 默认:'./src/global.css'
|
|
142
142
|
*/
|
|
143
143
|
input?: string;
|
|
144
|
+
/**
|
|
145
|
+
* stub 弹窗/提示文案的语言。
|
|
146
|
+
* 不设置时运行时自动检测(navigator.language / NativeModules)。
|
|
147
|
+
*/
|
|
148
|
+
locale?: 'zh' | 'en';
|
|
144
149
|
}
|
|
145
150
|
/**
|
|
146
151
|
* 一站式应用所有 devkit Metro wrapper。
|
package/dist/metro.js
CHANGED
|
@@ -630,7 +630,10 @@ function withPersistentCache(config, options = {}) {
|
|
|
630
630
|
// src/metro/withDevkit.ts
|
|
631
631
|
function withDevkit(config, options = {}) {
|
|
632
632
|
const projectRoot = config.projectRoot ?? process.cwd();
|
|
633
|
-
const { input = "./src/global.css" } = options;
|
|
633
|
+
const { input = "./src/global.css", locale } = options;
|
|
634
|
+
if (locale) {
|
|
635
|
+
process.env["DEVKIT_LOCALE"] = locale;
|
|
636
|
+
}
|
|
634
637
|
config = withTransformLogger(config);
|
|
635
638
|
config = withPersistentCache(config);
|
|
636
639
|
config = withWorkspaceNodeModules(config);
|
package/dist/metro.mjs
CHANGED
|
@@ -581,7 +581,10 @@ function withPersistentCache(config, options = {}) {
|
|
|
581
581
|
// src/metro/withDevkit.ts
|
|
582
582
|
function withDevkit(config, options = {}) {
|
|
583
583
|
const projectRoot = config.projectRoot ?? process.cwd();
|
|
584
|
-
const { input = "./src/global.css" } = options;
|
|
584
|
+
const { input = "./src/global.css", locale } = options;
|
|
585
|
+
if (locale) {
|
|
586
|
+
process.env["DEVKIT_LOCALE"] = locale;
|
|
587
|
+
}
|
|
585
588
|
config = withTransformLogger(config);
|
|
586
589
|
config = withPersistentCache(config);
|
|
587
590
|
config = withWorkspaceNodeModules(config);
|
|
@@ -1,10 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var import_react_native = require("react-native");
|
|
3
3
|
var import_web_stub_dialog = require("./web-stub-dialog");
|
|
4
|
+
var import_i18n = require("./i18n");
|
|
4
5
|
if (import_react_native.Platform.OS !== "web") {
|
|
5
6
|
module.exports = require("expo-calendar");
|
|
6
7
|
} else {
|
|
7
|
-
let
|
|
8
|
+
let createStubCalendar = function() {
|
|
9
|
+
return {
|
|
10
|
+
id: "stub-calendar",
|
|
11
|
+
title: (0, import_i18n.t)("calendar.previewCalendarTitle"),
|
|
12
|
+
color: "#1677FF",
|
|
13
|
+
entityType: "event",
|
|
14
|
+
source: { id: "stub", type: "local", name: (0, import_i18n.t)("calendar.sourceNameLocal") },
|
|
15
|
+
type: "local",
|
|
16
|
+
allowsModifications: true,
|
|
17
|
+
allowedAvailabilities: [],
|
|
18
|
+
allowedReminders: [],
|
|
19
|
+
allowedAttendeeTypes: [],
|
|
20
|
+
accessLevel: "owner"
|
|
21
|
+
};
|
|
22
|
+
}, showCalendarAlert = function(title, lines, isValid, errors) {
|
|
8
23
|
(0, import_web_stub_dialog.showWebStubDialog)({
|
|
9
24
|
title,
|
|
10
25
|
details: lines,
|
|
@@ -13,17 +28,17 @@ if (import_react_native.Platform.OS !== "web") {
|
|
|
13
28
|
}, validateId = function(id, label = "id") {
|
|
14
29
|
const errors = [];
|
|
15
30
|
if (typeof id !== "string" || id.trim().length === 0) {
|
|
16
|
-
errors.push(
|
|
31
|
+
errors.push((0, import_i18n.t)("validation.mustBeNonEmptyString", { label }));
|
|
17
32
|
}
|
|
18
33
|
return { ok: errors.length === 0, errors };
|
|
19
34
|
}, validateDate = function(value, label) {
|
|
20
35
|
const errors = [];
|
|
21
36
|
if (value == null) {
|
|
22
|
-
errors.push(
|
|
37
|
+
errors.push((0, import_i18n.t)("validation.cannotBeEmpty", { label }));
|
|
23
38
|
} else if (!(value instanceof Date) && typeof value !== "string") {
|
|
24
|
-
errors.push(
|
|
39
|
+
errors.push((0, import_i18n.t)("validation.mustBeDateOrString", { label }));
|
|
25
40
|
} else if (value instanceof Date && isNaN(value.getTime())) {
|
|
26
|
-
errors.push(
|
|
41
|
+
errors.push((0, import_i18n.t)("validation.invalidDateObject", { label }));
|
|
27
42
|
}
|
|
28
43
|
return errors;
|
|
29
44
|
}, formatDateArg = function(value) {
|
|
@@ -41,26 +56,13 @@ if (import_react_native.Platform.OS !== "web") {
|
|
|
41
56
|
const getPermission = useCallback(async () => GRANTED_PERMISSION, []);
|
|
42
57
|
return [permission, requestPermission, getPermission];
|
|
43
58
|
};
|
|
44
|
-
var showCalendarAlert2 = showCalendarAlert, validateId2 = validateId, validateDate2 = validateDate, formatDateArg2 = formatDateArg, useCalendarPermissions2 = useCalendarPermissions, useRemindersPermissions2 = useRemindersPermissions;
|
|
59
|
+
var createStubCalendar2 = createStubCalendar, showCalendarAlert2 = showCalendarAlert, validateId2 = validateId, validateDate2 = validateDate, formatDateArg2 = formatDateArg, useCalendarPermissions2 = useCalendarPermissions, useRemindersPermissions2 = useRemindersPermissions;
|
|
45
60
|
const GRANTED_PERMISSION = {
|
|
46
61
|
status: "granted",
|
|
47
62
|
granted: true,
|
|
48
63
|
canAskAgain: true,
|
|
49
64
|
expires: "never"
|
|
50
65
|
};
|
|
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"
|
|
63
|
-
};
|
|
64
66
|
const { useState, useCallback } = require("react");
|
|
65
67
|
const requestCalendarPermissionsAsync = async () => GRANTED_PERMISSION;
|
|
66
68
|
const getCalendarPermissionsAsync = async () => GRANTED_PERMISSION;
|
|
@@ -71,10 +73,10 @@ if (import_react_native.Platform.OS !== "web") {
|
|
|
71
73
|
const isAvailableAsync = async () => true;
|
|
72
74
|
const getCalendarsAsync = async (entityType) => {
|
|
73
75
|
void entityType;
|
|
74
|
-
return [
|
|
76
|
+
return [createStubCalendar()];
|
|
75
77
|
};
|
|
76
78
|
const getDefaultCalendarAsync = async () => {
|
|
77
|
-
showCalendarAlert("
|
|
79
|
+
showCalendarAlert((0, import_i18n.t)("calendar.getDefaultCalendar"), [(0, import_i18n.t)("calendar.getDefaultCalendarDetail"), (0, import_i18n.t)("preview.unsupported")], false, [(0, import_i18n.t)("preview.cannotAccessCalendar")]);
|
|
78
80
|
return void 0;
|
|
79
81
|
};
|
|
80
82
|
const createCalendarAsync = async (details) => {
|
|
@@ -82,13 +84,13 @@ if (import_react_native.Platform.OS !== "web") {
|
|
|
82
84
|
const d = details && typeof details === "object" ? details : {};
|
|
83
85
|
const titleVal = d["title"];
|
|
84
86
|
if (typeof titleVal !== "string" || titleVal.trim().length === 0) {
|
|
85
|
-
errors.push("details.title
|
|
87
|
+
errors.push((0, import_i18n.t)("validation.mustBeNonEmptyString", { label: "details.title" }));
|
|
86
88
|
}
|
|
87
89
|
const isValid = errors.length === 0;
|
|
88
|
-
const titleDisplay = typeof titleVal === "string" ? titleVal :
|
|
90
|
+
const titleDisplay = typeof titleVal === "string" ? titleVal : (0, import_i18n.t)("common.notFilled");
|
|
89
91
|
showCalendarAlert(
|
|
90
|
-
"
|
|
91
|
-
[
|
|
92
|
+
(0, import_i18n.t)("calendar.createCalendar"),
|
|
93
|
+
[(0, import_i18n.t)("calendar.calendarName", { value: titleDisplay }), (0, import_i18n.t)("calendar.calendarColor", { value: String(d["color"] ?? (0, import_i18n.t)("common.notSet")) })],
|
|
92
94
|
isValid,
|
|
93
95
|
isValid ? void 0 : errors
|
|
94
96
|
);
|
|
@@ -98,10 +100,10 @@ if (import_react_native.Platform.OS !== "web") {
|
|
|
98
100
|
const { ok: idOk, errors: idErrors } = validateId(id, "calendarId");
|
|
99
101
|
const d = details && typeof details === "object" ? details : {};
|
|
100
102
|
showCalendarAlert(
|
|
101
|
-
"
|
|
103
|
+
(0, import_i18n.t)("calendar.updateCalendar"),
|
|
102
104
|
[
|
|
103
|
-
|
|
104
|
-
|
|
105
|
+
(0, import_i18n.t)("calendar.calendarId", { value: typeof id === "string" ? id : String(id) }),
|
|
106
|
+
(0, import_i18n.t)("calendar.updateFields", { value: Object.keys(d).join(", ") || (0, import_i18n.t)("common.none") })
|
|
105
107
|
],
|
|
106
108
|
idOk,
|
|
107
109
|
idOk ? void 0 : idErrors
|
|
@@ -111,8 +113,8 @@ if (import_react_native.Platform.OS !== "web") {
|
|
|
111
113
|
const deleteCalendarAsync = async (id) => {
|
|
112
114
|
const { ok, errors } = validateId(id, "calendarId");
|
|
113
115
|
showCalendarAlert(
|
|
114
|
-
"
|
|
115
|
-
[
|
|
116
|
+
(0, import_i18n.t)("calendar.deleteCalendar"),
|
|
117
|
+
[(0, import_i18n.t)("calendar.calendarId", { value: typeof id === "string" ? id : String(id) })],
|
|
116
118
|
ok,
|
|
117
119
|
ok ? void 0 : errors
|
|
118
120
|
);
|
|
@@ -120,19 +122,19 @@ if (import_react_native.Platform.OS !== "web") {
|
|
|
120
122
|
const getEventsAsync = async (calendarIds, startDate, endDate) => {
|
|
121
123
|
const errors = [];
|
|
122
124
|
if (!Array.isArray(calendarIds) || calendarIds.length === 0) {
|
|
123
|
-
errors.push(
|
|
125
|
+
errors.push((0, import_i18n.t)("validation.calendarIdsMustBeNonEmptyArray"));
|
|
124
126
|
}
|
|
125
127
|
errors.push(...validateDate(startDate, "startDate"));
|
|
126
128
|
errors.push(...validateDate(endDate, "endDate"));
|
|
127
129
|
const isValid = errors.length === 0;
|
|
128
130
|
const idsStr = Array.isArray(calendarIds) ? `[${calendarIds.slice(0, 3).join(", ")}${calendarIds.length > 3 ? "\u2026" : ""}]` : String(calendarIds);
|
|
129
131
|
showCalendarAlert(
|
|
130
|
-
"
|
|
132
|
+
(0, import_i18n.t)("calendar.queryEvents"),
|
|
131
133
|
[
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
"
|
|
134
|
+
(0, import_i18n.t)("calendar.calendarIds", { value: idsStr }),
|
|
135
|
+
(0, import_i18n.t)("calendar.startTime", { value: formatDateArg(startDate) }),
|
|
136
|
+
(0, import_i18n.t)("calendar.endTime", { value: formatDateArg(endDate) }),
|
|
137
|
+
(0, import_i18n.t)("preview.returnsEmptyList")
|
|
136
138
|
],
|
|
137
139
|
isValid,
|
|
138
140
|
isValid ? void 0 : errors
|
|
@@ -142,8 +144,8 @@ if (import_react_native.Platform.OS !== "web") {
|
|
|
142
144
|
const getEventAsync = async (id) => {
|
|
143
145
|
const { ok, errors } = validateId(id, "eventId");
|
|
144
146
|
showCalendarAlert(
|
|
145
|
-
"
|
|
146
|
-
[
|
|
147
|
+
(0, import_i18n.t)("calendar.getEvent"),
|
|
148
|
+
[(0, import_i18n.t)("calendar.eventId", { value: typeof id === "string" ? id : String(id) })],
|
|
147
149
|
ok,
|
|
148
150
|
ok ? void 0 : errors
|
|
149
151
|
);
|
|
@@ -159,17 +161,17 @@ if (import_react_native.Platform.OS !== "web") {
|
|
|
159
161
|
errors.push(...validateDate(data["endDate"], "eventData.endDate"));
|
|
160
162
|
}
|
|
161
163
|
const titleVal = data["title"];
|
|
162
|
-
const titleDisplay = typeof titleVal === "string" ? titleVal :
|
|
163
|
-
const startDisplay = data["startDate"] != null ? formatDateArg(data["startDate"]) :
|
|
164
|
-
const endDisplay = data["endDate"] != null ? formatDateArg(data["endDate"]) :
|
|
164
|
+
const titleDisplay = typeof titleVal === "string" ? titleVal : (0, import_i18n.t)("common.notFilled");
|
|
165
|
+
const startDisplay = data["startDate"] != null ? formatDateArg(data["startDate"]) : (0, import_i18n.t)("common.notSet");
|
|
166
|
+
const endDisplay = data["endDate"] != null ? formatDateArg(data["endDate"]) : (0, import_i18n.t)("common.notSet");
|
|
165
167
|
const isValid = errors.length === 0;
|
|
166
168
|
showCalendarAlert(
|
|
167
|
-
"
|
|
169
|
+
(0, import_i18n.t)("calendar.createEvent"),
|
|
168
170
|
[
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
171
|
+
(0, import_i18n.t)("calendar.calendarId", { value: typeof calendarId === "string" ? calendarId : String(calendarId) }),
|
|
172
|
+
(0, import_i18n.t)("calendar.eventTitle", { value: titleDisplay }),
|
|
173
|
+
(0, import_i18n.t)("calendar.eventStart", { value: startDisplay }),
|
|
174
|
+
(0, import_i18n.t)("calendar.eventEnd", { value: endDisplay })
|
|
173
175
|
],
|
|
174
176
|
isValid,
|
|
175
177
|
isValid ? void 0 : errors
|
|
@@ -180,10 +182,10 @@ if (import_react_native.Platform.OS !== "web") {
|
|
|
180
182
|
const { ok, errors } = validateId(id, "eventId");
|
|
181
183
|
const d = details && typeof details === "object" ? details : {};
|
|
182
184
|
showCalendarAlert(
|
|
183
|
-
"
|
|
185
|
+
(0, import_i18n.t)("calendar.updateEvent"),
|
|
184
186
|
[
|
|
185
|
-
|
|
186
|
-
|
|
187
|
+
(0, import_i18n.t)("calendar.eventId", { value: typeof id === "string" ? id : String(id) }),
|
|
188
|
+
(0, import_i18n.t)("calendar.updateFields", { value: Object.keys(d).join(", ") || (0, import_i18n.t)("common.none") })
|
|
187
189
|
],
|
|
188
190
|
ok,
|
|
189
191
|
ok ? void 0 : errors
|
|
@@ -193,8 +195,8 @@ if (import_react_native.Platform.OS !== "web") {
|
|
|
193
195
|
const deleteEventAsync = async (id) => {
|
|
194
196
|
const { ok, errors } = validateId(id, "eventId");
|
|
195
197
|
showCalendarAlert(
|
|
196
|
-
"
|
|
197
|
-
[
|
|
198
|
+
(0, import_i18n.t)("calendar.deleteEvent"),
|
|
199
|
+
[(0, import_i18n.t)("calendar.eventId", { value: typeof id === "string" ? id : String(id) })],
|
|
198
200
|
ok,
|
|
199
201
|
ok ? void 0 : errors
|
|
200
202
|
);
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
var import_react_native = require("react-native");
|
|
3
3
|
var import_expo = require("expo");
|
|
4
4
|
var import_web_stub_dialog = require("./web-stub-dialog");
|
|
5
|
+
var import_i18n = require("./i18n");
|
|
5
6
|
if (import_react_native.Platform.OS !== "web" && !(0, import_expo.isRunningInExpoGo)()) {
|
|
6
7
|
module.exports = require("expo-contacts");
|
|
7
8
|
} else {
|
|
@@ -15,20 +16,20 @@ if (import_react_native.Platform.OS !== "web" && !(0, import_expo.isRunningInExp
|
|
|
15
16
|
});
|
|
16
17
|
return;
|
|
17
18
|
}
|
|
18
|
-
const statusLine = hasErrors ?
|
|
19
|
-
const parts = ["
|
|
19
|
+
const statusLine = hasErrors ? (0, import_i18n.t)("preview.statusInvalid") : (0, import_i18n.t)("preview.statusValid");
|
|
20
|
+
const parts = [(0, import_i18n.t)("preview.scanUnsupportedContacts"), "", ...lines, "", statusLine];
|
|
20
21
|
if (hasErrors) {
|
|
21
|
-
parts.push(
|
|
22
|
+
parts.push((0, import_i18n.t)("alert.issues", { value: errors.join(" / ") }));
|
|
22
23
|
parts.push("");
|
|
23
|
-
parts.push(
|
|
24
|
+
parts.push((0, import_i18n.t)("preview.screenshotForAgent"));
|
|
24
25
|
} else {
|
|
25
26
|
parts.push("");
|
|
26
|
-
parts.push(
|
|
27
|
+
parts.push((0, import_i18n.t)("preview.availableAfterPublish"));
|
|
27
28
|
}
|
|
28
|
-
import_react_native.Alert.alert(title, parts.join("\n"), [{ text: "
|
|
29
|
+
import_react_native.Alert.alert(title, parts.join("\n"), [{ text: (0, import_i18n.t)("common.dismiss") }]);
|
|
29
30
|
}, validateId = function(id, label = "id") {
|
|
30
31
|
if (typeof id !== "string" || id.trim().length === 0) {
|
|
31
|
-
return [
|
|
32
|
+
return [(0, import_i18n.t)("validation.mustBeNonEmptyString", { label })];
|
|
32
33
|
}
|
|
33
34
|
return [];
|
|
34
35
|
};
|
|
@@ -115,85 +116,85 @@ if (import_react_native.Platform.OS !== "web" && !(0, import_expo.isRunningInExp
|
|
|
115
116
|
};
|
|
116
117
|
const getPermissionsAsync = async () => DENIED_PERMISSION;
|
|
117
118
|
const requestPermissionsAsync = async () => {
|
|
118
|
-
showContactsAlert("
|
|
119
|
+
showContactsAlert((0, import_i18n.t)("contacts.requestPermission"), [(0, import_i18n.t)("contacts.requestPermissionDetail"), (0, import_i18n.t)("contacts.previewUnsupportedContacts")]);
|
|
119
120
|
return UNDETERMINED_PERMISSION;
|
|
120
121
|
};
|
|
121
122
|
const isAvailableAsync = async () => false;
|
|
122
123
|
const hasContactsAsync = async () => false;
|
|
123
124
|
const getContactsAsync = async (query) => {
|
|
124
|
-
const queryStr = query ? JSON.stringify(query) :
|
|
125
|
-
showContactsAlert("
|
|
125
|
+
const queryStr = query ? JSON.stringify(query) : (0, import_i18n.t)("common.noFilter");
|
|
126
|
+
showContactsAlert((0, import_i18n.t)("contacts.getContacts"), [
|
|
126
127
|
`query: ${queryStr}`,
|
|
127
|
-
"
|
|
128
|
+
(0, import_i18n.t)("preview.returnsEmptyList")
|
|
128
129
|
]);
|
|
129
130
|
return { data: [], hasNextPage: false, hasPreviousPage: false, total: 0 };
|
|
130
131
|
};
|
|
131
132
|
const getPagedContactsAsync = async (query) => {
|
|
132
|
-
const queryStr = query ? JSON.stringify(query) :
|
|
133
|
-
showContactsAlert("
|
|
133
|
+
const queryStr = query ? JSON.stringify(query) : (0, import_i18n.t)("common.noFilter");
|
|
134
|
+
showContactsAlert((0, import_i18n.t)("contacts.getPagedContacts"), [
|
|
134
135
|
`query: ${queryStr}`,
|
|
135
|
-
"
|
|
136
|
+
(0, import_i18n.t)("preview.returnsEmptyList")
|
|
136
137
|
]);
|
|
137
138
|
return { data: [], hasNextPage: false, hasPreviousPage: false, total: 0 };
|
|
138
139
|
};
|
|
139
140
|
const getContactByIdAsync = async (id) => {
|
|
140
141
|
const errors = validateId(id, "contactId");
|
|
141
|
-
showContactsAlert(
|
|
142
|
+
showContactsAlert((0, import_i18n.t)("contacts.getContactById"), [`contactId: ${JSON.stringify(id)}`], errors.length ? errors : void 0);
|
|
142
143
|
return null;
|
|
143
144
|
};
|
|
144
145
|
const addContactAsync = async (contact) => {
|
|
145
|
-
const nameStr = contact?.name ??
|
|
146
|
-
showContactsAlert("
|
|
146
|
+
const nameStr = contact?.name ?? (0, import_i18n.t)("contacts.noName");
|
|
147
|
+
showContactsAlert((0, import_i18n.t)("contacts.addContact"), [`name: ${nameStr}`]);
|
|
147
148
|
return "stub-contact-id";
|
|
148
149
|
};
|
|
149
150
|
const updateContactAsync = async (contact) => {
|
|
150
|
-
const idStr = contact?.id ??
|
|
151
|
+
const idStr = contact?.id ?? (0, import_i18n.t)("contacts.noId");
|
|
151
152
|
const errors = validateId(idStr, "contact.id");
|
|
152
|
-
showContactsAlert("
|
|
153
|
+
showContactsAlert((0, import_i18n.t)("contacts.updateContact"), [`id: ${idStr}`], errors.length ? errors : void 0);
|
|
153
154
|
return {};
|
|
154
155
|
};
|
|
155
156
|
const removeContactAsync = async (contactId) => {
|
|
156
157
|
const errors = validateId(contactId, "contactId");
|
|
157
|
-
showContactsAlert("
|
|
158
|
+
showContactsAlert((0, import_i18n.t)("contacts.removeContact"), [`contactId: ${JSON.stringify(contactId)}`], errors.length ? errors : void 0);
|
|
158
159
|
return {};
|
|
159
160
|
};
|
|
160
161
|
const shareContactAsync = async (contactId, message) => {
|
|
161
162
|
const errors = validateId(contactId, "contactId");
|
|
162
|
-
showContactsAlert("
|
|
163
|
+
showContactsAlert((0, import_i18n.t)("contacts.shareContact"), [
|
|
163
164
|
`contactId: ${JSON.stringify(contactId)}`,
|
|
164
|
-
`message: ${message != null ? JSON.stringify(message) :
|
|
165
|
+
`message: ${message != null ? JSON.stringify(message) : (0, import_i18n.t)("common.none")}`
|
|
165
166
|
], errors.length ? errors : void 0);
|
|
166
167
|
};
|
|
167
168
|
const writeContactToFileAsync = async (query) => {
|
|
168
|
-
showContactsAlert("
|
|
169
|
-
`query: ${query ? JSON.stringify(query) :
|
|
170
|
-
"
|
|
169
|
+
showContactsAlert((0, import_i18n.t)("contacts.exportToFile"), [
|
|
170
|
+
`query: ${query ? JSON.stringify(query) : (0, import_i18n.t)("common.none")}`,
|
|
171
|
+
(0, import_i18n.t)("preview.unsupportedOperation")
|
|
171
172
|
]);
|
|
172
173
|
return "file://stub/contact.vcf";
|
|
173
174
|
};
|
|
174
175
|
const presentFormAsync = async (contactId) => {
|
|
175
|
-
showContactsAlert("
|
|
176
|
-
`contactId: ${contactId != null ? JSON.stringify(contactId) :
|
|
177
|
-
|
|
176
|
+
showContactsAlert((0, import_i18n.t)("contacts.presentForm"), [
|
|
177
|
+
`contactId: ${contactId != null ? JSON.stringify(contactId) : (0, import_i18n.t)("contacts.newContact")}`,
|
|
178
|
+
(0, import_i18n.t)("contacts.webUnsupportedForm")
|
|
178
179
|
]);
|
|
179
180
|
return {};
|
|
180
181
|
};
|
|
181
182
|
const presentContactPickerAsync = async () => {
|
|
182
|
-
showContactsAlert("
|
|
183
|
+
showContactsAlert((0, import_i18n.t)("contacts.presentPicker"), [(0, import_i18n.t)("contacts.webUnsupportedPicker")]);
|
|
183
184
|
return null;
|
|
184
185
|
};
|
|
185
186
|
const createGroupAsync = async (name) => {
|
|
186
187
|
const errors = [];
|
|
187
|
-
if (typeof name !== "string" || !name.trim()) errors.push("name
|
|
188
|
-
showContactsAlert("
|
|
188
|
+
if (typeof name !== "string" || !name.trim()) errors.push((0, import_i18n.t)("validation.mustBeNonEmptyString", { label: "name" }));
|
|
189
|
+
showContactsAlert((0, import_i18n.t)("contacts.createGroup"), [`name: ${JSON.stringify(name)}`], errors.length ? errors : void 0);
|
|
189
190
|
return "stub-group-id";
|
|
190
191
|
};
|
|
191
192
|
const updateGroupNameAsync = async (groupName, groupId) => {
|
|
192
193
|
const errors = [
|
|
193
|
-
...typeof groupName !== "string" || !groupName.trim() ? ["groupName
|
|
194
|
+
...typeof groupName !== "string" || !groupName.trim() ? [(0, import_i18n.t)("validation.mustBeNonEmptyString", { label: "groupName" })] : [],
|
|
194
195
|
...validateId(groupId, "groupId")
|
|
195
196
|
];
|
|
196
|
-
showContactsAlert("
|
|
197
|
+
showContactsAlert((0, import_i18n.t)("contacts.updateGroupName"), [
|
|
197
198
|
`groupName: ${JSON.stringify(groupName)}`,
|
|
198
199
|
`groupId: ${JSON.stringify(groupId)}`
|
|
199
200
|
], errors.length ? errors : void 0);
|
|
@@ -201,13 +202,13 @@ if (import_react_native.Platform.OS !== "web" && !(0, import_expo.isRunningInExp
|
|
|
201
202
|
};
|
|
202
203
|
const removeGroupAsync = async (groupId) => {
|
|
203
204
|
const errors = validateId(groupId, "groupId");
|
|
204
|
-
showContactsAlert("
|
|
205
|
+
showContactsAlert((0, import_i18n.t)("contacts.removeGroup"), [`groupId: ${JSON.stringify(groupId)}`], errors.length ? errors : void 0);
|
|
205
206
|
return {};
|
|
206
207
|
};
|
|
207
208
|
const getGroupsAsync = async (query) => {
|
|
208
|
-
showContactsAlert("
|
|
209
|
-
`query: ${query ? JSON.stringify(query) :
|
|
210
|
-
"
|
|
209
|
+
showContactsAlert((0, import_i18n.t)("contacts.getGroups"), [
|
|
210
|
+
`query: ${query ? JSON.stringify(query) : (0, import_i18n.t)("common.none")}`,
|
|
211
|
+
(0, import_i18n.t)("preview.returnsEmptyList")
|
|
211
212
|
]);
|
|
212
213
|
return [];
|
|
213
214
|
};
|
|
@@ -216,7 +217,7 @@ if (import_react_native.Platform.OS !== "web" && !(0, import_expo.isRunningInExp
|
|
|
216
217
|
...validateId(contactId, "contactId"),
|
|
217
218
|
...validateId(groupId, "groupId")
|
|
218
219
|
];
|
|
219
|
-
showContactsAlert("
|
|
220
|
+
showContactsAlert((0, import_i18n.t)("contacts.addToGroup"), [
|
|
220
221
|
`contactId: ${JSON.stringify(contactId)}`,
|
|
221
222
|
`groupId: ${JSON.stringify(groupId)}`
|
|
222
223
|
], errors.length ? errors : void 0);
|
|
@@ -227,7 +228,7 @@ if (import_react_native.Platform.OS !== "web" && !(0, import_expo.isRunningInExp
|
|
|
227
228
|
...validateId(contactId, "contactId"),
|
|
228
229
|
...validateId(groupId, "groupId")
|
|
229
230
|
];
|
|
230
|
-
showContactsAlert("
|
|
231
|
+
showContactsAlert((0, import_i18n.t)("contacts.removeFromGroup"), [
|
|
231
232
|
`contactId: ${JSON.stringify(contactId)}`,
|
|
232
233
|
`groupId: ${JSON.stringify(groupId)}`
|
|
233
234
|
], errors.length ? errors : void 0);
|
|
@@ -238,21 +239,21 @@ if (import_react_native.Platform.OS !== "web" && !(0, import_expo.isRunningInExp
|
|
|
238
239
|
...validateId(groupId, "groupId"),
|
|
239
240
|
...validateId(containerId, "containerId")
|
|
240
241
|
];
|
|
241
|
-
showContactsAlert("
|
|
242
|
+
showContactsAlert((0, import_i18n.t)("contacts.addGroupToContainer"), [
|
|
242
243
|
`groupId: ${JSON.stringify(groupId)}`,
|
|
243
244
|
`containerId: ${JSON.stringify(containerId)}`
|
|
244
245
|
], errors.length ? errors : void 0);
|
|
245
246
|
return {};
|
|
246
247
|
};
|
|
247
248
|
const getContainersAsync = async (query) => {
|
|
248
|
-
showContactsAlert("
|
|
249
|
-
`query: ${query ? JSON.stringify(query) :
|
|
250
|
-
"
|
|
249
|
+
showContactsAlert((0, import_i18n.t)("contacts.getContainers"), [
|
|
250
|
+
`query: ${query ? JSON.stringify(query) : (0, import_i18n.t)("common.none")}`,
|
|
251
|
+
(0, import_i18n.t)("preview.returnsEmptyList")
|
|
251
252
|
]);
|
|
252
253
|
return [];
|
|
253
254
|
};
|
|
254
255
|
const getDefaultContainerIdAsync = async () => {
|
|
255
|
-
showContactsAlert(
|
|
256
|
+
showContactsAlert((0, import_i18n.t)("contacts.getDefaultContainerId"), [(0, import_i18n.t)("preview.unsupportedOperation")]);
|
|
256
257
|
return null;
|
|
257
258
|
};
|
|
258
259
|
const addContactsChangeListener = (_listener) => {
|
|
@@ -260,7 +261,7 @@ if (import_react_native.Platform.OS !== "web" && !(0, import_expo.isRunningInExp
|
|
|
260
261
|
} };
|
|
261
262
|
};
|
|
262
263
|
const presentAccessPickerAsync = async () => {
|
|
263
|
-
showContactsAlert("
|
|
264
|
+
showContactsAlert((0, import_i18n.t)("contacts.presentAccessPicker"), [(0, import_i18n.t)("contacts.webUnsupportedOperation")]);
|
|
264
265
|
return [];
|
|
265
266
|
};
|
|
266
267
|
const enums = {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var import_react_native = require("react-native");
|
|
3
3
|
var import_web_stub_dialog = require("./web-stub-dialog");
|
|
4
|
+
var import_i18n = require("./i18n");
|
|
4
5
|
if (import_react_native.Platform.OS !== "web") {
|
|
5
6
|
module.exports = require("expo-file-system");
|
|
6
7
|
} else {
|
|
@@ -33,10 +34,10 @@ if (import_react_native.Platform.OS !== "web") {
|
|
|
33
34
|
return false;
|
|
34
35
|
}
|
|
35
36
|
create(_options) {
|
|
36
|
-
(0, import_web_stub_dialog.showWebStubDialog)({ title: "
|
|
37
|
+
(0, import_web_stub_dialog.showWebStubDialog)({ title: (0, import_i18n.t)("fileSystemNext.createDir"), details: [`URI: ${this.uri}`] });
|
|
37
38
|
}
|
|
38
39
|
delete() {
|
|
39
|
-
(0, import_web_stub_dialog.showWebStubDialog)({ title: "
|
|
40
|
+
(0, import_web_stub_dialog.showWebStubDialog)({ title: (0, import_i18n.t)("fileSystemNext.deleteDir"), details: [`URI: ${this.uri}`] });
|
|
40
41
|
}
|
|
41
42
|
list() {
|
|
42
43
|
return [];
|
|
@@ -86,18 +87,18 @@ if (import_react_native.Platform.OS !== "web") {
|
|
|
86
87
|
}
|
|
87
88
|
copy(destination) {
|
|
88
89
|
(0, import_web_stub_dialog.showWebStubDialog)({
|
|
89
|
-
title: "
|
|
90
|
-
details: [
|
|
90
|
+
title: (0, import_i18n.t)("fileSystemNext.copyFile"),
|
|
91
|
+
details: [(0, import_i18n.t)("fileSystem.from", { value: this.uri }), (0, import_i18n.t)("fileSystem.to", { value: destination.uri })]
|
|
91
92
|
});
|
|
92
93
|
}
|
|
93
94
|
move(destination) {
|
|
94
95
|
(0, import_web_stub_dialog.showWebStubDialog)({
|
|
95
|
-
title: "
|
|
96
|
-
details: [
|
|
96
|
+
title: (0, import_i18n.t)("fileSystemNext.moveFile"),
|
|
97
|
+
details: [(0, import_i18n.t)("fileSystem.from", { value: this.uri }), (0, import_i18n.t)("fileSystem.to", { value: destination.uri })]
|
|
97
98
|
});
|
|
98
99
|
}
|
|
99
100
|
delete() {
|
|
100
|
-
(0, import_web_stub_dialog.showWebStubDialog)({ title: "
|
|
101
|
+
(0, import_web_stub_dialog.showWebStubDialog)({ title: (0, import_i18n.t)("fileSystemNext.deleteFile"), details: [`URI: ${this.uri}`] });
|
|
101
102
|
}
|
|
102
103
|
open() {
|
|
103
104
|
return null;
|
|
@@ -129,15 +130,15 @@ if (import_react_native.Platform.OS !== "web") {
|
|
|
129
130
|
}
|
|
130
131
|
}
|
|
131
132
|
File.downloadFileAsync = async (_url, destination) => {
|
|
132
|
-
(0, import_web_stub_dialog.showWebStubDialog)({ title: "
|
|
133
|
+
(0, import_web_stub_dialog.showWebStubDialog)({ title: (0, import_i18n.t)("fileSystemNext.downloadFile"), details: [(0, import_i18n.t)("fileSystem.target", { value: destination.uri })] });
|
|
133
134
|
return new File(destination.uri);
|
|
134
135
|
};
|
|
135
136
|
File.pickFileAsync = async () => {
|
|
136
|
-
(0, import_web_stub_dialog.showWebStubDialog)({ title: "
|
|
137
|
+
(0, import_web_stub_dialog.showWebStubDialog)({ title: (0, import_i18n.t)("fileSystemNext.pickFile"), details: [] });
|
|
137
138
|
return new File("document:/stub-pick");
|
|
138
139
|
};
|
|
139
140
|
Directory.pickDirectoryAsync = async () => {
|
|
140
|
-
(0, import_web_stub_dialog.showWebStubDialog)({ title: "
|
|
141
|
+
(0, import_web_stub_dialog.showWebStubDialog)({ title: (0, import_i18n.t)("fileSystemNext.pickDir"), details: [] });
|
|
141
142
|
return new Directory("document:/stub-pick");
|
|
142
143
|
};
|
|
143
144
|
const Paths = {
|