@bkbdev/core 1.0.0 → 1.1.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/babel.cjs +2 -1
- package/bkb-data.cjs +80 -0
- package/dist/assets.cjs.map +2 -2
- package/dist/assets.js.map +2 -2
- package/dist/auto.cjs.map +2 -2
- package/dist/auto.js.map +2 -2
- package/dist/images-automatic.cjs.map +2 -2
- package/dist/images-automatic.js.map +2 -2
- package/dist/images-react.cjs.map +2 -2
- package/dist/images-react.js.map +2 -2
- package/dist/images.cjs.map +2 -2
- package/dist/images.js.map +2 -2
- package/dist/index.cjs.map +2 -2
- package/dist/index.js.map +2 -2
- package/dist/inspector.cjs.map +2 -2
- package/dist/inspector.js.map +2 -2
- package/dist/network.cjs.map +2 -2
- package/dist/network.js.map +2 -2
- package/dist/protocol/src/bkb-config.d.ts +49 -8
- package/dist/register.cjs +20 -2
- package/dist/register.cjs.map +4 -4
- package/dist/register.js +20 -2
- package/dist/register.js.map +4 -4
- package/dist/renders.cjs.map +2 -2
- package/dist/renders.js.map +2 -2
- package/dist/sdk/src/project-config.d.ts +24 -0
- package/dist/sdk/src/register.d.ts +2 -1
- package/dist/storage.cjs.map +2 -2
- package/dist/storage.js.map +2 -2
- package/inspector/BKBInspector.podspec +1 -1
- package/package.json +2 -1
package/dist/inspector.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/inspector-native.ts", "../src/inspector-error.ts", "../src/serialize.ts", "../src/inspector-values.ts", "../src/inspector-orientation.ts", "../src/inspector-renderer.ts", "../src/environment.ts", "../src/types.ts"],
|
|
4
|
-
"sourcesContent": ["export type {\n InspectorProvider,\n InspectorGeometry,\n InspectorSelection,\n} from '../../protocol/src/inspector-provider';\nimport { InspectorUnavailable } from './inspector-error';\nimport { readInspectorOrientation } from './inspector-orientation';\nimport { inspectNativeView } from './inspector-renderer';\nimport { loggingEnabled } from './environment';\nimport { createId } from './types';\nimport { summarizeInspectorSelection, nativeMethod, nativeProperty } from './inspector-values';\nimport type {\n InspectorGeometry,\n InspectorProvider,\n InspectorSelection,\n} from '../../protocol/src/inspector-provider';\ndeclare const global: { __REACT_DEVTOOLS_GLOBAL_HOOK__?: unknown };\nexport interface ReactNativeInspectorConfig {\n enabled?: boolean;\n root(): unknown;\n native(): unknown;\n}\nexport function createReactNativeInspector(config: ReactNativeInspectorConfig): InspectorProvider {\n if (!loggingEnabled(config.enabled ?? true))\n return {\n instanceId: 'disabled',\n enabled: false,\n measure: () => Promise.reject(new Error('Inspector disabled.')),\n inspect: () => Promise.reject(new Error('Inspector disabled.')),\n dispose: () => undefined,\n };\n return new ReactNativeInspector(\n () => config.root(),\n () => config.native(),\n );\n}\nclass ReactNativeInspector implements InspectorProvider {\n readonly instanceId = createId();\n readonly enabled = true;\n private stopped = false;\n private readonly rootIds = new WeakMap<object, string>();\n private readonly pending = new Set<(error: Error) => void>();\n constructor(\n private readonly root: () => unknown,\n private readonly native: () => unknown,\n ) {}\n measure(): Promise<InspectorGeometry> {\n return this.callback((resolve, reject) => {\n const native = this.native();\n if (nativeProperty(nativeProperty(native, 'AppState'), 'currentState') !== 'active')\n throw new InspectorUnavailable(\n 'Bring the inspected development application to the foreground.',\n );\n const dimensions = nativeProperty(native, 'Dimensions');\n const screen = nativeMethod(dimensions, 'get')('screen');\n const pixelRatio = Number(nativeMethod(nativeProperty(native, 'PixelRatio'), 'get')());\n const root = this.root();\n const rootId = this.rootIdentity(root);\n nativeMethod(\n root,\n 'measure',\n )((_x: number, _y: number, width: number, height: number, pageX: number, pageY: number) => {\n try {\n if (this.root() !== root) {\n reject(new InspectorUnavailable('Inspection root changed. Capture again.'));\n return;\n }\n readInspectorOrientation(\n native,\n (interfaceOrientation) =>\n resolve({\n rootId,\n root: { width, height, pageX, pageY },\n pixelRatio,\n screen: {\n width: Number(nativeProperty(screen, 'width')),\n height: Number(nativeProperty(screen, 'height')),\n },\n ...(interfaceOrientation ? { interfaceOrientation } : {}),\n }),\n reject,\n );\n } catch {\n reject(new InspectorUnavailable('Inspection root unavailable. Capture again.'));\n }\n });\n });\n }\n inspect(x: number, y: number, index?: number): Promise<InspectorSelection> {\n return this.callback((resolve, reject) => {\n const root = this.root();\n inspectNativeView(\n global.__REACT_DEVTOOLS_GLOBAL_HOOK__,\n this.native(),\n root,\n x,\n y,\n (selection: unknown) => {\n try {\n if (this.root() !== root) throw new Error('Inspection root changed.');\n resolve(summarizeInspectorSelection(selection, index));\n } catch {\n reject(new InspectorUnavailable('Inspector selection unavailable. Capture again.'));\n }\n },\n reject,\n );\n });\n }\n private rootIdentity(root: unknown): string {\n if (!root || (typeof root !== 'object' && typeof root !== 'function'))\n throw new InspectorUnavailable('Mount the active native inspection root before capturing.');\n const existing = this.rootIds.get(root);\n if (existing) return existing;\n const id = createId();\n this.rootIds.set(root, id);\n return id;\n }\n private callback<T>(\n operation: (resolve: (value: T) => void, reject: (error: Error) => void) => void,\n ): Promise<T> {\n if (this.stopped) return Promise.reject(new Error('Inspector disposed.'));\n return new Promise<T>((resolve, reject) => {\n let settled = false;\n const finish = (error?: Error, value?: T): void => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n clearTimeout(dispatch);\n this.pending.delete(cancel);\n if (error) reject(error);\n else if (value !== undefined) resolve(value);\n };\n const cancel = (error: Error): void => finish(error);\n const timer = setTimeout(\n () =>\n cancel(\n new InspectorUnavailable(\n 'Native inspector callback timed out. Check that the root is mounted.',\n ),\n ),\n 3000,\n );\n this.pending.add(cancel);\n const dispatch = setTimeout(() => {\n try {\n operation((value) => finish(undefined, value), cancel);\n } catch (error) {\n cancel(\n error instanceof InspectorUnavailable\n ? error\n : new InspectorUnavailable('Native inspector operation unavailable.'),\n );\n }\n }, 0);\n });\n }\n dispose(): void {\n this.stopped = true;\n for (const cancel of this.pending) cancel(new Error('Inspector disposed.'));\n this.pending.clear();\n }\n}\n", "export class InspectorUnavailable extends Error {\n readonly inspectorCode = 'bkb-inspector-unavailable-v1';\n}\nexport function inspectorFailureReason(error: unknown): string {\n if (error && typeof error === 'object') {\n const code = Object.getOwnPropertyDescriptor(error, 'inspectorCode');\n const message = Object.getOwnPropertyDescriptor(error, 'message');\n if (code?.value === 'bkb-inspector-unavailable-v1' && typeof message?.value === 'string')\n return message.value.slice(0, 512);\n }\n return 'Inspector unavailable. Check the mounted root and supported development renderer.';\n}\n", "import type { JsonValue } from './types';\n\nfunction visit(\n value: unknown,\n seen: Set<object>,\n depth: number,\n budget: { nodes: number; characters: number },\n): JsonValue {\n if (--budget.nodes < 0) return '[size limit]';\n if (value === null || typeof value === 'boolean') return value;\n if (typeof value === 'string') {\n const length = Math.max(0, Math.min(4000, budget.characters));\n budget.characters -= Math.min(value.length, length);\n return value.length > length ? value.slice(0, length) + '[truncated]' : value;\n }\n if (typeof value === 'number') return Number.isFinite(value) ? value : String(value);\n if (typeof value === 'bigint' || typeof value === 'symbol') return String(value);\n if (typeof value !== 'object') return `[${typeof value}]`;\n if (depth >= 5) return '[depth limit]';\n if (seen.has(value)) return '[circular]';\n seen.add(value);\n try {\n if (value instanceof Error)\n return visit(\n {\n name: errorField(value, 'name') || 'Error',\n message: errorField(value, 'message'),\n stack: errorField(value, 'stack'),\n },\n seen,\n depth + 1,\n budget,\n );\n if (Array.isArray(value)) return visitArray(value, seen, depth, budget);\n const result: { [key: string]: JsonValue } = {};\n const keys = Object.keys(value);\n for (const key of keys.slice(0, 50)) {\n if (budget.nodes <= 0) {\n result['[truncated]'] = '[size limit]';\n break;\n }\n if (key === '__proto__' || key === 'constructor' || key === 'prototype') continue;\n try {\n const descriptor = Object.getOwnPropertyDescriptor(value, key);\n result[key.slice(0, 128)] =\n descriptor && 'value' in descriptor\n ? visit(descriptor.value, seen, depth + 1, budget)\n : '[unavailable]';\n } catch {\n result[key.slice(0, 128)] = '[unavailable]';\n }\n }\n if (keys.length > 50) result['[truncated]'] = '[property limit]';\n return result;\n } finally {\n seen.delete(value);\n }\n}\n\nexport function serialize(value: unknown): JsonValue {\n try {\n const result = visit(value, new Set(), 0, { nodes: 200, characters: 12000 });\n const encoded = JSON.stringify(result);\n return encoded.length <= 16000 ? result : { truncated: true, preview: encoded.slice(0, 4000) };\n } catch {\n return '[unserializable]';\n }\n}\n\nfunction errorField(value: Error, key: string): string {\n const descriptor =\n Object.getOwnPropertyDescriptor(value, key) ??\n Object.getOwnPropertyDescriptor(Object.getPrototypeOf(value), key);\n const field: unknown = descriptor && 'value' in descriptor ? descriptor.value : '';\n return typeof field === 'string' ? field.slice(0, 4000) : '';\n}\n\nfunction visitArray(\n value: unknown[],\n seen: Set<object>,\n depth: number,\n budget: { nodes: number; characters: number },\n): JsonValue[] {\n const result: JsonValue[] = [];\n for (let index = 0; index < Math.min(value.length, 100); index++) {\n if (budget.nodes <= 0) {\n result.push('[size limit]');\n break;\n }\n const descriptor = Object.getOwnPropertyDescriptor(value, String(index));\n result.push(\n descriptor && 'value' in descriptor\n ? visit(descriptor.value, seen, depth + 1, budget)\n : '[unavailable]',\n );\n }\n if (value.length > 100) result.push('[array limit]');\n return result;\n}\n", "import { InspectorUnavailable } from './inspector-error';\nimport { serialize } from './serialize';\nimport type { InspectorSelection, InspectorSource } from '../../protocol/src/inspector-provider';\nexport function nativeProperty(value: unknown, key: string): unknown {\n return value && (typeof value === 'object' || typeof value === 'function')\n ? (Reflect.get(value, key) as unknown)\n : undefined;\n}\nexport function nativeMethod(value: unknown, name: string): (...args: unknown[]) => unknown {\n const method = nativeProperty(value, name);\n if (typeof method !== 'function')\n throw new InspectorUnavailable('Native inspector method unavailable: ' + name + '.');\n return (...args) => Reflect.apply(method, value, args) as unknown;\n}\nfunction sourceLocation(value: unknown): InspectorSource | undefined {\n if (!value || typeof value !== 'object') return;\n const file = nativeProperty(value, 'file') ?? nativeProperty(value, 'fileName');\n const line = nativeProperty(value, 'line') ?? nativeProperty(value, 'lineNumber');\n const column = nativeProperty(value, 'column') ?? nativeProperty(value, 'columnNumber');\n if (\n typeof file !== 'string' ||\n file.length > 4096 ||\n typeof line !== 'number' ||\n !Number.isInteger(line) ||\n line < 1 ||\n typeof column !== 'number' ||\n !Number.isInteger(column) ||\n column < 1\n )\n return;\n return { file, line, column };\n}\n// A plain data property, never an accessor, so reading metadata cannot run app code.\nfunction ownValue(object: unknown, key: string): unknown {\n const descriptor =\n object && typeof object === 'object' ? Object.getOwnPropertyDescriptor(object, key) : undefined;\n return descriptor && 'value' in descriptor ? (descriptor.value as unknown) : undefined;\n}\nfunction inspectorSource(details: unknown): InspectorSource | undefined {\n return (\n sourceLocation(ownValue(nativeProperty(details, 'props'), '__bkbSource')) ??\n sourceLocation(nativeProperty(details, 'source'))\n );\n}\nconst MAX_OWNER_STEPS = 64;\n// Library UI (a modal, a sheet) has no source metadata of its own, because the Babel plugin\n// skips dependencies. React Native's React 19 builds return the fiber of the nearest component\n// as `closestInstance`; walking its owners reaches the nearest element written in the project,\n// which is where the library component is used.\nfunction nearestOwnerSource(selection: unknown): InspectorSource | undefined {\n let fiber = nativeProperty(selection, 'closestInstance');\n for (let step = 0; fiber && step < MAX_OWNER_STEPS; step++) {\n const source = sourceLocation(ownValue(nativeProperty(fiber, 'memoizedProps'), '__bkbSource'));\n if (source) return source;\n fiber = nativeProperty(fiber, '_debugOwner');\n }\n return undefined;\n}\nfunction inspectorProps(props: unknown) {\n const retained: Record<string, unknown> = {};\n if (props && typeof props === 'object') {\n for (const key of Object.keys(props).slice(0, 30)) {\n if (['children', '__bkbSource', '__proto__', 'constructor', 'prototype'].indexOf(key) !== -1)\n continue;\n const descriptor = Object.getOwnPropertyDescriptor(props, key);\n retained[key] =\n descriptor && 'value' in descriptor ? (descriptor.value as unknown) : '[accessor omitted]';\n }\n }\n const safe = serialize(retained);\n return JSON.stringify(safe).length > 8000 ? '[props exceed preview budget]' : safe;\n}\nexport function summarizeInspectorSelection(\n selection: unknown,\n index?: number,\n): InspectorSelection {\n const entries = nativeProperty(selection, 'hierarchy');\n if (!Array.isArray(entries) || !entries.length || entries.length > 40)\n throw new Error('Inspector hierarchy unavailable or exceeds 40 entries.');\n const selectedIndex = index === undefined ? nativeProperty(selection, 'selectedIndex') : index;\n if (typeof selectedIndex !== 'number' || !Number.isInteger(selectedIndex))\n throw new Error('Selected component index unavailable.');\n const selected = entries[selectedIndex] as unknown;\n if (!selected) throw new Error('Selected component unavailable.');\n const details =\n index === undefined ? selection : nativeMethod(selected, 'getInspectorData')(() => undefined);\n // An explicit index asks for that entry itself; the owner chain belongs to the default one.\n const source =\n inspectorSource(details) ?? (index === undefined ? nearestOwnerSource(selection) : undefined);\n const frame = nativeProperty(selection, 'frame');\n const hierarchy = entries.map((entry: unknown) => {\n const information = nativeMethod(entry, 'getInspectorData')(() => undefined);\n const source = inspectorSource(information);\n const name = nativeProperty(entry, 'name');\n return {\n name: typeof name === 'string' ? name.slice(0, 128) : 'Unknown component',\n ...(source ? { source } : {}),\n };\n });\n return {\n hierarchy,\n selectedIndex,\n props: inspectorProps(nativeProperty(details, 'props')),\n ...(source ? { source } : {}),\n frame: {\n left: Number(nativeProperty(frame, 'left')),\n top: Number(nativeProperty(frame, 'top')),\n width: Number(nativeProperty(frame, 'width')),\n height: Number(nativeProperty(frame, 'height')),\n },\n };\n}\n", "import type { InterfaceOrientation } from '../../protocol/src/inspector-provider';\nimport { nativeMethod, nativeProperty } from './inspector-values';\nimport { InspectorUnavailable } from './inspector-error';\n\nexport function readInspectorOrientation(\n native: unknown,\n receive: (orientation?: InterfaceOrientation) => void,\n reject: (error: Error) => void,\n): void {\n try {\n const module = nativeProperty(nativeProperty(native, 'NativeModules'), 'BKBInspector');\n if (nativeProperty(nativeProperty(native, 'Platform'), 'OS') !== 'ios' || !module) {\n receive();\n return;\n }\n nativeMethod(\n module,\n 'getOrientation',\n )((value: unknown) => {\n if (\n value === 'portrait' ||\n value === 'portrait-upside-down' ||\n value === 'landscape-left' ||\n value === 'landscape-right'\n )\n receive(value);\n else\n reject(\n new InspectorUnavailable(\n 'Native interface orientation unavailable. Bring the app to the foreground.',\n ),\n );\n });\n } catch {\n reject(\n new InspectorUnavailable(\n 'Native interface orientation unavailable. Check the optional BKBInspector pod.',\n ),\n );\n }\n}\n", "import { InspectorUnavailable } from './inspector-error';\nimport { nativeProperty, nativeMethod } from './inspector-values';\nexport function inspectNativeView(\n hook: unknown,\n native: unknown,\n root: unknown,\n x: number,\n y: number,\n receive: (selection: unknown) => void,\n failed: (error: Error) => void = () => undefined,\n): void {\n const renderers = nativeProperty(hook, 'renderers');\n if (!(renderers instanceof Map)) throw new Error('React renderer hook unavailable.');\n const modern: unknown[] = [];\n const legacy: unknown[] = [];\n renderers.forEach((renderer: unknown) => {\n const configuration = nativeProperty(renderer, 'rendererConfig');\n if (typeof nativeProperty(configuration, 'getInspectorDataForViewAtPoint') === 'function')\n modern.push(configuration);\n else if (typeof nativeProperty(renderer, 'getInspectorDataForViewTag') === 'function')\n legacy.push(renderer);\n });\n // React Native 0.79+ in bridgeless mode registers its Fabric and its legacy renderer; both\n // carry the same getInspectorDataForViewAtPoint, which handles Fabric and Paper roots itself,\n // so any one of them answers for the root (verified on RN 0.79: identical hierarchies).\n if (modern.length) {\n nativeMethod(modern[0], 'getInspectorDataForViewAtPoint')(root, x, y, receive);\n return;\n }\n if (legacy.length !== 1) throw new Error('Expected one supported inspector renderer.');\n const handle = nativeMethod(native, 'findNodeHandle')(root);\n nativeMethod(nativeProperty(native, 'UIManager'), 'findSubviewIn')(\n handle,\n [x, y],\n (tag: number, left: number, top: number, width: number, height: number) => {\n try {\n const details = nativeMethod(legacy[0], 'getInspectorDataForViewTag')(tag);\n receive({\n hierarchy: nativeProperty(details, 'hierarchy'),\n props: nativeProperty(details, 'props'),\n source: nativeProperty(details, 'source'),\n selectedIndex: nativeProperty(details, 'selection'),\n frame: { left, top, width, height },\n });\n } catch {\n failed(\n new InspectorUnavailable(\n 'The native view changed during legacy inspection. Capture again.',\n ),\n );\n }\n },\n );\n}\n", "declare const __DEV__: boolean | undefined;\nexport function loggingEnabled(enabled: boolean): boolean {\n return enabled === true && (typeof __DEV__ === 'undefined' || __DEV__ === true);\n}\nexport function utf8Bytes(text: string): number {\n let bytes = 0;\n for (let index = 0; index < text.length; index++) {\n const code = text.charCodeAt(index);\n if (code < 128) bytes++;\n else if (code < 2048) bytes += 2;\n else if (\n code >= 0xd800 &&\n code <= 0xdbff &&\n index + 1 < text.length &&\n text.charCodeAt(index + 1) >= 0xdc00 &&\n text.charCodeAt(index + 1) <= 0xdfff\n ) {\n bytes += 4;\n index++;\n } else bytes += 3;\n }\n return bytes;\n}\n", "import type { InspectorProvider } from '../../protocol/src/inspector-provider';\nimport type { RenderProvider } from '../../protocol/src/renders-provider';\nimport type { PluginCapability } from '../../protocol/src/plugin-channels';\nimport type { LogLevel, RuntimeMetadata } from '../../protocol/src/wire';\n\nexport type { JsonValue, LogLevel, RuntimeMetadata } from '../../protocol/src/wire';\nexport type ConnectionState = 'disabled' | 'connecting' | 'connected' | 'disconnected';\n\n// The content of bkb.config.json: what the Babel plugin injects from the project root, and\n// what you pass as `config` only when the plugin cannot find the file.\nexport interface BkbConfig {\n projectId: string;\n token: string;\n app: { id: string; name?: string; version?: string };\n metro?: { port?: number };\n // Only to reach BKB somewhere other than ws://127.0.0.1:8347, for example over the LAN.\n connection?: { endpoint?: string };\n}\n\n// A plugin's source of events. The logger sends every event the provider produces on the\n// plugin's reserved channel and tells BKB, in its hello message, that the plugin is active.\nexport interface PluginProvider {\n capability: PluginCapability;\n instanceId: string;\n subscribe: (listener: (event: unknown) => void) => () => void;\n // Answers a request from BKB with a result that fits one frame; a provider without it takes\n // no requests. Whatever it throws is reported as a refusal.\n handleCommand?: (command: unknown) => unknown;\n // How many events the plugin kept for BKB and then lost before the logger took them.\n droppedCount?: () => number;\n}\n\n// Settings that sit beside the configuration.\nexport interface LoggerExtras {\n pluginProviders?: PluginProvider[];\n inspector?: InspectorProvider;\n renders?: RenderProvider;\n reload?: () => void;\n runtimeMetadata?: RuntimeMetadata;\n // scheme://host:port the app loaded its bundle from; see readBundleOrigin.\n bundleOrigin?: string;\n tags?: Record<string, string>;\n}\n\n// Every SDK entry point that connects takes these: nothing is needed when the project's\n// bkb.config.json is injected by `@bkbdev/core/register`. `enabled` defaults to true.\nexport interface ConnectionOptions {\n config?: BkbConfig;\n enabled?: boolean;\n}\n\nexport type LoggerOptions = ConnectionOptions & LoggerExtras;\n\n// The resolved settings the transports use.\nexport interface LoggerConfig {\n enabled: boolean;\n pluginProviders?: PluginProvider[];\n inspector?: InspectorProvider;\n renders?: RenderProvider;\n reload?: () => void;\n runtimeMetadata?: RuntimeMetadata;\n bundleOrigin?: string;\n projectId: string;\n connection: { endpoint: string; token: string };\n app: { id: string; name?: string; version?: string };\n tags?: Record<string, string>;\n}\n\nexport interface LogOptions {\n level?: LogLevel;\n tags?: Record<string, string>;\n correlationId?: string;\n}\n\nexport interface Span {\n readonly id: string;\n end(data?: unknown): void;\n fail(error: unknown): void;\n}\n\nexport interface LogChannel {\n log(name: string, data?: unknown, options?: LogOptions): void;\n table(name: string, rows: ReadonlyArray<Record<string, unknown>>, options?: LogOptions): void;\n startSpan(name: string, data?: unknown, options?: LogOptions): Span;\n}\n\nexport interface Logger extends LogChannel {\n channel(name: string): LogChannel;\n getConnectionState(): ConnectionState;\n getDroppedEventCount(): number;\n disconnect(): void;\n}\n\nexport function createId(): string {\n return Date.now().toString(36) + '-' + Math.random().toString(36).slice(2, 12);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,uBAAN,cAAmC,MAAM;AAAA,EAAzC;AAAA;AACL,SAAS,gBAAgB;AAAA;AAC3B;;;ACAA,SAAS,MACP,OACA,MACA,OACA,QACW;AACX,MAAI,EAAE,OAAO,QAAQ,EAAG,QAAO;AAC/B,MAAI,UAAU,QAAQ,OAAO,UAAU,UAAW,QAAO;AACzD,MAAI,O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YAAY;AAC5E;;;
|
|
4
|
+
"sourcesContent": ["export type {\n InspectorProvider,\n InspectorGeometry,\n InspectorSelection,\n} from '../../protocol/src/inspector-provider';\nimport { InspectorUnavailable } from './inspector-error';\nimport { readInspectorOrientation } from './inspector-orientation';\nimport { inspectNativeView } from './inspector-renderer';\nimport { loggingEnabled } from './environment';\nimport { createId } from './types';\nimport { summarizeInspectorSelection, nativeMethod, nativeProperty } from './inspector-values';\nimport type {\n InspectorGeometry,\n InspectorProvider,\n InspectorSelection,\n} from '../../protocol/src/inspector-provider';\ndeclare const global: { __REACT_DEVTOOLS_GLOBAL_HOOK__?: unknown };\nexport interface ReactNativeInspectorConfig {\n enabled?: boolean;\n root(): unknown;\n native(): unknown;\n}\nexport function createReactNativeInspector(config: ReactNativeInspectorConfig): InspectorProvider {\n if (!loggingEnabled(config.enabled ?? true))\n return {\n instanceId: 'disabled',\n enabled: false,\n measure: () => Promise.reject(new Error('Inspector disabled.')),\n inspect: () => Promise.reject(new Error('Inspector disabled.')),\n dispose: () => undefined,\n };\n return new ReactNativeInspector(\n () => config.root(),\n () => config.native(),\n );\n}\nclass ReactNativeInspector implements InspectorProvider {\n readonly instanceId = createId();\n readonly enabled = true;\n private stopped = false;\n private readonly rootIds = new WeakMap<object, string>();\n private readonly pending = new Set<(error: Error) => void>();\n constructor(\n private readonly root: () => unknown,\n private readonly native: () => unknown,\n ) {}\n measure(): Promise<InspectorGeometry> {\n return this.callback((resolve, reject) => {\n const native = this.native();\n if (nativeProperty(nativeProperty(native, 'AppState'), 'currentState') !== 'active')\n throw new InspectorUnavailable(\n 'Bring the inspected development application to the foreground.',\n );\n const dimensions = nativeProperty(native, 'Dimensions');\n const screen = nativeMethod(dimensions, 'get')('screen');\n const pixelRatio = Number(nativeMethod(nativeProperty(native, 'PixelRatio'), 'get')());\n const root = this.root();\n const rootId = this.rootIdentity(root);\n nativeMethod(\n root,\n 'measure',\n )((_x: number, _y: number, width: number, height: number, pageX: number, pageY: number) => {\n try {\n if (this.root() !== root) {\n reject(new InspectorUnavailable('Inspection root changed. Capture again.'));\n return;\n }\n readInspectorOrientation(\n native,\n (interfaceOrientation) =>\n resolve({\n rootId,\n root: { width, height, pageX, pageY },\n pixelRatio,\n screen: {\n width: Number(nativeProperty(screen, 'width')),\n height: Number(nativeProperty(screen, 'height')),\n },\n ...(interfaceOrientation ? { interfaceOrientation } : {}),\n }),\n reject,\n );\n } catch {\n reject(new InspectorUnavailable('Inspection root unavailable. Capture again.'));\n }\n });\n });\n }\n inspect(x: number, y: number, index?: number): Promise<InspectorSelection> {\n return this.callback((resolve, reject) => {\n const root = this.root();\n inspectNativeView(\n global.__REACT_DEVTOOLS_GLOBAL_HOOK__,\n this.native(),\n root,\n x,\n y,\n (selection: unknown) => {\n try {\n if (this.root() !== root) throw new Error('Inspection root changed.');\n resolve(summarizeInspectorSelection(selection, index));\n } catch {\n reject(new InspectorUnavailable('Inspector selection unavailable. Capture again.'));\n }\n },\n reject,\n );\n });\n }\n private rootIdentity(root: unknown): string {\n if (!root || (typeof root !== 'object' && typeof root !== 'function'))\n throw new InspectorUnavailable('Mount the active native inspection root before capturing.');\n const existing = this.rootIds.get(root);\n if (existing) return existing;\n const id = createId();\n this.rootIds.set(root, id);\n return id;\n }\n private callback<T>(\n operation: (resolve: (value: T) => void, reject: (error: Error) => void) => void,\n ): Promise<T> {\n if (this.stopped) return Promise.reject(new Error('Inspector disposed.'));\n return new Promise<T>((resolve, reject) => {\n let settled = false;\n const finish = (error?: Error, value?: T): void => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n clearTimeout(dispatch);\n this.pending.delete(cancel);\n if (error) reject(error);\n else if (value !== undefined) resolve(value);\n };\n const cancel = (error: Error): void => finish(error);\n const timer = setTimeout(\n () =>\n cancel(\n new InspectorUnavailable(\n 'Native inspector callback timed out. Check that the root is mounted.',\n ),\n ),\n 3000,\n );\n this.pending.add(cancel);\n const dispatch = setTimeout(() => {\n try {\n operation((value) => finish(undefined, value), cancel);\n } catch (error) {\n cancel(\n error instanceof InspectorUnavailable\n ? error\n : new InspectorUnavailable('Native inspector operation unavailable.'),\n );\n }\n }, 0);\n });\n }\n dispose(): void {\n this.stopped = true;\n for (const cancel of this.pending) cancel(new Error('Inspector disposed.'));\n this.pending.clear();\n }\n}\n", "export class InspectorUnavailable extends Error {\n readonly inspectorCode = 'bkb-inspector-unavailable-v1';\n}\nexport function inspectorFailureReason(error: unknown): string {\n if (error && typeof error === 'object') {\n const code = Object.getOwnPropertyDescriptor(error, 'inspectorCode');\n const message = Object.getOwnPropertyDescriptor(error, 'message');\n if (code?.value === 'bkb-inspector-unavailable-v1' && typeof message?.value === 'string')\n return message.value.slice(0, 512);\n }\n return 'Inspector unavailable. Check the mounted root and supported development renderer.';\n}\n", "import type { JsonValue } from './types';\n\nfunction visit(\n value: unknown,\n seen: Set<object>,\n depth: number,\n budget: { nodes: number; characters: number },\n): JsonValue {\n if (--budget.nodes < 0) return '[size limit]';\n if (value === null || typeof value === 'boolean') return value;\n if (typeof value === 'string') {\n const length = Math.max(0, Math.min(4000, budget.characters));\n budget.characters -= Math.min(value.length, length);\n return value.length > length ? value.slice(0, length) + '[truncated]' : value;\n }\n if (typeof value === 'number') return Number.isFinite(value) ? value : String(value);\n if (typeof value === 'bigint' || typeof value === 'symbol') return String(value);\n if (typeof value !== 'object') return `[${typeof value}]`;\n if (depth >= 5) return '[depth limit]';\n if (seen.has(value)) return '[circular]';\n seen.add(value);\n try {\n if (value instanceof Error)\n return visit(\n {\n name: errorField(value, 'name') || 'Error',\n message: errorField(value, 'message'),\n stack: errorField(value, 'stack'),\n },\n seen,\n depth + 1,\n budget,\n );\n if (Array.isArray(value)) return visitArray(value, seen, depth, budget);\n const result: { [key: string]: JsonValue } = {};\n const keys = Object.keys(value);\n for (const key of keys.slice(0, 50)) {\n if (budget.nodes <= 0) {\n result['[truncated]'] = '[size limit]';\n break;\n }\n if (key === '__proto__' || key === 'constructor' || key === 'prototype') continue;\n try {\n const descriptor = Object.getOwnPropertyDescriptor(value, key);\n result[key.slice(0, 128)] =\n descriptor && 'value' in descriptor\n ? visit(descriptor.value, seen, depth + 1, budget)\n : '[unavailable]';\n } catch {\n result[key.slice(0, 128)] = '[unavailable]';\n }\n }\n if (keys.length > 50) result['[truncated]'] = '[property limit]';\n return result;\n } finally {\n seen.delete(value);\n }\n}\n\nexport function serialize(value: unknown): JsonValue {\n try {\n const result = visit(value, new Set(), 0, { nodes: 200, characters: 12000 });\n const encoded = JSON.stringify(result);\n return encoded.length <= 16000 ? result : { truncated: true, preview: encoded.slice(0, 4000) };\n } catch {\n return '[unserializable]';\n }\n}\n\nfunction errorField(value: Error, key: string): string {\n const descriptor =\n Object.getOwnPropertyDescriptor(value, key) ??\n Object.getOwnPropertyDescriptor(Object.getPrototypeOf(value), key);\n const field: unknown = descriptor && 'value' in descriptor ? descriptor.value : '';\n return typeof field === 'string' ? field.slice(0, 4000) : '';\n}\n\nfunction visitArray(\n value: unknown[],\n seen: Set<object>,\n depth: number,\n budget: { nodes: number; characters: number },\n): JsonValue[] {\n const result: JsonValue[] = [];\n for (let index = 0; index < Math.min(value.length, 100); index++) {\n if (budget.nodes <= 0) {\n result.push('[size limit]');\n break;\n }\n const descriptor = Object.getOwnPropertyDescriptor(value, String(index));\n result.push(\n descriptor && 'value' in descriptor\n ? visit(descriptor.value, seen, depth + 1, budget)\n : '[unavailable]',\n );\n }\n if (value.length > 100) result.push('[array limit]');\n return result;\n}\n", "import { InspectorUnavailable } from './inspector-error';\nimport { serialize } from './serialize';\nimport type { InspectorSelection, InspectorSource } from '../../protocol/src/inspector-provider';\nexport function nativeProperty(value: unknown, key: string): unknown {\n return value && (typeof value === 'object' || typeof value === 'function')\n ? (Reflect.get(value, key) as unknown)\n : undefined;\n}\nexport function nativeMethod(value: unknown, name: string): (...args: unknown[]) => unknown {\n const method = nativeProperty(value, name);\n if (typeof method !== 'function')\n throw new InspectorUnavailable('Native inspector method unavailable: ' + name + '.');\n return (...args) => Reflect.apply(method, value, args) as unknown;\n}\nfunction sourceLocation(value: unknown): InspectorSource | undefined {\n if (!value || typeof value !== 'object') return;\n const file = nativeProperty(value, 'file') ?? nativeProperty(value, 'fileName');\n const line = nativeProperty(value, 'line') ?? nativeProperty(value, 'lineNumber');\n const column = nativeProperty(value, 'column') ?? nativeProperty(value, 'columnNumber');\n if (\n typeof file !== 'string' ||\n file.length > 4096 ||\n typeof line !== 'number' ||\n !Number.isInteger(line) ||\n line < 1 ||\n typeof column !== 'number' ||\n !Number.isInteger(column) ||\n column < 1\n )\n return;\n return { file, line, column };\n}\n// A plain data property, never an accessor, so reading metadata cannot run app code.\nfunction ownValue(object: unknown, key: string): unknown {\n const descriptor =\n object && typeof object === 'object' ? Object.getOwnPropertyDescriptor(object, key) : undefined;\n return descriptor && 'value' in descriptor ? (descriptor.value as unknown) : undefined;\n}\nfunction inspectorSource(details: unknown): InspectorSource | undefined {\n return (\n sourceLocation(ownValue(nativeProperty(details, 'props'), '__bkbSource')) ??\n sourceLocation(nativeProperty(details, 'source'))\n );\n}\nconst MAX_OWNER_STEPS = 64;\n// Library UI (a modal, a sheet) has no source metadata of its own, because the Babel plugin\n// skips dependencies. React Native's React 19 builds return the fiber of the nearest component\n// as `closestInstance`; walking its owners reaches the nearest element written in the project,\n// which is where the library component is used.\nfunction nearestOwnerSource(selection: unknown): InspectorSource | undefined {\n let fiber = nativeProperty(selection, 'closestInstance');\n for (let step = 0; fiber && step < MAX_OWNER_STEPS; step++) {\n const source = sourceLocation(ownValue(nativeProperty(fiber, 'memoizedProps'), '__bkbSource'));\n if (source) return source;\n fiber = nativeProperty(fiber, '_debugOwner');\n }\n return undefined;\n}\nfunction inspectorProps(props: unknown) {\n const retained: Record<string, unknown> = {};\n if (props && typeof props === 'object') {\n for (const key of Object.keys(props).slice(0, 30)) {\n if (['children', '__bkbSource', '__proto__', 'constructor', 'prototype'].indexOf(key) !== -1)\n continue;\n const descriptor = Object.getOwnPropertyDescriptor(props, key);\n retained[key] =\n descriptor && 'value' in descriptor ? (descriptor.value as unknown) : '[accessor omitted]';\n }\n }\n const safe = serialize(retained);\n return JSON.stringify(safe).length > 8000 ? '[props exceed preview budget]' : safe;\n}\nexport function summarizeInspectorSelection(\n selection: unknown,\n index?: number,\n): InspectorSelection {\n const entries = nativeProperty(selection, 'hierarchy');\n if (!Array.isArray(entries) || !entries.length || entries.length > 40)\n throw new Error('Inspector hierarchy unavailable or exceeds 40 entries.');\n const selectedIndex = index === undefined ? nativeProperty(selection, 'selectedIndex') : index;\n if (typeof selectedIndex !== 'number' || !Number.isInteger(selectedIndex))\n throw new Error('Selected component index unavailable.');\n const selected = entries[selectedIndex] as unknown;\n if (!selected) throw new Error('Selected component unavailable.');\n const details =\n index === undefined ? selection : nativeMethod(selected, 'getInspectorData')(() => undefined);\n // An explicit index asks for that entry itself; the owner chain belongs to the default one.\n const source =\n inspectorSource(details) ?? (index === undefined ? nearestOwnerSource(selection) : undefined);\n const frame = nativeProperty(selection, 'frame');\n const hierarchy = entries.map((entry: unknown) => {\n const information = nativeMethod(entry, 'getInspectorData')(() => undefined);\n const source = inspectorSource(information);\n const name = nativeProperty(entry, 'name');\n return {\n name: typeof name === 'string' ? name.slice(0, 128) : 'Unknown component',\n ...(source ? { source } : {}),\n };\n });\n return {\n hierarchy,\n selectedIndex,\n props: inspectorProps(nativeProperty(details, 'props')),\n ...(source ? { source } : {}),\n frame: {\n left: Number(nativeProperty(frame, 'left')),\n top: Number(nativeProperty(frame, 'top')),\n width: Number(nativeProperty(frame, 'width')),\n height: Number(nativeProperty(frame, 'height')),\n },\n };\n}\n", "import type { InterfaceOrientation } from '../../protocol/src/inspector-provider';\nimport { nativeMethod, nativeProperty } from './inspector-values';\nimport { InspectorUnavailable } from './inspector-error';\n\nexport function readInspectorOrientation(\n native: unknown,\n receive: (orientation?: InterfaceOrientation) => void,\n reject: (error: Error) => void,\n): void {\n try {\n const module = nativeProperty(nativeProperty(native, 'NativeModules'), 'BKBInspector');\n if (nativeProperty(nativeProperty(native, 'Platform'), 'OS') !== 'ios' || !module) {\n receive();\n return;\n }\n nativeMethod(\n module,\n 'getOrientation',\n )((value: unknown) => {\n if (\n value === 'portrait' ||\n value === 'portrait-upside-down' ||\n value === 'landscape-left' ||\n value === 'landscape-right'\n )\n receive(value);\n else\n reject(\n new InspectorUnavailable(\n 'Native interface orientation unavailable. Bring the app to the foreground.',\n ),\n );\n });\n } catch {\n reject(\n new InspectorUnavailable(\n 'Native interface orientation unavailable. Check the optional BKBInspector pod.',\n ),\n );\n }\n}\n", "import { InspectorUnavailable } from './inspector-error';\nimport { nativeProperty, nativeMethod } from './inspector-values';\nexport function inspectNativeView(\n hook: unknown,\n native: unknown,\n root: unknown,\n x: number,\n y: number,\n receive: (selection: unknown) => void,\n failed: (error: Error) => void = () => undefined,\n): void {\n const renderers = nativeProperty(hook, 'renderers');\n if (!(renderers instanceof Map)) throw new Error('React renderer hook unavailable.');\n const modern: unknown[] = [];\n const legacy: unknown[] = [];\n renderers.forEach((renderer: unknown) => {\n const configuration = nativeProperty(renderer, 'rendererConfig');\n if (typeof nativeProperty(configuration, 'getInspectorDataForViewAtPoint') === 'function')\n modern.push(configuration);\n else if (typeof nativeProperty(renderer, 'getInspectorDataForViewTag') === 'function')\n legacy.push(renderer);\n });\n // React Native 0.79+ in bridgeless mode registers its Fabric and its legacy renderer; both\n // carry the same getInspectorDataForViewAtPoint, which handles Fabric and Paper roots itself,\n // so any one of them answers for the root (verified on RN 0.79: identical hierarchies).\n if (modern.length) {\n nativeMethod(modern[0], 'getInspectorDataForViewAtPoint')(root, x, y, receive);\n return;\n }\n if (legacy.length !== 1) throw new Error('Expected one supported inspector renderer.');\n const handle = nativeMethod(native, 'findNodeHandle')(root);\n nativeMethod(nativeProperty(native, 'UIManager'), 'findSubviewIn')(\n handle,\n [x, y],\n (tag: number, left: number, top: number, width: number, height: number) => {\n try {\n const details = nativeMethod(legacy[0], 'getInspectorDataForViewTag')(tag);\n receive({\n hierarchy: nativeProperty(details, 'hierarchy'),\n props: nativeProperty(details, 'props'),\n source: nativeProperty(details, 'source'),\n selectedIndex: nativeProperty(details, 'selection'),\n frame: { left, top, width, height },\n });\n } catch {\n failed(\n new InspectorUnavailable(\n 'The native view changed during legacy inspection. Capture again.',\n ),\n );\n }\n },\n );\n}\n", "declare const __DEV__: boolean | undefined;\nexport function loggingEnabled(enabled: boolean): boolean {\n return enabled === true && (typeof __DEV__ === 'undefined' || __DEV__ === true);\n}\nexport function utf8Bytes(text: string): number {\n let bytes = 0;\n for (let index = 0; index < text.length; index++) {\n const code = text.charCodeAt(index);\n if (code < 128) bytes++;\n else if (code < 2048) bytes += 2;\n else if (\n code >= 0xd800 &&\n code <= 0xdbff &&\n index + 1 < text.length &&\n text.charCodeAt(index + 1) >= 0xdc00 &&\n text.charCodeAt(index + 1) <= 0xdfff\n ) {\n bytes += 4;\n index++;\n } else bytes += 3;\n }\n return bytes;\n}\n", "import type { InspectorProvider } from '../../protocol/src/inspector-provider';\nimport type { RenderProvider } from '../../protocol/src/renders-provider';\nimport type { PluginCapability } from '../../protocol/src/plugin-channels';\nimport type { LogLevel, RuntimeMetadata } from '../../protocol/src/wire';\n\nexport type { JsonValue, LogLevel, RuntimeMetadata } from '../../protocol/src/wire';\nexport type ConnectionState = 'disabled' | 'connecting' | 'connected' | 'disconnected';\n\n// What an SDK entry point connects with: `@bkbdev/core/register` builds it from the project's\n// bkb.config.json (the block of the platform the app runs on). Pass it as `config` only when\n// the plugin cannot find the file.\nexport interface BkbConfig {\n projectId: string;\n token: string;\n app: { id: string; name?: string; version?: string };\n metro?: { port?: number };\n // Only to reach BKB somewhere other than ws://127.0.0.1:8347, for example over the LAN.\n connection?: { endpoint?: string };\n}\n\n// A plugin's source of events. The logger sends every event the provider produces on the\n// plugin's reserved channel and tells BKB, in its hello message, that the plugin is active.\nexport interface PluginProvider {\n capability: PluginCapability;\n instanceId: string;\n subscribe: (listener: (event: unknown) => void) => () => void;\n // Answers a request from BKB with a result that fits one frame; a provider without it takes\n // no requests. Whatever it throws is reported as a refusal.\n handleCommand?: (command: unknown) => unknown;\n // How many events the plugin kept for BKB and then lost before the logger took them.\n droppedCount?: () => number;\n}\n\n// Settings that sit beside the configuration.\nexport interface LoggerExtras {\n pluginProviders?: PluginProvider[];\n inspector?: InspectorProvider;\n renders?: RenderProvider;\n reload?: () => void;\n runtimeMetadata?: RuntimeMetadata;\n // scheme://host:port the app loaded its bundle from; see readBundleOrigin.\n bundleOrigin?: string;\n tags?: Record<string, string>;\n}\n\n// Every SDK entry point that connects takes these: nothing is needed when the project's\n// bkb.config.json is injected by `@bkbdev/core/register`. `enabled` defaults to true.\nexport interface ConnectionOptions {\n config?: BkbConfig;\n enabled?: boolean;\n}\n\nexport type LoggerOptions = ConnectionOptions & LoggerExtras;\n\n// The resolved settings the transports use.\nexport interface LoggerConfig {\n enabled: boolean;\n pluginProviders?: PluginProvider[];\n inspector?: InspectorProvider;\n renders?: RenderProvider;\n reload?: () => void;\n runtimeMetadata?: RuntimeMetadata;\n bundleOrigin?: string;\n projectId: string;\n connection: { endpoint: string; token: string };\n app: { id: string; name?: string; version?: string };\n tags?: Record<string, string>;\n}\n\nexport interface LogOptions {\n level?: LogLevel;\n tags?: Record<string, string>;\n correlationId?: string;\n}\n\nexport interface Span {\n readonly id: string;\n end(data?: unknown): void;\n fail(error: unknown): void;\n}\n\nexport interface LogChannel {\n log(name: string, data?: unknown, options?: LogOptions): void;\n table(name: string, rows: ReadonlyArray<Record<string, unknown>>, options?: LogOptions): void;\n startSpan(name: string, data?: unknown, options?: LogOptions): Span;\n}\n\nexport interface Logger extends LogChannel {\n channel(name: string): LogChannel;\n getConnectionState(): ConnectionState;\n getDroppedEventCount(): number;\n disconnect(): void;\n}\n\nexport function createId(): string {\n return Date.now().toString(36) + '-' + Math.random().toString(36).slice(2, 12);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;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;AACF;",
|
|
6
6
|
"names": ["source", "module"]
|
|
7
7
|
}
|
package/dist/inspector.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/inspector-error.ts", "../src/serialize.ts", "../src/inspector-values.ts", "../src/inspector-orientation.ts", "../src/inspector-renderer.ts", "../src/environment.ts", "../src/types.ts", "../src/inspector-native.ts"],
|
|
4
|
-
"sourcesContent": ["export class InspectorUnavailable extends Error {\n readonly inspectorCode = 'bkb-inspector-unavailable-v1';\n}\nexport function inspectorFailureReason(error: unknown): string {\n if (error && typeof error === 'object') {\n const code = Object.getOwnPropertyDescriptor(error, 'inspectorCode');\n const message = Object.getOwnPropertyDescriptor(error, 'message');\n if (code?.value === 'bkb-inspector-unavailable-v1' && typeof message?.value === 'string')\n return message.value.slice(0, 512);\n }\n return 'Inspector unavailable. Check the mounted root and supported development renderer.';\n}\n", "import type { JsonValue } from './types';\n\nfunction visit(\n value: unknown,\n seen: Set<object>,\n depth: number,\n budget: { nodes: number; characters: number },\n): JsonValue {\n if (--budget.nodes < 0) return '[size limit]';\n if (value === null || typeof value === 'boolean') return value;\n if (typeof value === 'string') {\n const length = Math.max(0, Math.min(4000, budget.characters));\n budget.characters -= Math.min(value.length, length);\n return value.length > length ? value.slice(0, length) + '[truncated]' : value;\n }\n if (typeof value === 'number') return Number.isFinite(value) ? value : String(value);\n if (typeof value === 'bigint' || typeof value === 'symbol') return String(value);\n if (typeof value !== 'object') return `[${typeof value}]`;\n if (depth >= 5) return '[depth limit]';\n if (seen.has(value)) return '[circular]';\n seen.add(value);\n try {\n if (value instanceof Error)\n return visit(\n {\n name: errorField(value, 'name') || 'Error',\n message: errorField(value, 'message'),\n stack: errorField(value, 'stack'),\n },\n seen,\n depth + 1,\n budget,\n );\n if (Array.isArray(value)) return visitArray(value, seen, depth, budget);\n const result: { [key: string]: JsonValue } = {};\n const keys = Object.keys(value);\n for (const key of keys.slice(0, 50)) {\n if (budget.nodes <= 0) {\n result['[truncated]'] = '[size limit]';\n break;\n }\n if (key === '__proto__' || key === 'constructor' || key === 'prototype') continue;\n try {\n const descriptor = Object.getOwnPropertyDescriptor(value, key);\n result[key.slice(0, 128)] =\n descriptor && 'value' in descriptor\n ? visit(descriptor.value, seen, depth + 1, budget)\n : '[unavailable]';\n } catch {\n result[key.slice(0, 128)] = '[unavailable]';\n }\n }\n if (keys.length > 50) result['[truncated]'] = '[property limit]';\n return result;\n } finally {\n seen.delete(value);\n }\n}\n\nexport function serialize(value: unknown): JsonValue {\n try {\n const result = visit(value, new Set(), 0, { nodes: 200, characters: 12000 });\n const encoded = JSON.stringify(result);\n return encoded.length <= 16000 ? result : { truncated: true, preview: encoded.slice(0, 4000) };\n } catch {\n return '[unserializable]';\n }\n}\n\nfunction errorField(value: Error, key: string): string {\n const descriptor =\n Object.getOwnPropertyDescriptor(value, key) ??\n Object.getOwnPropertyDescriptor(Object.getPrototypeOf(value), key);\n const field: unknown = descriptor && 'value' in descriptor ? descriptor.value : '';\n return typeof field === 'string' ? field.slice(0, 4000) : '';\n}\n\nfunction visitArray(\n value: unknown[],\n seen: Set<object>,\n depth: number,\n budget: { nodes: number; characters: number },\n): JsonValue[] {\n const result: JsonValue[] = [];\n for (let index = 0; index < Math.min(value.length, 100); index++) {\n if (budget.nodes <= 0) {\n result.push('[size limit]');\n break;\n }\n const descriptor = Object.getOwnPropertyDescriptor(value, String(index));\n result.push(\n descriptor && 'value' in descriptor\n ? visit(descriptor.value, seen, depth + 1, budget)\n : '[unavailable]',\n );\n }\n if (value.length > 100) result.push('[array limit]');\n return result;\n}\n", "import { InspectorUnavailable } from './inspector-error';\nimport { serialize } from './serialize';\nimport type { InspectorSelection, InspectorSource } from '../../protocol/src/inspector-provider';\nexport function nativeProperty(value: unknown, key: string): unknown {\n return value && (typeof value === 'object' || typeof value === 'function')\n ? (Reflect.get(value, key) as unknown)\n : undefined;\n}\nexport function nativeMethod(value: unknown, name: string): (...args: unknown[]) => unknown {\n const method = nativeProperty(value, name);\n if (typeof method !== 'function')\n throw new InspectorUnavailable('Native inspector method unavailable: ' + name + '.');\n return (...args) => Reflect.apply(method, value, args) as unknown;\n}\nfunction sourceLocation(value: unknown): InspectorSource | undefined {\n if (!value || typeof value !== 'object') return;\n const file = nativeProperty(value, 'file') ?? nativeProperty(value, 'fileName');\n const line = nativeProperty(value, 'line') ?? nativeProperty(value, 'lineNumber');\n const column = nativeProperty(value, 'column') ?? nativeProperty(value, 'columnNumber');\n if (\n typeof file !== 'string' ||\n file.length > 4096 ||\n typeof line !== 'number' ||\n !Number.isInteger(line) ||\n line < 1 ||\n typeof column !== 'number' ||\n !Number.isInteger(column) ||\n column < 1\n )\n return;\n return { file, line, column };\n}\n// A plain data property, never an accessor, so reading metadata cannot run app code.\nfunction ownValue(object: unknown, key: string): unknown {\n const descriptor =\n object && typeof object === 'object' ? Object.getOwnPropertyDescriptor(object, key) : undefined;\n return descriptor && 'value' in descriptor ? (descriptor.value as unknown) : undefined;\n}\nfunction inspectorSource(details: unknown): InspectorSource | undefined {\n return (\n sourceLocation(ownValue(nativeProperty(details, 'props'), '__bkbSource')) ??\n sourceLocation(nativeProperty(details, 'source'))\n );\n}\nconst MAX_OWNER_STEPS = 64;\n// Library UI (a modal, a sheet) has no source metadata of its own, because the Babel plugin\n// skips dependencies. React Native's React 19 builds return the fiber of the nearest component\n// as `closestInstance`; walking its owners reaches the nearest element written in the project,\n// which is where the library component is used.\nfunction nearestOwnerSource(selection: unknown): InspectorSource | undefined {\n let fiber = nativeProperty(selection, 'closestInstance');\n for (let step = 0; fiber && step < MAX_OWNER_STEPS; step++) {\n const source = sourceLocation(ownValue(nativeProperty(fiber, 'memoizedProps'), '__bkbSource'));\n if (source) return source;\n fiber = nativeProperty(fiber, '_debugOwner');\n }\n return undefined;\n}\nfunction inspectorProps(props: unknown) {\n const retained: Record<string, unknown> = {};\n if (props && typeof props === 'object') {\n for (const key of Object.keys(props).slice(0, 30)) {\n if (['children', '__bkbSource', '__proto__', 'constructor', 'prototype'].indexOf(key) !== -1)\n continue;\n const descriptor = Object.getOwnPropertyDescriptor(props, key);\n retained[key] =\n descriptor && 'value' in descriptor ? (descriptor.value as unknown) : '[accessor omitted]';\n }\n }\n const safe = serialize(retained);\n return JSON.stringify(safe).length > 8000 ? '[props exceed preview budget]' : safe;\n}\nexport function summarizeInspectorSelection(\n selection: unknown,\n index?: number,\n): InspectorSelection {\n const entries = nativeProperty(selection, 'hierarchy');\n if (!Array.isArray(entries) || !entries.length || entries.length > 40)\n throw new Error('Inspector hierarchy unavailable or exceeds 40 entries.');\n const selectedIndex = index === undefined ? nativeProperty(selection, 'selectedIndex') : index;\n if (typeof selectedIndex !== 'number' || !Number.isInteger(selectedIndex))\n throw new Error('Selected component index unavailable.');\n const selected = entries[selectedIndex] as unknown;\n if (!selected) throw new Error('Selected component unavailable.');\n const details =\n index === undefined ? selection : nativeMethod(selected, 'getInspectorData')(() => undefined);\n // An explicit index asks for that entry itself; the owner chain belongs to the default one.\n const source =\n inspectorSource(details) ?? (index === undefined ? nearestOwnerSource(selection) : undefined);\n const frame = nativeProperty(selection, 'frame');\n const hierarchy = entries.map((entry: unknown) => {\n const information = nativeMethod(entry, 'getInspectorData')(() => undefined);\n const source = inspectorSource(information);\n const name = nativeProperty(entry, 'name');\n return {\n name: typeof name === 'string' ? name.slice(0, 128) : 'Unknown component',\n ...(source ? { source } : {}),\n };\n });\n return {\n hierarchy,\n selectedIndex,\n props: inspectorProps(nativeProperty(details, 'props')),\n ...(source ? { source } : {}),\n frame: {\n left: Number(nativeProperty(frame, 'left')),\n top: Number(nativeProperty(frame, 'top')),\n width: Number(nativeProperty(frame, 'width')),\n height: Number(nativeProperty(frame, 'height')),\n },\n };\n}\n", "import type { InterfaceOrientation } from '../../protocol/src/inspector-provider';\nimport { nativeMethod, nativeProperty } from './inspector-values';\nimport { InspectorUnavailable } from './inspector-error';\n\nexport function readInspectorOrientation(\n native: unknown,\n receive: (orientation?: InterfaceOrientation) => void,\n reject: (error: Error) => void,\n): void {\n try {\n const module = nativeProperty(nativeProperty(native, 'NativeModules'), 'BKBInspector');\n if (nativeProperty(nativeProperty(native, 'Platform'), 'OS') !== 'ios' || !module) {\n receive();\n return;\n }\n nativeMethod(\n module,\n 'getOrientation',\n )((value: unknown) => {\n if (\n value === 'portrait' ||\n value === 'portrait-upside-down' ||\n value === 'landscape-left' ||\n value === 'landscape-right'\n )\n receive(value);\n else\n reject(\n new InspectorUnavailable(\n 'Native interface orientation unavailable. Bring the app to the foreground.',\n ),\n );\n });\n } catch {\n reject(\n new InspectorUnavailable(\n 'Native interface orientation unavailable. Check the optional BKBInspector pod.',\n ),\n );\n }\n}\n", "import { InspectorUnavailable } from './inspector-error';\nimport { nativeProperty, nativeMethod } from './inspector-values';\nexport function inspectNativeView(\n hook: unknown,\n native: unknown,\n root: unknown,\n x: number,\n y: number,\n receive: (selection: unknown) => void,\n failed: (error: Error) => void = () => undefined,\n): void {\n const renderers = nativeProperty(hook, 'renderers');\n if (!(renderers instanceof Map)) throw new Error('React renderer hook unavailable.');\n const modern: unknown[] = [];\n const legacy: unknown[] = [];\n renderers.forEach((renderer: unknown) => {\n const configuration = nativeProperty(renderer, 'rendererConfig');\n if (typeof nativeProperty(configuration, 'getInspectorDataForViewAtPoint') === 'function')\n modern.push(configuration);\n else if (typeof nativeProperty(renderer, 'getInspectorDataForViewTag') === 'function')\n legacy.push(renderer);\n });\n // React Native 0.79+ in bridgeless mode registers its Fabric and its legacy renderer; both\n // carry the same getInspectorDataForViewAtPoint, which handles Fabric and Paper roots itself,\n // so any one of them answers for the root (verified on RN 0.79: identical hierarchies).\n if (modern.length) {\n nativeMethod(modern[0], 'getInspectorDataForViewAtPoint')(root, x, y, receive);\n return;\n }\n if (legacy.length !== 1) throw new Error('Expected one supported inspector renderer.');\n const handle = nativeMethod(native, 'findNodeHandle')(root);\n nativeMethod(nativeProperty(native, 'UIManager'), 'findSubviewIn')(\n handle,\n [x, y],\n (tag: number, left: number, top: number, width: number, height: number) => {\n try {\n const details = nativeMethod(legacy[0], 'getInspectorDataForViewTag')(tag);\n receive({\n hierarchy: nativeProperty(details, 'hierarchy'),\n props: nativeProperty(details, 'props'),\n source: nativeProperty(details, 'source'),\n selectedIndex: nativeProperty(details, 'selection'),\n frame: { left, top, width, height },\n });\n } catch {\n failed(\n new InspectorUnavailable(\n 'The native view changed during legacy inspection. Capture again.',\n ),\n );\n }\n },\n );\n}\n", "declare const __DEV__: boolean | undefined;\nexport function loggingEnabled(enabled: boolean): boolean {\n return enabled === true && (typeof __DEV__ === 'undefined' || __DEV__ === true);\n}\nexport function utf8Bytes(text: string): number {\n let bytes = 0;\n for (let index = 0; index < text.length; index++) {\n const code = text.charCodeAt(index);\n if (code < 128) bytes++;\n else if (code < 2048) bytes += 2;\n else if (\n code >= 0xd800 &&\n code <= 0xdbff &&\n index + 1 < text.length &&\n text.charCodeAt(index + 1) >= 0xdc00 &&\n text.charCodeAt(index + 1) <= 0xdfff\n ) {\n bytes += 4;\n index++;\n } else bytes += 3;\n }\n return bytes;\n}\n", "import type { InspectorProvider } from '../../protocol/src/inspector-provider';\nimport type { RenderProvider } from '../../protocol/src/renders-provider';\nimport type { PluginCapability } from '../../protocol/src/plugin-channels';\nimport type { LogLevel, RuntimeMetadata } from '../../protocol/src/wire';\n\nexport type { JsonValue, LogLevel, RuntimeMetadata } from '../../protocol/src/wire';\nexport type ConnectionState = 'disabled' | 'connecting' | 'connected' | 'disconnected';\n\n// The content of bkb.config.json: what the Babel plugin injects from the project root, and\n// what you pass as `config` only when the plugin cannot find the file.\nexport interface BkbConfig {\n projectId: string;\n token: string;\n app: { id: string; name?: string; version?: string };\n metro?: { port?: number };\n // Only to reach BKB somewhere other than ws://127.0.0.1:8347, for example over the LAN.\n connection?: { endpoint?: string };\n}\n\n// A plugin's source of events. The logger sends every event the provider produces on the\n// plugin's reserved channel and tells BKB, in its hello message, that the plugin is active.\nexport interface PluginProvider {\n capability: PluginCapability;\n instanceId: string;\n subscribe: (listener: (event: unknown) => void) => () => void;\n // Answers a request from BKB with a result that fits one frame; a provider without it takes\n // no requests. Whatever it throws is reported as a refusal.\n handleCommand?: (command: unknown) => unknown;\n // How many events the plugin kept for BKB and then lost before the logger took them.\n droppedCount?: () => number;\n}\n\n// Settings that sit beside the configuration.\nexport interface LoggerExtras {\n pluginProviders?: PluginProvider[];\n inspector?: InspectorProvider;\n renders?: RenderProvider;\n reload?: () => void;\n runtimeMetadata?: RuntimeMetadata;\n // scheme://host:port the app loaded its bundle from; see readBundleOrigin.\n bundleOrigin?: string;\n tags?: Record<string, string>;\n}\n\n// Every SDK entry point that connects takes these: nothing is needed when the project's\n// bkb.config.json is injected by `@bkbdev/core/register`. `enabled` defaults to true.\nexport interface ConnectionOptions {\n config?: BkbConfig;\n enabled?: boolean;\n}\n\nexport type LoggerOptions = ConnectionOptions & LoggerExtras;\n\n// The resolved settings the transports use.\nexport interface LoggerConfig {\n enabled: boolean;\n pluginProviders?: PluginProvider[];\n inspector?: InspectorProvider;\n renders?: RenderProvider;\n reload?: () => void;\n runtimeMetadata?: RuntimeMetadata;\n bundleOrigin?: string;\n projectId: string;\n connection: { endpoint: string; token: string };\n app: { id: string; name?: string; version?: string };\n tags?: Record<string, string>;\n}\n\nexport interface LogOptions {\n level?: LogLevel;\n tags?: Record<string, string>;\n correlationId?: string;\n}\n\nexport interface Span {\n readonly id: string;\n end(data?: unknown): void;\n fail(error: unknown): void;\n}\n\nexport interface LogChannel {\n log(name: string, data?: unknown, options?: LogOptions): void;\n table(name: string, rows: ReadonlyArray<Record<string, unknown>>, options?: LogOptions): void;\n startSpan(name: string, data?: unknown, options?: LogOptions): Span;\n}\n\nexport interface Logger extends LogChannel {\n channel(name: string): LogChannel;\n getConnectionState(): ConnectionState;\n getDroppedEventCount(): number;\n disconnect(): void;\n}\n\nexport function createId(): string {\n return Date.now().toString(36) + '-' + Math.random().toString(36).slice(2, 12);\n}\n", "export type {\n InspectorProvider,\n InspectorGeometry,\n InspectorSelection,\n} from '../../protocol/src/inspector-provider';\nimport { InspectorUnavailable } from './inspector-error';\nimport { readInspectorOrientation } from './inspector-orientation';\nimport { inspectNativeView } from './inspector-renderer';\nimport { loggingEnabled } from './environment';\nimport { createId } from './types';\nimport { summarizeInspectorSelection, nativeMethod, nativeProperty } from './inspector-values';\nimport type {\n InspectorGeometry,\n InspectorProvider,\n InspectorSelection,\n} from '../../protocol/src/inspector-provider';\ndeclare const global: { __REACT_DEVTOOLS_GLOBAL_HOOK__?: unknown };\nexport interface ReactNativeInspectorConfig {\n enabled?: boolean;\n root(): unknown;\n native(): unknown;\n}\nexport function createReactNativeInspector(config: ReactNativeInspectorConfig): InspectorProvider {\n if (!loggingEnabled(config.enabled ?? true))\n return {\n instanceId: 'disabled',\n enabled: false,\n measure: () => Promise.reject(new Error('Inspector disabled.')),\n inspect: () => Promise.reject(new Error('Inspector disabled.')),\n dispose: () => undefined,\n };\n return new ReactNativeInspector(\n () => config.root(),\n () => config.native(),\n );\n}\nclass ReactNativeInspector implements InspectorProvider {\n readonly instanceId = createId();\n readonly enabled = true;\n private stopped = false;\n private readonly rootIds = new WeakMap<object, string>();\n private readonly pending = new Set<(error: Error) => void>();\n constructor(\n private readonly root: () => unknown,\n private readonly native: () => unknown,\n ) {}\n measure(): Promise<InspectorGeometry> {\n return this.callback((resolve, reject) => {\n const native = this.native();\n if (nativeProperty(nativeProperty(native, 'AppState'), 'currentState') !== 'active')\n throw new InspectorUnavailable(\n 'Bring the inspected development application to the foreground.',\n );\n const dimensions = nativeProperty(native, 'Dimensions');\n const screen = nativeMethod(dimensions, 'get')('screen');\n const pixelRatio = Number(nativeMethod(nativeProperty(native, 'PixelRatio'), 'get')());\n const root = this.root();\n const rootId = this.rootIdentity(root);\n nativeMethod(\n root,\n 'measure',\n )((_x: number, _y: number, width: number, height: number, pageX: number, pageY: number) => {\n try {\n if (this.root() !== root) {\n reject(new InspectorUnavailable('Inspection root changed. Capture again.'));\n return;\n }\n readInspectorOrientation(\n native,\n (interfaceOrientation) =>\n resolve({\n rootId,\n root: { width, height, pageX, pageY },\n pixelRatio,\n screen: {\n width: Number(nativeProperty(screen, 'width')),\n height: Number(nativeProperty(screen, 'height')),\n },\n ...(interfaceOrientation ? { interfaceOrientation } : {}),\n }),\n reject,\n );\n } catch {\n reject(new InspectorUnavailable('Inspection root unavailable. Capture again.'));\n }\n });\n });\n }\n inspect(x: number, y: number, index?: number): Promise<InspectorSelection> {\n return this.callback((resolve, reject) => {\n const root = this.root();\n inspectNativeView(\n global.__REACT_DEVTOOLS_GLOBAL_HOOK__,\n this.native(),\n root,\n x,\n y,\n (selection: unknown) => {\n try {\n if (this.root() !== root) throw new Error('Inspection root changed.');\n resolve(summarizeInspectorSelection(selection, index));\n } catch {\n reject(new InspectorUnavailable('Inspector selection unavailable. Capture again.'));\n }\n },\n reject,\n );\n });\n }\n private rootIdentity(root: unknown): string {\n if (!root || (typeof root !== 'object' && typeof root !== 'function'))\n throw new InspectorUnavailable('Mount the active native inspection root before capturing.');\n const existing = this.rootIds.get(root);\n if (existing) return existing;\n const id = createId();\n this.rootIds.set(root, id);\n return id;\n }\n private callback<T>(\n operation: (resolve: (value: T) => void, reject: (error: Error) => void) => void,\n ): Promise<T> {\n if (this.stopped) return Promise.reject(new Error('Inspector disposed.'));\n return new Promise<T>((resolve, reject) => {\n let settled = false;\n const finish = (error?: Error, value?: T): void => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n clearTimeout(dispatch);\n this.pending.delete(cancel);\n if (error) reject(error);\n else if (value !== undefined) resolve(value);\n };\n const cancel = (error: Error): void => finish(error);\n const timer = setTimeout(\n () =>\n cancel(\n new InspectorUnavailable(\n 'Native inspector callback timed out. Check that the root is mounted.',\n ),\n ),\n 3000,\n );\n this.pending.add(cancel);\n const dispatch = setTimeout(() => {\n try {\n operation((value) => finish(undefined, value), cancel);\n } catch (error) {\n cancel(\n error instanceof InspectorUnavailable\n ? error\n : new InspectorUnavailable('Native inspector operation unavailable.'),\n );\n }\n }, 0);\n });\n }\n dispose(): void {\n this.stopped = true;\n for (const cancel of this.pending) cancel(new Error('Inspector disposed.'));\n this.pending.clear();\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAO,IAAM,uBAAN,cAAmC,MAAM;AAAA,EAAzC;AAAA;AACL,SAAS,gBAAgB;AAAA;AAC3B;;;ACAA,SAAS,MACP,OACA,MACA,OACA,QACW;AACX,MAAI,EAAE,OAAO,QAAQ,EAAG,QAAO;AAC/B,MAAI,UAAU,QAAQ,OAAO,UAAU,UAAW,QAAO;AACzD,MAAI,OAAO,UAAU,UAAU;AAC7B,UAAM,SAAS,KAAK,IAAI,GAAG,KAAK,IAAI,KAAM,OAAO,UAAU,CAAC;AAC5D,WAAO,cAAc,KAAK,IAAI,MAAM,QAAQ,MAAM;AAClD,WAAO,MAAM,SAAS,SAAS,MAAM,MAAM,GAAG,MAAM,IAAI,gBAAgB;AAAA,EAC1E;AACA,MAAI,OAAO,UAAU,SAAU,QAAO,OAAO,SAAS,KAAK,IAAI,QAAQ,OAAO,KAAK;AACnF,MAAI,OAAO,UAAU,YAAY,OAAO,UAAU,SAAU,QAAO,OAAO,KAAK;AAC/E,MAAI,OAAO,UAAU,SAAU,QAAO,IAAI,OAAO,KAAK;AACtD,MAAI,SAAS,EAAG,QAAO;AACvB,MAAI,KAAK,IAAI,KAAK,EAAG,QAAO;AAC5B,OAAK,IAAI,KAAK;AACd,MAAI;AACF,QAAI,iBAAiB;AACnB,aAAO;AAAA,QACL;AAAA,UACE,MAAM,WAAW,OAAO,MAAM,KAAK;AAAA,UACnC,SAAS,WAAW,OAAO,SAAS;AAAA,UACpC,OAAO,WAAW,OAAO,OAAO;AAAA,QAClC;AAAA,QACA;AAAA,QACA,QAAQ;AAAA,QACR;AAAA,MACF;AACF,QAAI,MAAM,QAAQ,KAAK,EAAG,QAAO,WAAW,OAAO,MAAM,OAAO,MAAM;AACtE,UAAM,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Q;AAAA,UACN,WAAW,eAAe,SAAS,WAAW;AAAA,UAC9C,OAAO,eAAe,SAAS,OAAO;AAAA,UACtC,QAAQ,eAAe,SAAS,QAAQ;AAAA,UACxC,eAAe,eAAe,SAAS,WAAW;AAAA,UAClD,OAAO,EAAE,MAAM,KAAK,OAAO,OAAO;AAAA,QACpC,CAAC;AAAA,MACH,SAAQ;AACN;AAAA,UACE,IAAI;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;;;ACpDO,SAAS,eAAe,SAA2B;AACxD,SAAO,YAAY,SAAS,OAAO,YAAY,eAAe,YAAY;AAC5E;;;
|
|
4
|
+
"sourcesContent": ["export class InspectorUnavailable extends Error {\n readonly inspectorCode = 'bkb-inspector-unavailable-v1';\n}\nexport function inspectorFailureReason(error: unknown): string {\n if (error && typeof error === 'object') {\n const code = Object.getOwnPropertyDescriptor(error, 'inspectorCode');\n const message = Object.getOwnPropertyDescriptor(error, 'message');\n if (code?.value === 'bkb-inspector-unavailable-v1' && typeof message?.value === 'string')\n return message.value.slice(0, 512);\n }\n return 'Inspector unavailable. Check the mounted root and supported development renderer.';\n}\n", "import type { JsonValue } from './types';\n\nfunction visit(\n value: unknown,\n seen: Set<object>,\n depth: number,\n budget: { nodes: number; characters: number },\n): JsonValue {\n if (--budget.nodes < 0) return '[size limit]';\n if (value === null || typeof value === 'boolean') return value;\n if (typeof value === 'string') {\n const length = Math.max(0, Math.min(4000, budget.characters));\n budget.characters -= Math.min(value.length, length);\n return value.length > length ? value.slice(0, length) + '[truncated]' : value;\n }\n if (typeof value === 'number') return Number.isFinite(value) ? value : String(value);\n if (typeof value === 'bigint' || typeof value === 'symbol') return String(value);\n if (typeof value !== 'object') return `[${typeof value}]`;\n if (depth >= 5) return '[depth limit]';\n if (seen.has(value)) return '[circular]';\n seen.add(value);\n try {\n if (value instanceof Error)\n return visit(\n {\n name: errorField(value, 'name') || 'Error',\n message: errorField(value, 'message'),\n stack: errorField(value, 'stack'),\n },\n seen,\n depth + 1,\n budget,\n );\n if (Array.isArray(value)) return visitArray(value, seen, depth, budget);\n const result: { [key: string]: JsonValue } = {};\n const keys = Object.keys(value);\n for (const key of keys.slice(0, 50)) {\n if (budget.nodes <= 0) {\n result['[truncated]'] = '[size limit]';\n break;\n }\n if (key === '__proto__' || key === 'constructor' || key === 'prototype') continue;\n try {\n const descriptor = Object.getOwnPropertyDescriptor(value, key);\n result[key.slice(0, 128)] =\n descriptor && 'value' in descriptor\n ? visit(descriptor.value, seen, depth + 1, budget)\n : '[unavailable]';\n } catch {\n result[key.slice(0, 128)] = '[unavailable]';\n }\n }\n if (keys.length > 50) result['[truncated]'] = '[property limit]';\n return result;\n } finally {\n seen.delete(value);\n }\n}\n\nexport function serialize(value: unknown): JsonValue {\n try {\n const result = visit(value, new Set(), 0, { nodes: 200, characters: 12000 });\n const encoded = JSON.stringify(result);\n return encoded.length <= 16000 ? result : { truncated: true, preview: encoded.slice(0, 4000) };\n } catch {\n return '[unserializable]';\n }\n}\n\nfunction errorField(value: Error, key: string): string {\n const descriptor =\n Object.getOwnPropertyDescriptor(value, key) ??\n Object.getOwnPropertyDescriptor(Object.getPrototypeOf(value), key);\n const field: unknown = descriptor && 'value' in descriptor ? descriptor.value : '';\n return typeof field === 'string' ? field.slice(0, 4000) : '';\n}\n\nfunction visitArray(\n value: unknown[],\n seen: Set<object>,\n depth: number,\n budget: { nodes: number; characters: number },\n): JsonValue[] {\n const result: JsonValue[] = [];\n for (let index = 0; index < Math.min(value.length, 100); index++) {\n if (budget.nodes <= 0) {\n result.push('[size limit]');\n break;\n }\n const descriptor = Object.getOwnPropertyDescriptor(value, String(index));\n result.push(\n descriptor && 'value' in descriptor\n ? visit(descriptor.value, seen, depth + 1, budget)\n : '[unavailable]',\n );\n }\n if (value.length > 100) result.push('[array limit]');\n return result;\n}\n", "import { InspectorUnavailable } from './inspector-error';\nimport { serialize } from './serialize';\nimport type { InspectorSelection, InspectorSource } from '../../protocol/src/inspector-provider';\nexport function nativeProperty(value: unknown, key: string): unknown {\n return value && (typeof value === 'object' || typeof value === 'function')\n ? (Reflect.get(value, key) as unknown)\n : undefined;\n}\nexport function nativeMethod(value: unknown, name: string): (...args: unknown[]) => unknown {\n const method = nativeProperty(value, name);\n if (typeof method !== 'function')\n throw new InspectorUnavailable('Native inspector method unavailable: ' + name + '.');\n return (...args) => Reflect.apply(method, value, args) as unknown;\n}\nfunction sourceLocation(value: unknown): InspectorSource | undefined {\n if (!value || typeof value !== 'object') return;\n const file = nativeProperty(value, 'file') ?? nativeProperty(value, 'fileName');\n const line = nativeProperty(value, 'line') ?? nativeProperty(value, 'lineNumber');\n const column = nativeProperty(value, 'column') ?? nativeProperty(value, 'columnNumber');\n if (\n typeof file !== 'string' ||\n file.length > 4096 ||\n typeof line !== 'number' ||\n !Number.isInteger(line) ||\n line < 1 ||\n typeof column !== 'number' ||\n !Number.isInteger(column) ||\n column < 1\n )\n return;\n return { file, line, column };\n}\n// A plain data property, never an accessor, so reading metadata cannot run app code.\nfunction ownValue(object: unknown, key: string): unknown {\n const descriptor =\n object && typeof object === 'object' ? Object.getOwnPropertyDescriptor(object, key) : undefined;\n return descriptor && 'value' in descriptor ? (descriptor.value as unknown) : undefined;\n}\nfunction inspectorSource(details: unknown): InspectorSource | undefined {\n return (\n sourceLocation(ownValue(nativeProperty(details, 'props'), '__bkbSource')) ??\n sourceLocation(nativeProperty(details, 'source'))\n );\n}\nconst MAX_OWNER_STEPS = 64;\n// Library UI (a modal, a sheet) has no source metadata of its own, because the Babel plugin\n// skips dependencies. React Native's React 19 builds return the fiber of the nearest component\n// as `closestInstance`; walking its owners reaches the nearest element written in the project,\n// which is where the library component is used.\nfunction nearestOwnerSource(selection: unknown): InspectorSource | undefined {\n let fiber = nativeProperty(selection, 'closestInstance');\n for (let step = 0; fiber && step < MAX_OWNER_STEPS; step++) {\n const source = sourceLocation(ownValue(nativeProperty(fiber, 'memoizedProps'), '__bkbSource'));\n if (source) return source;\n fiber = nativeProperty(fiber, '_debugOwner');\n }\n return undefined;\n}\nfunction inspectorProps(props: unknown) {\n const retained: Record<string, unknown> = {};\n if (props && typeof props === 'object') {\n for (const key of Object.keys(props).slice(0, 30)) {\n if (['children', '__bkbSource', '__proto__', 'constructor', 'prototype'].indexOf(key) !== -1)\n continue;\n const descriptor = Object.getOwnPropertyDescriptor(props, key);\n retained[key] =\n descriptor && 'value' in descriptor ? (descriptor.value as unknown) : '[accessor omitted]';\n }\n }\n const safe = serialize(retained);\n return JSON.stringify(safe).length > 8000 ? '[props exceed preview budget]' : safe;\n}\nexport function summarizeInspectorSelection(\n selection: unknown,\n index?: number,\n): InspectorSelection {\n const entries = nativeProperty(selection, 'hierarchy');\n if (!Array.isArray(entries) || !entries.length || entries.length > 40)\n throw new Error('Inspector hierarchy unavailable or exceeds 40 entries.');\n const selectedIndex = index === undefined ? nativeProperty(selection, 'selectedIndex') : index;\n if (typeof selectedIndex !== 'number' || !Number.isInteger(selectedIndex))\n throw new Error('Selected component index unavailable.');\n const selected = entries[selectedIndex] as unknown;\n if (!selected) throw new Error('Selected component unavailable.');\n const details =\n index === undefined ? selection : nativeMethod(selected, 'getInspectorData')(() => undefined);\n // An explicit index asks for that entry itself; the owner chain belongs to the default one.\n const source =\n inspectorSource(details) ?? (index === undefined ? nearestOwnerSource(selection) : undefined);\n const frame = nativeProperty(selection, 'frame');\n const hierarchy = entries.map((entry: unknown) => {\n const information = nativeMethod(entry, 'getInspectorData')(() => undefined);\n const source = inspectorSource(information);\n const name = nativeProperty(entry, 'name');\n return {\n name: typeof name === 'string' ? name.slice(0, 128) : 'Unknown component',\n ...(source ? { source } : {}),\n };\n });\n return {\n hierarchy,\n selectedIndex,\n props: inspectorProps(nativeProperty(details, 'props')),\n ...(source ? { source } : {}),\n frame: {\n left: Number(nativeProperty(frame, 'left')),\n top: Number(nativeProperty(frame, 'top')),\n width: Number(nativeProperty(frame, 'width')),\n height: Number(nativeProperty(frame, 'height')),\n },\n };\n}\n", "import type { InterfaceOrientation } from '../../protocol/src/inspector-provider';\nimport { nativeMethod, nativeProperty } from './inspector-values';\nimport { InspectorUnavailable } from './inspector-error';\n\nexport function readInspectorOrientation(\n native: unknown,\n receive: (orientation?: InterfaceOrientation) => void,\n reject: (error: Error) => void,\n): void {\n try {\n const module = nativeProperty(nativeProperty(native, 'NativeModules'), 'BKBInspector');\n if (nativeProperty(nativeProperty(native, 'Platform'), 'OS') !== 'ios' || !module) {\n receive();\n return;\n }\n nativeMethod(\n module,\n 'getOrientation',\n )((value: unknown) => {\n if (\n value === 'portrait' ||\n value === 'portrait-upside-down' ||\n value === 'landscape-left' ||\n value === 'landscape-right'\n )\n receive(value);\n else\n reject(\n new InspectorUnavailable(\n 'Native interface orientation unavailable. Bring the app to the foreground.',\n ),\n );\n });\n } catch {\n reject(\n new InspectorUnavailable(\n 'Native interface orientation unavailable. Check the optional BKBInspector pod.',\n ),\n );\n }\n}\n", "import { InspectorUnavailable } from './inspector-error';\nimport { nativeProperty, nativeMethod } from './inspector-values';\nexport function inspectNativeView(\n hook: unknown,\n native: unknown,\n root: unknown,\n x: number,\n y: number,\n receive: (selection: unknown) => void,\n failed: (error: Error) => void = () => undefined,\n): void {\n const renderers = nativeProperty(hook, 'renderers');\n if (!(renderers instanceof Map)) throw new Error('React renderer hook unavailable.');\n const modern: unknown[] = [];\n const legacy: unknown[] = [];\n renderers.forEach((renderer: unknown) => {\n const configuration = nativeProperty(renderer, 'rendererConfig');\n if (typeof nativeProperty(configuration, 'getInspectorDataForViewAtPoint') === 'function')\n modern.push(configuration);\n else if (typeof nativeProperty(renderer, 'getInspectorDataForViewTag') === 'function')\n legacy.push(renderer);\n });\n // React Native 0.79+ in bridgeless mode registers its Fabric and its legacy renderer; both\n // carry the same getInspectorDataForViewAtPoint, which handles Fabric and Paper roots itself,\n // so any one of them answers for the root (verified on RN 0.79: identical hierarchies).\n if (modern.length) {\n nativeMethod(modern[0], 'getInspectorDataForViewAtPoint')(root, x, y, receive);\n return;\n }\n if (legacy.length !== 1) throw new Error('Expected one supported inspector renderer.');\n const handle = nativeMethod(native, 'findNodeHandle')(root);\n nativeMethod(nativeProperty(native, 'UIManager'), 'findSubviewIn')(\n handle,\n [x, y],\n (tag: number, left: number, top: number, width: number, height: number) => {\n try {\n const details = nativeMethod(legacy[0], 'getInspectorDataForViewTag')(tag);\n receive({\n hierarchy: nativeProperty(details, 'hierarchy'),\n props: nativeProperty(details, 'props'),\n source: nativeProperty(details, 'source'),\n selectedIndex: nativeProperty(details, 'selection'),\n frame: { left, top, width, height },\n });\n } catch {\n failed(\n new InspectorUnavailable(\n 'The native view changed during legacy inspection. Capture again.',\n ),\n );\n }\n },\n );\n}\n", "declare const __DEV__: boolean | undefined;\nexport function loggingEnabled(enabled: boolean): boolean {\n return enabled === true && (typeof __DEV__ === 'undefined' || __DEV__ === true);\n}\nexport function utf8Bytes(text: string): number {\n let bytes = 0;\n for (let index = 0; index < text.length; index++) {\n const code = text.charCodeAt(index);\n if (code < 128) bytes++;\n else if (code < 2048) bytes += 2;\n else if (\n code >= 0xd800 &&\n code <= 0xdbff &&\n index + 1 < text.length &&\n text.charCodeAt(index + 1) >= 0xdc00 &&\n text.charCodeAt(index + 1) <= 0xdfff\n ) {\n bytes += 4;\n index++;\n } else bytes += 3;\n }\n return bytes;\n}\n", "import type { InspectorProvider } from '../../protocol/src/inspector-provider';\nimport type { RenderProvider } from '../../protocol/src/renders-provider';\nimport type { PluginCapability } from '../../protocol/src/plugin-channels';\nimport type { LogLevel, RuntimeMetadata } from '../../protocol/src/wire';\n\nexport type { JsonValue, LogLevel, RuntimeMetadata } from '../../protocol/src/wire';\nexport type ConnectionState = 'disabled' | 'connecting' | 'connected' | 'disconnected';\n\n// What an SDK entry point connects with: `@bkbdev/core/register` builds it from the project's\n// bkb.config.json (the block of the platform the app runs on). Pass it as `config` only when\n// the plugin cannot find the file.\nexport interface BkbConfig {\n projectId: string;\n token: string;\n app: { id: string; name?: string; version?: string };\n metro?: { port?: number };\n // Only to reach BKB somewhere other than ws://127.0.0.1:8347, for example over the LAN.\n connection?: { endpoint?: string };\n}\n\n// A plugin's source of events. The logger sends every event the provider produces on the\n// plugin's reserved channel and tells BKB, in its hello message, that the plugin is active.\nexport interface PluginProvider {\n capability: PluginCapability;\n instanceId: string;\n subscribe: (listener: (event: unknown) => void) => () => void;\n // Answers a request from BKB with a result that fits one frame; a provider without it takes\n // no requests. Whatever it throws is reported as a refusal.\n handleCommand?: (command: unknown) => unknown;\n // How many events the plugin kept for BKB and then lost before the logger took them.\n droppedCount?: () => number;\n}\n\n// Settings that sit beside the configuration.\nexport interface LoggerExtras {\n pluginProviders?: PluginProvider[];\n inspector?: InspectorProvider;\n renders?: RenderProvider;\n reload?: () => void;\n runtimeMetadata?: RuntimeMetadata;\n // scheme://host:port the app loaded its bundle from; see readBundleOrigin.\n bundleOrigin?: string;\n tags?: Record<string, string>;\n}\n\n// Every SDK entry point that connects takes these: nothing is needed when the project's\n// bkb.config.json is injected by `@bkbdev/core/register`. `enabled` defaults to true.\nexport interface ConnectionOptions {\n config?: BkbConfig;\n enabled?: boolean;\n}\n\nexport type LoggerOptions = ConnectionOptions & LoggerExtras;\n\n// The resolved settings the transports use.\nexport interface LoggerConfig {\n enabled: boolean;\n pluginProviders?: PluginProvider[];\n inspector?: InspectorProvider;\n renders?: RenderProvider;\n reload?: () => void;\n runtimeMetadata?: RuntimeMetadata;\n bundleOrigin?: string;\n projectId: string;\n connection: { endpoint: string; token: string };\n app: { id: string; name?: string; version?: string };\n tags?: Record<string, string>;\n}\n\nexport interface LogOptions {\n level?: LogLevel;\n tags?: Record<string, string>;\n correlationId?: string;\n}\n\nexport interface Span {\n readonly id: string;\n end(data?: unknown): void;\n fail(error: unknown): void;\n}\n\nexport interface LogChannel {\n log(name: string, data?: unknown, options?: LogOptions): void;\n table(name: string, rows: ReadonlyArray<Record<string, unknown>>, options?: LogOptions): void;\n startSpan(name: string, data?: unknown, options?: LogOptions): Span;\n}\n\nexport interface Logger extends LogChannel {\n channel(name: string): LogChannel;\n getConnectionState(): ConnectionState;\n getDroppedEventCount(): number;\n disconnect(): void;\n}\n\nexport function createId(): string {\n return Date.now().toString(36) + '-' + Math.random().toString(36).slice(2, 12);\n}\n", "export type {\n InspectorProvider,\n InspectorGeometry,\n InspectorSelection,\n} from '../../protocol/src/inspector-provider';\nimport { InspectorUnavailable } from './inspector-error';\nimport { readInspectorOrientation } from './inspector-orientation';\nimport { inspectNativeView } from './inspector-renderer';\nimport { loggingEnabled } from './environment';\nimport { createId } from './types';\nimport { summarizeInspectorSelection, nativeMethod, nativeProperty } from './inspector-values';\nimport type {\n InspectorGeometry,\n InspectorProvider,\n InspectorSelection,\n} from '../../protocol/src/inspector-provider';\ndeclare const global: { __REACT_DEVTOOLS_GLOBAL_HOOK__?: unknown };\nexport interface ReactNativeInspectorConfig {\n enabled?: boolean;\n root(): unknown;\n native(): unknown;\n}\nexport function createReactNativeInspector(config: ReactNativeInspectorConfig): InspectorProvider {\n if (!loggingEnabled(config.enabled ?? true))\n return {\n instanceId: 'disabled',\n enabled: false,\n measure: () => Promise.reject(new Error('Inspector disabled.')),\n inspect: () => Promise.reject(new Error('Inspector disabled.')),\n dispose: () => undefined,\n };\n return new ReactNativeInspector(\n () => config.root(),\n () => config.native(),\n );\n}\nclass ReactNativeInspector implements InspectorProvider {\n readonly instanceId = createId();\n readonly enabled = true;\n private stopped = false;\n private readonly rootIds = new WeakMap<object, string>();\n private readonly pending = new Set<(error: Error) => void>();\n constructor(\n private readonly root: () => unknown,\n private readonly native: () => unknown,\n ) {}\n measure(): Promise<InspectorGeometry> {\n return this.callback((resolve, reject) => {\n const native = this.native();\n if (nativeProperty(nativeProperty(native, 'AppState'), 'currentState') !== 'active')\n throw new InspectorUnavailable(\n 'Bring the inspected development application to the foreground.',\n );\n const dimensions = nativeProperty(native, 'Dimensions');\n const screen = nativeMethod(dimensions, 'get')('screen');\n const pixelRatio = Number(nativeMethod(nativeProperty(native, 'PixelRatio'), 'get')());\n const root = this.root();\n const rootId = this.rootIdentity(root);\n nativeMethod(\n root,\n 'measure',\n )((_x: number, _y: number, width: number, height: number, pageX: number, pageY: number) => {\n try {\n if (this.root() !== root) {\n reject(new InspectorUnavailable('Inspection root changed. Capture again.'));\n return;\n }\n readInspectorOrientation(\n native,\n (interfaceOrientation) =>\n resolve({\n rootId,\n root: { width, height, pageX, pageY },\n pixelRatio,\n screen: {\n width: Number(nativeProperty(screen, 'width')),\n height: Number(nativeProperty(screen, 'height')),\n },\n ...(interfaceOrientation ? { interfaceOrientation } : {}),\n }),\n reject,\n );\n } catch {\n reject(new InspectorUnavailable('Inspection root unavailable. Capture again.'));\n }\n });\n });\n }\n inspect(x: number, y: number, index?: number): Promise<InspectorSelection> {\n return this.callback((resolve, reject) => {\n const root = this.root();\n inspectNativeView(\n global.__REACT_DEVTOOLS_GLOBAL_HOOK__,\n this.native(),\n root,\n x,\n y,\n (selection: unknown) => {\n try {\n if (this.root() !== root) throw new Error('Inspection root changed.');\n resolve(summarizeInspectorSelection(selection, index));\n } catch {\n reject(new InspectorUnavailable('Inspector selection unavailable. Capture again.'));\n }\n },\n reject,\n );\n });\n }\n private rootIdentity(root: unknown): string {\n if (!root || (typeof root !== 'object' && typeof root !== 'function'))\n throw new InspectorUnavailable('Mount the active native inspection root before capturing.');\n const existing = this.rootIds.get(root);\n if (existing) return existing;\n const id = createId();\n this.rootIds.set(root, id);\n return id;\n }\n private callback<T>(\n operation: (resolve: (value: T) => void, reject: (error: Error) => void) => void,\n ): Promise<T> {\n if (this.stopped) return Promise.reject(new Error('Inspector disposed.'));\n return new Promise<T>((resolve, reject) => {\n let settled = false;\n const finish = (error?: Error, value?: T): void => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n clearTimeout(dispatch);\n this.pending.delete(cancel);\n if (error) reject(error);\n else if (value !== undefined) resolve(value);\n };\n const cancel = (error: Error): void => finish(error);\n const timer = setTimeout(\n () =>\n cancel(\n new InspectorUnavailable(\n 'Native inspector callback timed out. Check that the root is mounted.',\n ),\n ),\n 3000,\n );\n this.pending.add(cancel);\n const dispatch = setTimeout(() => {\n try {\n operation((value) => finish(undefined, value), cancel);\n } catch (error) {\n cancel(\n error instanceof InspectorUnavailable\n ? error\n : new InspectorUnavailable('Native inspector operation unavailable.'),\n );\n }\n }, 0);\n });\n }\n dispose(): void {\n this.stopped = true;\n for (const cancel of this.pending) cancel(new Error('Inspector disposed.'));\n this.pending.clear();\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAAO,IAAM,uBAAN,cAAmC,MAAM;AAAA,EAAzC;AAAA;AACL,SAAS,gBAAgB;AAAA;AAC3B;;;ACAA,SAAS,MACP,OACA,MACA,OACA,QACW;AACX,MAAI,EAAE,OAAO,QAAQ,EAAG,QAAO;AAC/B,MAAI,UAAU,QAAQ,OAAO,UAAU,UAAW,QAAO;AACzD,MAAI,OAAO,UAAU,UAAU;AAC7B,UAAM,SAAS,KAAK,IAAI,GAAG,KAAK,IAAI,KAAM,OAAO,UAAU,CAAC;AAC5D,WAAO,cAAc,KAAK,IAAI,MAAM,QAAQ,MAAM;AAClD,WAAO,MAAM,SAAS,SAAS,MAAM,MAAM,GAAG,MAAM,IAAI,gBAAgB;AAAA,EAC1E;AACA,MAAI,OAAO,UAAU,SAAU,QAAO,OAAO,SAAS,KAAK,IAAI,QAAQ,OAAO,KAAK;AACnF,MAAI,OAAO,UAAU,YAAY,OAAO,UAAU,SAAU,QAAO,OAAO,KAAK;AAC/E,MAAI,OAAO,UAAU,SAAU,QAAO,IAAI,OAAO,KAAK;AACtD,MAAI,SAAS,EAAG,QAAO;AACvB,MAAI,KAAK,IAAI,KAAK,EAAG,QAAO;AAC5B,OAAK,IAAI,KAAK;AACd,MAAI;AACF,QAAI,iBAAiB;AACnB,aAAO;AAAA,QACL;AAAA,UACE,MAAM,WAAW,OAAO,MAAM,KAAK;AAAA,UACnC,SAAS,WAAW,OAAO,SAAS;AAAA,UACp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