universal-parcel-scraper 0.959.2-main.5205 → 0.960.2-main.5209

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 CHANGED
@@ -163,7 +163,7 @@ the command line's `track --source ParcelsApp` does the same.
163
163
  <!-- GENERATED:stages -->
164
164
  <img src="docs/assets/stages.svg" alt="DHL: Die Sendung wurde in das Zustellfahrzeug geladen.; Mondial Relay: En cours de livraison; Correios Brazil: Objeto saiu para entrega ao destinatário; Correos Express: EN REPARTO; Yamato Transport: 配達中; La Poste / Colissimo: DISTOU. All are filed under out_for_delivery." width="760">
165
165
 
166
- The carrier folders record 18,767 such statuses, each filed under one stage.
166
+ The carrier folders record 18,770 such statuses, each filed under one stage.
167
167
  <!-- /GENERATED:stages -->
168
168
 
169
169
  Wording nobody recorded yet goes through a classifier that reads seven European languages.
package/data/catalog.json CHANGED
@@ -30398,7 +30398,8 @@
30398
30398
  "mode": "automatic",
30399
30399
  "adapter": "mailamericas",
30400
30400
  "recognitionRank": 985,
30401
- "localClocks": true
30401
+ "localClocks": true,
30402
+ "browser": true
30402
30403
  },
30403
30404
  "canaryUrl": "https://mailamericas.com/tracking",
30404
30405
  "trackingUrlTemplate": "https://mailamericas.com/tracking?number_id={trackingNumber}",
@@ -78753,6 +78753,14 @@
78753
78753
  "japan-post"
78754
78754
  ]
78755
78755
  },
78756
+ {
78757
+ "input": "EN544513815JP",
78758
+ "carrier": "japan-post",
78759
+ "confidence": "high",
78760
+ "candidates": [
78761
+ "japan-post"
78762
+ ]
78763
+ },
78756
78764
  {
78757
78765
  "input": "EN844273821IN",
78758
78766
  "carrier": "india-post",
@@ -23461,7 +23461,8 @@ var ct = {
23461
23461
  mode: "automatic",
23462
23462
  adapter: "mailamericas",
23463
23463
  recognitionRank: 985,
23464
- localClocks: !0
23464
+ localClocks: !0,
23465
+ browser: !0
23465
23466
  },
23466
23467
  canaryUrl: "https://mailamericas.com/tracking",
23467
23468
  trackingUrlTemplate: "https://mailamericas.com/tracking?number_id={trackingNumber}",
@@ -19,10 +19,13 @@ const OFFSET = /^[+-]\d{2}:\d{2}$/;
19
19
  const HOME_ZONE = SEVENTEENFEIA_HOME_ZONE;
20
20
  /**
21
21
  * 17FEIA's steps at its warehouse in China before the flight, from its
22
- * receipt. The backend writes them on Beijing time; the offset they carry is
23
- * the destination line's, whatever the step's clock.
22
+ * receipt, and the domestic return that sends a parcel back from there. The
23
+ * backend writes them on Beijing time; the offset they carry is the
24
+ * destination line's, whatever the step's clock.
24
25
  */
25
- const WAREHOUSE_STEPS = new Set(['包裹在去设施路上', '仓库收货', '订单待客户确认', '订单已确认', '订单已出库', '出口报关中']);
26
+ const WAREHOUSE_STEPS = new Set(['包裹在去设施路上', '仓库收货', '订单待客户确认', '订单已确认', '订单已出库', '出口报关中', '国内退回']);
27
+ /** A line's system name where a place would go, as "DE-DHL-server" on a domestic return: no place. */
28
+ const SYSTEM_PLACE = /-server$/i;
26
29
  // States whose places keep different clocks, so a state does not settle a clock's zone.
27
30
  const SPLIT_STATES = new Set(['AK', 'AZ', 'FL', 'ID', 'IN', 'KS', 'KY', 'MI', 'ND', 'NE', 'NV', 'OR', 'SD', 'TN', 'TX']);
28
31
  const MAX_ROWS = 500;
@@ -108,7 +111,7 @@ function projectRow(row, readAt) {
108
111
  // A row dated after the read is not a scan yet.
109
112
  if (at > readAt)
110
113
  return null;
111
- const place = text(row, 'location', 200) || text(row, 'city', 200);
114
+ const place = [text(row, 'location', 200), text(row, 'city', 200)].find((part) => part && !SYSTEM_PLACE.test(part)) ?? '';
112
115
  // A relayed place often ends with its country already, as `Town, MA, US` or `FR`.
113
116
  const named = /^[A-Z]{2}$/.test(country) && place.split(/,\s*/).at(-1)?.toUpperCase() !== country;
114
117
  const location = [place, named ? country : ''].filter(Boolean).join(', ');
@@ -40,6 +40,8 @@ const LABELS = new Map([
40
40
  // Handed in at the partner's depot, before the partner's own first scan.
41
41
  ['已交仓,等待上网', 'in_transit'],
42
42
  ['成功签收', 'delivered'],
43
+ // The parcel goes back to the sender in China instead of leaving the country.
44
+ ['国内退回', 'returned'],
43
45
  ]);
44
46
  /** The label on rows relayed from the delivering partner: their wording is the partner's. */
45
47
  export const RELAYED_LABEL = '运输途中';
@@ -31,6 +31,7 @@
31
31
  {"code": "运输途中", "wording": "The international shipment has been processed in the parcel center of origin", "stage": "in_transit", "language": "en", "confirmedBy": "live", "note": "Relayed from DHL in Germany, with DHL's place, country and offset. The label marks every relayed row; the stage comes from the partner's wording."},
32
32
  {"code": "运输途中", "wording": "The international shipment has been processed in the export parcel center", "stage": "in_transit", "language": "en", "confirmedBy": "live", "note": "Relayed from DHL in Germany."},
33
33
  {"code": "运输途中", "wording": "The shipment will be transported to the destination country/destination area and, from there, handed over to the delivery organization.", "stage": "in_transit", "language": "en", "confirmedBy": "live", "note": "Relayed from DHL in Germany, for a parcel bound for France."},
34
- {"code": "成功签收", "stage": "delivered", "language": "zh", "confirmedBy": "bundle", "note": "The last box of the tracking page's progress rail."}
34
+ {"code": "成功签收", "stage": "delivered", "language": "zh", "confirmedBy": "bundle", "note": "The last box of the tracking page's progress rail."},
35
+ {"code": "国内退回", "wording": "包裹已做国内退回处理", "stage": "returned", "language": "zh", "confirmedBy": "live", "note": "A domestic return: after the warehouse confirmed the order, the parcel goes back to the sender in China instead of leaving the country."}
35
36
  ]
36
37
  }
