miaoda-expo-devkit 0.1.1-beta.32 → 0.1.1-beta.34

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.
@@ -5,27 +5,52 @@ var import_web_stub_dialog = require("./web-stub-dialog");
5
5
  if (import_react_native.Platform.OS !== "web" && !(0, import_expo.isRunningInExpoGo)()) {
6
6
  module.exports = require("expo-media-library");
7
7
  } else {
8
- let showStubAlert = function(title, detail) {
8
+ let showMediaLibraryAlert = function(title, lines, isValid, errors) {
9
9
  if (import_react_native.Platform.OS === "web") {
10
- (0, import_web_stub_dialog.showWebStubDialog)({ title, details: [detail] });
11
- } else {
12
- import_react_native.Alert.alert(
10
+ (0, import_web_stub_dialog.showWebStubDialog)({
13
11
  title,
14
- ["\u79D2\u54D2\u626B\u7801\u9884\u89C8\u4E0D\u652F\u6301\u8BBF\u95EE\u624B\u673A\u76F8\u518C", `\u64CD\u4F5C: ${detail}`, "", "\u53D1\u5E03\u4E3A\u6B63\u5F0F App \u540E\u53EF\u6B63\u5E38\u4F7F\u7528"].join("\n"),
15
- [{ text: "\u77E5\u9053\u4E86" }]
16
- );
12
+ details: lines,
13
+ errors: !isValid && errors && errors.length > 0 ? errors : void 0
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\u76F8\u518C", "", ...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");
17
26
  }
27
+ import_react_native.Alert.alert(title, parts.join("\n"), [{ text: "\u77E5\u9053\u4E86" }]);
28
+ }, validateUri = function(uri) {
29
+ const errors = [];
30
+ if (typeof uri !== "string" || uri.trim().length === 0) {
31
+ errors.push("uri \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32");
32
+ return { ok: false, errors };
33
+ }
34
+ const validPrefixes = ["file://", "content://", "http://", "https://", "ph://"];
35
+ if (!validPrefixes.some((p) => uri.startsWith(p))) {
36
+ errors.push("uri \u683C\u5F0F\u4E0D\u8BC6\u522B\uFF0C\u671F\u671B file:// / content:// / http(s):// / ph://");
37
+ }
38
+ return { ok: errors.length === 0, errors };
18
39
  }, usePermissions = function() {
19
40
  const [permission, setPermission] = useState(UNDETERMINED_PERMISSION);
20
41
  const requestPermission = useCallback(async () => {
21
- showStubAlert("\u8BF7\u6C42\u76F8\u518C\u6743\u9650", "\u8BFB\u5199\u624B\u673A\u76F8\u518C");
42
+ showMediaLibraryAlert(
43
+ "\u8BF7\u6C42\u76F8\u518C\u6743\u9650",
44
+ ["\u64CD\u4F5C: \u8BF7\u6C42\u8BBF\u95EE\u624B\u673A\u76F8\u518C\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"],
45
+ true
46
+ );
22
47
  setPermission(DENIED_PERMISSION);
23
48
  return DENIED_PERMISSION;
24
49
  }, []);
25
50
  const getPermission = useCallback(async () => permission, [permission]);
26
51
  return [permission, requestPermission, getPermission];
27
52
  };
28
- var showStubAlert2 = showStubAlert, usePermissions2 = usePermissions;
53
+ var showMediaLibraryAlert2 = showMediaLibraryAlert, validateUri2 = validateUri, usePermissions2 = usePermissions;
29
54
  const UNDETERMINED_PERMISSION = {
30
55
  status: "undetermined",
31
56
  granted: false,
@@ -40,16 +65,21 @@ if (import_react_native.Platform.OS !== "web" && !(0, import_expo.isRunningInExp
40
65
  };
41
66
  const { useState, useCallback } = require("react");
42
67
  const saveToLibraryAsync = async (uri) => {
43
- const uriStr = typeof uri === "string" ? uri.length > 60 ? uri.slice(0, 60) + "\u2026" : uri : String(uri);
44
- showStubAlert("\u4FDD\u5B58\u5230\u76F8\u518C", `\u56FE\u7247: ${uriStr}`);
68
+ const { ok, errors } = validateUri(uri);
69
+ const uriStr = typeof uri === "string" ? uri : String(uri);
70
+ const uriDisplay = uriStr.length > 60 ? uriStr.slice(0, 60) + "\u2026" : uriStr;
71
+ showMediaLibraryAlert("\u4FDD\u5B58\u5230\u76F8\u518C", [`URI: ${uriDisplay}`], ok, errors);
45
72
  };
46
73
  const createAssetAsync = async (uri) => {
47
- const uriStr = typeof uri === "string" ? uri.slice(0, 60) : String(uri);
48
- showStubAlert("\u521B\u5EFA\u5A92\u4F53\u8D44\u4EA7", `\u6587\u4EF6: ${uriStr}`);
74
+ const { ok, errors } = validateUri(uri);
75
+ const uriStr = typeof uri === "string" ? uri : String(uri);
76
+ const filename = uriStr.split("/").pop() ?? "(\u672A\u77E5\u6587\u4EF6\u540D)";
77
+ const uriDisplay = uriStr.length > 60 ? uriStr.slice(0, 60) + "\u2026" : uriStr;
78
+ showMediaLibraryAlert("\u521B\u5EFA\u5A92\u4F53\u8D44\u4EA7", [`URI: ${uriDisplay}`, `\u6587\u4EF6\u540D: ${filename}`], ok, errors);
49
79
  return {
50
80
  id: "stub",
51
- filename: "stub.jpg",
52
- uri: String(uri),
81
+ filename,
82
+ uri: uriStr,
53
83
  mediaType: "photo",
54
84
  mediaSubtypes: [],
55
85
  width: 0,
@@ -60,7 +90,11 @@ if (import_react_native.Platform.OS !== "web" && !(0, import_expo.isRunningInExp
60
90
  };
61
91
  };
62
92
  const requestPermissionsAsync = async () => {
63
- showStubAlert("\u8BF7\u6C42\u76F8\u518C\u6743\u9650", "\u8BFB\u5199\u624B\u673A\u76F8\u518C");
93
+ showMediaLibraryAlert(
94
+ "\u8BF7\u6C42\u76F8\u518C\u6743\u9650",
95
+ ["\u64CD\u4F5C: \u8BF7\u6C42\u8BBF\u95EE\u624B\u673A\u76F8\u518C\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"],
96
+ true
97
+ );
64
98
  return DENIED_PERMISSION;
65
99
  };
66
100
  const getPermissionsAsync = async () => DENIED_PERMISSION;
@@ -348,8 +348,10 @@ class EditorController {
348
348
  if (!this.activeNode) return;
349
349
  this.stopObservingActiveNode();
350
350
  this.clearSiblingHighlights();
351
- removeActiveAttr(this.activeNode);
351
+ const nodeToDelete = this.activeNode;
352
+ removeActiveAttr(nodeToDelete);
352
353
  this.activeNode = null;
354
+ nodeToDelete.remove();
353
355
  postToParent("iframe-node-clear");
354
356
  }
355
357
  }
@@ -88,6 +88,12 @@ const STYLES = {
88
88
  font-size: 12px;
89
89
  color: #666;
90
90
  font-family: system-ui, sans-serif;
91
+ margin: 0 0 8px;
92
+ `,
93
+ agent: `
94
+ font-size: 12px;
95
+ color: #888;
96
+ font-family: system-ui, sans-serif;
91
97
  margin: 0 0 16px;
92
98
  `,
93
99
  button: `
@@ -130,12 +136,18 @@ function showWebStubDialog(opts) {
130
136
  card.appendChild(detailEl);
131
137
  if (opts.errors && opts.errors.length > 0) {
132
138
  const errEl = document.createElement("p");
133
- errEl.setAttribute(
134
- "style",
135
- STYLES.footer + "color: #ff5252;"
136
- );
137
- errEl.textContent = "\u53C2\u6570\u95EE\u9898: " + opts.errors.join(" / ");
139
+ errEl.setAttribute("style", STYLES.footer + "color: #ff5252;");
140
+ errEl.textContent = "\u274C \u53C2\u6570\u95EE\u9898: " + opts.errors.join(" / ");
138
141
  card.appendChild(errEl);
142
+ const agentEl = document.createElement("p");
143
+ agentEl.setAttribute("style", STYLES.agent);
144
+ agentEl.textContent = "\u5982\u6709\u95EE\u9898\u8BF7\u622A\u56FE\u53D1\u7ED9\u79D2\u54D2 Agent \u4FEE\u590D";
145
+ card.appendChild(agentEl);
146
+ } else {
147
+ const okEl = document.createElement("p");
148
+ okEl.setAttribute("style", STYLES.footer + "color: #00E676;");
149
+ okEl.textContent = "\u2705 \u53C2\u6570\u5408\u89C4\uFF0C\u53D1\u5E03\u4E3A\u6B63\u5F0F App \u540E\u53EF\u6B63\u5E38\u4F7F\u7528";
150
+ card.appendChild(okEl);
139
151
  }
140
152
  const btn = document.createElement("button");
141
153
  btn.setAttribute("style", STYLES.button);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "miaoda-expo-devkit",
3
- "version": "0.1.1-beta.32",
3
+ "version": "0.1.1-beta.34",
4
4
  "description": "Expo 应用开发工具集:Sentry DSN 替换 stub、错误/网络捕获、Metro 符号化",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",