dsh-browser-playwright-codex 0.6.0 → 0.6.5

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.
@@ -1,43 +0,0 @@
1
- /**
2
- * shipped-gates — 「出厂包里那两个闸门到底是什么值」,只此一份实现。
3
- *
4
- * 为什么要单独成模块:这段逻辑被注释骗过一次(2026-10-02)。包里 0.4.7 起两个闸门都是
5
- * false,而 cordis.patch.yml 里同时写着「怎么开启」的注释示例 —— 里面先出现一行
6
- * `allowEvaluate: true`。一个不剥注释的正则会匹配到**注释**,于是 cost 脚本把出厂层
7
- * 报成 "两个都开着 / 22 工具 ≈ 4842",而真实是 "都关着 / 20 工具 ≈ 4176"。
8
- * 抽出来之后:脚本用它、守卫测试也用它(并对着一份独立解析比对),谁改坏了都会当场失败。
9
- */
10
- import { readFileSync } from 'node:fs'
11
-
12
- /**
13
- * Read the shipped bundle layer: what a deployment actually gets.
14
- *
15
- * Comment lines are stripped first, and that is not cosmetic: the file documents the
16
- * opt-in snippet, so a naive regex matches the *example* `allowEvaluate: true` inside a
17
- * comment. Attribute lines inside comments are documentation, not configuration.
18
- *
19
- * @param {URL} [patchUrl] - defaults to this package's cordis.patch.yml.
20
- * @returns {{ allowEvaluate: boolean, allowCdp: boolean }}
21
- */
22
- export function bundleConfig(patchUrl = new URL('../cordis.patch.yml', import.meta.url)) {
23
- const yml = readFileSync(patchUrl, 'utf8')
24
- const code = stripComments(yml)
25
- const row = code.split(/\n(?=\s*- id: )/).find((block) => block.includes('dsh-browser-playwright-codex/tool')) ?? ''
26
- if (row === '') throw new Error('cordis.patch.yml: no dsh-browser-playwright-codex/tool row found')
27
- const flag = (name) => new RegExp(name + ':\\s*(true|false)').exec(row)?.[1] === 'true'
28
- return { allowEvaluate: flag('allowEvaluate'), allowCdp: flag('allowCdp') }
29
- }
30
-
31
- /**
32
- * Drop `#` comments (full-line and trailing) so documentation examples cannot be read
33
- * as configuration. Exported so a guard test can compare an independent parse.
34
- * @param {string} yml
35
- * @returns {string}
36
- */
37
- export function stripComments(yml) {
38
- return yml
39
- .split('\n')
40
- .map((line) => line.replace(/\s+#.*$/, ''))
41
- .filter((line) => !/^\s*#/.test(line))
42
- .join('\n')
43
- }