@@ -15,6 +15,8 @@ const labels = {
15
15
  'UNKNOWN/INCOMPLETE CONSIGNEE': { status: 'exception', stage: 'failed_attempt' },
16
16
  // The courier found no one in and left a notice.
17
17
  'NOTICE OF ATTEMPTED DELIVERY': { status: 'exception', stage: 'failed_attempt' },
18
+ // The partner abroad found no one in on its round; the next round or a return follows.
19
+ 'ABSENT AFTER ATTEMPT.DELIVERY': { status: 'exception', stage: 'failed_attempt' },
18
20
  // A public demonstration holds the parcel up.
19
21
  TURMOIL: { status: 'exception', stage: 'exception' },
20
22
  'RETURNED TO SENDER': { status: 'exception', stage: 'returned' },
@@ -82,6 +82,13 @@
82
82
  "confirmedBy": "live",
83
83
  "note": "The courier found no one in and left a notice."
84
84
  },
85
+ {
86
+ "wording": "ABSENT AFTER ATTEMPT.DELIVERY",
87
+ "language": "en",
88
+ "stage": "failed_attempt",
89
+ "confirmedBy": "live",
90
+ "note": "The partner abroad that delivers the parcel found no one in on its round; another round or the return to the sender follows."
91
+ },
85
92
  {
86
93
  "wording": "TURMOIL",
87
94
  "language": "en",
@@ -0,0 +1,57 @@
1
+ /** Remove long background rules, interpolating across them to retain crossing strokes. */
2
+ export function removeChunghwaGrid(pixels, width, height) {
3
+ if (width !== 162 || height !== 54 || pixels.length !== width * height) throw new Error('unsupported-image');
4
+ const rows = Array.from({ length: height }, (_, y) => {
5
+ let dark = 0;
6
+ for (let x = 0; x < width; x++) if (pixels[y * width + x] < 140) dark++;
7
+ return dark > width * 0.7;
8
+ });
9
+ const columns = Array.from({ length: width }, (_, x) => {
10
+ let dark = 0;
11
+ for (let y = 0; y < height; y++) if (pixels[y * width + x] < 140) dark++;
12
+ return dark > height * 0.8;
13
+ });
14
+ const output = Uint8Array.from(pixels);
15
+ for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
16
+ if (!rows[y] && !columns[x]) continue;
17
+ let top = y - 1, bottom = y + 1, left = x - 1, right = x + 1;
18
+ while (top >= 0 && rows[top]) top--;
19
+ while (bottom < height && rows[bottom]) bottom++;
20
+ while (left >= 0 && columns[left]) left--;
21
+ while (right < width && columns[right]) right++;
22
+ output[y * width + x] = rows[y] && !columns[x] && top >= 0 && bottom < height
23
+ ? (pixels[top * width + x] + pixels[bottom * width + x]) / 2
24
+ : columns[x] && !rows[y] && left >= 0 && right < width
25
+ ? (pixels[y * width + left] + pixels[y * width + right]) / 2 : 255;
26
+ }
27
+ return output;
28
+ }
29
+
30
+ /** Digit-only CTC, scored against every class so a weak digit remains uncertain. */
31
+ export function decodeChunghwaDigits(data, dims, alphabet) {
32
+ if (dims.length !== 3 || dims[0] < 1 || dims[0] > 64 || dims[1] !== 1 || dims[2] !== 8210
33
+ || data.length !== dims[0] * dims[2]) throw new Error('Invalid OCR tensor');
34
+ const candidates = Object.keys(alphabet).map(Number).filter(index => index === 0 || /^\d$/.test(alphabet[index]));
35
+ let previous = -1, answer = '', peak = 0;
36
+ const peaks = [];
37
+ for (let step = 0; step < dims[0]; step++) {
38
+ const offset = step * dims[2];
39
+ let best = 0;
40
+ for (const index of candidates) if (data[offset + index] > data[offset + best]) best = index;
41
+ if (best !== previous) {
42
+ if (previous > 0) peaks.push(peak);
43
+ peak = 0;
44
+ if (best) answer += alphabet[best];
45
+ }
46
+ let sum = 0;
47
+ for (let index = 0; index < dims[2]; index++) {
48
+ const value = data[offset + index];
49
+ if (!Number.isFinite(value)) throw new Error('Invalid OCR score');
50
+ if (best) sum += Math.exp(value - data[offset + best]);
51
+ }
52
+ if (best) peak = Math.max(peak, 1 / sum);
53
+ previous = best;
54
+ }
55
+ if (previous > 0) peaks.push(peak);
56
+ return { answer, confidence: peaks.length ? peaks.reduce((sum, value) => sum + Math.log(value), 0) / peaks.length : -Infinity };
57
+ }
@@ -230,6 +230,25 @@
230
230
  "confidence": "high"
