@mearl/native-host 2.0.0 → 2.0.1

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.
Files changed (2) hide show
  1. package/dist/index.js +321 -70
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -677,15 +677,75 @@ function buildCookieHeaderValue(cookieMap) {
677
677
 
678
678
  // ../browser-core/dist/eventParsers.js
679
679
  var APLUS_URL_PATTERN = /\.mmstat\.com\//;
680
+ var RUM_URL_PATTERN = /\.rum\.aliyuncs\.com\//;
680
681
  var ARMS_URL_PATTERN = /arms-retcode\.aliyuncs\.com\//;
681
682
  var aplusCounter = 0;
682
683
  var armsCounter = 0;
684
+ var rumCounter = 0;
683
685
  function formatTimestamp(ms) {
684
686
  const d = new Date(ms);
685
687
  const pad = (n) => String(n).padStart(2, "0");
686
688
  return `${d.getFullYear()}/${pad(d.getMonth() + 1)}/${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;
687
689
  }
688
- function parseAplusRequest(url2) {
690
+ function parseParams(value) {
691
+ const params = {};
692
+ value.split("&").forEach((pair) => {
693
+ const eqIndex = pair.indexOf("=");
694
+ if (eqIndex === -1)
695
+ return;
696
+ const rawKey = pair.slice(0, eqIndex);
697
+ const rawValue = pair.slice(eqIndex + 1);
698
+ try {
699
+ params[decodeURIComponent(rawKey)] = rawValue;
700
+ } catch {
701
+ params[rawKey] = rawValue;
702
+ }
703
+ });
704
+ return params;
705
+ }
706
+ function decodeParamValue(value) {
707
+ try {
708
+ return decodeURIComponent(value);
709
+ } catch {
710
+ return value;
711
+ }
712
+ }
713
+ function extractSpmFromUrl(spmOrUrl) {
714
+ if (!/^https?:\/\//i.test(spmOrUrl))
715
+ return spmOrUrl;
716
+ try {
717
+ return new URL(spmOrUrl).searchParams.get("spm") ?? spmOrUrl;
718
+ } catch {
719
+ return spmOrUrl;
720
+ }
721
+ }
722
+ function resolveAplusSpm(eventType, raw) {
723
+ const expdata = Array.isArray(raw.expdata) ? raw.expdata : [];
724
+ const expSpm = expdata[0]?.spm || "";
725
+ const gokeyParams = parseParams(raw.gokey || "");
726
+ const gokeySpm = decodeParamValue(gokeyParams.spm || "");
727
+ const rawSpmUrl = raw["spm-url"] || decodeParamValue(gokeyParams["spm-url"] || "");
728
+ const spmUrl = extractSpmFromUrl(rawSpmUrl);
729
+ let pointSpm;
730
+ switch (eventType) {
731
+ case "CLK":
732
+ pointSpm = gokeySpm || expSpm;
733
+ break;
734
+ case "EXP":
735
+ pointSpm = expSpm;
736
+ break;
737
+ case "PV":
738
+ pointSpm = spmUrl;
739
+ break;
740
+ default:
741
+ pointSpm = gokeySpm || expSpm;
742
+ }
743
+ return {
744
+ mainSpm: pointSpm,
745
+ highlightSpm: pointSpm
746
+ };
747
+ }
748
+ function parseAplusRequest(url2, options = {}) {
689
749
  if (!APLUS_URL_PATTERN.test(url2))
690
750
  return null;
691
751
  let urlObj;
@@ -703,59 +763,47 @@ function parseAplusRequest(url2) {
703
763
  const pathCategory = urlPathName.split(".")[1];
704
764
  const eventType = pathCategory === "selfdefine" ? "SDF" : gmkey;
705
765
  const gokeyRaw = params.gokey ?? "";
706
- const gokeyParams = {};
707
- try {
708
- gokeyRaw.split("&").forEach((pair) => {
709
- const eqIdx = pair.indexOf("=");
710
- if (eqIdx === -1)
711
- return;
712
- const k = decodeURIComponent(pair.slice(0, eqIdx));
713
- const v = pair.slice(eqIdx + 1);
714
- gokeyParams[k] = v;
715
- });
716
- } catch {
717
- }
766
+ const gokeyParams = parseParams(gokeyRaw);
718
767
  let expdata = [];
719
768
  try {
720
769
  if (gokeyParams.expdata) {
721
770
  expdata = JSON.parse(gokeyParams.expdata);
722
771
  expdata = expdata.map((item) => {
723
- if (item?.exargs && typeof item.exargs === "object") {
724
- const decoded = {};
725
- for (const [k, v] of Object.entries(item.exargs)) {
726
- if (typeof v === "string") {
727
- try {
728
- decoded[k] = JSON.parse(decodeURIComponent(v));
729
- } catch {
730
- decoded[k] = v;
731
- }
732
- } else {
733
- decoded[k] = v;
734
- }
772
+ if (!item?.exargs || typeof item.exargs !== "object")
773
+ return item;
774
+ const decoded = {};
775
+ for (const [key, value] of Object.entries(item.exargs)) {
776
+ if (typeof value !== "string") {
777
+ decoded[key] = value;
778
+ continue;
779
+ }
780
+ try {
781
+ decoded[key] = JSON.parse(decodeURIComponent(value));
782
+ } catch {
783
+ decoded[key] = value;
735
784
  }
736
- return { ...item, exargs: decoded };
737
785
  }
738
- return item;
786
+ return { ...item, exargs: decoded };
739
787
  });
740
788
  }
741
789
  } catch {
742
790
  }
743
- const spmFromPath = eventType !== "SDF" ? urlPathName.split(".").slice(1).join(".") : "";
744
- const spm = gokeyParams.spm || expdata[0]?.spm || spmFromPath || "";
745
- const pageUrl = params["_p_url"] ?? gokeyParams["_p_url"] ?? "";
746
- const eventName = eventType === "SDF" ? urlPathName.split(".").slice(1).join(".") : spm || pageUrl;
747
- const now = Date.now();
748
- const eventId = `aplus-${++aplusCounter}-${now}`;
749
- const { gokey: _rawGokey, ...topLevelParams } = params;
791
+ const pageUrl = params["_p_url"] ?? (gokeyParams["_p_url"] ? decodeParamValue(gokeyParams["_p_url"]) : "");
792
+ const { gokey: rawGokey, ...topLevelParams } = params;
750
793
  const rawData = {
751
794
  ...topLevelParams,
752
795
  _path: urlPathName,
753
796
  _url: url2,
754
- gokey: _rawGokey,
797
+ gokey: rawGokey,
755
798
  ...expdata.length > 0 ? { expdata } : {}
756
799
  };
800
+ const spm = resolveAplusSpm(eventType, rawData).mainSpm;
801
+ const pathName = urlPathName.split(".").slice(1).join(".");
802
+ const eventName = eventType === "SDF" ? pathName : spm || pathName || pageUrl;
803
+ const now = options.now ?? Date.now();
804
+ const sequence = options.sequence ?? ++aplusCounter;
757
805
  return {
758
- id: eventId,
806
+ id: `aplus-${sequence}-${now}`,
759
807
  source: "aplus",
760
808
  batchId: 0,
761
809
  batchTimestampMs: now,
@@ -785,7 +833,132 @@ function parseAplusRequest(url2) {
785
833
  }
786
834
  };
787
835
  }
788
- function parseArmsRequest(url2) {
836
+ var RUM_TYPE_ALIAS = {
837
+ cst: "custom"
838
+ };
839
+ var I18N_TRACKER_TYPE_MAP = {
840
+ "i18n-tracker-exp": "EXP",
841
+ "i18n-tracker-clk": "CLK"
842
+ };
843
+ function parseRumBody(postData) {
844
+ if (!postData)
845
+ return null;
846
+ if (typeof postData === "object")
847
+ return postData;
848
+ try {
849
+ return JSON.parse(postData);
850
+ } catch {
851
+ return null;
852
+ }
853
+ }
854
+ function tryConvertI18nTracker(event, base) {
855
+ const normalizedType = RUM_TYPE_ALIAS[event.type] ?? event.type;
856
+ if (event.event_type !== "action" || normalizedType !== "custom")
857
+ return null;
858
+ let snapshots;
859
+ try {
860
+ snapshots = typeof event.snapshots === "string" ? JSON.parse(event.snapshots) : event.snapshots;
861
+ } catch {
862
+ return null;
863
+ }
864
+ if (!snapshots || typeof snapshots !== "object")
865
+ return null;
866
+ const eventType = I18N_TRACKER_TYPE_MAP[snapshots.message];
867
+ if (!eventType)
868
+ return null;
869
+ const spm = [snapshots.c1 ?? "", snapshots.c2 ?? ""].filter(Boolean).join(".");
870
+ const exargs = {};
871
+ if (typeof snapshots.c3 === "string") {
872
+ snapshots.c3.split("&").forEach((pair) => {
873
+ const eqIndex = pair.indexOf("=");
874
+ if (eqIndex === -1)
875
+ return;
876
+ const key = pair.slice(0, eqIndex);
877
+ const rawValue = pair.slice(eqIndex + 1);
878
+ try {
879
+ exargs[key] = JSON.parse(decodeURIComponent(rawValue));
880
+ } catch {
881
+ exargs[key] = rawValue;
882
+ }
883
+ });
884
+ }
885
+ const dataAttrs = snapshots.trackerInfo?.dataAttrs;
886
+ if (dataAttrs && typeof dataAttrs === "object" && dataAttrs["data-biz-args"] && !exargs.bizArgs) {
887
+ try {
888
+ exargs.bizArgs = JSON.parse(dataAttrs["data-biz-args"]);
889
+ } catch {
890
+ exargs.bizArgs = dataAttrs["data-biz-args"];
891
+ }
892
+ }
893
+ return {
894
+ ...base,
895
+ event_type: eventType,
896
+ name: spm,
897
+ _raw: {
898
+ ...event,
899
+ expdata: [
900
+ {
901
+ spm,
902
+ ...Object.keys(exargs).length > 0 ? { exargs } : {}
903
+ }
904
+ ],
905
+ "spm-url": spm
906
+ }
907
+ };
908
+ }
909
+ function parseRumRequest(url2, postData, options = {}) {
910
+ if (!RUM_URL_PATTERN.test(url2))
911
+ return [];
912
+ const parsed = parseRumBody(postData);
913
+ const rawEvents = Array.isArray(parsed?.events) ? parsed.events : [];
914
+ if (rawEvents.length === 0)
915
+ return [];
916
+ const now = options.now ?? Date.now();
917
+ const batchId = options.sequence ?? ++rumCounter;
918
+ const context = {
919
+ requestUrl: url2,
920
+ app: parsed?.app ?? {},
921
+ user: parsed?.user ?? {},
922
+ session: parsed?.session ?? {},
923
+ view: parsed?.view ?? {},
924
+ properties: parsed?.properties ?? {},
925
+ os: parsed?.os ?? {},
926
+ net: parsed?.net ?? {}
927
+ };
928
+ return rawEvents.flatMap((rawEvent, index) => {
929
+ if (!rawEvent || typeof rawEvent !== "object" || Array.isArray(rawEvent))
930
+ return [];
931
+ const event = rawEvent;
932
+ const normalizedType = RUM_TYPE_ALIAS[event.type] ?? event.type;
933
+ const base = {
934
+ id: `${batchId}-${event.event_id ?? index}`,
935
+ batchId,
936
+ batchTimestampMs: now,
937
+ batchTimestamp: formatTimestamp(now),
938
+ type: normalizedType,
939
+ url: event.url,
940
+ timestamp: event.timestamp ?? now,
941
+ success: event.success,
942
+ status_code: event.status_code,
943
+ method: event.method,
944
+ duration: event.duration,
945
+ source: "rum",
946
+ _context: context
947
+ };
948
+ const converted = tryConvertI18nTracker(event, base);
949
+ if (converted)
950
+ return [converted];
951
+ return [
952
+ {
953
+ ...base,
954
+ event_type: event.event_type ?? "unknown",
955
+ name: event.name,
956
+ _raw: event
957
+ }
958
+ ];
959
+ });
960
+ }
961
+ function parseArmsRequest(url2, options = {}) {
789
962
  if (!ARMS_URL_PATTERN.test(url2))
790
963
  return null;
791
964
  let urlObj;
@@ -800,11 +973,12 @@ function parseArmsRequest(url2) {
800
973
  });
801
974
  const eventType = (params.t ?? "unknown").toLowerCase();
802
975
  const page = params.page ?? "";
803
- const now = Date.now();
804
- const eventId = `arms-${++armsCounter}-${now}`;
805
- const timestamp = params.begin ? parseInt(params.begin, 10) : now;
976
+ const now = options.now ?? Date.now();
977
+ const sequence = options.sequence ?? ++armsCounter;
978
+ const parsedTimestamp2 = params.begin ? Number.parseInt(params.begin, 10) : now;
979
+ const timestamp = Number.isFinite(parsedTimestamp2) ? parsedTimestamp2 : now;
806
980
  return {
807
- id: eventId,
981
+ id: `arms-${sequence}-${now}`,
808
982
  source: "arms",
809
983
  batchId: 0,
810
984
  batchTimestampMs: now,
@@ -840,6 +1014,58 @@ function parseArmsRequest(url2) {
840
1014
  }
841
1015
  };
842
1016
  }
1017
+ function parseTrackingRequest(url2, postData, options = {}) {
1018
+ const rumEvents = parseRumRequest(url2, postData, options);
1019
+ if (rumEvents.length > 0)
1020
+ return rumEvents;
1021
+ const aplusEvent = parseAplusRequest(url2, options);
1022
+ if (aplusEvent)
1023
+ return [aplusEvent];
1024
+ const armsEvent = parseArmsRequest(url2, options);
1025
+ return armsEvent ? [armsEvent] : [];
1026
+ }
1027
+
1028
+ // ../browser-core/dist/eventFilters.js
1029
+ var TRACKING_CAPTURE_ARMED_HINT = "Event capture is active, but this tab has no captured history yet. Reload the current tab or repeat the triggering action, then call get_events again.";
1030
+ function matchesRegex(value, pattern) {
1031
+ return value ? pattern.test(value) : false;
1032
+ }
1033
+ function compilePattern(value) {
1034
+ try {
1035
+ return { regex: new RegExp(value, "i"), fallback: "" };
1036
+ } catch {
1037
+ return { regex: null, fallback: value.toLowerCase() };
1038
+ }
1039
+ }
1040
+ function queryTrackingEvents(buffer, options = {}) {
1041
+ const { source = "all", event_type, filter, since, limit = 20, now = Date.now() } = options;
1042
+ let events = [...buffer].reverse();
1043
+ if (source !== "all") {
1044
+ events = events.filter((event) => event.source === source);
1045
+ }
1046
+ if (since !== void 0) {
1047
+ const sinceTimestamp = now - since * 1e3;
1048
+ events = events.filter((event) => event.batchTimestampMs >= sinceTimestamp);
1049
+ }
1050
+ if (event_type) {
1051
+ const { regex, fallback } = compilePattern(event_type);
1052
+ events = events.filter((event) => regex ? regex.test(event.event_type) : event.event_type.toLowerCase().includes(fallback));
1053
+ }
1054
+ if (filter) {
1055
+ const { regex, fallback } = compilePattern(filter);
1056
+ events = events.filter((event) => {
1057
+ if (regex) {
1058
+ return matchesRegex(event.name, regex) || matchesRegex(event.url, regex);
1059
+ }
1060
+ return event.name?.toLowerCase().includes(fallback) === true || event.url?.toLowerCase().includes(fallback) === true;
1061
+ });
1062
+ }
1063
+ return {
1064
+ events: events.slice(0, limit),
1065
+ totalMatched: events.length,
1066
+ totalInBuffer: buffer.length
1067
+ };
1068
+ }
843
1069
 
844
1070
  // ../browser-core/dist/requestSerializer.js
845
1071
  function parsePath(path12) {
@@ -2804,8 +3030,23 @@ function parsePostData(postData) {
2804
3030
  }
2805
3031
  }
2806
3032
  }
3033
+ function appendTrackingEvents(buffers, url2, postData, sequence) {
3034
+ const events = parseTrackingRequest(url2, postData, {
3035
+ sequence,
3036
+ now: Date.now()
3037
+ });
3038
+ if (events.length === 0) return false;
3039
+ buffers.events.push(...events);
3040
+ if (buffers.events.length > MAX_EVENTS) {
3041
+ buffers.events.splice(0, buffers.events.length - MAX_EVENTS);
3042
+ }
3043
+ return true;
3044
+ }
2807
3045
  function setupBufferListeners(client2, buffers) {
2808
- ensureCdpDomain(client2, "Network", { maxTotalBufferSize: 10 * 1024 * 1024 }).catch(() => {
3046
+ ensureCdpDomain(client2, "Network", {
3047
+ maxTotalBufferSize: 10 * 1024 * 1024,
3048
+ maxPostDataSize: 5 * 1024 * 1024
3049
+ }).catch(() => {
2809
3050
  });
2810
3051
  ensureCdpDomain(client2, "Runtime").catch(() => {
2811
3052
  });
@@ -2836,15 +3077,12 @@ function setupBufferListeners(client2, buffers) {
2836
3077
  startTs: ts
2837
3078
  };
2838
3079
  buffers.pending.set(params.requestId, partial2);
2839
- const aplusEvent = parseAplusRequest(url2);
2840
- if (aplusEvent) {
2841
- buffers.events.push(aplusEvent);
2842
- if (buffers.events.length > MAX_EVENTS) buffers.events.shift();
2843
- }
2844
- const armsEvent = parseArmsRequest(url2);
2845
- if (armsEvent) {
2846
- buffers.events.push(armsEvent);
2847
- if (buffers.events.length > MAX_EVENTS) buffers.events.shift();
3080
+ const captured = appendTrackingEvents(buffers, url2, params.request?.postData, id);
3081
+ if (!captured && params.request?.hasPostData && !params.request?.postData) {
3082
+ client2.sendCommand("Network.getRequestPostData", { requestId: params.requestId }, 1e4).then((result) => {
3083
+ appendTrackingEvents(buffers, url2, result?.postData, id);
3084
+ }).catch(() => {
3085
+ });
2848
3086
  }
2849
3087
  });
2850
3088
  client2.on("Network.responseReceived", (params) => {
@@ -3209,7 +3447,7 @@ var CdpSession = class {
3209
3447
  };
3210
3448
 
3211
3449
  // src/cdp-backend/controlled-indicator.ts
3212
- var CONTROLLED_FAVICON_DATA_URL = "data:image/x-icon;base64,AAABAAEAQEAAAAEAIACLBAAAFgAAAIlQTkcNChoKAAAADUlIRFIAAABAAAAAQAgGAAAAqmlx3gAABFJJREFUeNrtm+1PHEUcxz+/Wa0eh6/kwEpfYHgyJprYNAaTEqsxYGIiwQSsvGnKEeMb3/AGFfpGmmhf9A9QOfEhIWpTEmJiQnwqbVAbE2PUBJEjkqhYuPLGcmKxO+OL44jH0233bndO4PNy92bn+/3OzO7M7o2QFyO1PVcPK00bQjNwEDgERPOXDZU0hl8Rrghc1Jqx5HDs23yFZCfjdd2pDkQGBRpsu/PJtBEzkByKnQcxngOoe26hVlw1Ajxk20FxMF8r0V3TQ3f9kjeAhu7FowY5j1BpW3aRQ1hSojqnhyo+3zaA2u7Uo0oYB261LTcgVo2mJTkcm9gUQGPPlXu0cS4DMdsqg8UsaWiaTVQmAdTaQdHGeX/3mweQOxW8C0bWA2joSXWya254nkJ4u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/DXAakgWDZE3gh6dpSWVwAALt9OMHxn0dPD1LwCADAxazGRgx7Pi71APmkbwDaAbQDbALYBOFH8vu3oWb7V5xjA7fFFrA3qtezks2zLrfocA5iYtTh3dX5No1a+1rqxqnOrvow+j4PP/x9QLINg3Mf+542gUz4GMGkU+dvnAHTQr+4F6TfGaJ9fAdhKnySvxcXGQZ/2WfePR7sqnjUgqtgdPkyAD5IcgGQUzAwD9X6wrsrQaHd5I4guL4VFbUtPItz1gf85E5B3Vi5Sru4FxnpDv6ulx4GlIja/hLHfHOks/3XDzdBoT6jfGHkFiBVjz4vqa9HOysEtd4M/dpYPPRDqgW+LKedtS+tGukPfrJ8MNi8m1ZHYseXbVc8U6lSHSkf0fPmXm/8kDdVFYtW2scKoNAKVwH7y76LFAvAXMInKgB2QvrHOsrFUhf4D7h6pmvycyIkAAAAASUVORK5CYII=";
3213
3451
  var injectedSessions = /* @__PURE__ */ new WeakSet();
3214
3452
  var FAVICON_SCRIPT = `(() => {
3215
3453
  if (window !== window.top) return;
@@ -3938,21 +4176,27 @@ async function cdpGetLogs(session, data) {
3938
4176
  };
3939
4177
  }
3940
4178
  async function cdpGetEvents(session, data) {
3941
- const { since, limit = 100, filter } = data;
3942
- let events = [...session.buffers.events];
3943
- if (since !== void 0) {
3944
- events = events.filter((e) => e.batchTimestampMs >= since);
3945
- }
3946
- if (filter) {
3947
- const f = filter.toLowerCase();
3948
- events = events.filter(
3949
- (e) => e.event_type?.toLowerCase().includes(f) || e.name?.toLowerCase().includes(f) || e.url?.toLowerCase().includes(f)
3950
- );
3951
- }
3952
- events = events.slice(-limit);
4179
+ const { source = "all", event_type, since, limit = 20, filter } = data;
4180
+ const response = queryTrackingEvents(session.buffers.events, {
4181
+ source,
4182
+ event_type,
4183
+ since,
4184
+ limit,
4185
+ filter
4186
+ });
4187
+ const captureStatus = response.totalInBuffer === 0 ? "armed" : "active";
4188
+ const hint = response.events.length === 0 && captureStatus === "armed" ? TRACKING_CAPTURE_ARMED_HINT : void 0;
3953
4189
  return {
3954
- meta: { count: events.length, source: "cdp" },
3955
- events
4190
+ meta: {
4191
+ count: response.events.length,
4192
+ totalMatched: response.totalMatched,
4193
+ totalInBuffer: response.totalInBuffer,
4194
+ source,
4195
+ captureStatus,
4196
+ captureSource: "cdp",
4197
+ hint
4198
+ },
4199
+ events: response.events
3956
4200
  };
3957
4201
  }
3958
4202
  registerActions([
@@ -24687,7 +24931,7 @@ var ActiveSession = class _ActiveSession {
24687
24931
  return [prompt];
24688
24932
  }
24689
24933
  };
24690
- function parseParams(parser, params) {
24934
+ function parseParams2(parser, params) {
24691
24935
  if (!parser) {
24692
24936
  return params;
24693
24937
  }
@@ -24703,13 +24947,13 @@ function notificationSpec(method, params) {
24703
24947
  return { method, params };
24704
24948
  }
24705
24949
  function registerAppRequest(builder, spec, context, handler) {
24706
- builder.onReceiveRequest(spec.method, (params) => parseParams(spec.params, params), async (params, responder, cx) => {
24950
+ builder.onReceiveRequest(spec.method, (params) => parseParams2(spec.params, params), async (params, responder, cx) => {
24707
24951
  const response = await handler(context(params, cx, responder.signal, responder.id));
24708
24952
  await responder.respond(spec.mapResponse ? spec.mapResponse(response) : response);
24709
24953
  });
24710
24954
  }
24711
24955
  function registerAppNotification(builder, spec, context, handler) {
24712
- builder.onReceiveNotification(spec.method, (params) => parseParams(spec.params, params), (params, cx) => handler(context(params, cx, cx.signal)));
24956
+ builder.onReceiveNotification(spec.method, (params) => parseParams2(spec.params, params), (params, cx) => handler(context(params, cx, cx.signal)));
24713
24957
  }
24714
24958
  function specsByMethod(specs) {
24715
24959
  const byMethod = {};
@@ -26205,7 +26449,7 @@ ${output.stderr}`, "project")
26205
26449
  };
26206
26450
 
26207
26451
  // src/index.ts
26208
- var NATIVE_HOST_VERSION = true ? "2.0.0" : "unknown";
26452
+ var NATIVE_HOST_VERSION = true ? "2.0.1" : "unknown";
26209
26453
  var cliArgs = process.argv.slice(2);
26210
26454
  var cliArg = cliArgs[0];
26211
26455
  var isDaemonMode = cliArgs.includes("--daemon");
@@ -26277,6 +26521,7 @@ var DEFAULT_TIMEOUT_MS = 15e3;
26277
26521
  var INVENTORY_IDLE_EXIT_MS = 1e3;
26278
26522
  var extensionVersion = null;
26279
26523
  var versionWarningEmitted = false;
26524
+ var cdpPermissionNoticeLogged = false;
26280
26525
  var EXTENSION_INSTALL_URL = "https://chromewebstore.google.com/detail/mearl/aoehhjnofngknnjefamjbplchbolghkm";
26281
26526
  function majorMinor(version2) {
26282
26527
  const parts = version2.split(".");
@@ -26742,6 +26987,12 @@ async function handleSocketLine(socket, line) {
26742
26987
  if (useExtension) {
26743
26988
  result = await sendRequestToExtension(action, data, toTimeoutMs(action, data));
26744
26989
  } else {
26990
+ if (!cdpPermissionNoticeLogged) {
26991
+ cdpPermissionNoticeLogged = true;
26992
+ log(
26993
+ "CDP mode: domain permission checks are not enforced — all actions run without domain authorization"
26994
+ );
26995
+ }
26745
26996
  result = await handleViaCdp(action, data, toTimeoutMs(action, data));
26746
26997
  }
26747
26998
  trackAction(action, { success: true, transport: useExtension ? "extension" : "cdp" });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mearl/native-host",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Native Messaging Host for Mearl — bridges Chrome Extension and local socket server",
5
5
  "type": "module",
6
6
  "main": "dist/install.js",
@@ -32,8 +32,8 @@
32
32
  "@types/node": "^24.9.1",
33
33
  "esbuild": "^0.25.2",
34
34
  "typescript": "^5.8.3",
35
- "@mearl/daemon-core": "2.0.0",
36
- "@mearl/browser-core": "2.0.0"
35
+ "@mearl/browser-core": "2.0.1",
36
+ "@mearl/daemon-core": "2.0.1"
37
37
  },
38
38
  "scripts": {
39
39
  "build": "rm -rf dist/ && node build.mjs",