miaoda-expo-devkit 0.1.1-beta.51 → 0.1.1-beta.52

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/cli/lint.js CHANGED
@@ -3,6 +3,8 @@
3
3
 
4
4
  // src/cli/lint.ts
5
5
  var import_node_child_process = require("child_process");
6
+ var import_node_fs = require("fs");
7
+ var import_node_module = require("module");
6
8
  var import_node_path = require("path");
7
9
  var devkitRoot = (0, import_node_path.resolve)(__dirname, "../..");
8
10
  var oxlintConfig = (0, import_node_path.join)(devkitRoot, "oxlint-config.json");
@@ -14,8 +16,32 @@ function run(name, cmd, args) {
14
16
  const r = (0, import_node_child_process.spawnSync)(cmd, args, { stdio: "inherit" });
15
17
  results.push({ name, ok: (r.status ?? 1) === 0 });
16
18
  }
19
+ function generateTypedRoutes() {
20
+ const projectRoot = process.cwd();
21
+ try {
22
+ const appJson = JSON.parse((0, import_node_fs.readFileSync)((0, import_node_path.join)(projectRoot, "app.json"), "utf8"));
23
+ const routerRoot = appJson?.expo?.router?.root ?? "src";
24
+ process.env.EXPO_ROUTER_APP_ROOT = (0, import_node_path.join)(projectRoot, routerRoot, "app");
25
+ const expoRouterDir = (0, import_node_path.dirname)(
26
+ require.resolve("expo-router/package.json", { paths: [projectRoot] })
27
+ );
28
+ const req = (0, import_node_module.createRequire)((0, import_node_path.join)(expoRouterDir, "index.js"));
29
+ const { getTypedRoutesDeclarationFile } = req("@expo/router-server/build/typed-routes/generate");
30
+ const ctx = req("expo-router/internal/testing").requireContext(
31
+ process.env.EXPO_ROUTER_APP_ROOT,
32
+ true,
33
+ req("expo-router/_ctx-shared").EXPO_ROUTER_CTX_IGNORE
34
+ );
35
+ const content = getTypedRoutesDeclarationFile(ctx);
36
+ const typesDir = (0, import_node_path.join)(projectRoot, ".expo/types");
37
+ (0, import_node_fs.mkdirSync)(typesDir, { recursive: true });
38
+ (0, import_node_fs.writeFileSync)((0, import_node_path.join)(typesDir, "router.d.ts"), content);
39
+ } catch {
40
+ }
41
+ }
17
42
  run("oxlint", "oxlint", ["--config", oxlintConfig, ...lintTargets]);
18
43
  run("biome", "biome", ["lint", "--config-path", biomeConfig, ...lintTargets]);
44
+ generateTypedRoutes();
19
45
  run("tsc", "tsc", ["--noEmit"]);
20
46
  var failed = results.filter((r) => !r.ok);
21
47
  if (failed.length > 0) {
@@ -162,50 +162,36 @@ function openCameraDialog(facingMode) {
162
162
  });
163
163
  });
164
164
  }
165
- async function dataUrlToPickerResult(dataUrl) {
165
+ function dataUrlToFile(dataUrl, fileName) {
166
+ const [header, b64] = dataUrl.split(",");
167
+ const mime = header.match(/:(.*?);/)?.[1] ?? "image/jpeg";
168
+ const bytes = Uint8Array.from(atob(b64), (c) => c.charCodeAt(0));
169
+ return new File([bytes], fileName, { type: mime });
170
+ }
171
+ async function dataUrlToPickerResult(dataUrl, includeBase64) {
166
172
  return new Promise((resolve) => {
173
+ const fileName = `photo_${Date.now()}.jpg`;
174
+ const b64Part = dataUrl.split(",")[1] ?? "";
175
+ const fileSize = Math.round(b64Part.length * 3 / 4);
176
+ const file = dataUrlToFile(dataUrl, fileName);
177
+ const asset = {
178
+ uri: dataUrl,
179
+ type: "image",
180
+ fileName,
181
+ mimeType: "image/jpeg",
182
+ fileSize,
183
+ file,
184
+ ...includeBase64 ? { base64: b64Part } : {}
185
+ };
167
186
  const img = new Image();
168
187
  img.onload = () => {
169
188
  resolve({
170
189
  canceled: false,
171
- assets: [
172
- {
173
- uri: dataUrl,
174
- width: img.naturalWidth || img.width,
175
- height: img.naturalHeight || img.height,
176
- type: "image",
177
- fileName: `photo_${Date.now()}.jpg`,
178
- mimeType: "image/jpeg",
179
- base64: null,
180
- exif: null,
181
- duration: null,
182
- rotation: null,
183
- assetId: null,
184
- pairedVideoAsset: null
185
- }
186
- ]
190
+ assets: [{ ...asset, width: img.naturalWidth || img.width, height: img.naturalHeight || img.height }]
187
191
  });
188
192
  };
189
193
  img.onerror = () => {
190
- resolve({
191
- canceled: false,
192
- assets: [
193
- {
194
- uri: dataUrl,
195
- width: 0,
196
- height: 0,
197
- type: "image",
198
- fileName: `photo_${Date.now()}.jpg`,
199
- mimeType: "image/jpeg",
200
- base64: null,
201
- exif: null,
202
- duration: null,
203
- rotation: null,
204
- assetId: null,
205
- pairedVideoAsset: null
206
- }
207
- ]
208
- });
194
+ resolve({ canceled: false, assets: [{ ...asset, width: 0, height: 0 }] });
209
195
  };
210
196
  img.src = dataUrl;
211
197
  });
@@ -229,7 +215,7 @@ if (import_react_native.Platform.OS === "web") {
229
215
  if (result.canceled || !result.dataUrl) {
230
216
  return { canceled: true, assets: null };
231
217
  }
232
- return dataUrlToPickerResult(result.dataUrl);
218
+ return dataUrlToPickerResult(result.dataUrl, options.base64 === true);
233
219
  };
234
220
  module.exports = {
235
221
  ...ExpoImagePicker,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "miaoda-expo-devkit",
3
- "version": "0.1.1-beta.51",
3
+ "version": "0.1.1-beta.52",
4
4
  "description": "Expo 应用开发工具集:Sentry DSN 替换 stub、错误/网络捕获、Metro 符号化",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",