231
231
  },
232
232
  "note": "Made-up number in the shape of Taiwan-issued UH letter post. The tracker's notes say U letter post cannot be followed online, though the tracker answered one such item with the scan a universal provider had. Its serial sits far beyond the range in use."
233
+ },
234
+ {
235
+ "number": "EN544513815JP",
236
+ "role": "shipment",
237
+ "evidence": "open_source_example",
238
+ "source": {
239
+ "url": "https://github.com/x43x61x69/Taiwan-Post-Chrome-Extension/blob/fb14ba3ec788ff4487e421259b4e4235bc1f0881/README.md",
240
+ "date": "2026-10-11",
241
+ "dateKind": "publication",
242
+ "access": "full_page"
243
+ },
244
+ "context": {
245
+ "assessment": "confirmed"
246
+ },
247
+ "expect": {
248
+ "carrier": "japan-post",
249
+ "confidence": "high"
250
+ },
251
+ "note": "The extension uses this Japan-issued EMS item as its international-query example. Chunghwa Post handles its destination tracking."
233
252
  }
234
253
  ]
235
254
  }
@@ -0,0 +1,48 @@
1
+ import { parentPort } from 'node:worker_threads';
2
+ import { readFile } from 'node:fs/promises';
3
+ import * as ort from 'onnxruntime-web';
4
+ import sharp from 'sharp';
5
+ import characters from '../../core/transport/text-captcha-model/characters.json' with { type: 'json' };
6
+ import { decodeTextCaptchaLogits } from '../../core/transport/text-captcha-decode.mjs';
7
+ import { decodeChunghwaDigits, removeChunghwaGrid } from './captcha.mjs';
8
+
9
+ ort.env.wasm.numThreads = 1;
10
+ ort.env.logLevel = 'error';
11
+ let session;
12
+
13
+ async function solve(bytes) {
14
+ if (!(bytes instanceof Uint8Array) || !bytes.length || bytes.length > 50_000) throw new Error('unsupported-image');
15
+ const image = sharp(bytes, { limitInputPixels: 10_000, pages: 1, failOn: 'warning' });
16
+ const metadata = await image.metadata().catch(() => { throw new Error('unsupported-image'); });
17
+ if (metadata.format !== 'jpeg' || metadata.width !== 162 || metadata.height !== 54 || (metadata.pages ?? 1) !== 1) {
18
+ throw new Error('unsupported-image');
19
+ }
20
+ const pixels = await image.flatten({ background: '#ffffff' }).greyscale().raw().toBuffer();
21
+ const cleared = removeChunghwaGrid(pixels, 162, 54);
22
+ if (!session) session = await ort.InferenceSession.create(new Uint8Array(await readFile(
23
+ new URL('../../core/transport/text-captcha-model/captcha.onnx', import.meta.url))),
24
+ { executionProviders: ['wasm'], graphOptimizationLevel: 'all', logSeverityLevel: 3 });
25
+ let best = { answer: '', confidence: -Infinity };
26
+ // Preserve the original four-digit reading: removing a rule can damage a crossing digit.
27
+ for (const [source, width] of [[pixels, 256], [cleared, 192], [pixels, 192]]) {
28
+ const resized = source === pixels && width === 256
29
+ ? await image.clone().resize(256, 64).raw().toBuffer()
30
+ : await sharp(source, { raw: { width: 162, height: 54, channels: 1 } })
31
+ .resize(width, 64, { fit: 'fill' }).greyscale().raw().toBuffer();
32
+ const input = new ort.Tensor('float32', Float32Array.from(resized, value => value / 127.5 - 1), [1, 1, 64, width]);
33
+ const output = (await session.run({ input1: input }))['387'];
34
+ if (!output || output.type !== 'float32') throw new Error('Invalid OCR output');
35
+ if (source === pixels && width === 256) {
36
+ const original = decodeTextCaptchaLogits(output.data, output.dims);
37
+ if (/^\d{4}$/.test(original)) return original;
38
+ }
39
+ const candidate = decodeChunghwaDigits(output.data, output.dims, characters);
40
+ if (/^\d{4}$/.test(candidate.answer) && candidate.confidence > best.confidence) best = candidate;
41
+ }
42
+ return best.answer;
43
+ }
44
+
45
+ parentPort?.on('message', async ({ id, bytes }) => {
46
+ try { parentPort.postMessage({ id, answer: await solve(bytes) }); }
47
+ catch (error) { parentPort.postMessage({ id, error: error?.message === 'unsupported-image' ? 'unsupported-image' : 'inference-failed' }); }
48
+ });
@@ -1,6 +1,6 @@
1
1
  import { OcrWorker } from '../../core/transport/ocrWorker.js';
