extension-develop 4.0.18 → 4.0.19

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.
@@ -222,9 +222,6 @@ class LogRingBuffer {
222
222
  };
223
223
  }
224
224
  }
225
- const CLOSE_BAD_INSTANCE = 4001;
226
- const CLOSE_BAD_HELLO = 4002;
227
- const CLOSE_CONTROL_UNAVAILABLE = 4003;
228
225
  const DEFAULT_CMD_TIMEOUT_MS = 5000;
229
226
  const MAX_CMD_TIMEOUT_MS = 30000;
230
227
  const CONTROL_OPS = new Set([
@@ -398,7 +395,7 @@ class BridgeBroker {
398
395
  return true;
399
396
  }
400
397
  onHello(conn, hello) {
401
- if (1 !== hello.v) return void conn.close(CLOSE_BAD_HELLO, 'unsupported envelope version');
398
+ if (1 !== hello.v) return void conn.close(4002, 'unsupported envelope version');
402
399
  if (hello.instanceId !== this.instanceId) {
403
400
  if ('producer' === hello.role) {
404
401
  this.lastStaleHelloAt = this.now();
@@ -411,17 +408,17 @@ class BridgeBroker {
411
408
  });
412
409
  }
413
410
  }
414
- conn.close(CLOSE_BAD_INSTANCE, 'instanceId mismatch');
411
+ conn.close(4001, 'instanceId mismatch');
415
412
  return;
416
413
  }
417
414
  if ('controller' === hello.role) {
418
- if (!this.allowControl) return void conn.close(CLOSE_CONTROL_UNAVAILABLE, 'control channel not available');
415
+ if (!this.allowControl) return void conn.close(4003, 'control channel not available');
419
416
  this.roles.set(conn, 'controller');
420
417
  this.evalGate.set(conn, this.gateEval(hello.token));
421
418
  conn.send(this.controllerReady());
422
419
  return;
423
420
  }
424
- if ('producer' !== hello.role && 'consumer' !== hello.role) return void conn.close(CLOSE_BAD_HELLO, 'unknown role');
421
+ if ('producer' !== hello.role && 'consumer' !== hello.role) return void conn.close(4002, 'unknown role');
425
422
  this.roles.set(conn, hello.role);
426
423
  if ('producer' === hello.role) {
427
424
  this.producerEverConnected = true;
@@ -736,7 +733,6 @@ class LogsFileWriter {
736
733
  }
737
734
  }
738
735
  const SLOW_CONSUMER_BYTES = 8388608;
739
- const CLOSE_SLOW_CONSUMER = 4008;
740
736
  const PRODUCER_KEEPALIVE_INTERVAL_MS = 20000;
741
737
  let connSeq = 0;
742
738
  function startControlServer(options) {
@@ -757,7 +753,7 @@ function startControlServer(options) {
757
753
  if (socket.readyState !== WebSocket.OPEN) return;
758
754
  if (socket.bufferedAmount > SLOW_CONSUMER_BYTES) {
759
755
  try {
760
- socket.close(CLOSE_SLOW_CONSUMER, 'slow consumer');
756
+ socket.close(4008, 'slow consumer');
761
757
  } catch {}
762
758
  return;
763
759
  }
@@ -14,7 +14,7 @@ import node_fs from "node:fs";
14
14
  import node_path from "node:path";
15
15
  import { isResourceUnderDirs, canonicalizeDir, toResourceKey } from "./93.mjs";
16
16
  import { prefix as messaging_prefix, isDebug } from "./349.mjs";
17
- import { debugExtensionsToLoad, package_namespaceObject, getDirs, asAbsolute, browserRunnerDisabled, packagingDistributionFiles, PlaywrightPlugin, toPosixPath, resolveCompanionExtensionDirs, debugContextPath, isGeckoBasedBrowser, spacerLine, messages_ready, CHROMIUM_FAMILY_ALIASES, treeWithSourceAndDistFiles, treeWithDistFilesbrowser, computeExtensionsToLoad, noCompanionExtensionsResolved, treeWithSourceFiles, bundlerFatalError, bundlerRecompiling, noEntrypointsDetected, GECKO_FAMILY_ALIASES, packagingSourceFiles, debugBrowser, debugOutputPath, manifestInvalidJson, isChromiumBasedBrowser, getSpecialFoldersDataForCompiler } from "./101.mjs";
17
+ import { debugExtensionsToLoad, package_namespaceObject, getDirs, asAbsolute, browserRunnerDisabled, treeWithDistFilesBrowser, packagingDistributionFiles, toPosixPath, PlaywrightPlugin, debugContextPath, resolveCompanionExtensionDirs, isGeckoBasedBrowser, spacerLine, messages_ready, CHROMIUM_FAMILY_ALIASES, treeWithSourceAndDistFiles, computeExtensionsToLoad, noCompanionExtensionsResolved, treeWithSourceFiles, bundlerFatalError, bundlerRecompiling, noEntrypointsDetected, GECKO_FAMILY_ALIASES, packagingSourceFiles, debugBrowser, debugOutputPath, manifestInvalidJson, isChromiumBasedBrowser, getSpecialFoldersDataForCompiler } from "./101.mjs";
18
18
  import { unixify as paths_unixify, getManifestOverrides, isUsingTypeScript, resolvePackageManager, jsFrameworksIntegrationsEnabled, resolveRootAbsoluteRef, isStaticThemeSource, buildCanonicalManifest, getCurrentManifestContent, ensureTypeScriptConfig, resolveDevelopInstallRoot, filterKeysForThisBrowser as manifest_utils_filterKeysForThisBrowser, isUsingCustomLoader, getUserTypeScriptConfigFile, isUsingIntegration as messages_isUsingIntegration, reportToCompilation, normalizeManifestOutputPath, jsFrameworksHmrSummary, ReloadPlugin, humanLine, jsFrameworksConfigsDetected, collectRootAbsoluteRefs, getManifestContent, resolveDevelopDistFile, hasDependency, setOriginalManifestContent, isFromFilepathList, setCurrentManifestContent } from "./839.mjs";
19
19
  import { scrubBrand, makeSanitizedConsole } from "./0~branding.mjs";
20
20
  import { stripBom, parseJsonSafe } from "./23.mjs";
@@ -614,6 +614,11 @@ function resolveManifestName(rawName, manifest, searchRoots, fallback) {
614
614
  return fallback;
615
615
  }
616
616
  const toPosix = (p)=>p.replace(/\\/g, '/');
617
+ const COMPANION_DIR = 'extensions';
618
+ function isCompanionExtension(file) {
619
+ const [first] = toPosix(file).split('/');
620
+ return first === COMPANION_DIR;
621
+ }
617
622
  async function getFilesToZip(projectDir) {
618
623
  const gitignorePath = __rspack_external_node_path_c5b9b54f.join(projectDir, '.gitignore');
619
624
  const ig = ignore();
@@ -625,7 +630,7 @@ async function getFilesToZip(projectDir) {
625
630
  cwd: projectDir,
626
631
  dot: true
627
632
  });
628
- return files.filter((file)=>!ig.ignores(file));
633
+ return files.filter((file)=>!ig.ignores(file) && !isCompanionExtension(file));
629
634
  }
630
635
  class ZipPlugin {
631
636
  options;
@@ -688,7 +693,7 @@ class ZipPlugin {
688
693
  const distItem = created.find((c)=>'dist' === c.kind);
689
694
  if (sourceItem && distItem) console.log(treeWithSourceAndDistFiles(this.browser, name, sourceItem.path, distItem.path));
690
695
  else if (sourceItem) console.log(treeWithSourceFiles(name, 'zip', this.browser, sourceItem.path));
691
- else if (distItem) console.log(treeWithDistFilesbrowser(name, 'zip', this.browser, distItem.path));
696
+ else if (distItem) console.log(treeWithDistFilesBrowser(name, 'zip', this.browser, distItem.path));
692
697
  }
693
698
  } catch (error) {
694
699
  if (stats?.compilation?.warnings) stats.compilation.warnings.push(new Error(`ZipPlugin: Failed to create zip(s): ${String(error)}`));
package/dist/101.mjs CHANGED
@@ -214,7 +214,7 @@ function packagingDistributionFiles(zipPath) {
214
214
  function treeWithSourceAndDistFiles(browser, name, sourceZip, destZip) {
215
215
  return `${messaging_prefix('debug')} zip name=${name} browser=${String(browser)} source=${sourceZip} dist=${destZip}`;
216
216
  }
217
- function treeWithDistFilesbrowser(name, ext, browser, zipPath) {
217
+ function treeWithDistFilesBrowser(name, ext, browser, zipPath) {
218
218
  return `${messaging_prefix('debug')} zip name=${name}.${ext} browser=${String(browser)} dist=${zipPath}`;
219
219
  }
220
220
  function treeWithSourceFiles(name, ext, browser, zipPath) {
@@ -643,7 +643,7 @@ async function config_loader_isUsingExperimentalConfig(projectPath) {
643
643
  }
644
644
  return false;
645
645
  }
646
- var package_namespaceObject = /*#__PURE__*/ JSON.parse('{"rE":"4.0.18","El":{"@prefresh/core":"1.5.9","@prefresh/utils":"1.2.1","@rspack/core":"^2.1.1","@rspack/dev-server":"2.1.0","@rspack/plugin-preact-refresh":"2.0.1","@rspack/plugin-react-refresh":"2.0.2","@vue/compiler-sfc":"3.5.26","acorn":"^8.16.0","adm-zip":"^0.6.0","browser-extension-manifest-fields":"^2.2.9","case-sensitive-paths-webpack-plugin":"^2.4.0","content-security-policy-parser":"^0.6.0","dotenv":"^17.2.3","es-module-lexer":"^2.1.0","extension-from-store":"^0.1.1","go-git-it":"^5.1.5","ignore":"^7.0.5","less":"4.6.7","less-loader":"13.0.0","parse5-utilities":"^1.0.0","pintor":"0.3.0","postcss":"8.5.18","postcss-loader":"8.2.1","postcss-preset-env":"11.1.1","postcss-scss":"4.0.9","preact":"10.27.3","prefers-yarn":"2.0.1","react-refresh":"0.18.0","sass-loader":"17.0.0","schema-utils":"^4.3.3","svelte-loader":"3.2.4","tiny-glob":"^0.2.9","vue":"3.5.26","vue-loader":"17.4.2","webextension-polyfill":"^0.12.0","webpack-merge":"^6.0.1","webpack-target-webextension":"^2.1.3","ws":"^8.20.1"}}');
646
+ var package_namespaceObject = /*#__PURE__*/ JSON.parse('{"rE":"4.0.19","El":{"@prefresh/core":"1.5.9","@prefresh/utils":"1.2.1","@rspack/core":"^2.1.1","@rspack/dev-server":"2.1.0","@rspack/plugin-preact-refresh":"2.0.1","@rspack/plugin-react-refresh":"2.0.2","@vue/compiler-sfc":"3.5.26","acorn":"^8.16.0","adm-zip":"^0.6.0","browser-extension-manifest-fields":"^2.2.9","case-sensitive-paths-webpack-plugin":"^2.4.0","content-security-policy-parser":"^0.6.0","dotenv":"^17.2.3","es-module-lexer":"^2.1.0","extension-from-store":"^0.1.1","go-git-it":"^5.1.5","ignore":"^7.0.5","less":"4.6.7","less-loader":"13.0.0","parse5-utilities":"^1.0.0","pintor":"0.3.0","postcss":"8.5.18","postcss-loader":"8.2.1","postcss-preset-env":"11.1.1","postcss-scss":"4.0.9","preact":"10.27.3","prefers-yarn":"2.0.1","react-refresh":"0.18.0","sass-loader":"17.0.0","schema-utils":"^4.3.3","svelte-loader":"3.2.4","tiny-glob":"^0.2.9","vue":"3.5.26","vue-loader":"17.4.2","webextension-polyfill":"^0.12.0","webpack-merge":"^6.0.1","webpack-target-webextension":"^2.1.3","ws":"^8.20.1"}}');
647
647
  function asAbsolute(p) {
648
648
  return __rspack_external_node_path_c5b9b54f.isAbsolute(p) ? p : __rspack_external_node_path_c5b9b54f.resolve(p);
649
649
  }
@@ -2234,4 +2234,4 @@ async function extensionPreview(pathOrRemoteUrl, previewOptions, browserLauncher
2234
2234
  await browserLauncher(resolvedOpts);
2235
2235
  metadata.writeReady();
2236
2236
  }
2237
- export { CHROMIUM_FAMILY_ALIASES, GECKO_FAMILY_ALIASES, PlaywrightPlugin, asAbsolute, assertNoManagedDependencyConflicts, authorInstallNotice, autoExitForceKill, autoExitModeEnabled, autoExitTriggered, browserLaunchFailed, browserRunnerDisabled, buildCommandFailed, buildSuccess, buildSuccessWithWarnings, buildWarningsDetails, buildWebpack, bundlerFatalError, bundlerRecompiling, computeExtensionsToLoad, createPlaywrightMetadataWriter, debugBrowser, debugContextPath, debugDirs, debugExtensionsToLoad, debugOutputPath, devCommandFailed, devServerStartTimeout, downloadingText, extensionJsRunnerError, extensionLoadRecovered, extensionLoadStillRefused, extensionPreview, failedToDownloadOrExtractZIPFileError, getDirs, getDistPath, getProjectStructure, getSessionRunId, getSpecialFoldersDataForCompiler, getSpecialFoldersDataForProjectRoot, invalidRemoteZip, isChromiumBasedBrowser, isGeckoBasedBrowser, loadBrowserConfig, loadCommandConfig, loadCustomConfig, localZipNotFound, manifestInvalidJson, messages_ready, needsInstall, noCompanionExtensionsResolved, noEntrypointsDetected, normalizeBrowser, notAZipArchive, package_namespaceObject, packagingDistributionFiles, packagingSourceFiles, portInUse, projectInstallFallbackToNpm, projectInstallScriptsDisabled, resolveCompanionExtensionDirs, resolveCompanionExtensionsConfig, sanitize, spacerLine, toPosixPath, treeWithDistFilesbrowser, treeWithSourceAndDistFiles, treeWithSourceFiles, unpackagedSuccessfully, unpackagingExtension, writingTypeDefinitions, writingTypeDefinitionsError };
2237
+ export { CHROMIUM_FAMILY_ALIASES, GECKO_FAMILY_ALIASES, PlaywrightPlugin, asAbsolute, assertNoManagedDependencyConflicts, authorInstallNotice, autoExitForceKill, autoExitModeEnabled, autoExitTriggered, browserLaunchFailed, browserRunnerDisabled, buildCommandFailed, buildSuccess, buildSuccessWithWarnings, buildWarningsDetails, buildWebpack, bundlerFatalError, bundlerRecompiling, computeExtensionsToLoad, createPlaywrightMetadataWriter, debugBrowser, debugContextPath, debugDirs, debugExtensionsToLoad, debugOutputPath, devCommandFailed, devServerStartTimeout, downloadingText, extensionJsRunnerError, extensionLoadRecovered, extensionLoadStillRefused, extensionPreview, failedToDownloadOrExtractZIPFileError, getDirs, getDistPath, getProjectStructure, getSessionRunId, getSpecialFoldersDataForCompiler, getSpecialFoldersDataForProjectRoot, invalidRemoteZip, isChromiumBasedBrowser, isGeckoBasedBrowser, loadBrowserConfig, loadCommandConfig, loadCustomConfig, localZipNotFound, manifestInvalidJson, messages_ready, needsInstall, noCompanionExtensionsResolved, noEntrypointsDetected, normalizeBrowser, notAZipArchive, package_namespaceObject, packagingDistributionFiles, packagingSourceFiles, portInUse, projectInstallFallbackToNpm, projectInstallScriptsDisabled, resolveCompanionExtensionDirs, resolveCompanionExtensionsConfig, sanitize, spacerLine, toPosixPath, treeWithDistFilesBrowser, treeWithSourceAndDistFiles, treeWithSourceFiles, unpackagedSuccessfully, unpackagingExtension, writingTypeDefinitions, writingTypeDefinitionsError };
package/dist/494.mjs CHANGED
@@ -51,4 +51,4 @@ function actionsPath(projectPath, browser) {
51
51
  function buildSummaryPath(projectPath, browser) {
52
52
  return __rspack_external_node_path_c5b9b54f.join(browserArtifactsDir(projectPath, browser), 'build-summary.json');
53
53
  }
54
- export { actionsPath, browserArtifactsDir, buildSummaryPath, controlPortFilePath, controlTokenPath, ensureSessionArtifactsIgnoreFile, eventsPath, legacyControlPortFilePath, legacyControlTokenPath, logsPath, readyContractPath };
54
+ export { actionsPath, browserArtifactsDir, buildSummaryPath, controlPortFilePath, controlTokenPath, ensureSessionArtifactsIgnoreFile, eventsPath, legacyControlPortFilePath, legacyControlTokenPath, logsPath, readyContractPath, sessionArtifactsRootDir, sessionStateDir };
package/dist/839.mjs CHANGED
@@ -271,7 +271,7 @@ function attachLifecycleStream(compiler, stream) {
271
271
  }
272
272
  const MAX_SUMMARY_WARNINGS = 20;
273
273
  const build_summary_ANSI_PATTERN = /\u001b\[[0-9;]*m/g;
274
- function getBuildSummary(browser, info) {
274
+ function getBuildSummary(browser, info, outputPath) {
275
275
  const assets = info?.assets || [];
276
276
  const warnings = (info?.warnings || []).slice(0, MAX_SUMMARY_WARNINGS).map((warning)=>{
277
277
  const message = warning && 'object' == typeof warning ? String(warning.message ?? '') : String(warning ?? '');
@@ -279,6 +279,9 @@ function getBuildSummary(browser, info) {
279
279
  }).filter(Boolean);
280
280
  return {
281
281
  browser,
282
+ ...outputPath ? {
283
+ output_path: outputPath
284
+ } : {},
282
285
  total_assets: assets.length,
283
286
  total_bytes: assets.reduce((n, a)=>n + (a.size || 0), 0),
284
287
  largest_asset_bytes: assets.reduce((m, a)=>Math.max(m, a.size || 0), 0),
@@ -1022,6 +1025,7 @@ async function extensionBuild(pathOrRemoteUrl, buildOptions) {
1022
1025
  const compiler = rspack(compilerConfig);
1023
1026
  let summary = {
1024
1027
  browser,
1028
+ output_path: distPath,
1025
1029
  total_assets: 0,
1026
1030
  total_bytes: 0,
1027
1031
  largest_asset_bytes: 0,
@@ -1049,7 +1053,7 @@ async function extensionBuild(pathOrRemoteUrl, buildOptions) {
1049
1053
  warnings: true,
1050
1054
  errors: true
1051
1055
  });
1052
- summary = getBuildSummary(browser, info);
1056
+ summary = getBuildSummary(browser, info, distPath);
1053
1057
  try {
1054
1058
  const summaryFile = buildSummaryPath(packageJsonDir, browser);
1055
1059
  __rspack_external_node_fs_5ea92f0c.mkdirSync(__rspack_external_node_path_c5b9b54f.dirname(summaryFile), {
@@ -1069,13 +1073,22 @@ async function extensionBuild(pathOrRemoteUrl, buildOptions) {
1069
1073
  });
1070
1074
  if (('safari' === browser || 'webkit-based' === browser) && buildOptions?.safariPackager) {
1071
1075
  const safariConfig = await loadBrowserConfig(packageJsonDir, browser);
1072
- await buildOptions.safariPackager(distPath, 'full', {
1076
+ const safari = await buildOptions.safariPackager(distPath, 'full', {
1073
1077
  appName: buildOptions.appName ?? safariConfig.appName,
1074
1078
  bundleId: buildOptions.bundleId ?? safariConfig.bundleId,
1075
1079
  macOsOnly: buildOptions.macOsOnly ?? safariConfig.macOsOnly,
1076
1080
  forceRegenerate: buildOptions.forceRegenerate,
1077
1081
  safariBinary: buildOptions.safariBinary ?? safariConfig.safariBinary
1078
1082
  });
1083
+ if (safari) {
1084
+ summary = {
1085
+ ...summary,
1086
+ safari
1087
+ };
1088
+ try {
1089
+ __rspack_external_node_fs_5ea92f0c.writeFileSync(buildSummaryPath(packageJsonDir, browser), JSON.stringify(summary));
1090
+ } catch {}
1091
+ }
1079
1092
  }
1080
1093
  return summary;
1081
1094
  } catch (error) {
@@ -1,5 +1,8 @@
1
1
  export { BridgeConsumer, type ConsumerOptions, type ReadyContractInfo, readReadyContract } from './dev-server/control-bridge/consumer-client';
2
2
  export type { BridgeTarget, CommandOp, GapFrame, LogContext, LogEvent, LogLevel, ReadyFrame, ResultFrame } from './dev-server/control-bridge/contracts';
3
+ export { CLOSE_BAD_HELLO, CLOSE_BAD_INSTANCE, CLOSE_CONTROL_UNAVAILABLE, CLOSE_SLOW_CONSUMER, CONTROL_ENVELOPE_VERSION, CONTROL_WS_PATH, LOG_EVENT_VERSION } from './dev-server/control-bridge/contracts';
3
4
  export { controlPortFilePath, readPersistedControlPort } from './dev-server/control-bridge/control-port-store';
4
5
  export { BridgeController, type CommandInput, type ControllerOptions } from './dev-server/control-bridge/controller-client';
6
+ export { LOG_LEVEL_ORDER, type LogQuery, logLevelRank, matchesLogQuery, readLogEvents } from './dev-server/control-bridge/logs-query';
5
7
  export { controlTokenPath, readControlToken } from './dev-server/control-bridge/session-token';
8
+ export { actionsPath, browserArtifactsDir, buildSummaryPath, eventsPath, logsPath, readyContractPath, sessionArtifactsRootDir, sessionStateDir } from './lib/session-paths';
package/dist/bridge.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createRequire as __extjsCreateRequire } from "node:module"; const require = __extjsCreateRequire(import.meta.url);
2
2
  import { WebSocket } from "ws";
3
- import { readyContractPath } from "./494.mjs";
3
+ import { readyContractPath, logsPath } from "./494.mjs";
4
4
  import { CONTROL_WS_PATH } from "./887.mjs";
5
5
  import * as __rspack_external_node_fs_5ea92f0c from "node:fs";
6
6
  function readReadyContract(projectPath, browser = 'chrome') {
@@ -232,6 +232,86 @@ class BridgeController {
232
232
  this.pending.clear();
233
233
  }
234
234
  }
235
- export { controlPortFilePath, controlTokenPath } from "./494.mjs";
236
- export { readControlToken, readPersistedControlPort } from "./887.mjs";
237
- export { BridgeConsumer, BridgeController, readReadyContract };
235
+ const LOG_LEVEL_ORDER = [
236
+ 'error',
237
+ 'warn',
238
+ 'info',
239
+ 'debug',
240
+ 'trace'
241
+ ];
242
+ function logLevelRank(level) {
243
+ const normalized = 'log' === level ? 'info' : level;
244
+ const index = LOG_LEVEL_ORDER.indexOf(normalized);
245
+ return -1 === index ? LOG_LEVEL_ORDER.length : index;
246
+ }
247
+ function toContextSet(context) {
248
+ if (null == context) return null;
249
+ const list = Array.isArray(context) ? context : String(context).split(',');
250
+ const names = list.map((name)=>name.trim()).filter(Boolean);
251
+ if (0 === names.length) return null;
252
+ if (1 === names.length && 'all' === names[0].toLowerCase()) return null;
253
+ return new Set(names);
254
+ }
255
+ function makeUrlMatcher(pattern) {
256
+ const escaped = pattern.includes('*') ? pattern.replace(/[.+?^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.*') : null;
257
+ const expression = null == escaped ? null : new RegExp(escaped);
258
+ return (event)=>{
259
+ const candidates = [
260
+ event.url,
261
+ event.hostname
262
+ ].filter((value)=>'string' == typeof value);
263
+ if (0 === candidates.length) return false;
264
+ return candidates.some((candidate)=>expression ? expression.test(candidate) : candidate.includes(pattern));
265
+ };
266
+ }
267
+ function toFiniteNumber(value) {
268
+ if (null == value || '' === value) return null;
269
+ const parsed = 'number' == typeof value ? value : Number(value);
270
+ return Number.isFinite(parsed) ? parsed : null;
271
+ }
272
+ function matchesLogQuery(event, query) {
273
+ if (!event || 'object' != typeof event) return false;
274
+ if ('header' === event.type) return false;
275
+ if (query.signalsOnly && 'dx.signal' !== event.eventType) return false;
276
+ const contexts = toContextSet(query.context);
277
+ if (contexts && !contexts.has(String(event.context))) return false;
278
+ const minLevel = String(query.level ?? 'all').toLowerCase();
279
+ if ('all' !== minLevel && 'off' !== minLevel) {
280
+ if (logLevelRank(String(event.level || '')) > logLevelRank(minLevel)) return false;
281
+ }
282
+ const since = toFiniteNumber(query.since);
283
+ if (null != since && 'number' == typeof event.seq && event.seq <= since) return false;
284
+ if (query.url && !makeUrlMatcher(query.url)(event)) return false;
285
+ const tabId = toFiniteNumber(query.tab);
286
+ if (null != tabId && event.tabId !== tabId) return false;
287
+ return true;
288
+ }
289
+ function readLogEvents(projectPath, browser = 'chrome', query = {}) {
290
+ let raw;
291
+ try {
292
+ raw = __rspack_external_node_fs_5ea92f0c.readFileSync(logsPath(projectPath, browser), 'utf-8');
293
+ } catch {
294
+ return [];
295
+ }
296
+ const events = [];
297
+ for (const line of raw.split('\n')){
298
+ if (!line) continue;
299
+ let event;
300
+ try {
301
+ event = JSON.parse(line);
302
+ } catch {
303
+ continue;
304
+ }
305
+ if (matchesLogQuery(event, query)) events.push(event);
306
+ }
307
+ return events;
308
+ }
309
+ var bridge_entry_CLOSE_BAD_HELLO = 4002;
310
+ var bridge_entry_CLOSE_BAD_INSTANCE = 4001;
311
+ var bridge_entry_CLOSE_CONTROL_UNAVAILABLE = 4003;
312
+ var bridge_entry_CLOSE_SLOW_CONSUMER = 4008;
313
+ var bridge_entry_CONTROL_ENVELOPE_VERSION = 1;
314
+ var bridge_entry_LOG_EVENT_VERSION = 1;
315
+ export { CONTROL_WS_PATH, readControlToken, readPersistedControlPort } from "./887.mjs";
316
+ export { actionsPath, browserArtifactsDir, buildSummaryPath, controlPortFilePath, controlTokenPath, eventsPath, logsPath, readyContractPath, sessionArtifactsRootDir, sessionStateDir } from "./494.mjs";
317
+ export { BridgeConsumer, BridgeController, LOG_LEVEL_ORDER, bridge_entry_CLOSE_BAD_HELLO as CLOSE_BAD_HELLO, bridge_entry_CLOSE_BAD_INSTANCE as CLOSE_BAD_INSTANCE, bridge_entry_CLOSE_CONTROL_UNAVAILABLE as CLOSE_CONTROL_UNAVAILABLE, bridge_entry_CLOSE_SLOW_CONSUMER as CLOSE_SLOW_CONSUMER, bridge_entry_CONTROL_ENVELOPE_VERSION as CONTROL_ENVELOPE_VERSION, bridge_entry_LOG_EVENT_VERSION as LOG_EVENT_VERSION, logLevelRank, matchesLogQuery, readLogEvents, readReadyContract };
@@ -6,7 +6,19 @@
6
6
  "value": {
7
7
  "projectPath": "/home/dev/my-extension",
8
8
  "browsers": ["chromium"],
9
- "mode": "production"
9
+ "mode": "production",
10
+ "summaries": [
11
+ {
12
+ "browser": "chromium",
13
+ "output_path": "/home/dev/my-extension/dist/chromium",
14
+ "total_assets": 12,
15
+ "total_bytes": 248320,
16
+ "largest_asset_bytes": 131072,
17
+ "warnings_count": 1,
18
+ "errors_count": 0,
19
+ "warnings": ["Asset size exceeds the recommended limit (128 KiB)."]
20
+ }
21
+ ]
10
22
  },
11
23
  "error": null,
12
24
  "warnings": []
@@ -23,9 +23,7 @@ export interface BridgeBrokerOptions {
23
23
  clearTimer?: (handle: ReturnType<typeof setTimeout>) => void;
24
24
  onExecutorAttached?: () => void;
25
25
  }
26
- export declare const CLOSE_BAD_INSTANCE = 4001;
27
- export declare const CLOSE_BAD_HELLO = 4002;
28
- export declare const CLOSE_CONTROL_UNAVAILABLE = 4003;
26
+ export { CLOSE_BAD_HELLO, CLOSE_BAD_INSTANCE, CLOSE_CONTROL_UNAVAILABLE, CLOSE_SLOW_CONSUMER } from './contracts';
29
27
  export declare const DEFAULT_CMD_TIMEOUT_MS = 5000;
30
28
  export declare const MAX_CMD_TIMEOUT_MS = 30000;
31
29
  export declare class BridgeBroker {
@@ -151,3 +151,11 @@ export type ClientFrame = HelloFrame | LogFrame | CommandFrame | ReloadAckFrame;
151
151
  export type ServerFrame = ReadyFrame | LogFrame | GapFrame | ResultFrame | ReloadFrame | PingFrame;
152
152
  export type AnyFrame = ClientFrame | ServerFrame;
153
153
  export declare const CONTROL_WS_PATH = "/extjs-control";
154
+ /** The hello named an instanceId from a previous dev session. */
155
+ export declare const CLOSE_BAD_INSTANCE = 4001;
156
+ /** The hello was malformed: wrong envelope version, or an unknown role. */
157
+ export declare const CLOSE_BAD_HELLO = 4002;
158
+ /** A controller dialed a session started without `--allow-control`. */
159
+ export declare const CLOSE_CONTROL_UNAVAILABLE = 4003;
160
+ /** The socket fell far enough behind that it was dropped to protect the broker. */
161
+ export declare const CLOSE_SLOW_CONSUMER = 4008;
@@ -0,0 +1,37 @@
1
+ /** Increasing verbosity; a level selects itself plus everything more severe. */
2
+ export declare const LOG_LEVEL_ORDER: readonly ['error', 'warn', 'info', 'debug', 'trace'];
3
+ export type LogLevelFilter = (typeof LOG_LEVEL_ORDER)[number] | 'all' | 'off' | (string & {});
4
+ export interface LogQuery {
5
+ /** One context, a comma-separated list, an array, or 'all'. */
6
+ context?: string | string[];
7
+ /** Minimum severity. 'all' and 'off' select every level. */
8
+ level?: LogLevelFilter;
9
+ /** Only structured dx.signal diagnostics. */
10
+ signalsOnly?: boolean;
11
+ /** Only events whose seq is strictly greater than this. */
12
+ since?: number | string;
13
+ /** Glob (`*` = any run of chars) or plain substring over url then hostname. */
14
+ url?: string;
15
+ /** Only events carrying this tab id. */
16
+ tab?: number | string;
17
+ }
18
+ /** A bridge log line as read off disk: dynamic, so the probed fields only. */
19
+ export interface LogEventLike {
20
+ type?: unknown;
21
+ eventType?: unknown;
22
+ context?: unknown;
23
+ level?: unknown;
24
+ seq?: unknown;
25
+ url?: unknown;
26
+ hostname?: unknown;
27
+ tabId?: unknown;
28
+ }
29
+ export declare function logLevelRank(level: string): number;
30
+ /** True when the event passes every clause of the query. */
31
+ export declare function matchesLogQuery(event: LogEventLike, query: LogQuery): boolean;
32
+ /**
33
+ * One-shot read of a session's logs.ndjson. Returns an empty array when the
34
+ * session has never written one: an absent file is "nothing logged yet", and
35
+ * making that a throw would force every caller to guard it.
36
+ */
37
+ export declare function readLogEvents(projectPath: string, browser?: string, query?: LogQuery): LogEventLike[];
@@ -1,5 +1,22 @@
1
+ /**
2
+ * What the injected Safari packager reports back about the app it produced.
3
+ * `bundleIdDerived` is the load-bearing one: a generated `dev.extensionjs.*`
4
+ * identifier is fine locally and rejected by Apple for distribution, and the
5
+ * only other place that fact appeared was a human log line.
6
+ */
7
+ export interface SafariPackageSummary {
8
+ appName?: string;
9
+ bundleId?: string;
10
+ bundleIdDerived?: boolean;
11
+ appPath?: string;
12
+ xcodeProjectPath?: string;
13
+ macOsOnly?: boolean;
14
+ }
1
15
  export type BuildSummary = {
2
16
  browser: string;
17
+ /** Absolute dist directory the build emitted into. Hosts that shell out
18
+ * would otherwise have to re-derive `<project>/dist/<browser>` themselves. */
19
+ output_path?: string;
3
20
  total_assets: number;
4
21
  total_bytes: number;
5
22
  largest_asset_bytes: number;
@@ -8,6 +25,8 @@ export type BuildSummary = {
8
25
  /** Plain-text warning messages (ANSI-stripped, capped) so programmatic
9
26
  * consumers get a structured channel instead of scraping stdout. */
10
27
  warnings?: string[];
28
+ /** Present only for safari/webkit-based builds that ran the packager. */
29
+ safari?: SafariPackageSummary;
11
30
  };
12
31
  export declare function getBuildSummary(browser: string, info: {
13
32
  assets?: Array<{
@@ -15,4 +34,4 @@ export declare function getBuildSummary(browser: string, info: {
15
34
  }>;
16
35
  warnings?: unknown[];
17
36
  errors?: unknown[];
18
- } | null): BuildSummary;
37
+ } | null, outputPath?: string): BuildSummary;
@@ -40,7 +40,7 @@ export declare function downloadedProjectFolderNotFound(cwd: string, candidates:
40
40
  export declare function packagingSourceFiles(zipPath: string): string;
41
41
  export declare function packagingDistributionFiles(zipPath: string): string;
42
42
  export declare function treeWithSourceAndDistFiles(browser: DevOptions['browser'], name: string, sourceZip: string, destZip: string): string;
43
- export declare function treeWithDistFilesbrowser(name: string, ext: string, browser: DevOptions['browser'], zipPath: string): string;
43
+ export declare function treeWithDistFilesBrowser(name: string, ext: string, browser: DevOptions['browser'], zipPath: string): string;
44
44
  export declare function treeWithSourceFiles(name: string, ext: string, browser: DevOptions['browser'], zipPath: string): string;
45
45
  export declare function writingTypeDefinitions(manifest: Manifest): string;
46
46
  export declare function writingTypeDefinitionsError(error: unknown): string;
package/dist/module.d.ts CHANGED
@@ -2,7 +2,9 @@ import './lib/rust-min-stack';
2
2
  import { extensionBuild } from './command-build';
3
3
  import { extensionDev } from './command-dev';
4
4
  import { extensionPreview } from './command-preview';
5
+ import type { BuildSummary, SafariPackageSummary } from './lib/build-summary';
5
6
  import { type BrowserController, type BrowserLauncherFn, type BrowserLaunchOptions, BuildEmitter, type BuildErrorEvent, type CompiledEvent } from './plugin-browsers';
6
7
  import type { ReloadInstruction, ReloadType } from './plugin-reload';
7
- import type { BuildOptions, DevOptions, FileConfig, Manifest, PreviewOptions } from './types';
8
- export { extensionBuild, type BuildOptions, extensionDev, type DevOptions, extensionPreview, type PreviewOptions, type FileConfig, type Manifest, BuildEmitter, type CompiledEvent, type BuildErrorEvent, type ReloadType, type ReloadInstruction, type BrowserLauncherFn, type BrowserLaunchOptions, type BrowserController };
8
+ import type { CompanionExtensionsConfig } from './plugin-special-folders/folder-extensions/types';
9
+ import type { BrowserConfig, BrowserType, BuildOptions, DevOptions, FileConfig, Manifest, PreviewOptions, SafariPackagerFn, SafariPackagerOverrides, StartOptions } from './types';
10
+ export { extensionBuild, type BuildOptions, extensionDev, type DevOptions, extensionPreview, type PreviewOptions, type StartOptions, type FileConfig, type BrowserConfig, type BrowserType, type CompanionExtensionsConfig, type Manifest, type BuildSummary, type SafariPackageSummary, type SafariPackagerFn, type SafariPackagerOverrides, BuildEmitter, type CompiledEvent, type BuildErrorEvent, type ReloadType, type ReloadInstruction, type BrowserLauncherFn, type BrowserLaunchOptions, type BrowserController };
@@ -1,6 +1,6 @@
1
1
  import type { Compiler } from '@rspack/core';
2
2
  import { BuildEmitter, type RunnerPlugin } from './index';
3
- export type SafariPackagerFn = (distPath: string, mode: 'full' | 'resync') => Promise<void>;
3
+ export type SafariPackagerFn = (distPath: string, mode: 'full' | 'resync') => Promise<unknown>;
4
4
  export declare class SafariDevPlugin implements RunnerPlugin {
5
5
  private readonly packager;
6
6
  static readonly name = "safari-dev";
package/dist/types.d.ts CHANGED
@@ -56,6 +56,7 @@ export interface JsFramework {
56
56
  alias: Record<string, string> | undefined;
57
57
  }
58
58
  import type { Configuration } from '@rspack/core';
59
+ import type { SafariPackageSummary } from './lib/build-summary';
59
60
  import type { CompanionExtensionsConfig } from './plugin-special-folders/folder-extensions/types';
60
61
  export type BrowserType = 'chrome' | 'edge' | 'firefox' | 'chromium' | 'brave' | 'opera' | 'vivaldi' | 'yandex' | 'waterfox' | 'librewolf' | 'chromium-based' | 'gecko-based' | 'firefox-based' | 'safari' | 'webkit-based';
61
62
  export interface BrowserOptionsBase {
@@ -110,6 +111,13 @@ export interface SafariPackagerOverrides {
110
111
  forceRegenerate?: boolean;
111
112
  safariBinary?: string;
112
113
  }
114
+ /**
115
+ * The packaging callback develop calls once the Safari dist is on disk. The
116
+ * CLI injects `createSafariPackager()` from `extension/browsers`; a library
117
+ * caller must inject the same thing or no Safari app is produced at all.
118
+ * Returning a summary is optional so older packagers keep type-checking.
119
+ */
120
+ export type SafariPackagerFn = (distPath: string, mode: 'full' | 'resync', overrides?: SafariPackagerOverrides) => Promise<SafariPackageSummary | void>;
113
121
  export interface NonBinaryOptions extends BrowserOptionsBase {
114
122
  browser: Exclude<BrowserType, 'chromium-based' | 'gecko-based' | 'webkit-based'>;
115
123
  }
@@ -156,12 +164,23 @@ export interface DevOptions extends BrowserOptionsBase {
156
164
  logUrl?: string;
157
165
  logTab?: number | string;
158
166
  hashContentScripts?: boolean;
167
+ /**
168
+ * Open the agent-bridge control channel for the bounded act verbs
169
+ * (storage/reload/open). The CLI sets this from `--allow-control`.
170
+ */
171
+ allowControl?: boolean;
172
+ /**
173
+ * Additionally allow the `eval` verb, which runs arbitrary code inside a
174
+ * context and writes a 0600 session token. Only honored together with
175
+ * `allowControl`. The CLI sets this from `--allow-eval`.
176
+ */
177
+ allowEval?: boolean;
159
178
  exitOnError?: boolean;
160
179
  appName?: SafariOptions['appName'];
161
180
  bundleId?: SafariOptions['bundleId'];
162
181
  macOsOnly?: SafariOptions['macOsOnly'];
163
182
  forceRegenerate?: boolean;
164
- safariPackager?: (distPath: string, mode: 'full' | 'resync', overrides?: SafariPackagerOverrides) => Promise<void>;
183
+ safariPackager?: SafariPackagerFn;
165
184
  }
166
185
  export interface BuildOptions {
167
186
  browser: BrowserOptionsBase['browser'];
@@ -202,7 +221,7 @@ export interface BuildOptions {
202
221
  bundleId?: SafariOptions['bundleId'];
203
222
  macOsOnly?: SafariOptions['macOsOnly'];
204
223
  forceRegenerate?: boolean;
205
- safariPackager?: (distPath: string, mode: 'full' | 'resync', overrides?: SafariPackagerOverrides) => Promise<void>;
224
+ safariPackager?: SafariPackagerFn;
206
225
  }
207
226
  export interface PreviewOptions extends BrowserOptionsBase {
208
227
  mode: 'production';
package/package.json CHANGED
@@ -34,7 +34,7 @@
34
34
  "runtime"
35
35
  ],
36
36
  "name": "extension-develop",
37
- "version": "4.0.18",
37
+ "version": "4.0.19",
38
38
  "description": "Develop, build, preview, and package Extension.js projects.",
39
39
  "author": {
40
40
  "name": "Cezar Augusto",