proxylang 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -313,7 +313,7 @@ const vless = proxy.vless({
313
313
  });
314
314
  ```
315
315
 
316
- 把这些值放进程序的 `nodes`,便可用 `route("ss")` 或策略组的 `members: ["ss", "vmess"]` 引用。还提供 `proxy.trojan`、`proxy.anytls`、`proxy.http`;已有对象声明仍可用。节点可带 `region`、`provider`、`tags`,供 `selectNodes` 组合筛选;`via` 引用另一个节点或组,声明拨号链。
316
+ 把这些值放进程序的 `nodes`,便可用 `route("ss")` 或策略组的 `members: ["ss", "vmess"]` 引用。还提供 `proxy.trojan`、`proxy.anytls`、`proxy.http`;已有对象声明仍可用。地区、供应商等业务信息由应用维护,通过普通数组选择代理或 ID;`via` 引用另一个节点或组,声明拨号链。
317
317
 
318
318
  TLS 的 `serverName` 是证书身份,WebSocket 的 `host` 是 HTTP Host,二者明确分开。省略 `tls` 表示不启用 TLS,省略 `transport` 表示普通 TCP。VMess 当前固定 AEAD/AES-128-GCM;VMess 与 VLESS 暂只允许 TCP 规则,不能作为覆盖 UDP 的 fallback。SS 支持三种 AEAD 方法及 TCP/UDP。
319
319
 
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { H as StaticRuleSetUnknownError, N as compile, P as explain, R as targetCatalog, i as buildToDirectory, n as defineBuild, q as requestSchema, r as runBuild, t as checkBuild } from "./profile-build-EO6TsFJ-.js";
2
+ import { K as requestSchema, L as targetCatalog, M as compile, N as explain, V as StaticRuleSetUnknownError, i as buildToDirectory, n as defineBuild, r as runBuild, t as checkBuild } from "./profile-build-DuHp9nQt.js";
3
3
  import { lstat, open, stat } from "node:fs/promises";
4
4
  import { resolve } from "node:path";
5
5
  import { pathToFileURL } from "node:url";
package/dist/index.d.ts CHANGED
@@ -98,9 +98,6 @@ export type ProxyBase = {
98
98
  readonly via?: string;
99
99
  readonly tcpFastOpen?: boolean;
100
100
  readonly label?: string;
101
- readonly region?: string;
102
- readonly provider?: string;
103
- readonly tags?: readonly string[];
104
101
  };
105
102
  export type ProxyTLS = {
106
103
  readonly serverName: string;
@@ -649,12 +646,6 @@ export declare function defineRoutes(input: {
649
646
  readonly when: readonly ProfileCondition[];
650
647
  readonly to: ProfileDestination;
651
648
  }): RouteDefinition[];
652
- export declare function selectProxies(nodes: readonly ProxyNode[], query?: {
653
- ids?: readonly string[];
654
- regions?: readonly string[];
655
- providers?: readonly string[];
656
- tags?: readonly string[];
657
- }): ProxyNode[];
658
649
  //#endregion
659
650
  //#region src/profile.d.ts
660
651
  type DeepReadonly<T> = T extends object ? { readonly [K in keyof T]: DeepReadonly<T[K]>; } : T;
@@ -833,12 +824,6 @@ export declare const defineConfig: <const T extends Config>(config: T & {
833
824
  readonly program: string extends NonNullable<NoInfer<T>["cases"]>[number]["program"] ? string : keyof NoInfer<T>["programs"] & string;
834
825
  })[];
835
826
  }) => T;
836
- /** Filtering is stable: catalogue order determines initial selector order. */
837
- export declare function selectNodes(nodes: readonly ProxyNode[], query?: {
838
- regions?: readonly string[];
839
- providers?: readonly string[];
840
- tags?: readonly string[];
841
- }): string[];
842
827
  /** A shared strategy declares an algorithm or explicitly selects native implementations. */
843
828
  export declare const strategy: (definition: StrategyDefinition) => Strategy;
844
829
  export declare const group: {
@@ -1162,7 +1147,7 @@ export declare function runBuild(input: BuildDefinition, output: string, options
1162
1147
  //#endregion
1163
1148
  //#region src/proxy-id.d.ts
1164
1149
  /** Stable identity independent of engine and mutable metadata. */
1165
- export declare function proxyId(provider: string, label: string): string;
1150
+ export declare function proxyId(namespace: string, label: string): string;
1166
1151
  //#endregion
1167
1152
  //#region src/secret-inputs.d.ts
1168
1153
  type SecretsInput = {
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as inspectDefinition, A as renderSurgeProfile, B as surgeProxy, C as slot, D as compileProfile, E as use, F as compileStrategyGroups, G as idSchema, H as StaticRuleSetUnknownError, I as isReservedNativeName, J as ProfileDefinitionError, K as nodeSchema, L as nativeNameSchema, M as secretReader, N as compile, O as defineProfile, P as explain, Q as exactDefinition, R as targetCatalog, S as singbox, T as surge, U as assertData, V as validateProxyOptions, W as deepFreeze, X as defineRoute, Y as defineProxyGroup, Z as defineRoutes, _ as rule, a as render, b as selectNodes, c as direct, d as match, et as outbound, f as mihomo, g as route, h as reject, i as buildToDirectory, j as renderSurgeProfiles, k as compileSurgeProfile, l as dnsRule, m as proxy, n as defineBuild, o as block, p as policy, r as runBuild, s as defineConfig, t as checkBuild, tt as selectProxies, u as group, v as ruleSet, w as strategy, x as sequence, y as secret, z as RenderError } from "./profile-build-EO6TsFJ-.js";
1
+ import { $ as outbound, A as renderSurgeProfiles, B as validateProxyOptions, C as strategy, D as defineProfile, E as compileProfile, F as isReservedNativeName, G as nodeSchema, H as assertData, I as nativeNameSchema, J as defineProxyGroup, L as targetCatalog, M as compile, N as explain, O as compileSurgeProfile, P as compileStrategyGroups, Q as inspectDefinition, R as RenderError, S as slot, T as use, U as deepFreeze, V as StaticRuleSetUnknownError, W as idSchema, X as defineRoutes, Y as defineRoute, Z as exactDefinition, _ as rule, a as render, b as sequence, c as direct, d as match, f as mihomo, g as route, h as reject, i as buildToDirectory, j as secretReader, k as renderSurgeProfile, l as dnsRule, m as proxy, n as defineBuild, o as block, p as policy, q as ProfileDefinitionError, r as runBuild, s as defineConfig, t as checkBuild, u as group, v as ruleSet, w as surge, x as singbox, y as secret, z as surgeProxy } from "./profile-build-DuHp9nQt.js";
2
2
  import { z } from "zod";
3
3
  import { createHash } from "node:crypto";
4
4
  //#region src/proxy-fragments.ts
@@ -132,9 +132,9 @@ function renderProxyNodes(compilation, resolveSecret) {
132
132
  //#endregion
133
133
  //#region src/proxy-id.ts
134
134
  /** Stable identity independent of engine and mutable metadata. */
135
- function proxyId(provider, label) {
136
- if (typeof provider !== "string" || !provider.length || typeof label !== "string" || !label.length) throw new Error("INVALID_PROXY_ID_INPUT");
137
- return `node-${createHash("sha256").update(JSON.stringify([provider, label])).digest("hex").slice(0, 16)}`;
135
+ function proxyId(namespace, label) {
136
+ if (typeof namespace !== "string" || !namespace.length || typeof label !== "string" || !label.length) throw new Error("INVALID_PROXY_ID_INPUT");
137
+ return `node-${createHash("sha256").update(JSON.stringify([namespace, label])).digest("hex").slice(0, 16)}`;
138
138
  }
139
139
  //#endregion
140
140
  //#region src/secret-inputs.ts
@@ -191,4 +191,4 @@ function secrets(input, environment = process.env) {
191
191
  };
192
192
  }
193
193
  //#endregion
194
- export { ProfileDefinitionError, RenderError, StaticRuleSetUnknownError, block, buildToDirectory, checkBuild, compile, compileProfile, compileProxyNodes, compileStrategyGroups, compileSurgeProfile, defineBuild, defineConfig, defineProfile, defineProxyGroup, defineRoute, defineRoutes, direct, dnsRule, explain, group, match, mihomo, outbound, policy, proxy, proxyId, reject, render, renderProxyNodes, renderSurgeProfile, renderSurgeProfiles, route, rule, ruleSet, runBuild, secret, secrets, selectNodes, selectProxies, sequence, singbox, slot, strategy, surge, targetCatalog, use };
194
+ export { ProfileDefinitionError, RenderError, StaticRuleSetUnknownError, block, buildToDirectory, checkBuild, compile, compileProfile, compileProxyNodes, compileStrategyGroups, compileSurgeProfile, defineBuild, defineConfig, defineProfile, defineProxyGroup, defineRoute, defineRoutes, direct, dnsRule, explain, group, match, mihomo, outbound, policy, proxy, proxyId, reject, render, renderProxyNodes, renderSurgeProfile, renderSurgeProfiles, route, rule, ruleSet, runBuild, secret, secrets, sequence, singbox, slot, strategy, surge, targetCatalog, use };
@@ -212,21 +212,6 @@ function defineRoutes(input) {
212
212
  to: input.to
213
213
  }));
214
214
  }
215
- function selectProxies(nodes, query = {}) {
216
- inspectDefinition({
217
- nodes,
218
- query
219
- });
220
- exactDefinition(query, [
221
- "ids",
222
- "regions",
223
- "providers",
224
- "tags"
225
- ]);
226
- if (!Array.isArray(nodes) || nodes.some((node) => !node || typeof node !== "object")) fail$1("DEFINITION_NOT_DATA");
227
- for (const values of Object.values(query)) if (values !== void 0 && !Array.isArray(values)) fail$1("DEFINITION_NOT_DATA");
228
- return nodes.filter((node) => (!query.ids || query.ids.includes(node.id)) && (!query.regions || node.region !== void 0 && query.regions.includes(node.region)) && (!query.providers || node.provider !== void 0 && query.providers.includes(node.provider)) && (!query.tags || query.tags.every((tag) => node.tags?.includes(tag))));
229
- }
230
215
  function lowerSurgeProfile(input) {
231
216
  inspectDefinition(input);
232
217
  exactDefinition(input, [
@@ -565,10 +550,7 @@ const nodeBase = {
565
550
  port: port$1,
566
551
  via: idSchema.optional(),
567
552
  tcpFastOpen: z.boolean().optional(),
568
- label: z.string().min(1).max(256).optional(),
569
- region: z.string().regex(/^[A-Z]{2}$/).optional(),
570
- provider: idSchema.optional(),
571
- tags: z.array(idSchema).refine(unique).optional()
553
+ label: z.string().min(1).max(256).optional()
572
554
  };
573
555
  const tlsSchema = z.strictObject({
574
556
  serverName: domain$1,
@@ -790,8 +772,9 @@ function assertData(value) {
790
772
  if (typeof v !== "object" || ancestors.has(v)) throw new Error("INPUT_GRAPH");
791
773
  if (!Array.isArray(v) && Object.getPrototypeOf(v) !== Object.prototype && Object.getPrototypeOf(v) !== null) throw new Error("INPUT_OBJECT");
792
774
  ancestors.add(v);
793
- for (const descriptor of Object.values(Object.getOwnPropertyDescriptors(v))) {
794
- if (descriptor.get || descriptor.set) throw new Error("INPUT_ACCESSOR");
775
+ for (const key of Reflect.ownKeys(v)) {
776
+ const descriptor = Object.getOwnPropertyDescriptor(v, key);
777
+ if (typeof key !== "string" || !("value" in descriptor) || !descriptor.enumerable && !(Array.isArray(v) && key === "length")) throw new Error("INPUT_OBJECT");
795
778
  visit(descriptor.value, depth + 1);
796
779
  }
797
780
  ancestors.delete(v);
@@ -2889,10 +2872,6 @@ const use = (definition, options) => ({
2889
2872
  });
2890
2873
  const sequence = (...parts) => parts.flatMap((part) => Array.isArray(part) ? part : [part]);
2891
2874
  const defineConfig = (config) => config;
2892
- /** Filtering is stable: catalogue order determines initial selector order. */
2893
- function selectNodes(nodes, query = {}) {
2894
- return nodes.filter((node) => (!query.regions || node.region !== void 0 && query.regions.includes(node.region)) && (!query.providers || node.provider !== void 0 && query.providers.includes(node.provider)) && (!query.tags || query.tags.every((tag) => node.tags?.includes(tag)))).map((node) => node.id);
2895
- }
2896
2875
  /** A shared strategy declares an algorithm or explicitly selects native implementations. */
2897
2876
  const strategy = (definition) => ({
2898
2877
  type: "strategy",
@@ -3599,4 +3578,4 @@ async function runBuild(input, output, options = {}) {
3599
3578
  };
3600
3579
  }
3601
3580
  //#endregion
3602
- export { inspectDefinition as $, renderSurgeProfile as A, surgeProxy as B, slot as C, compileProfile as D, use as E, compileStrategyGroups as F, idSchema as G, StaticRuleSetUnknownError as H, isReservedNativeName as I, ProfileDefinitionError as J, nodeSchema as K, nativeNameSchema as L, secretReader as M, compile as N, defineProfile as O, explain as P, exactDefinition as Q, targetCatalog as R, singbox$1 as S, surge$1 as T, assertData as U, validateProxyOptions as V, deepFreeze as W, defineRoute as X, defineProxyGroup as Y, defineRoutes as Z, rule as _, render as a, selectNodes as b, direct as c, match as d, outbound as et, mihomo as f, route as g, reject as h, buildToDirectory as i, renderSurgeProfiles as j, compileSurgeProfile as k, dnsRule as l, proxy as m, defineBuild as n, block as o, policy as p, requestSchema as q, runBuild as r, defineConfig as s, checkBuild as t, selectProxies as tt, group as u, ruleSet as v, strategy as w, sequence as x, secret as y, RenderError as z };
3581
+ export { outbound as $, renderSurgeProfiles as A, validateProxyOptions as B, strategy as C, defineProfile as D, compileProfile as E, isReservedNativeName as F, nodeSchema as G, assertData as H, nativeNameSchema as I, defineProxyGroup as J, requestSchema as K, targetCatalog as L, compile as M, explain as N, compileSurgeProfile as O, compileStrategyGroups as P, inspectDefinition as Q, RenderError as R, slot as S, use as T, deepFreeze as U, StaticRuleSetUnknownError as V, idSchema as W, defineRoutes as X, defineRoute as Y, exactDefinition as Z, rule as _, render as a, sequence as b, direct as c, match as d, mihomo as f, route as g, reject as h, buildToDirectory as i, secretReader as j, renderSurgeProfile as k, dnsRule as l, proxy as m, defineBuild as n, block as o, policy as p, ProfileDefinitionError as q, runBuild as r, defineConfig as s, checkBuild as t, group as u, ruleSet as v, surge$1 as w, singbox$1 as x, secret as y, surgeProxy as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "proxylang",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Composable routing policies in TypeScript with explicit platform targets",
5
5
  "homepage": "https://github.com/CorrectRoadH/proxylang#readme",
6
6
  "bugs": {