2
2
  export class ChunghwaPostOcr extends OcrWorker {
3
3
  constructor() {
4
- super('Chunghwa Post', new URL('../../core/transport/text-captcha-worker.mjs', import.meta.url), { profile: 'chunghwa-post' });
4
+ super('Chunghwa Post', new URL('./ocr-worker.mjs', import.meta.url));
5
5
  }
6
6
  }
@@ -108,5 +108,5 @@ export function parseCiblexTrackingHtml(html, raw) {
108
108
  return { status: mapped.status, ...(mapped.status !== 'unknown' ? { current_stage: mapped.stage } : {}),
109
109
  last_status_text: latest.description, last_update: latest.time ?? null, expected_delivery: null,
110
110
  ...(latest.local_time ? { last_update_local: latest.local_time } : {}),
111
- timezone: 'Europe/Paris', events: events.slice(0, 100) };
111
+ timezone: 'Europe/Paris', ...(events.length > 100 ? { history_truncated: true } : {}), events: events.slice(0, 100) };
112
112
  }
@@ -1,6 +1,7 @@
1
1
  import { type AdapterFactory, type TrackingContext } from '../../core/adapter/index.js';
2
2
  import type { CarrierResult } from '../../core/result/index.js';
3
3
  import { type StepRecorder } from '../../core/telemetry/index.js';
