scandit-react-native-datacapture-core 8.7.0-beta.1 → 8.7.0
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 +11 -0
- package/android/build.gradle +1 -1
- package/dist/core.js +235 -340
- package/dist/core.js.flow +50 -143
- package/dist/core.js.map +1 -1
- package/dist/dts/core.d.ts +55 -152
- package/dist/dts/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.flow +0 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/scandit-react-native-datacapture-core.podspec +1 -1
package/dist/core.js
CHANGED
|
@@ -1842,8 +1842,6 @@ var LogCategory;
|
|
|
1842
1842
|
LogCategory[LogCategory["Listener"] = 4] = "Listener";
|
|
1843
1843
|
LogCategory[LogCategory["Events"] = 8] = "Events";
|
|
1844
1844
|
})(LogCategory || (LogCategory = {}));
|
|
1845
|
-
const DEFAULT_CATEGORIES = LogCategory.Bridge | LogCategory.Lifecycle | LogCategory.Listener;
|
|
1846
|
-
const ALL_CATEGORIES = DEFAULT_CATEGORIES | LogCategory.Events;
|
|
1847
1845
|
const NAMES$1 = {
|
|
1848
1846
|
[LogCategory.Bridge]: 'Bridge',
|
|
1849
1847
|
[LogCategory.Lifecycle]: 'Lifecycle',
|
|
@@ -1890,14 +1888,6 @@ function callCore(proxy, args) {
|
|
|
1890
1888
|
return proxy._call('executeCore', args);
|
|
1891
1889
|
}
|
|
1892
1890
|
|
|
1893
|
-
function categoryNames(mask) {
|
|
1894
|
-
const names = [];
|
|
1895
|
-
for (let bit = 1; bit <= ALL_CATEGORIES; bit <<= 1) {
|
|
1896
|
-
if ((mask & bit) !== 0)
|
|
1897
|
-
names.push(logCategoryName(bit));
|
|
1898
|
-
}
|
|
1899
|
-
return names;
|
|
1900
|
-
}
|
|
1901
1891
|
// FactoryMaker throws until the framework has bound its proxies.
|
|
1902
1892
|
function coreProxy() {
|
|
1903
1893
|
try {
|
|
@@ -1917,57 +1907,37 @@ function sdkVersion() {
|
|
|
1917
1907
|
return 'unknown';
|
|
1918
1908
|
}
|
|
1919
1909
|
}
|
|
1920
|
-
function
|
|
1921
|
-
|
|
1910
|
+
function serializeLogRecord(record) {
|
|
1911
|
+
return JSON.stringify(Object.assign(Object.assign({}, record), { time: new Date(record.ts).toISOString(), level: logLevelName(record.level).trim(), category: logCategoryName(record.category) }));
|
|
1912
|
+
}
|
|
1913
|
+
function buildLogHeader(level, now = new Date()) {
|
|
1914
|
+
return JSON.stringify({
|
|
1922
1915
|
type: 'scandit-debug-log',
|
|
1923
|
-
formatVersion:
|
|
1916
|
+
formatVersion: 2,
|
|
1924
1917
|
sdkVersion: sdkVersion(),
|
|
1925
1918
|
exportedAt: now.toISOString(),
|
|
1926
|
-
level: logLevelName(
|
|
1927
|
-
categories: config.categories,
|
|
1928
|
-
categoryNames: categoryNames(config.categories),
|
|
1929
|
-
bufferSize: config.bufferSize,
|
|
1930
|
-
logBridgeArgs: config.logBridgeArgs,
|
|
1931
|
-
logErrorStacks: config.logErrorStacks,
|
|
1932
|
-
recordCount: records.length,
|
|
1919
|
+
level: logLevelName(level).trim(),
|
|
1933
1920
|
});
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
return Promise.reject(new Error('ScanditLogger.writeLogs: debug mode is not enabled — call ScanditLogger.setLevel() first'));
|
|
1945
|
-
}
|
|
1946
|
-
if (records.length === 0) {
|
|
1947
|
-
return Promise.reject(new Error('ScanditLogger.writeLogs: the log buffer is empty'));
|
|
1948
|
-
}
|
|
1949
|
-
const proxy = coreProxy();
|
|
1950
|
-
if (proxy === undefined) {
|
|
1951
|
-
return Promise.reject(new Error('ScanditLogger.writeLogs: the SDK is not initialised yet'));
|
|
1952
|
-
}
|
|
1953
|
-
const { header, body } = buildLogExport(records, config);
|
|
1954
|
-
return callCore(proxy, {
|
|
1955
|
-
moduleName: 'CoreModule',
|
|
1956
|
-
methodName: 'writeLogs',
|
|
1957
|
-
isEventRegistration: false,
|
|
1958
|
-
path,
|
|
1959
|
-
header,
|
|
1960
|
-
body,
|
|
1961
|
-
}).then(result => {
|
|
1962
|
-
// Every FrameworksResult implementation wraps a non-map success value as `{ data: <string> }`;
|
|
1963
|
-
// a null one resolves with nothing, which is why the caller's own path stays as the fallback.
|
|
1921
|
+
}
|
|
1922
|
+
function writeLogs(path, level, flushPending) {
|
|
1923
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1924
|
+
const proxy = coreProxy();
|
|
1925
|
+
if (proxy === undefined) {
|
|
1926
|
+
throw new Error('ScanditLogger.writeLogs: the SDK is not initialised yet');
|
|
1927
|
+
}
|
|
1928
|
+
yield flushPending();
|
|
1929
|
+
const result = yield callCore(proxy, Object.assign(Object.assign({ moduleName: 'CoreModule', methodName: 'writeLogs', isEventRegistration: false }, (path === undefined ? {} : { path })), { header: buildLogHeader(level) }));
|
|
1930
|
+
// Every FrameworksResult implementation wraps a non-map success value as `{ data: <string> }`.
|
|
1964
1931
|
const written = result === null || result === void 0 ? void 0 : result.data;
|
|
1965
|
-
|
|
1932
|
+
if (typeof written !== 'string' || written.length === 0) {
|
|
1933
|
+
throw new Error('ScanditLogger.writeLogs: the native side did not report where the file was written');
|
|
1934
|
+
}
|
|
1935
|
+
return written;
|
|
1966
1936
|
});
|
|
1967
1937
|
}
|
|
1968
1938
|
|
|
1969
|
-
const
|
|
1970
|
-
const
|
|
1939
|
+
const BUFFER_SIZE = 1000;
|
|
1940
|
+
const NATIVE_QUEUE_CAP = 1000;
|
|
1971
1941
|
const REDACTED = '[redacted]';
|
|
1972
1942
|
const REDACTED_ARG_KEYS = Object.freeze([
|
|
1973
1943
|
'frameData',
|
|
@@ -2003,10 +1973,14 @@ const REDACTED_ARG_KEYS = Object.freeze([
|
|
|
2003
1973
|
'age',
|
|
2004
1974
|
'frontReviewImage',
|
|
2005
1975
|
]);
|
|
2006
|
-
//
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
1976
|
+
// Log-storage calls carry headers and record batches, never worth storing as a record's args.
|
|
1977
|
+
const REDACTED_ARG_METHODS = Object.freeze([
|
|
1978
|
+
'parseString',
|
|
1979
|
+
'parseRawData',
|
|
1980
|
+
'writeLogs',
|
|
1981
|
+
'appendLogs',
|
|
1982
|
+
'clearLogs',
|
|
1983
|
+
]);
|
|
2010
1984
|
class ScanditLogger {
|
|
2011
1985
|
/**
|
|
2012
1986
|
* Merge per-method log metadata into the global registry. Called as a
|
|
@@ -2022,32 +1996,6 @@ class ScanditLogger {
|
|
|
2022
1996
|
static getMethodMetadata(methodName) {
|
|
2023
1997
|
return ScanditLogger._methodMetadata.get(methodName);
|
|
2024
1998
|
}
|
|
2025
|
-
static setLogBridgeArgs(enabled) {
|
|
2026
|
-
ScanditLogger._logBridgeArgs = enabled;
|
|
2027
|
-
}
|
|
2028
|
-
static getLogBridgeArgs() {
|
|
2029
|
-
return ScanditLogger._logBridgeArgs;
|
|
2030
|
-
}
|
|
2031
|
-
static setLogErrorStacks(enabled) {
|
|
2032
|
-
ScanditLogger._logErrorStacks = enabled;
|
|
2033
|
-
}
|
|
2034
|
-
static getLogErrorStacks() {
|
|
2035
|
-
return ScanditLogger._logErrorStacks;
|
|
2036
|
-
}
|
|
2037
|
-
static setAdditionalRedactedArgKeys(keys) {
|
|
2038
|
-
ScanditLogger._extraRedactedArgKeys = new Set(keys);
|
|
2039
|
-
ScanditLogger._recomputeRedactedArgKeys();
|
|
2040
|
-
}
|
|
2041
|
-
static addRedactedArgKey(key) {
|
|
2042
|
-
ScanditLogger._extraRedactedArgKeys.add(key);
|
|
2043
|
-
ScanditLogger._recomputeRedactedArgKeys();
|
|
2044
|
-
}
|
|
2045
|
-
static getRedactedArgKeys() {
|
|
2046
|
-
return new Set(ScanditLogger._effectiveRedactedArgKeys);
|
|
2047
|
-
}
|
|
2048
|
-
static _recomputeRedactedArgKeys() {
|
|
2049
|
-
ScanditLogger._effectiveRedactedArgKeys = new Set([...REDACTED_ARG_KEYS, ...ScanditLogger._extraRedactedArgKeys]);
|
|
2050
|
-
}
|
|
2051
1999
|
static _redactValue(value) {
|
|
2052
2000
|
if (value == null)
|
|
2053
2001
|
return value;
|
|
@@ -2070,7 +2018,7 @@ class ScanditLogger {
|
|
|
2070
2018
|
if (typeof value === 'object') {
|
|
2071
2019
|
const out = {};
|
|
2072
2020
|
for (const [k, v] of Object.entries(value)) {
|
|
2073
|
-
out[k] = ScanditLogger.
|
|
2021
|
+
out[k] = ScanditLogger._redactedArgKeys.has(k) ? REDACTED : ScanditLogger._redactValue(v);
|
|
2074
2022
|
}
|
|
2075
2023
|
return out;
|
|
2076
2024
|
}
|
|
@@ -2080,8 +2028,6 @@ class ScanditLogger {
|
|
|
2080
2028
|
if (fields === undefined || !('args' in fields))
|
|
2081
2029
|
return fields;
|
|
2082
2030
|
const { args } = fields, rest = __rest(fields, ["args"]);
|
|
2083
|
-
if (!ScanditLogger._logBridgeArgs)
|
|
2084
|
-
return Object.keys(rest).length > 0 ? rest : undefined;
|
|
2085
2031
|
const redacted = ScanditLogger._isRedactedArgMethod(message)
|
|
2086
2032
|
? ScanditLogger._redactEveryValue(args)
|
|
2087
2033
|
: ScanditLogger._redactValue(args);
|
|
@@ -2103,7 +2049,7 @@ class ScanditLogger {
|
|
|
2103
2049
|
return REDACTED;
|
|
2104
2050
|
}
|
|
2105
2051
|
static _applyErrorPolicy(error) {
|
|
2106
|
-
if (error === undefined ||
|
|
2052
|
+
if (error === undefined || error.stack === undefined)
|
|
2107
2053
|
return error;
|
|
2108
2054
|
const rest = __rest(error, ["stack"]);
|
|
2109
2055
|
return rest;
|
|
@@ -2115,26 +2061,8 @@ class ScanditLogger {
|
|
|
2115
2061
|
static getLevel() {
|
|
2116
2062
|
return ScanditLogger._level;
|
|
2117
2063
|
}
|
|
2118
|
-
static setCategories(mask) {
|
|
2119
|
-
ScanditLogger._categories = mask;
|
|
2120
|
-
ScanditLogger._emitConfig();
|
|
2121
|
-
}
|
|
2122
|
-
static getCategories() {
|
|
2123
|
-
return ScanditLogger._categories;
|
|
2124
|
-
}
|
|
2125
|
-
static setBufferSize(size) {
|
|
2126
|
-
const next = Math.max(MIN_BUFFER_SIZE, Math.floor(size));
|
|
2127
|
-
if (next === ScanditLogger._bufferSize)
|
|
2128
|
-
return;
|
|
2129
|
-
ScanditLogger._bufferSize = next;
|
|
2130
|
-
ScanditLogger._buffer = new Array(next);
|
|
2131
|
-
ScanditLogger._writeIdx = 0;
|
|
2132
|
-
ScanditLogger._count = 0;
|
|
2133
|
-
ScanditLogger._emitConfig();
|
|
2134
|
-
}
|
|
2135
2064
|
/**
|
|
2136
|
-
* Subscribe to configuration changes (`setLevel`
|
|
2137
|
-
* `setBufferSize`). The callback fires immediately with the current
|
|
2065
|
+
* Subscribe to configuration changes (`setLevel`). The callback fires immediately with the current
|
|
2138
2066
|
* configuration when attached, then again on every subsequent change.
|
|
2139
2067
|
* Returns an unsubscribe function.
|
|
2140
2068
|
*
|
|
@@ -2144,11 +2072,7 @@ class ScanditLogger {
|
|
|
2144
2072
|
static onConfigChange(cb) {
|
|
2145
2073
|
ScanditLogger._configListeners.add(cb);
|
|
2146
2074
|
try {
|
|
2147
|
-
cb({
|
|
2148
|
-
level: ScanditLogger._level,
|
|
2149
|
-
categories: ScanditLogger._categories,
|
|
2150
|
-
bufferSize: ScanditLogger._bufferSize,
|
|
2151
|
-
});
|
|
2075
|
+
cb({ level: ScanditLogger._level });
|
|
2152
2076
|
}
|
|
2153
2077
|
catch (err) {
|
|
2154
2078
|
console.error('[ScanditLogger] config listener threw on attach:', err);
|
|
@@ -2158,11 +2082,7 @@ class ScanditLogger {
|
|
|
2158
2082
|
static _emitConfig() {
|
|
2159
2083
|
if (ScanditLogger._configListeners.size === 0)
|
|
2160
2084
|
return;
|
|
2161
|
-
const cfg = {
|
|
2162
|
-
level: ScanditLogger._level,
|
|
2163
|
-
categories: ScanditLogger._categories,
|
|
2164
|
-
bufferSize: ScanditLogger._bufferSize,
|
|
2165
|
-
};
|
|
2085
|
+
const cfg = { level: ScanditLogger._level };
|
|
2166
2086
|
// Snapshot: a listener may attach another (the lazy receiver does), and a live
|
|
2167
2087
|
// Set iteration would visit the newcomer in the same pass, firing it twice.
|
|
2168
2088
|
for (const cb of [...ScanditLogger._configListeners]) {
|
|
@@ -2174,17 +2094,13 @@ class ScanditLogger {
|
|
|
2174
2094
|
}
|
|
2175
2095
|
}
|
|
2176
2096
|
}
|
|
2177
|
-
static getBufferSize() {
|
|
2178
|
-
return ScanditLogger._bufferSize;
|
|
2179
|
-
}
|
|
2180
2097
|
static getRecentLogs() {
|
|
2181
2098
|
const out = [];
|
|
2182
|
-
const size = ScanditLogger._bufferSize;
|
|
2183
2099
|
const count = ScanditLogger._count;
|
|
2184
|
-
const start = count <
|
|
2185
|
-
const total = Math.min(count,
|
|
2100
|
+
const start = count < BUFFER_SIZE ? 0 : ScanditLogger._writeIdx;
|
|
2101
|
+
const total = Math.min(count, BUFFER_SIZE);
|
|
2186
2102
|
for (let i = 0; i < total; i++) {
|
|
2187
|
-
const record = ScanditLogger._buffer[(start + i) %
|
|
2103
|
+
const record = ScanditLogger._buffer[(start + i) % BUFFER_SIZE];
|
|
2188
2104
|
if (record !== undefined)
|
|
2189
2105
|
out.push(record);
|
|
2190
2106
|
}
|
|
@@ -2195,39 +2111,73 @@ class ScanditLogger {
|
|
|
2195
2111
|
return () => ScanditLogger._subscribers.delete(cb);
|
|
2196
2112
|
}
|
|
2197
2113
|
static clear() {
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2114
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2115
|
+
var _a;
|
|
2116
|
+
ScanditLogger._buffer = new Array(BUFFER_SIZE);
|
|
2117
|
+
ScanditLogger._writeIdx = 0;
|
|
2118
|
+
ScanditLogger._count = 0;
|
|
2119
|
+
ScanditLogger._pendingForNative = [];
|
|
2120
|
+
const proxy = coreProxy();
|
|
2121
|
+
if (proxy === undefined)
|
|
2122
|
+
return;
|
|
2123
|
+
// An appendLogs already in flight would otherwise land after the delete.
|
|
2124
|
+
yield ((_a = ScanditLogger._nativeSink) === null || _a === void 0 ? void 0 : _a.flush());
|
|
2125
|
+
yield callCore(proxy, {
|
|
2126
|
+
moduleName: 'CoreModule',
|
|
2127
|
+
methodName: 'clearLogs',
|
|
2128
|
+
isEventRegistration: false,
|
|
2129
|
+
});
|
|
2130
|
+
});
|
|
2131
|
+
}
|
|
2132
|
+
/** TS-emitted records not yet handed to native storage. Internal: used by `installNativeLogReceiver`. */
|
|
2133
|
+
static pendingNativeRecordCount() {
|
|
2134
|
+
return ScanditLogger._pendingForNative.length;
|
|
2135
|
+
}
|
|
2136
|
+
/** Removes and returns every record waiting for native storage. Internal. */
|
|
2137
|
+
static takePendingNativeRecords() {
|
|
2138
|
+
const records = ScanditLogger._pendingForNative;
|
|
2139
|
+
ScanditLogger._pendingForNative = [];
|
|
2140
|
+
return records;
|
|
2141
|
+
}
|
|
2142
|
+
/** Registers (or, with `undefined`, removes) the sink that moves queued records to native storage. Internal. */
|
|
2143
|
+
static setNativeSink(sink) {
|
|
2144
|
+
ScanditLogger._nativeSink = sink;
|
|
2145
|
+
}
|
|
2146
|
+
static _enqueueForNative(record) {
|
|
2147
|
+
var _a;
|
|
2148
|
+
const queue = ScanditLogger._pendingForNative;
|
|
2149
|
+
queue.push(record);
|
|
2150
|
+
if (queue.length > NATIVE_QUEUE_CAP)
|
|
2151
|
+
queue.shift();
|
|
2152
|
+
try {
|
|
2153
|
+
(_a = ScanditLogger._nativeSink) === null || _a === void 0 ? void 0 : _a.onQueued();
|
|
2154
|
+
}
|
|
2155
|
+
catch (err) {
|
|
2156
|
+
console.error('[ScanditLogger] native sink threw:', err);
|
|
2157
|
+
}
|
|
2201
2158
|
}
|
|
2202
2159
|
/**
|
|
2203
|
-
* Writes the
|
|
2204
|
-
* absolute path written.
|
|
2160
|
+
* Writes the records the SDK stored on the device, oldest first, as a redacted JSON-lines file
|
|
2161
|
+
* and resolves with the absolute path written. Without `path` the file is
|
|
2162
|
+
* `scandit-debug-log.jsonl` in the application's cache directory, replaced on every call.
|
|
2205
2163
|
*
|
|
2206
2164
|
* An app can only write inside its own storage: pass a path under the app container on iOS
|
|
2207
2165
|
* (Documents, Library or the temporary directory) or under `Context.getFilesDir()` /
|
|
2208
2166
|
* `Context.getExternalFilesDir()` on Android. A relative `path` is resolved against the app's
|
|
2209
2167
|
* documents/files directory, which is the portable way to ask for a destination.
|
|
2210
2168
|
*
|
|
2211
|
-
* Rejects when
|
|
2212
|
-
*
|
|
2169
|
+
* Rejects when no record is stored (call `setLevel` first), the SDK is not initialized yet,
|
|
2170
|
+
* or the destination cannot be written.
|
|
2213
2171
|
*/
|
|
2214
2172
|
static writeLogs(path) {
|
|
2215
|
-
return writeLogs(path, ScanditLogger.
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
logErrorStacks: ScanditLogger.getLogErrorStacks(),
|
|
2221
|
-
});
|
|
2173
|
+
return writeLogs(path, ScanditLogger.getLevel(), () => { var _a, _b; return (_b = (_a = ScanditLogger._nativeSink) === null || _a === void 0 ? void 0 : _a.flush()) !== null && _b !== void 0 ? _b : Promise.resolve(); });
|
|
2174
|
+
}
|
|
2175
|
+
/** Whether a record at `level` would be kept under the current level. */
|
|
2176
|
+
static isEnabled(level) {
|
|
2177
|
+
return level !== LogLevel.Off && ScanditLogger._level !== LogLevel.Off && level <= ScanditLogger._level;
|
|
2222
2178
|
}
|
|
2223
2179
|
static emit(level, category, source, message, fields, durationMs, error) {
|
|
2224
|
-
if (level
|
|
2225
|
-
return;
|
|
2226
|
-
if (ScanditLogger._level === LogLevel.Off)
|
|
2227
|
-
return;
|
|
2228
|
-
if (level > ScanditLogger._level)
|
|
2229
|
-
return;
|
|
2230
|
-
if ((ScanditLogger._categories & category) === 0)
|
|
2180
|
+
if (!ScanditLogger.isEnabled(level))
|
|
2231
2181
|
return;
|
|
2232
2182
|
const record = {
|
|
2233
2183
|
ts: Date.now(),
|
|
@@ -2239,10 +2189,10 @@ class ScanditLogger {
|
|
|
2239
2189
|
durationMs,
|
|
2240
2190
|
error: ScanditLogger._applyErrorPolicy(error),
|
|
2241
2191
|
};
|
|
2242
|
-
const size = ScanditLogger._bufferSize;
|
|
2243
2192
|
ScanditLogger._buffer[ScanditLogger._writeIdx] = record;
|
|
2244
|
-
ScanditLogger._writeIdx = (ScanditLogger._writeIdx + 1) %
|
|
2193
|
+
ScanditLogger._writeIdx = (ScanditLogger._writeIdx + 1) % BUFFER_SIZE;
|
|
2245
2194
|
ScanditLogger._count++;
|
|
2195
|
+
ScanditLogger._enqueueForNative(record);
|
|
2246
2196
|
ScanditLogger.writeToNativeSink(record);
|
|
2247
2197
|
for (const sub of ScanditLogger._subscribers) {
|
|
2248
2198
|
try {
|
|
@@ -2257,19 +2207,12 @@ class ScanditLogger {
|
|
|
2257
2207
|
/**
|
|
2258
2208
|
* Insert a `LogRecord` produced by the native side into the local buffer.
|
|
2259
2209
|
*
|
|
2260
|
-
* Applies TS-side level
|
|
2261
|
-
* `setCategories` is the single source of truth for what lands in the
|
|
2262
|
-
* unified buffer, regardless of how the native side categorized the
|
|
2263
|
-
* record. This matters because the native sides (Android/iOS) don't yet
|
|
2264
|
-
* consume the generated `logCategory` metadata — they emit per-frame
|
|
2265
|
-
* `finish*` records at `Bridge`, but the customer expects them under
|
|
2266
|
-
* `Events` (default-masked-off). The override + gate here closes that
|
|
2267
|
-
* gap until a native LogMetadata file exists.
|
|
2210
|
+
* Applies the TS-side level gate; native already applied its per-method override.
|
|
2268
2211
|
*
|
|
2269
2212
|
* Skips the platform-native console sink (the native side already wrote
|
|
2270
2213
|
* to `android.util.Log` / `os_log` / etc.).
|
|
2271
2214
|
*
|
|
2272
|
-
* Best-effort correlation: when the
|
|
2215
|
+
* Best-effort correlation: when the incoming
|
|
2273
2216
|
* record has a `durationMs`, look back for the most recent unmatched
|
|
2274
2217
|
* `ts.bridge` record with the same method name (last segment after the
|
|
2275
2218
|
* dot) within a 10-second window and attach a derived
|
|
@@ -2280,30 +2223,13 @@ class ScanditLogger {
|
|
|
2280
2223
|
* platform adapters — not part of the customer-facing API.
|
|
2281
2224
|
*/
|
|
2282
2225
|
static ingest(record) {
|
|
2283
|
-
const meta = ScanditLogger.getMethodMetadata(record.message);
|
|
2284
|
-
// Errors are exempt from the category override, mirroring the native rule
|
|
2285
|
-
// (`ScanditLogger.kt` `emit`). The override exists to keep the
|
|
2286
|
-
// high-frequency per-frame *success* path out of the default mask; an
|
|
2287
|
-
// error on one of those methods is rare and is the record that matters
|
|
2288
|
-
// most. Without this, a throwing `finishBarcodeCaptureDidScan` arrives
|
|
2289
|
-
// from native as `Error`/`Bridge`, gets re-categorised to `Events`, and is
|
|
2290
|
-
// then dropped by `DEFAULT_CATEGORIES` — so it reaches neither the unified
|
|
2291
|
-
// buffer nor its subscribers, which is where a customer-facing log dump is
|
|
2292
|
-
// assembled.
|
|
2293
|
-
const overridable = record.level > LogLevel.Error;
|
|
2294
|
-
let effective = overridable && (meta === null || meta === void 0 ? void 0 : meta.category) != null && meta.category !== record.category
|
|
2295
|
-
? Object.assign(Object.assign({}, record), { category: meta.category }) : record;
|
|
2296
2226
|
if (ScanditLogger._level === LogLevel.Off)
|
|
2297
2227
|
return;
|
|
2298
|
-
if (
|
|
2299
|
-
return;
|
|
2300
|
-
if ((ScanditLogger._categories & effective.category) === 0)
|
|
2228
|
+
if (record.level > ScanditLogger._level)
|
|
2301
2229
|
return;
|
|
2302
|
-
|
|
2303
|
-
const enriched = ScanditLogger._withBridgeOverhead(effective);
|
|
2304
|
-
const size = ScanditLogger._bufferSize;
|
|
2230
|
+
const enriched = ScanditLogger._withBridgeOverhead(Object.assign(Object.assign({}, record), { fields: ScanditLogger._applyArgPolicy(record.message, record.fields), error: ScanditLogger._applyErrorPolicy(record.error) }));
|
|
2305
2231
|
ScanditLogger._buffer[ScanditLogger._writeIdx] = enriched;
|
|
2306
|
-
ScanditLogger._writeIdx = (ScanditLogger._writeIdx + 1) %
|
|
2232
|
+
ScanditLogger._writeIdx = (ScanditLogger._writeIdx + 1) % BUFFER_SIZE;
|
|
2307
2233
|
ScanditLogger._count++;
|
|
2308
2234
|
for (const sub of ScanditLogger._subscribers) {
|
|
2309
2235
|
try {
|
|
@@ -2322,14 +2248,13 @@ class ScanditLogger {
|
|
|
2322
2248
|
return record;
|
|
2323
2249
|
const nativeMethod = record.message;
|
|
2324
2250
|
const window = ScanditLogger._CORRELATION_WINDOW_MS;
|
|
2325
|
-
const
|
|
2326
|
-
const total = Math.min(ScanditLogger._count, size);
|
|
2251
|
+
const total = Math.min(ScanditLogger._count, BUFFER_SIZE);
|
|
2327
2252
|
if (total === 0)
|
|
2328
2253
|
return record;
|
|
2329
2254
|
const writeIdx = ScanditLogger._writeIdx;
|
|
2330
2255
|
// Walk newest → oldest in the ring buffer.
|
|
2331
2256
|
for (let i = 1; i <= total; i++) {
|
|
2332
|
-
const idx = (writeIdx - i +
|
|
2257
|
+
const idx = (writeIdx - i + BUFFER_SIZE * 2) % BUFFER_SIZE;
|
|
2333
2258
|
const candidate = ScanditLogger._buffer[idx];
|
|
2334
2259
|
if (!candidate)
|
|
2335
2260
|
continue;
|
|
@@ -2392,17 +2317,13 @@ class ScanditLogger {
|
|
|
2392
2317
|
}
|
|
2393
2318
|
}
|
|
2394
2319
|
ScanditLogger._level = LogLevel.Off;
|
|
2395
|
-
ScanditLogger.
|
|
2396
|
-
ScanditLogger._bufferSize = DEFAULT_BUFFER_SIZE;
|
|
2397
|
-
ScanditLogger._buffer = new Array(DEFAULT_BUFFER_SIZE);
|
|
2320
|
+
ScanditLogger._buffer = new Array(BUFFER_SIZE);
|
|
2398
2321
|
ScanditLogger._writeIdx = 0;
|
|
2399
2322
|
ScanditLogger._count = 0;
|
|
2400
2323
|
ScanditLogger._subscribers = new Set();
|
|
2401
2324
|
ScanditLogger._configListeners = new Set();
|
|
2402
|
-
ScanditLogger.
|
|
2403
|
-
ScanditLogger.
|
|
2404
|
-
ScanditLogger._extraRedactedArgKeys = new Set();
|
|
2405
|
-
ScanditLogger._effectiveRedactedArgKeys = new Set(REDACTED_ARG_KEYS);
|
|
2325
|
+
ScanditLogger._pendingForNative = [];
|
|
2326
|
+
ScanditLogger._redactedArgKeys = new Set(REDACTED_ARG_KEYS);
|
|
2406
2327
|
ScanditLogger._CORRELATION_WINDOW_MS = 10000;
|
|
2407
2328
|
ScanditLogger._methodMetadata = new Map();
|
|
2408
2329
|
|
|
@@ -3452,13 +3373,23 @@ class BaseController {
|
|
|
3452
3373
|
}
|
|
3453
3374
|
}
|
|
3454
3375
|
|
|
3376
|
+
function errorMessage(err) {
|
|
3377
|
+
return err instanceof Error ? err.message : String(err);
|
|
3378
|
+
}
|
|
3379
|
+
|
|
3455
3380
|
const INSTRUMENTED = Symbol.for('scanditLogger.bridgeCallInstrumented');
|
|
3456
3381
|
const SOURCE = 'ts.bridge';
|
|
3382
|
+
// The log file's own commands: a record about storing records would be stored in turn, forever.
|
|
3383
|
+
const UNLOGGED_METHODS = new Set(['appendLogs', 'clearLogs']);
|
|
3457
3384
|
var BridgeCallKind;
|
|
3458
3385
|
(function (BridgeCallKind) {
|
|
3459
3386
|
BridgeCallKind["Method"] = "method";
|
|
3460
3387
|
BridgeCallKind["EventRegistration"] = "eventRegistration";
|
|
3461
3388
|
})(BridgeCallKind || (BridgeCallKind = {}));
|
|
3389
|
+
function isUnlogged(args) {
|
|
3390
|
+
const method = args === null || args === void 0 ? void 0 : args.methodName;
|
|
3391
|
+
return typeof method === 'string' && UNLOGGED_METHODS.has(method);
|
|
3392
|
+
}
|
|
3462
3393
|
function isInstrumented(call) {
|
|
3463
3394
|
return call[INSTRUMENTED] === true;
|
|
3464
3395
|
}
|
|
@@ -3481,7 +3412,7 @@ function createDispatcher(call, defaultCategory, tag) {
|
|
|
3481
3412
|
return (fnName, args) => {
|
|
3482
3413
|
// Gate on Off alone: gating on Debug would also suppress the LogLevel.Error
|
|
3483
3414
|
// record the catch block emits, which a level of e.g. Error must still get.
|
|
3484
|
-
if (ScanditLogger.getLevel() === LogLevel.Off) {
|
|
3415
|
+
if (ScanditLogger.getLevel() === LogLevel.Off || isUnlogged(args)) {
|
|
3485
3416
|
try {
|
|
3486
3417
|
return call(fnName, args);
|
|
3487
3418
|
}
|
|
@@ -3497,17 +3428,30 @@ function createDispatcher(call, defaultCategory, tag) {
|
|
|
3497
3428
|
function instrument(call, fnName, args, defaultCategory, tag) {
|
|
3498
3429
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3499
3430
|
const start = Date.now();
|
|
3500
|
-
const { message, category, errorCategory,
|
|
3431
|
+
const { message, level, category, errorCategory, buildFields } = resolveDispatch(fnName, args, defaultCategory, tag);
|
|
3432
|
+
// Built once, and only if a record will use it: per-frame Trace calls are dropped at Debug.
|
|
3433
|
+
let fields;
|
|
3434
|
+
let fieldsBuilt = false;
|
|
3435
|
+
const getFields = () => {
|
|
3436
|
+
if (!fieldsBuilt) {
|
|
3437
|
+
fields = buildFields();
|
|
3438
|
+
fieldsBuilt = true;
|
|
3439
|
+
}
|
|
3440
|
+
return fields;
|
|
3441
|
+
};
|
|
3442
|
+
// Snapshot the args before the call can mutate them.
|
|
3443
|
+
if (ScanditLogger.isEnabled(level))
|
|
3444
|
+
getFields();
|
|
3501
3445
|
try {
|
|
3502
3446
|
// `await` tolerates both Promise and non-Promise returns. Some test
|
|
3503
3447
|
// doubles (and historical native modules) return plain values; we still
|
|
3504
3448
|
// want to record one LogRecord per call.
|
|
3505
3449
|
const result = yield call(fnName, args);
|
|
3506
|
-
ScanditLogger.emit(
|
|
3450
|
+
ScanditLogger.emit(level, category, SOURCE, message, ScanditLogger.isEnabled(level) ? getFields() : undefined, Date.now() - start);
|
|
3507
3451
|
return result;
|
|
3508
3452
|
}
|
|
3509
3453
|
catch (err) {
|
|
3510
|
-
ScanditLogger.emit(LogLevel.Error, errorCategory, SOURCE, message,
|
|
3454
|
+
ScanditLogger.emit(LogLevel.Error, errorCategory, SOURCE, message, getFields(), Date.now() - start, toLogError(err));
|
|
3511
3455
|
throw err;
|
|
3512
3456
|
}
|
|
3513
3457
|
});
|
|
@@ -3525,7 +3469,18 @@ const ID_KEYS = new Set(['modeId', 'viewId', 'parentId']);
|
|
|
3525
3469
|
function resolveDispatch(fnName, args, defaultCategory, tag) {
|
|
3526
3470
|
var _a, _b, _c;
|
|
3527
3471
|
const dispatcher = (args !== null && args !== void 0 ? args : {});
|
|
3528
|
-
const
|
|
3472
|
+
const method = typeof dispatcher.methodName === 'string' ? dispatcher.methodName : undefined;
|
|
3473
|
+
const baseCategory = method !== undefined && dispatcher.isEventRegistration ? LogCategory.Listener : defaultCategory;
|
|
3474
|
+
const override = ScanditLogger.getMethodMetadata(method !== null && method !== void 0 ? method : fnName);
|
|
3475
|
+
return {
|
|
3476
|
+
message: method !== undefined ? `${(_a = dispatcher.moduleName) !== null && _a !== void 0 ? _a : fnName}.${method}` : `${tag}${fnName}`,
|
|
3477
|
+
level: (_b = override === null || override === void 0 ? void 0 : override.level) !== null && _b !== void 0 ? _b : LogLevel.Debug,
|
|
3478
|
+
category: (_c = override === null || override === void 0 ? void 0 : override.category) !== null && _c !== void 0 ? _c : baseCategory,
|
|
3479
|
+
errorCategory: baseCategory,
|
|
3480
|
+
buildFields: () => buildFields(args, dispatcher),
|
|
3481
|
+
};
|
|
3482
|
+
}
|
|
3483
|
+
function buildFields(args, dispatcher) {
|
|
3529
3484
|
const fields = {};
|
|
3530
3485
|
if (typeof dispatcher.modeId === 'number')
|
|
3531
3486
|
fields.modeId = dispatcher.modeId;
|
|
@@ -3533,12 +3488,9 @@ function resolveDispatch(fnName, args, defaultCategory, tag) {
|
|
|
3533
3488
|
fields.viewId = dispatcher.viewId;
|
|
3534
3489
|
if (typeof dispatcher.parentId === 'number')
|
|
3535
3490
|
fields.parentId = dispatcher.parentId;
|
|
3536
|
-
//
|
|
3537
|
-
//
|
|
3538
|
-
|
|
3539
|
-
// opting out skips the per-call copy; `ScanditLogger.emit` decides which
|
|
3540
|
-
// values survive.
|
|
3541
|
-
if (args != null && typeof args === 'object' && ScanditLogger.getLogBridgeArgs()) {
|
|
3491
|
+
// Inner args go under `fields.args`, minus dispatcher boilerplate and the
|
|
3492
|
+
// already-promoted IDs; `ScanditLogger.emit` decides which values survive.
|
|
3493
|
+
if (args != null && typeof args === 'object') {
|
|
3542
3494
|
const innerArgs = {};
|
|
3543
3495
|
for (const [key, value] of Object.entries(dispatcher)) {
|
|
3544
3496
|
if (DISPATCHER_KEYS.has(key) || ID_KEYS.has(key))
|
|
@@ -3549,33 +3501,13 @@ function resolveDispatch(fnName, args, defaultCategory, tag) {
|
|
|
3549
3501
|
fields.args = innerArgs;
|
|
3550
3502
|
}
|
|
3551
3503
|
}
|
|
3552
|
-
|
|
3553
|
-
const module = (_a = dispatcher.moduleName) !== null && _a !== void 0 ? _a : fnName;
|
|
3554
|
-
const method = dispatcher.methodName;
|
|
3555
|
-
const baseCategory = dispatcher.isEventRegistration ? LogCategory.Listener : defaultCategory;
|
|
3556
|
-
// Generated metadata can override the category for known-noisy methods
|
|
3557
|
-
// (e.g. per-frame `finish*DidUpdateSession` ack callbacks → Events).
|
|
3558
|
-
const override = (_b = ScanditLogger.getMethodMetadata(method)) === null || _b === void 0 ? void 0 : _b.category;
|
|
3559
|
-
return {
|
|
3560
|
-
message: `${module}.${method}`,
|
|
3561
|
-
category: override !== null && override !== void 0 ? override : baseCategory,
|
|
3562
|
-
errorCategory: baseCategory,
|
|
3563
|
-
fields: Object.keys(fields).length ? fields : undefined,
|
|
3564
|
-
};
|
|
3565
|
-
}
|
|
3566
|
-
const override = (_c = ScanditLogger.getMethodMetadata(fnName)) === null || _c === void 0 ? void 0 : _c.category;
|
|
3567
|
-
return {
|
|
3568
|
-
message: `${tag}${fnName}`,
|
|
3569
|
-
category: override !== null && override !== void 0 ? override : defaultCategory,
|
|
3570
|
-
errorCategory: defaultCategory,
|
|
3571
|
-
fields: Object.keys(fields).length ? fields : undefined,
|
|
3572
|
-
};
|
|
3504
|
+
return Object.keys(fields).length ? fields : undefined;
|
|
3573
3505
|
}
|
|
3574
|
-
function toLogError
|
|
3506
|
+
function toLogError(err) {
|
|
3575
3507
|
if (err instanceof Error) {
|
|
3576
|
-
return { name: err.name, message: err
|
|
3508
|
+
return { name: err.name, message: errorMessage(err), stack: err.stack };
|
|
3577
3509
|
}
|
|
3578
|
-
return { name: 'Error', message:
|
|
3510
|
+
return { name: 'Error', message: errorMessage(err) };
|
|
3579
3511
|
}
|
|
3580
3512
|
|
|
3581
3513
|
/** Instruments a proxy's bridge calls for logging; `NativeProxy` already does this at construction. Idempotent. */
|
|
@@ -3584,81 +3516,9 @@ function wrapNativeProxy(target) {
|
|
|
3584
3516
|
target._callEventRegistration = instrumentBridgeCall(target._callEventRegistration, target, BridgeCallKind.EventRegistration);
|
|
3585
3517
|
}
|
|
3586
3518
|
|
|
3587
|
-
/**
|
|
3588
|
-
* Method decorator that emits a `LogRecord` for each invocation of the
|
|
3589
|
-
* annotated method, capturing its arguments under `fields.args`.
|
|
3590
|
-
*
|
|
3591
|
-
* `ScanditLogger.emit` redacts by argument **key name** and by method name. A
|
|
3592
|
-
* positional scalar argument has neither, so it is logged as-is: a method whose
|
|
3593
|
-
* sensitive data arrives as a bare string or number needs an entry in
|
|
3594
|
-
* `REDACTED_ARG_METHODS`, or no annotation.
|
|
3595
|
-
*
|
|
3596
|
-
* `source` and `category` are **required**: they are taxonomy labels, and a
|
|
3597
|
-
* default would silently mislabel every record from a module that forgot to
|
|
3598
|
-
* pass one — e.g. a barcode class inheriting `'ts.core'` and being filed under
|
|
3599
|
-
* the wrong subsystem, which is worse than a compile error. `level` does have a
|
|
3600
|
-
* default (`LogLevel.Debug`) because it is a severity, not a label: an
|
|
3601
|
-
* unintended `Debug` is visible and harmless. Failures always emit at
|
|
3602
|
-
* `LogLevel.Error` with the error attached, regardless of `level`.
|
|
3603
|
-
*/
|
|
3604
|
-
function LogValues(options) {
|
|
3605
|
-
var _a;
|
|
3606
|
-
const source = options.source;
|
|
3607
|
-
const category = options.category;
|
|
3608
|
-
const level = (_a = options.level) !== null && _a !== void 0 ? _a : LogLevel.Debug;
|
|
3609
|
-
return function (target, propertyKey, descriptor) {
|
|
3610
|
-
var _a, _b;
|
|
3611
|
-
const original = descriptor.value;
|
|
3612
|
-
if (typeof original !== 'function')
|
|
3613
|
-
return descriptor;
|
|
3614
|
-
const className = (_b = (_a = target.constructor) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : 'Object';
|
|
3615
|
-
const methodName = String(propertyKey);
|
|
3616
|
-
descriptor.value = function (...args) {
|
|
3617
|
-
const start = Date.now();
|
|
3618
|
-
const message = `${className}.${methodName}`;
|
|
3619
|
-
const fields = { args: safeSnapshot(args) };
|
|
3620
|
-
const emit = (durationMs, error) => {
|
|
3621
|
-
ScanditLogger.emit(error ? LogLevel.Error : level, category, source, message, fields, durationMs, error);
|
|
3622
|
-
};
|
|
3623
|
-
let result;
|
|
3624
|
-
try {
|
|
3625
|
-
result = original.apply(this, args);
|
|
3626
|
-
}
|
|
3627
|
-
catch (err) {
|
|
3628
|
-
emit(Date.now() - start, toLogError(err));
|
|
3629
|
-
throw err;
|
|
3630
|
-
}
|
|
3631
|
-
if (result instanceof Promise) {
|
|
3632
|
-
return result.then(value => {
|
|
3633
|
-
emit(Date.now() - start);
|
|
3634
|
-
return value;
|
|
3635
|
-
}, (err) => {
|
|
3636
|
-
emit(Date.now() - start, toLogError(err));
|
|
3637
|
-
throw err;
|
|
3638
|
-
});
|
|
3639
|
-
}
|
|
3640
|
-
emit(Date.now() - start);
|
|
3641
|
-
return result;
|
|
3642
|
-
};
|
|
3643
|
-
return descriptor;
|
|
3644
|
-
};
|
|
3645
|
-
}
|
|
3646
|
-
function safeSnapshot(args) {
|
|
3647
|
-
try {
|
|
3648
|
-
return JSON.parse(JSON.stringify(args));
|
|
3649
|
-
}
|
|
3650
|
-
catch (_a) {
|
|
3651
|
-
return args.map(a => (typeof a === 'object' ? '[unserializable]' : a));
|
|
3652
|
-
}
|
|
3653
|
-
}
|
|
3654
|
-
function toLogError(err) {
|
|
3655
|
-
if (err instanceof Error) {
|
|
3656
|
-
return { name: err.name, message: err.message, stack: err.stack };
|
|
3657
|
-
}
|
|
3658
|
-
return { name: 'Error', message: String(err) };
|
|
3659
|
-
}
|
|
3660
|
-
|
|
3661
3519
|
const BATCH_EVENT = 'ScanditLogger.batch';
|
|
3520
|
+
const FILE_FLUSH_INTERVAL_MS = 100;
|
|
3521
|
+
const FILE_FLUSH_MAX_RECORDS = 50;
|
|
3662
3522
|
/**
|
|
3663
3523
|
* Per-proxy teardown for everything `installNativeLogReceiver` registers — both
|
|
3664
3524
|
* the BATCH_EVENT listener and the config listener. Keyed weakly so a discarded
|
|
@@ -3701,6 +3561,52 @@ function parseBatchPayload(raw) {
|
|
|
3701
3561
|
}
|
|
3702
3562
|
return null;
|
|
3703
3563
|
}
|
|
3564
|
+
// Sends queued records to `appendLogs` at 50 waiting or 100 ms after the first, draining any
|
|
3565
|
+
// queued earlier on attach; the returned detach leaves unsent records queued.
|
|
3566
|
+
function attachNativeFileSink(proxy) {
|
|
3567
|
+
let timer;
|
|
3568
|
+
let sending = Promise.resolve();
|
|
3569
|
+
const sendAll = () => {
|
|
3570
|
+
if (timer !== undefined) {
|
|
3571
|
+
clearTimeout(timer);
|
|
3572
|
+
timer = undefined;
|
|
3573
|
+
}
|
|
3574
|
+
const records = ScanditLogger.takePendingNativeRecords();
|
|
3575
|
+
for (let i = 0; i < records.length; i += FILE_FLUSH_MAX_RECORDS) {
|
|
3576
|
+
const lines = records
|
|
3577
|
+
.slice(i, i + FILE_FLUSH_MAX_RECORDS)
|
|
3578
|
+
.map(serializeLogRecord)
|
|
3579
|
+
.join('\n');
|
|
3580
|
+
sending = sending
|
|
3581
|
+
.then(() => callCore(proxy, { moduleName: 'CoreModule', methodName: 'appendLogs', isEventRegistration: false, lines }))
|
|
3582
|
+
.then(() => undefined)
|
|
3583
|
+
.catch((err) => {
|
|
3584
|
+
console.warn('[ScanditLogger] could not store log records on the device:', errorMessage(err));
|
|
3585
|
+
});
|
|
3586
|
+
}
|
|
3587
|
+
};
|
|
3588
|
+
const onQueued = () => {
|
|
3589
|
+
if (ScanditLogger.pendingNativeRecordCount() >= FILE_FLUSH_MAX_RECORDS) {
|
|
3590
|
+
sendAll();
|
|
3591
|
+
}
|
|
3592
|
+
else if (timer === undefined) {
|
|
3593
|
+
timer = setTimeout(sendAll, FILE_FLUSH_INTERVAL_MS);
|
|
3594
|
+
}
|
|
3595
|
+
};
|
|
3596
|
+
const flush = () => {
|
|
3597
|
+
sendAll();
|
|
3598
|
+
return sending;
|
|
3599
|
+
};
|
|
3600
|
+
ScanditLogger.setNativeSink({ onQueued, flush });
|
|
3601
|
+
if (ScanditLogger.pendingNativeRecordCount() > 0)
|
|
3602
|
+
onQueued();
|
|
3603
|
+
return () => {
|
|
3604
|
+
ScanditLogger.setNativeSink(undefined);
|
|
3605
|
+
if (timer !== undefined)
|
|
3606
|
+
clearTimeout(timer);
|
|
3607
|
+
timer = undefined;
|
|
3608
|
+
};
|
|
3609
|
+
}
|
|
3704
3610
|
/**
|
|
3705
3611
|
* Wire up the cross-bridge log channel: subscribe to the native-emitted
|
|
3706
3612
|
* `ScanditLogger.batch` event and merge each incoming record into the local
|
|
@@ -3717,8 +3623,8 @@ function parseBatchPayload(raw) {
|
|
|
3717
3623
|
* Call this once per framework, immediately after the NativeProxy is bound
|
|
3718
3624
|
* (typically in `init*Proxy.ts`).
|
|
3719
3625
|
*
|
|
3720
|
-
* Returns a teardown that detaches
|
|
3721
|
-
* listener, so the receiver can be turned off again. Calling this function more
|
|
3626
|
+
* Returns a teardown that detaches the BATCH_EVENT handler, the config
|
|
3627
|
+
* listener and the `appendLogs` sink, so the receiver can be turned off again. Calling this function more
|
|
3722
3628
|
* than once on the same proxy is safe: the previous registration is disposed
|
|
3723
3629
|
* first. It is NOT safe to rely on the EventEmitter to de-duplicate — it does
|
|
3724
3630
|
* not (see `previousTeardowns`).
|
|
@@ -3751,31 +3657,29 @@ function installNativeLogReceiver(proxy) {
|
|
|
3751
3657
|
}
|
|
3752
3658
|
};
|
|
3753
3659
|
proxy.eventEmitter.on(BATCH_EVENT, onBatch);
|
|
3754
|
-
// Push TS-side config (level
|
|
3660
|
+
// Push TS-side config (level) to the native singleton.
|
|
3755
3661
|
// Fires once immediately on attach (carrying whatever level the customer
|
|
3756
|
-
// already set), then again on every subsequent setLevel
|
|
3757
|
-
// setBufferSize call. Failures are logged but never throw.
|
|
3662
|
+
// already set), then again on every subsequent setLevel call. Failures are logged but never throw.
|
|
3758
3663
|
//
|
|
3759
3664
|
// Each onConfigChange call adds a fresh closure to a Set, so without a
|
|
3760
3665
|
// teardown a re-install would leave the previous listener attached and fire
|
|
3761
3666
|
// one redundant `setLoggerConfig` bridge call per accumulated listener on
|
|
3762
|
-
// every subsequent setLevel
|
|
3667
|
+
// every subsequent setLevel.
|
|
3763
3668
|
const disposeConfigListener = ScanditLogger.onConfigChange(cfg => {
|
|
3764
3669
|
void callCore(proxy, {
|
|
3765
3670
|
moduleName: 'CoreModule',
|
|
3766
3671
|
methodName: 'setLoggerConfig',
|
|
3767
3672
|
isEventRegistration: false,
|
|
3768
3673
|
level: cfg.level,
|
|
3769
|
-
categories: cfg.categories,
|
|
3770
|
-
bufferSize: cfg.bufferSize,
|
|
3771
3674
|
}).catch((err) => {
|
|
3772
|
-
|
|
3773
|
-
console.warn('[ScanditLogger] native config sync failed:', msg);
|
|
3675
|
+
console.warn('[ScanditLogger] native config sync failed:', errorMessage(err));
|
|
3774
3676
|
});
|
|
3775
3677
|
});
|
|
3678
|
+
const detachFileSink = attachNativeFileSink(proxy);
|
|
3776
3679
|
const teardown = () => {
|
|
3777
3680
|
proxy.eventEmitter.off(BATCH_EVENT, onBatch);
|
|
3778
3681
|
disposeConfigListener();
|
|
3682
|
+
detachFileSink();
|
|
3779
3683
|
previousTeardowns.delete(proxy);
|
|
3780
3684
|
};
|
|
3781
3685
|
// Publish the teardown SYNCHRONOUSLY, before the first `await` below. Everything
|
|
@@ -3899,13 +3803,10 @@ function subscribeNativeLogChannel(proxy) {
|
|
|
3899
3803
|
// Generator: scripts/bridge_generator/generate.py
|
|
3900
3804
|
// Schema: scripts/bridge_generator/schemas/core.json
|
|
3901
3805
|
/**
|
|
3902
|
-
* Per-method `LogRecord` category overrides for the CoreProxy
|
|
3903
|
-
* bridge surface. Consumed by the centralized `ScanditLogger` interceptor
|
|
3904
|
-
*
|
|
3905
|
-
*
|
|
3906
|
-
* default category mask. Level and category gate independently: those
|
|
3907
|
-
* records are emitted at `Debug` and stay hidden until the category is
|
|
3908
|
-
* opted into, so raising the level does not reveal them.
|
|
3806
|
+
* Per-method `LogRecord` level and category overrides for the CoreProxy
|
|
3807
|
+
* bridge surface. Consumed by the centralized `ScanditLogger` interceptor:
|
|
3808
|
+
* per-frame / per-scan callbacks log at `Trace` under their category label, so
|
|
3809
|
+
* they only show once the level is raised to `Trace`.
|
|
3909
3810
|
*
|
|
3910
3811
|
* Auto-registered as a side effect of importing this module via the
|
|
3911
3812
|
* generated `index.ts` barrel — no customer wiring required.
|
|
@@ -5112,21 +5013,6 @@ __decorate([
|
|
|
5112
5013
|
__decorate([
|
|
5113
5014
|
ignoreFromSerialization
|
|
5114
5015
|
], DataCaptureContext.prototype, "listeners", void 0);
|
|
5115
|
-
__decorate([
|
|
5116
|
-
LogValues({ source: 'ts.core', category: LogCategory.Lifecycle })
|
|
5117
|
-
], DataCaptureContext.prototype, "setFrameSource", null);
|
|
5118
|
-
__decorate([
|
|
5119
|
-
LogValues({ source: 'ts.core', category: LogCategory.Lifecycle })
|
|
5120
|
-
], DataCaptureContext.prototype, "addMode", null);
|
|
5121
|
-
__decorate([
|
|
5122
|
-
LogValues({ source: 'ts.core', category: LogCategory.Lifecycle })
|
|
5123
|
-
], DataCaptureContext.prototype, "removeMode", null);
|
|
5124
|
-
__decorate([
|
|
5125
|
-
LogValues({ source: 'ts.core', category: LogCategory.Lifecycle })
|
|
5126
|
-
], DataCaptureContext.prototype, "dispose", null);
|
|
5127
|
-
__decorate([
|
|
5128
|
-
LogValues({ source: 'ts.core', category: LogCategory.Lifecycle })
|
|
5129
|
-
], DataCaptureContext.prototype, "applySettings", null);
|
|
5130
5016
|
__decorate([
|
|
5131
5017
|
ignoreFromSerialization
|
|
5132
5018
|
], DataCaptureContext, "_instance", void 0);
|
|
@@ -5196,10 +5082,11 @@ class ModeBase extends DefaultSerializeable {
|
|
|
5196
5082
|
withController(action, fallback) {
|
|
5197
5083
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5198
5084
|
if (!(yield this.awaitCreation())) {
|
|
5085
|
+
this.logHeld();
|
|
5199
5086
|
return fallback;
|
|
5200
5087
|
}
|
|
5201
5088
|
if (!this.controller) {
|
|
5202
|
-
|
|
5089
|
+
this.logModeError('controller is not created');
|
|
5203
5090
|
return fallback;
|
|
5204
5091
|
}
|
|
5205
5092
|
return action(this.controller);
|
|
@@ -5208,15 +5095,26 @@ class ModeBase extends DefaultSerializeable {
|
|
|
5208
5095
|
withListenerController(action, fallback) {
|
|
5209
5096
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5210
5097
|
if (!(yield this.awaitCreation())) {
|
|
5098
|
+
this.logHeld();
|
|
5211
5099
|
return fallback;
|
|
5212
5100
|
}
|
|
5213
5101
|
if (!this.listenerController) {
|
|
5214
|
-
|
|
5102
|
+
this.logModeError('listener controller is not created');
|
|
5215
5103
|
return fallback;
|
|
5216
5104
|
}
|
|
5217
5105
|
return action(this.listenerController);
|
|
5218
5106
|
});
|
|
5219
5107
|
}
|
|
5108
|
+
logHeld() {
|
|
5109
|
+
ScanditLogger.emit(LogLevel.Debug, LogCategory.Lifecycle, 'ts.mode', `${this.constructor.name}: held until it is added to a context`);
|
|
5110
|
+
}
|
|
5111
|
+
logModeError(detail) {
|
|
5112
|
+
const message = `${this.constructor.name}: ${detail}`;
|
|
5113
|
+
ScanditLogger.emit(LogLevel.Error, LogCategory.Lifecycle, 'ts.mode', message);
|
|
5114
|
+
if (ScanditLogger.getLevel() < LogLevel.Error) {
|
|
5115
|
+
console.error(message);
|
|
5116
|
+
}
|
|
5117
|
+
}
|
|
5220
5118
|
get context() {
|
|
5221
5119
|
return this._context;
|
|
5222
5120
|
}
|
|
@@ -6230,7 +6128,11 @@ class Camera extends DefaultSerializeable {
|
|
|
6230
6128
|
}
|
|
6231
6129
|
if (!this.isActiveCamera) {
|
|
6232
6130
|
// Phase 1: Not yet added to context
|
|
6233
|
-
|
|
6131
|
+
const warning = 'The current camera is not added to the DataCaptureContext. Add camera to the DataCaptureContext first.';
|
|
6132
|
+
ScanditLogger.emit(LogLevel.Warn, LogCategory.Lifecycle, 'ts.camera', warning);
|
|
6133
|
+
if (ScanditLogger.getLevel() < LogLevel.Warn) {
|
|
6134
|
+
console.warn(warning);
|
|
6135
|
+
}
|
|
6234
6136
|
return;
|
|
6235
6137
|
}
|
|
6236
6138
|
// Phase 3: Execute immediately
|
|
@@ -6351,7 +6253,9 @@ class Camera extends DefaultSerializeable {
|
|
|
6351
6253
|
// Phase 3: Execute immediately
|
|
6352
6254
|
yield this.didChange();
|
|
6353
6255
|
}
|
|
6354
|
-
|
|
6256
|
+
else {
|
|
6257
|
+
ScanditLogger.emit(LogLevel.Debug, LogCategory.Lifecycle, 'ts.camera', 'Camera.applySettings: stored until the camera is set as the frame source');
|
|
6258
|
+
}
|
|
6355
6259
|
});
|
|
6356
6260
|
}
|
|
6357
6261
|
set context(newContext) {
|
|
@@ -6554,12 +6458,6 @@ __decorate([
|
|
|
6554
6458
|
__decorate([
|
|
6555
6459
|
ignoreFromSerialization
|
|
6556
6460
|
], Camera.prototype, "nativeReadyTimeout", void 0);
|
|
6557
|
-
__decorate([
|
|
6558
|
-
LogValues({ source: 'ts.core', category: LogCategory.Lifecycle })
|
|
6559
|
-
], Camera.prototype, "switchToDesiredState", null);
|
|
6560
|
-
__decorate([
|
|
6561
|
-
LogValues({ source: 'ts.core', category: LogCategory.Lifecycle })
|
|
6562
|
-
], Camera.prototype, "applySettings", null);
|
|
6563
6461
|
__decorate([
|
|
6564
6462
|
ignoreFromSerialization
|
|
6565
6463
|
], Camera, "_cameraInstances", void 0);
|
|
@@ -8872,9 +8770,6 @@ __decorate([
|
|
|
8872
8770
|
__decorate([
|
|
8873
8771
|
ignoreFromSerialization
|
|
8874
8772
|
], BaseDataCaptureView.prototype, "viewCreationGate", void 0);
|
|
8875
|
-
__decorate([
|
|
8876
|
-
LogValues({ source: 'ts.core', category: LogCategory.Lifecycle })
|
|
8877
|
-
], BaseDataCaptureView.prototype, "dispose", null);
|
|
8878
8773
|
|
|
8879
8774
|
/**
|
|
8880
8775
|
* Fills the whole view with a single colour.
|
|
@@ -9112,5 +9007,5 @@ var ClusteringMode;
|
|
|
9112
9007
|
ClusteringMode["AutoWithManualCorrection"] = "autoWithManualCorrection";
|
|
9113
9008
|
})(ClusteringMode || (ClusteringMode = {}));
|
|
9114
9009
|
|
|
9115
|
-
export { AimerViewfinder, Anchor, BaseController, BaseDataCaptureView, Brush, CORE_PROXY_LOG_METADATA, CORE_PROXY_TYPE_NAMES, Camera, CameraController, CameraOwnershipHelper, CameraOwnershipManager, CameraPosition, CameraSettings, CameraSwitchControl, CameraSwitchControlController, ClusteringMode, Color, ColorFillOverlay, ContextStatus, ControlImage, CoreProxyAdapter,
|
|
9010
|
+
export { AimerViewfinder, Anchor, BaseController, BaseDataCaptureView, Brush, CORE_PROXY_LOG_METADATA, CORE_PROXY_TYPE_NAMES, Camera, CameraController, CameraOwnershipHelper, CameraOwnershipManager, CameraPosition, CameraSettings, CameraSwitchControl, CameraSwitchControlController, ClusteringMode, Color, ColorFillOverlay, ContextStatus, ControlImage, CoreProxyAdapter, DataCaptureContext, DataCaptureContextEvents, DataCaptureContextSettings, DataCaptureViewController, DataCaptureViewEvents, DefaultSerializeable, Direction, EventDataParser, EventEmitter, Expiration, FactoryMaker, Feedback, FocusGestureListenerEvents, FocusGestureStrategy, FocusRange, FontFamily, FrameDataController, FrameDataSettings, FrameDataSettingsBuilder, FrameSourceListenerEvents, FrameSourceState, HTMLElementState, HtmlElementPosition, HtmlElementSize, ImageBuffer, ImageFrameSource, LaserlineViewfinder, LicenseInfo, ListenerRegistry, LogCategory, LogLevel, LogoStyle, MacroMode, MacroModeListenerEvents, MarginsWithUnit, MeasureUnit, ModeBase, NativeProxy, NoViewfinder, NoneLocationSelection, NumberWithUnit, Observable, OpenSourceSoftwareLicenseInfo, Orientation, PinchToZoom, Point, PointWithUnit, PrivateFocusGestureDeserializer, PrivateFrameData, PrivateZoomGestureDeserializer, Quadrilateral, REDACTED_ARG_KEYS, REDACTED_ARG_METHODS, RadiusLocationSelection, Rect, RectWithUnit, RectangularLocationSelection, RectangularViewfinder, RectangularViewfinderAnimation, RectangularViewfinderLineStyle, RectangularViewfinderStyle, SKIP, ScanIntention, ScanditIcon, ScanditIconBuilder, ScanditIconShape, ScanditIconType, ScanditLogger, SelectionMode, SequenceFrameSource, Size, SizeWithAspect, SizeWithUnit, SizeWithUnitAndAspect, SizingMode, Sound, SwipeToZoom, TapToFocus, TextAlignment, TorchListenerEvents, TorchState, TorchSwitchControl, VIEW_CREATION_PRE_BEGIN_TIMEOUT_MS, VIEW_CREATION_TIMEOUT_MS, Vibration, VibrationType, VideoResolution, ViewCreationGate, WaveFormVibration, ZoomGestureListenerEvents, ZoomListenerEvents, ZoomSwitchControl, ZoomSwitchOrientation, armNativeLogReceiver, buildStaticCoreDefaultsJson, createNativeProxy, ensureCoreDefaults, generateIdentifier, getCoreDefaults, ignoreFromSerialization, ignoreFromSerializationIfNull, installNativeLogReceiver, loadCoreDefaults, markSingleInstancePerView, nameForSerialization, registerCoreProxies, registerProxies, resetCameraControllerPayloadParserWarnings, resetDataCaptureViewPayloadParserWarnings, serializationDefault, setCoreDefaultsLoader, singleInstanceOverlayName, subscribeNativeLogChannel, wrapNativeProxy };
|
|
9116
9011
|
//# sourceMappingURL=core.js.map
|