4
+ import type { TrawlClient } from '../../core/transport/trawl.js';
4
5
  /** The lookup the tracking page on mailamericas.com makes for the number typed in. */
5
6
  export declare const MAILAMERICAS_API = "https://mailamericas.com/api/tracking";
6
7
  export declare class MailamericasTracker {
@@ -9,7 +10,9 @@ export declare class MailamericasTracker {
9
10
  fetcher?: typeof fetch;
10
11
  recorder?: StepRecorder;
11
12
  userAgent?: string;
13
+ trawl?: TrawlClient | null;
12
14
  });
15
+ private browser;
13
16
  fetch(raw: string, context?: TrackingContext): Promise<CarrierResult>;
14
17
  }
15
18
  export declare const adapter: AdapterFactory;
@@ -1,5 +1,5 @@
1
1
  import { accepted, recognizeFromLookup } from '../../core/adapter/index.js';
2
- import { ChallengeError, RateLimitedError, SchemaError, TransportError } from '../../core/errors/index.js';
2
+ import { BudgetExceededError, carrierErrorKind, ChallengeError, RateLimitedError, SchemaError, TransportError, UpstreamHttpError } from '../../core/errors/index.js';
3
3
  import { runSteps } from '../../core/runner/index.js';
4
4
  import { NOOP_RECORDER } from '../../core/telemetry/index.js';
5
5
  import { decodeText, fetchBounded, userAgentOf } from '../../core/transport/index.js';
@@ -26,11 +26,43 @@ export class MailamericasTracker {
26
26
  constructor(options = {}) {
27
27
  this.options = options;
28
28
  }
29
+ async browser(number, signal, remainingMs) {
30
+ const timeoutMs = Math.floor(remainingMs);
31
+ if (timeoutMs <= 2500)
32
+ throw new BudgetExceededError(PROVIDER, timeoutMs);
33
+ const page = await this.options.trawl.scrape({
34
+ url: `https://mailamericas.com/tracking?number_id=${number}`, skipHttp: true, maxTier: 3,
35
+ maxTimeout: timeoutMs - 2000, captureResponses: [MAILAMERICAS_API],
36
+ }, { provider: PROVIDER, signal, timeoutMs, maxBytes: 4 * MAILAMERICAS_MAX_BYTES,
37
+ requireSolved: false, captureWindow: 'last', allowHttpStatuses: [403, 405], fetcher: this.options.fetcher });
38
+ // A helper binds the POST, even when the carrier's unknown-item reply has no identity.
39
+ const replies = page.capturedResponses.filter(entry => entry.url === MAILAMERICAS_API && entry.trackingNumberSubmitted === number);
40
+ const reply = replies.at(-1);
41
+ if (!reply)
42
+ throw new ChallengeError(PROVIDER, 'MailAmericas browser verification did not yield a bound tracking reply', { reason: 'verification_unfinished' });
43
+ if (reply.headers['x-amzn-waf-action'] || [202, 403, 405].includes(reply.status)) {
44
+ throw new ChallengeError(PROVIDER, 'MailAmericas browser verification remained blocked', { status: reply.status, reason: 'verification_refused' });
45
+ }
46
+ if (reply.status === 429 || reply.status >= 500) {
47
+ const retry = reply.headers['retry-after'];
48
+ const retryAfterMs = retry === undefined ? undefined : /^\d+$/.test(retry.trim())
49
+ ? Number(retry) * 1000 : Date.parse(retry) - Date.now();
50
+ throw new UpstreamHttpError(PROVIDER, reply.status, Number.isFinite(retryAfterMs) ? Math.max(0, retryAfterMs) : undefined);
51
+ }
52
+ if (reply.status !== 200)
53
+ throw new TransportError(PROVIDER, 'MailAmericas browser tracking did not answer', { status: reply.status });
54
+ if (reply.truncated || reply.base64Encoded || reply.error || reply.body === null
55
+ || new TextEncoder().encode(reply.body).length > MAILAMERICAS_MAX_BYTES) {
56
+ throw new SchemaError(PROVIDER, 'MailAmericas browser tracking returned an unreadable reply');
57
+ }
58
+ return parseMailamericas(json(reply.body), number);
59
+ }
29
60
  async fetch(raw, context = {}) {
30
61
  const number = normalizeMailamericasNumber(raw);
31
62
  const read = async (signal, timeoutMs) => {
32
63
  const { response, bytes } = await fetchBounded(MAILAMERICAS_API, { method: 'POST', signal, headers: {
33
64
  Accept: 'application/json', 'Content-Type': 'application/json', 'User-Agent': userAgentOf(this.options.userAgent),
65
+ Origin: 'https://mailamericas.com', Referer: 'https://mailamericas.com/tracking',
34
66
  }, body: JSON.stringify({ trackingNumber: number, language: 'en' }) }, { provider: PROVIDER, timeoutMs: Math.max(1, Math.floor(timeoutMs)),
35
67
  maxBytes: MAILAMERICAS_MAX_BYTES, redirect: 'manual', fetcher: this.options.fetcher, allowHttpStatuses: [...REDIRECTS, 403, 404, 410] });
36
68
  if (REDIRECTS.includes(response.status))
@@ -54,17 +86,20 @@ export class MailamericasTracker {
54
86
  };
55
87
  // One read with the whole budget: a parcel the service has not looked up
56
88
  // lately takes it twenty seconds to answer.
57
- return runSteps({ carrier: 'mailamericas', budgetMs: context.budgetMs ?? 30_000, signal: context.signal,
89
+ return runSteps({ carrier: 'mailamericas', budgetMs: context.budgetMs ?? (this.options.trawl ? 60_000 : 30_000), signal: context.signal,
58
90
  recorder: this.options.recorder ?? NOOP_RECORDER }, [
59
91
  { id: 'direct', run: ({ signal, remainingMs }) => read(signal, remainingMs) },
92
+ { id: 'trawl', enabled: Boolean(this.options.trawl), recovers: error => carrierErrorKind(error) === 'challenge',
93
+ run: ({ signal, remainingMs }) => this.browser(number, signal, remainingMs) },
60
94
  ]);
61
95
  }
62
96
  }
63
97
  export const adapter = (environment) => {
64
- const tracker = new MailamericasTracker({ fetcher: environment.fetcher, recorder: environment.recorder, userAgent: environment.userAgent });
98
+ const tracker = new MailamericasTracker({ fetcher: environment.fetcher, recorder: environment.recorder, userAgent: environment.userAgent, trawl: environment.trawl });
99
+ const http = new MailamericasTracker({ fetcher: environment.fetcher, recorder: environment.recorder, userAgent: environment.userAgent });
65
100
  return {
66
- id: 'mailamericas', recordsSteps: true, steps: ['direct'],
101
+ id: 'mailamericas', recordsSteps: true, steps: ['direct', 'trawl'],
67
102
  track: (input, context) => tracker.fetch(input.number, context),
68
- recognize: (number, context) => recognizeFromLookup(() => tracker.fetch(number, context), () => accepted(() => normalizeMailamericasNumber(number))),
103
+ recognize: (number, context) => recognizeFromLookup(() => http.fetch(number, context), () => accepted(() => normalizeMailamericasNumber(number))),
69
104
  };
70
105
  };
@@ -27,8 +27,10 @@
27
27
  "tracking": {
28
28
  "mode": "automatic",
29
29
  "adapter": "mailamericas",
30
+ "browser": true,
30
31
  "steps": [
31
- "direct"
32
+ "direct",
33
+ "trawl"
32
34
  ],
33
35
  "recognition": {
34
36
  "rank": 985
@@ -306,6 +306,13 @@
306
306
  "confirmedBy": "live",
307
307
  "note": "A hub on the way to the delivering carrier, after customs released the parcel at the gateway airport."
308
308
  },
309
+ {
310
+ "wording": "Parcel arrived at branch",
311
+ "stage": "in_transit",
312
+ "language": "en",
313
+ "confirmedBy": "live",
314
+ "note": "The delivering carrier's local branch, after the hub: the parcel waits there for its round, not for collection."
315
+ },
309
316
  {
310
317
  "wording": "货物电子信息已经收到",
311
318
  "stage": "registered",
@@ -0,0 +1,24 @@
1
+ import characters from './text-captcha-model/characters.json' with { type: 'json' };
2
+
3
+ /** @param {Record<number, string>} alphabet */
4
+ export function decodeTextCaptchaLogits(data, dims, alphabet = characters) {
5
+ if (dims.length !== 3 || dims[0] < 1 || dims[0] > 64 || dims[1] !== 1 || dims[2] !== 8210 || data.length !== dims[0] * 8210) {
6
+ throw new Error('Invalid OCR tensor');
7
+ }
8
+ let previous = -1, answer = '';
9
+ for (let step = 0; step < dims[0]; step++) {
10
+ let best = 0;
11
+ for (let column = 0; column < 8210; column++) {
12
+ const value = data[step * 8210 + column];
13
+ if (!Number.isFinite(value)) throw new Error('Invalid OCR score');
14
+ if (value > data[step * 8210 + best]) best = column;
15
+ }
16
+ if (best !== previous && best !== 0) {
17
+ const character = alphabet[best];
18
+ if (!character) return '';
19
+ answer += character;
20
+ }
21
+ previous = best;
22
+ }
23
+ return answer;
24
+ }
@@ -17,28 +17,8 @@ ort.env.wasm.numThreads = 1;
17
17
  ort.env.logLevel = 'error';
18
18
  let session;
19
19
 
20
- /** @param {Record<number, string>} alphabet */
21
- export function decodeTextCaptchaLogits(data, dims, alphabet = characters) {
22
- if (dims.length !== 3 || dims[0] < 1 || dims[0] > 64 || dims[1] !== 1 || dims[2] !== 8210 || data.length !== dims[0] * 8210) {
23
- throw new Error('Invalid OCR tensor');
24
- }
25
- let previous = -1, answer = '';
26
- for (let step = 0; step < dims[0]; step++) {
27
- let best = 0;
28
- for (let column = 0; column < 8210; column++) {
29
- const value = data[step * 8210 + column];
30
- if (!Number.isFinite(value)) throw new Error('Invalid OCR score');
31
- if (value > data[step * 8210 + best]) best = column;
32
- }
33
- if (best !== previous && best !== 0) {
34
- const character = alphabet[best];
35
- if (!character) return '';
36
- answer += character;
37
- }
38
- previous = best;
39
- }
40
- return answer;
41
- }
20
+ export { decodeTextCaptchaLogits } from './text-captcha-decode.mjs';
21
+ import { decodeTextCaptchaLogits } from './text-captcha-decode.mjs';
42
22
 
43
23
  async function solve(bytes) {
44
24
  if (!(bytes instanceof Uint8Array) || !bytes.length || bytes.length > 50_000) throw new Error('unsupported-image');
@@ -30398,7 +30398,8 @@
30398
30398
  "mode": "automatic",
30399
30399
  "adapter": "mailamericas",
30400
30400
  "recognitionRank": 985,
30401
- "localClocks": true
30401
+ "localClocks": true,
30402
+ "browser": true
30402
30403
  },
30403
30404
  "canaryUrl": "https://mailamericas.com/tracking",
30404
30405
  "trackingUrlTemplate": "https://mailamericas.com/tracking?number_id={trackingNumber}",
@@ -30399,7 +30399,8 @@ export const CARRIER_CATALOG = {
30399
30399
  "mode": "automatic",
30400
30400
  "adapter": "mailamericas",
30401
30401
  "recognitionRank": 985,
30402
- "localClocks": true
30402
+ "localClocks": true,
30403
+ "browser": true
30403
30404
  },
30404
30405
  "canaryUrl": "https://mailamericas.com/tracking",
30405
30406
  "trackingUrlTemplate": "https://mailamericas.com/tracking?number_id={trackingNumber}",
@@ -2,7 +2,7 @@
2
2
  "openapi": "3.1.0",
3
3
  "info": {
4
4
  "title": "Universal Parcel Scraper",
5
- "version": "0.959.2-main.5205"
5
+ "version": "0.960.2-main.5209"
6
6
  },
7
7
  "paths": {
8
8
  "/health": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "universal-parcel-scraper",
3
- "version": "0.959.2-main.5205",
3
+ "version": "0.960.2-main.5209",
4
4
  "description": "Self-hosted parcel tracking: carrier detection, dedicated scrapers and optional universal providers.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",