@webext-core/proxy-service 1.2.2 → 2.0.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/lib/index.d.ts +40 -47
- package/lib/index.global.js +72 -234
- package/lib/index.js +61 -102
- package/lib/types.d.ts +15 -0
- package/package.json +10 -15
- package/lib/index.cjs +0 -173
package/lib/index.d.ts
CHANGED
|
@@ -1,63 +1,56 @@
|
|
|
1
|
-
import { ExtensionMessagingConfig } from '@webext-core/messaging';
|
|
1
|
+
import { ExtensionMessagingConfig, RemoveListenerCallback } from '@webext-core/messaging';
|
|
2
|
+
import { DeepAsync, Service } from './types.js';
|
|
2
3
|
|
|
3
|
-
type Proimsify<T> = T extends Promise<any> ? T : Promise<T>;
|
|
4
|
-
type Service = ((...args: any[]) => Promise<any>) | {
|
|
5
|
-
[key: string]: any | Service;
|
|
6
|
-
};
|
|
7
4
|
/**
|
|
8
5
|
* A type that ensures a service has only async methods.
|
|
6
|
+
*
|
|
9
7
|
* - ***If all methods are async***, it returns the original type.
|
|
10
8
|
* - ***If the service has non-async methods***, it returns a `DeepAsync` of the service.
|
|
11
9
|
*/
|
|
12
|
-
type ProxyService<
|
|
10
|
+
type ProxyService<T> = T extends DeepAsync<T> ? T : DeepAsync<T>;
|
|
13
11
|
/**
|
|
14
|
-
*
|
|
12
|
+
* Create a proxy service that uses the message APIs to proxy function calls to
|
|
13
|
+
* the real service registered in the background with `registerService`.
|
|
14
|
+
*
|
|
15
|
+
* @param key The service key to listen for, must be the same string as the one
|
|
16
|
+
* used in `registerService`.
|
|
15
17
|
*/
|
|
16
|
-
|
|
17
|
-
[key: string]: any;
|
|
18
|
-
} ? {
|
|
19
|
-
[fn in keyof TService]: DeepAsync<TService[fn]>;
|
|
20
|
-
} : never;
|
|
21
|
-
type ToAsyncFunction<T extends (...args: any) => any> = (...args: Parameters<T>) => Proimsify<ReturnType<T>>;
|
|
18
|
+
declare function createProxyService<T extends Service>(key: ProxyServiceKey<T> | string, config?: ExtensionMessagingConfig): ProxyService<T>;
|
|
22
19
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
20
|
+
* Sets up message listeners that receive messages from proxies created with
|
|
21
|
+
* `createProxyService`.
|
|
22
|
+
*
|
|
23
|
+
* @param key The service key to listen for, must be the same string as the one
|
|
24
|
+
* used in `createProxyService`.
|
|
25
|
+
* @param realService The real service instance that will handle the requests.
|
|
25
26
|
*/
|
|
26
|
-
|
|
27
|
+
declare function registerService<T extends Service, K extends string = ProxyServiceKey<T> | string>(key: K, realService: T, config?: ExtensionMessagingConfig): RemoveListenerCallback;
|
|
28
|
+
declare function isProxyService<T>(obj: unknown): obj is ProxyService<T>;
|
|
29
|
+
interface ProxyServiceConstraint<_> {
|
|
27
30
|
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Utility for creating a service whose functions are executed in the background script regardless
|
|
31
|
-
* of the JS context the they are called from.
|
|
32
|
-
*
|
|
33
|
-
* @param name A unique name for the service. Used to identify which service is being executed.
|
|
34
|
-
* @param init A function that returns your real service implementation. If args are listed,
|
|
35
|
-
* `registerService` will require the same set of arguments.
|
|
36
|
-
* @param config
|
|
37
|
-
* @returns
|
|
38
|
-
* - `registerService`: Used to register your service in the background
|
|
39
|
-
* - `getService`: Used to get an instance of the service anywhere in the extension.
|
|
40
|
-
*/
|
|
41
|
-
declare function defineProxyService<TService extends Service, TArgs extends any[]>(name: string, init: (...args: TArgs) => TService, config?: ProxyServiceConfig): [registerService: (...args: TArgs) => TService, getService: () => ProxyService<TService>];
|
|
42
|
-
|
|
43
31
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* > This can be used to simplify handling `Promise<Dependency>` passed in your services.
|
|
32
|
+
* Used to constrain a service's type between calls to `createProxyService` and
|
|
33
|
+
* `registerService`.
|
|
48
34
|
*
|
|
49
35
|
* @example
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
36
|
+
* ```ts
|
|
37
|
+
* // utils/proxy-service-keys.ts
|
|
38
|
+
* import type { ProxyServiceKey } from '@webext-core/proxy-service';
|
|
39
|
+
* import type { MathService } from './math-service';
|
|
40
|
+
*
|
|
41
|
+
* export const PROXY_SERVICE_KEY = 'math-service' as ProxyServiceKey<MathService>;
|
|
42
|
+
*
|
|
43
|
+
* // background.ts
|
|
44
|
+
* import { PROXY_SERVICE_KEY } from './utils/proxy-service-keys';
|
|
45
|
+
*
|
|
46
|
+
* registerService(PROXY_SERVICE_KEY, new MathService())
|
|
47
|
+
*
|
|
48
|
+
* // content-script.ts
|
|
49
|
+
* import { PROXY_SERVICE_KEY } from './utils/proxy-service-keys';
|
|
50
|
+
*
|
|
51
|
+
* const mathService = await createProxyService(PROXY_SERVICE_KEY);
|
|
52
|
+
* ```
|
|
60
53
|
*/
|
|
61
|
-
|
|
54
|
+
type ProxyServiceKey<T> = string & ProxyServiceConstraint<T>;
|
|
62
55
|
|
|
63
|
-
export {
|
|
56
|
+
export { ProxyService, ProxyServiceKey, createProxyService, isProxyService, registerService };
|
package/lib/index.global.js
CHANGED
|
@@ -4,9 +4,22 @@ var webExtCoreProxyService = (() => {
|
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
8
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
9
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
11
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
10
23
|
var __commonJS = (cb, mod) => function __require() {
|
|
11
24
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
12
25
|
};
|
|
@@ -1051,136 +1064,14 @@ var webExtCoreProxyService = (() => {
|
|
|
1051
1064
|
}
|
|
1052
1065
|
});
|
|
1053
1066
|
|
|
1054
|
-
// ../../node_modules/.bun/isobject@3.0.1/node_modules/isobject/index.js
|
|
1055
|
-
var require_isobject = __commonJS({
|
|
1056
|
-
"../../node_modules/.bun/isobject@3.0.1/node_modules/isobject/index.js"(exports, module) {
|
|
1057
|
-
"use strict";
|
|
1058
|
-
module.exports = function isObject(val) {
|
|
1059
|
-
return val != null && typeof val === "object" && Array.isArray(val) === false;
|
|
1060
|
-
};
|
|
1061
|
-
}
|
|
1062
|
-
});
|
|
1063
|
-
|
|
1064
|
-
// ../../node_modules/.bun/get-value@3.0.1/node_modules/get-value/index.js
|
|
1065
|
-
var require_get_value = __commonJS({
|
|
1066
|
-
"../../node_modules/.bun/get-value@3.0.1/node_modules/get-value/index.js"(exports, module) {
|
|
1067
|
-
var isObject = require_isobject();
|
|
1068
|
-
module.exports = function(target, path, options) {
|
|
1069
|
-
if (!isObject(options)) {
|
|
1070
|
-
options = { default: options };
|
|
1071
|
-
}
|
|
1072
|
-
if (!isValidObject(target)) {
|
|
1073
|
-
return typeof options.default !== "undefined" ? options.default : target;
|
|
1074
|
-
}
|
|
1075
|
-
if (typeof path === "number") {
|
|
1076
|
-
path = String(path);
|
|
1077
|
-
}
|
|
1078
|
-
const isArray = Array.isArray(path);
|
|
1079
|
-
const isString = typeof path === "string";
|
|
1080
|
-
const splitChar = options.separator || ".";
|
|
1081
|
-
const joinChar = options.joinChar || (typeof splitChar === "string" ? splitChar : ".");
|
|
1082
|
-
if (!isString && !isArray) {
|
|
1083
|
-
return target;
|
|
1084
|
-
}
|
|
1085
|
-
if (isString && path in target) {
|
|
1086
|
-
return isValid(path, target, options) ? target[path] : options.default;
|
|
1087
|
-
}
|
|
1088
|
-
let segs = isArray ? path : split(path, splitChar, options);
|
|
1089
|
-
let len = segs.length;
|
|
1090
|
-
let idx = 0;
|
|
1091
|
-
do {
|
|
1092
|
-
let prop = segs[idx];
|
|
1093
|
-
if (typeof prop === "number") {
|
|
1094
|
-
prop = String(prop);
|
|
1095
|
-
}
|
|
1096
|
-
while (prop && prop.slice(-1) === "\\") {
|
|
1097
|
-
prop = join([prop.slice(0, -1), segs[++idx] || ""], joinChar, options);
|
|
1098
|
-
}
|
|
1099
|
-
if (prop in target) {
|
|
1100
|
-
if (!isValid(prop, target, options)) {
|
|
1101
|
-
return options.default;
|
|
1102
|
-
}
|
|
1103
|
-
target = target[prop];
|
|
1104
|
-
} else {
|
|
1105
|
-
let hasProp = false;
|
|
1106
|
-
let n = idx + 1;
|
|
1107
|
-
while (n < len) {
|
|
1108
|
-
prop = join([prop, segs[n++]], joinChar, options);
|
|
1109
|
-
if (hasProp = prop in target) {
|
|
1110
|
-
if (!isValid(prop, target, options)) {
|
|
1111
|
-
return options.default;
|
|
1112
|
-
}
|
|
1113
|
-
target = target[prop];
|
|
1114
|
-
idx = n - 1;
|
|
1115
|
-
break;
|
|
1116
|
-
}
|
|
1117
|
-
}
|
|
1118
|
-
if (!hasProp) {
|
|
1119
|
-
return options.default;
|
|
1120
|
-
}
|
|
1121
|
-
}
|
|
1122
|
-
} while (++idx < len && isValidObject(target));
|
|
1123
|
-
if (idx === len) {
|
|
1124
|
-
return target;
|
|
1125
|
-
}
|
|
1126
|
-
return options.default;
|
|
1127
|
-
};
|
|
1128
|
-
function join(segs, joinChar, options) {
|
|
1129
|
-
if (typeof options.join === "function") {
|
|
1130
|
-
return options.join(segs);
|
|
1131
|
-
}
|
|
1132
|
-
return segs[0] + joinChar + segs[1];
|
|
1133
|
-
}
|
|
1134
|
-
function split(path, splitChar, options) {
|
|
1135
|
-
if (typeof options.split === "function") {
|
|
1136
|
-
return options.split(path);
|
|
1137
|
-
}
|
|
1138
|
-
return path.split(splitChar);
|
|
1139
|
-
}
|
|
1140
|
-
function isValid(key, target, options) {
|
|
1141
|
-
if (typeof options.isValid === "function") {
|
|
1142
|
-
return options.isValid(key, target);
|
|
1143
|
-
}
|
|
1144
|
-
return true;
|
|
1145
|
-
}
|
|
1146
|
-
function isValidObject(val) {
|
|
1147
|
-
return isObject(val) || Array.isArray(val) || typeof val === "function";
|
|
1148
|
-
}
|
|
1149
|
-
}
|
|
1150
|
-
});
|
|
1151
|
-
|
|
1152
1067
|
// src/index.ts
|
|
1153
1068
|
var src_exports = {};
|
|
1154
1069
|
__export(src_exports, {
|
|
1155
|
-
|
|
1156
|
-
|
|
1070
|
+
createProxyService: () => createProxyService,
|
|
1071
|
+
isProxyService: () => isProxyService,
|
|
1072
|
+
registerService: () => registerService
|
|
1157
1073
|
});
|
|
1158
1074
|
|
|
1159
|
-
// src/isBackground.ts
|
|
1160
|
-
var import_webextension_polyfill = __toESM(require_browser_polyfill(), 1);
|
|
1161
|
-
function isBackground() {
|
|
1162
|
-
if (!canAccessExtensionApi())
|
|
1163
|
-
return false;
|
|
1164
|
-
const manifest = import_webextension_polyfill.default.runtime.getManifest();
|
|
1165
|
-
if (!manifest.background)
|
|
1166
|
-
return false;
|
|
1167
|
-
return manifest.manifest_version === 3 ? isBackgroundServiceWorker() : isBackgroundPage();
|
|
1168
|
-
}
|
|
1169
|
-
function canAccessExtensionApi() {
|
|
1170
|
-
var _a;
|
|
1171
|
-
return !!((_a = import_webextension_polyfill.default.runtime) == null ? void 0 : _a.id);
|
|
1172
|
-
}
|
|
1173
|
-
var KNOWN_BACKGROUND_PAGE_PATHNAMES = [
|
|
1174
|
-
// Firefox
|
|
1175
|
-
"/_generated_background_page.html"
|
|
1176
|
-
];
|
|
1177
|
-
function isBackgroundPage() {
|
|
1178
|
-
return typeof window !== "undefined" && KNOWN_BACKGROUND_PAGE_PATHNAMES.includes(location.pathname);
|
|
1179
|
-
}
|
|
1180
|
-
function isBackgroundServiceWorker() {
|
|
1181
|
-
return typeof window === "undefined";
|
|
1182
|
-
}
|
|
1183
|
-
|
|
1184
1075
|
// ../../node_modules/.bun/serialize-error@11.0.3/node_modules/serialize-error/error-constructors.js
|
|
1185
1076
|
var list = [
|
|
1186
1077
|
// Native ES errors https://262.ecma-international.org/12.0/#sec-well-known-intrinsic-objects
|
|
@@ -1373,17 +1264,17 @@ var webExtCoreProxyService = (() => {
|
|
|
1373
1264
|
var __defProp2 = Object.defineProperty;
|
|
1374
1265
|
var __defProps = Object.defineProperties;
|
|
1375
1266
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
1376
|
-
var
|
|
1267
|
+
var __getOwnPropSymbols2 = Object.getOwnPropertySymbols;
|
|
1377
1268
|
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
1378
|
-
var
|
|
1269
|
+
var __propIsEnum2 = Object.prototype.propertyIsEnumerable;
|
|
1379
1270
|
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1380
|
-
var
|
|
1271
|
+
var __spreadValues2 = (a, b) => {
|
|
1381
1272
|
for (var prop in b || (b = {}))
|
|
1382
1273
|
if (__hasOwnProp2.call(b, prop))
|
|
1383
1274
|
__defNormalProp2(a, prop, b[prop]);
|
|
1384
|
-
if (
|
|
1385
|
-
for (var prop of
|
|
1386
|
-
if (
|
|
1275
|
+
if (__getOwnPropSymbols2)
|
|
1276
|
+
for (var prop of __getOwnPropSymbols2(b)) {
|
|
1277
|
+
if (__propIsEnum2.call(b, prop))
|
|
1387
1278
|
__defNormalProp2(a, prop, b[prop]);
|
|
1388
1279
|
}
|
|
1389
1280
|
return a;
|
|
@@ -1505,15 +1396,15 @@ var webExtCoreProxyService = (() => {
|
|
|
1505
1396
|
}
|
|
1506
1397
|
|
|
1507
1398
|
// ../messaging/lib/index.js
|
|
1508
|
-
var
|
|
1399
|
+
var import_webextension_polyfill = __toESM(require_browser_polyfill(), 1);
|
|
1509
1400
|
function defineExtensionMessaging(config) {
|
|
1510
|
-
return defineGenericMessanging(__spreadProps(
|
|
1401
|
+
return defineGenericMessanging(__spreadProps(__spreadValues2({}, config), {
|
|
1511
1402
|
sendMessage(message, arg) {
|
|
1512
1403
|
if (arg == null) {
|
|
1513
|
-
return
|
|
1404
|
+
return import_webextension_polyfill.default.runtime.sendMessage(message);
|
|
1514
1405
|
}
|
|
1515
1406
|
const options = typeof arg === "number" ? { tabId: arg } : arg;
|
|
1516
|
-
return
|
|
1407
|
+
return import_webextension_polyfill.default.tabs.sendMessage(
|
|
1517
1408
|
options.tabId,
|
|
1518
1409
|
message,
|
|
1519
1410
|
// Pass frameId if specified
|
|
@@ -1523,118 +1414,65 @@ var webExtCoreProxyService = (() => {
|
|
|
1523
1414
|
addRootListener(processMessage) {
|
|
1524
1415
|
const listener = (message, sender) => {
|
|
1525
1416
|
if (typeof message === "object")
|
|
1526
|
-
return processMessage(__spreadProps(
|
|
1417
|
+
return processMessage(__spreadProps(__spreadValues2({}, message), { sender }));
|
|
1527
1418
|
else
|
|
1528
1419
|
return processMessage(message);
|
|
1529
1420
|
};
|
|
1530
|
-
|
|
1531
|
-
return () =>
|
|
1421
|
+
import_webextension_polyfill.default.runtime.onMessage.addListener(listener);
|
|
1422
|
+
return () => import_webextension_polyfill.default.runtime.onMessage.removeListener(listener);
|
|
1532
1423
|
}
|
|
1533
1424
|
}));
|
|
1534
1425
|
}
|
|
1535
1426
|
|
|
1536
|
-
// src/
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
const
|
|
1542
|
-
|
|
1543
|
-
const
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1427
|
+
// src/index.ts
|
|
1428
|
+
function createProxyService(key, config) {
|
|
1429
|
+
return createProxy(defineProxyMessaging(key, config));
|
|
1430
|
+
}
|
|
1431
|
+
function registerService(key, realService, config) {
|
|
1432
|
+
const messenger = defineProxyMessaging(key, config);
|
|
1433
|
+
return messenger.onMessage(messenger.messageKey, ({ data }) => {
|
|
1434
|
+
const method = data.path == null ? realService : get(realService != null ? realService : {}, data.path);
|
|
1435
|
+
if (method)
|
|
1436
|
+
return Promise.resolve(method.bind(realService)(...data.args));
|
|
1437
|
+
});
|
|
1438
|
+
}
|
|
1439
|
+
function isProxyService(obj) {
|
|
1440
|
+
return (obj == null ? void 0 : obj[ProxyServiceSymbol]) === true;
|
|
1441
|
+
}
|
|
1442
|
+
function defineProxyMessaging(key, config) {
|
|
1443
|
+
const messaging = defineExtensionMessaging(config);
|
|
1444
|
+
return __spreadValues({
|
|
1445
|
+
messageKey: `proxy-service.${key}`
|
|
1446
|
+
}, messaging);
|
|
1447
|
+
}
|
|
1448
|
+
function createProxy(messenger, path) {
|
|
1449
|
+
const wrapped = () => {
|
|
1450
|
+
};
|
|
1451
|
+
const proxy = new Proxy(wrapped, {
|
|
1452
|
+
apply(_target, _thisArg, args) {
|
|
1453
|
+
return __async(this, null, function* () {
|
|
1454
|
+
const res = yield messenger.sendMessage(messenger.messageKey, {
|
|
1455
|
+
path,
|
|
1456
|
+
args
|
|
1554
1457
|
});
|
|
1555
|
-
|
|
1556
|
-
// Executed when accessing a property on an object
|
|
1557
|
-
get(target, propertyName, receiver) {
|
|
1558
|
-
if (propertyName === "__proxy" || typeof propertyName === "symbol") {
|
|
1559
|
-
return Reflect.get(target, propertyName, receiver);
|
|
1560
|
-
}
|
|
1561
|
-
return createProxy(path == null ? propertyName : `${path}.${propertyName}`);
|
|
1562
|
-
}
|
|
1563
|
-
});
|
|
1564
|
-
proxy.__proxy = true;
|
|
1565
|
-
return proxy;
|
|
1566
|
-
}
|
|
1567
|
-
return [
|
|
1568
|
-
function registerService(...args) {
|
|
1569
|
-
service = init(...args);
|
|
1570
|
-
onMessage(messageKey, ({ data }) => {
|
|
1571
|
-
const method = data.path == null ? service : (0, import_get_value.default)(service != null ? service : {}, data.path);
|
|
1572
|
-
if (method)
|
|
1573
|
-
return Promise.resolve(method.bind(service)(...data.args));
|
|
1458
|
+
return res;
|
|
1574
1459
|
});
|
|
1575
|
-
return service;
|
|
1576
1460
|
},
|
|
1577
|
-
|
|
1578
|
-
if (
|
|
1579
|
-
return
|
|
1580
|
-
if (service == null) {
|
|
1581
|
-
throw Error(
|
|
1582
|
-
`Failed to get an instance of ${name}: in background, but registerService has not been called. Did you forget to call registerService?`
|
|
1583
|
-
);
|
|
1461
|
+
get(target, propertyName, receiver) {
|
|
1462
|
+
if (typeof propertyName === "symbol") {
|
|
1463
|
+
return Reflect.get(target, propertyName, receiver);
|
|
1584
1464
|
}
|
|
1585
|
-
return
|
|
1465
|
+
return createProxy(messenger, path == null ? [propertyName] : path.concat([propertyName]));
|
|
1586
1466
|
}
|
|
1587
|
-
|
|
1467
|
+
});
|
|
1468
|
+
proxy[ProxyServiceSymbol] = true;
|
|
1469
|
+
return proxy;
|
|
1588
1470
|
}
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
const wrapped = () => {
|
|
1595
|
-
};
|
|
1596
|
-
const proxy = new Proxy(wrapped, {
|
|
1597
|
-
apply(_target, _thisArg, args) {
|
|
1598
|
-
return __async(this, null, function* () {
|
|
1599
|
-
const t = yield promise;
|
|
1600
|
-
const thisArg = (location2 == null ? void 0 : location2.parentPath) ? (0, import_get_value2.default)(t, location2.parentPath) : t;
|
|
1601
|
-
const fn = location2 ? (0, import_get_value2.default)(t, location2.propertyPath) : t;
|
|
1602
|
-
return fn.apply(thisArg, args);
|
|
1603
|
-
});
|
|
1604
|
-
},
|
|
1605
|
-
// Executed when accessing a property on an object
|
|
1606
|
-
get(target, propertyName, receiver) {
|
|
1607
|
-
if (propertyName === "__proxy" || typeof propertyName === "symbol") {
|
|
1608
|
-
return Reflect.get(target, propertyName, receiver);
|
|
1609
|
-
}
|
|
1610
|
-
return createProxy({
|
|
1611
|
-
propertyPath: location2 == null ? propertyName : `${location2.propertyPath}.${propertyName}`,
|
|
1612
|
-
parentPath: location2 == null ? void 0 : location2.propertyPath
|
|
1613
|
-
});
|
|
1614
|
-
}
|
|
1615
|
-
});
|
|
1616
|
-
proxy.__proxy = true;
|
|
1617
|
-
return proxy;
|
|
1618
|
-
}
|
|
1619
|
-
return createProxy();
|
|
1471
|
+
var ProxyServiceSymbol = Symbol();
|
|
1472
|
+
function get(obj, path) {
|
|
1473
|
+
if (path.length === 0)
|
|
1474
|
+
return obj;
|
|
1475
|
+
return path.reduce((acc, key) => acc == null ? void 0 : acc[key], obj);
|
|
1620
1476
|
}
|
|
1621
1477
|
return __toCommonJS(src_exports);
|
|
1622
1478
|
})();
|
|
1623
|
-
/*! Bundled license information:
|
|
1624
|
-
|
|
1625
|
-
isobject/index.js:
|
|
1626
|
-
(*!
|
|
1627
|
-
* isobject <https://github.com/jonschlinkert/isobject>
|
|
1628
|
-
*
|
|
1629
|
-
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
1630
|
-
* Released under the MIT License.
|
|
1631
|
-
*)
|
|
1632
|
-
|
|
1633
|
-
get-value/index.js:
|
|
1634
|
-
(*!
|
|
1635
|
-
* get-value <https://github.com/jonschlinkert/get-value>
|
|
1636
|
-
*
|
|
1637
|
-
* Copyright (c) 2014-2018, Jon Schlinkert.
|
|
1638
|
-
* Released under the MIT License.
|
|
1639
|
-
*)
|
|
1640
|
-
*/
|
package/lib/index.js
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
1
17
|
var __async = (__this, __arguments, generator) => {
|
|
2
18
|
return new Promise((resolve, reject) => {
|
|
3
19
|
var fulfilled = (value) => {
|
|
@@ -19,118 +35,61 @@ var __async = (__this, __arguments, generator) => {
|
|
|
19
35
|
});
|
|
20
36
|
};
|
|
21
37
|
|
|
22
|
-
// src/
|
|
23
|
-
import
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (!manifest.background)
|
|
29
|
-
return false;
|
|
30
|
-
return manifest.manifest_version === 3 ? isBackgroundServiceWorker() : isBackgroundPage();
|
|
38
|
+
// src/index.ts
|
|
39
|
+
import {
|
|
40
|
+
defineExtensionMessaging
|
|
41
|
+
} from "@webext-core/messaging";
|
|
42
|
+
function createProxyService(key, config) {
|
|
43
|
+
return createProxy(defineProxyMessaging(key, config));
|
|
31
44
|
}
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
return
|
|
45
|
+
function registerService(key, realService, config) {
|
|
46
|
+
const messenger = defineProxyMessaging(key, config);
|
|
47
|
+
return messenger.onMessage(messenger.messageKey, ({ data }) => {
|
|
48
|
+
const method = data.path == null ? realService : get(realService != null ? realService : {}, data.path);
|
|
49
|
+
if (method)
|
|
50
|
+
return Promise.resolve(method.bind(realService)(...data.args));
|
|
51
|
+
});
|
|
35
52
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"/_generated_background_page.html"
|
|
39
|
-
];
|
|
40
|
-
function isBackgroundPage() {
|
|
41
|
-
return typeof window !== "undefined" && KNOWN_BACKGROUND_PAGE_PATHNAMES.includes(location.pathname);
|
|
53
|
+
function isProxyService(obj) {
|
|
54
|
+
return (obj == null ? void 0 : obj[ProxyServiceSymbol]) === true;
|
|
42
55
|
}
|
|
43
|
-
function
|
|
44
|
-
|
|
56
|
+
function defineProxyMessaging(key, config) {
|
|
57
|
+
const messaging = defineExtensionMessaging(config);
|
|
58
|
+
return __spreadValues({
|
|
59
|
+
messageKey: `proxy-service.${key}`
|
|
60
|
+
}, messaging);
|
|
45
61
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const wrapped = () => {
|
|
56
|
-
};
|
|
57
|
-
const proxy = new Proxy(wrapped, {
|
|
58
|
-
// Executed when the object is called as a function
|
|
59
|
-
apply(_target, _thisArg, args) {
|
|
60
|
-
return __async(this, null, function* () {
|
|
61
|
-
const res = yield sendMessage(messageKey, {
|
|
62
|
-
path,
|
|
63
|
-
args
|
|
64
|
-
});
|
|
65
|
-
return res;
|
|
62
|
+
function createProxy(messenger, path) {
|
|
63
|
+
const wrapped = () => {
|
|
64
|
+
};
|
|
65
|
+
const proxy = new Proxy(wrapped, {
|
|
66
|
+
apply(_target, _thisArg, args) {
|
|
67
|
+
return __async(this, null, function* () {
|
|
68
|
+
const res = yield messenger.sendMessage(messenger.messageKey, {
|
|
69
|
+
path,
|
|
70
|
+
args
|
|
66
71
|
});
|
|
67
|
-
|
|
68
|
-
// Executed when accessing a property on an object
|
|
69
|
-
get(target, propertyName, receiver) {
|
|
70
|
-
if (propertyName === "__proxy" || typeof propertyName === "symbol") {
|
|
71
|
-
return Reflect.get(target, propertyName, receiver);
|
|
72
|
-
}
|
|
73
|
-
return createProxy(path == null ? propertyName : `${path}.${propertyName}`);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
proxy.__proxy = true;
|
|
77
|
-
return proxy;
|
|
78
|
-
}
|
|
79
|
-
return [
|
|
80
|
-
function registerService(...args) {
|
|
81
|
-
service = init(...args);
|
|
82
|
-
onMessage(messageKey, ({ data }) => {
|
|
83
|
-
const method = data.path == null ? service : get(service != null ? service : {}, data.path);
|
|
84
|
-
if (method)
|
|
85
|
-
return Promise.resolve(method.bind(service)(...data.args));
|
|
72
|
+
return res;
|
|
86
73
|
});
|
|
87
|
-
return service;
|
|
88
74
|
},
|
|
89
|
-
|
|
90
|
-
if (
|
|
91
|
-
return
|
|
92
|
-
if (service == null) {
|
|
93
|
-
throw Error(
|
|
94
|
-
`Failed to get an instance of ${name}: in background, but registerService has not been called. Did you forget to call registerService?`
|
|
95
|
-
);
|
|
75
|
+
get(target, propertyName, receiver) {
|
|
76
|
+
if (typeof propertyName === "symbol") {
|
|
77
|
+
return Reflect.get(target, propertyName, receiver);
|
|
96
78
|
}
|
|
97
|
-
return
|
|
79
|
+
return createProxy(messenger, path == null ? [propertyName] : path.concat([propertyName]));
|
|
98
80
|
}
|
|
99
|
-
|
|
81
|
+
});
|
|
82
|
+
proxy[ProxyServiceSymbol] = true;
|
|
83
|
+
return proxy;
|
|
100
84
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const wrapped = () => {
|
|
107
|
-
};
|
|
108
|
-
const proxy = new Proxy(wrapped, {
|
|
109
|
-
apply(_target, _thisArg, args) {
|
|
110
|
-
return __async(this, null, function* () {
|
|
111
|
-
const t = yield promise;
|
|
112
|
-
const thisArg = (location2 == null ? void 0 : location2.parentPath) ? get2(t, location2.parentPath) : t;
|
|
113
|
-
const fn = location2 ? get2(t, location2.propertyPath) : t;
|
|
114
|
-
return fn.apply(thisArg, args);
|
|
115
|
-
});
|
|
116
|
-
},
|
|
117
|
-
// Executed when accessing a property on an object
|
|
118
|
-
get(target, propertyName, receiver) {
|
|
119
|
-
if (propertyName === "__proxy" || typeof propertyName === "symbol") {
|
|
120
|
-
return Reflect.get(target, propertyName, receiver);
|
|
121
|
-
}
|
|
122
|
-
return createProxy({
|
|
123
|
-
propertyPath: location2 == null ? propertyName : `${location2.propertyPath}.${propertyName}`,
|
|
124
|
-
parentPath: location2 == null ? void 0 : location2.propertyPath
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
proxy.__proxy = true;
|
|
129
|
-
return proxy;
|
|
130
|
-
}
|
|
131
|
-
return createProxy();
|
|
85
|
+
var ProxyServiceSymbol = Symbol();
|
|
86
|
+
function get(obj, path) {
|
|
87
|
+
if (path.length === 0)
|
|
88
|
+
return obj;
|
|
89
|
+
return path.reduce((acc, key) => acc == null ? void 0 : acc[key], obj);
|
|
132
90
|
}
|
|
133
91
|
export {
|
|
134
|
-
|
|
135
|
-
|
|
92
|
+
createProxyService,
|
|
93
|
+
isProxyService,
|
|
94
|
+
registerService
|
|
136
95
|
};
|
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type Proimsify<T> = T extends Promise<any> ? T : Promise<T>;
|
|
2
|
+
type Service = ((...args: any[]) => Promise<any>) | {
|
|
3
|
+
[key: string]: any | Service;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* A recursive type that deeply converts all methods in `TService` to be async.
|
|
7
|
+
*/
|
|
8
|
+
type DeepAsync<TService> = TService extends (...args: any) => any ? ToAsyncFunction<TService> : TService extends {
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
} ? {
|
|
11
|
+
[fn in keyof TService]: DeepAsync<TService[fn]>;
|
|
12
|
+
} : never;
|
|
13
|
+
type ToAsyncFunction<T extends (...args: any) => any> = (...args: Parameters<T>) => Proimsify<ReturnType<T>>;
|
|
14
|
+
|
|
15
|
+
export { DeepAsync, Proimsify, Service };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webext-core/proxy-service",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "A type-safe wrapper around the web extension messaging APIs that lets you call a function from anywhere, but execute it in the background. Supports all browsers (Chrome, Firefox, Safari, etc)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -35,29 +35,24 @@
|
|
|
35
35
|
"types": "lib/index.d.ts",
|
|
36
36
|
"exports": {
|
|
37
37
|
".": {
|
|
38
|
-
"types": "lib/index.d.ts",
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
"types": "./lib/index.d.ts",
|
|
39
|
+
"default": "./lib/index.js"
|
|
40
|
+
},
|
|
41
|
+
"./types": "./lib/types.d.ts"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
|
-
"build": "buildc -- tsup
|
|
44
|
+
"build": "buildc -- tsup",
|
|
45
45
|
"test": "buildc --deps-only -- vitest -r src",
|
|
46
46
|
"test:coverage": "buildc --deps-only -- vitest run -r src --coverage",
|
|
47
|
-
"check": "buildc --deps-only --
|
|
48
|
-
"check:typescript": "tsc --noEmit",
|
|
49
|
-
"check:type-tests": "vitest run --typecheck types"
|
|
50
|
-
},
|
|
51
|
-
"dependencies": {
|
|
52
|
-
"get-value": "^3.0.1",
|
|
53
|
-
"webextension-polyfill": "^0.10.0"
|
|
47
|
+
"check": "buildc --deps-only -- tsc --noEmit"
|
|
54
48
|
},
|
|
55
49
|
"devDependencies": {
|
|
56
50
|
"@types/get-value": "^3.0.3",
|
|
57
51
|
"@types/webextension-polyfill": "^0.9.1",
|
|
58
|
-
"@webext-core/fake-browser": "1.3.
|
|
52
|
+
"@webext-core/fake-browser": "1.3.4",
|
|
59
53
|
"@webext-core/messaging": "2.3.0",
|
|
60
|
-
"tsconfig": "0.0.0"
|
|
54
|
+
"tsconfig": "0.0.0",
|
|
55
|
+
"webextension-polyfill": "^0.10.0"
|
|
61
56
|
},
|
|
62
57
|
"peerDependencies": {
|
|
63
58
|
"webextension-polyfill": ">=0.10.0",
|
package/lib/index.cjs
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var __async = (__this, __arguments, generator) => {
|
|
30
|
-
return new Promise((resolve, reject) => {
|
|
31
|
-
var fulfilled = (value) => {
|
|
32
|
-
try {
|
|
33
|
-
step(generator.next(value));
|
|
34
|
-
} catch (e) {
|
|
35
|
-
reject(e);
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var rejected = (value) => {
|
|
39
|
-
try {
|
|
40
|
-
step(generator.throw(value));
|
|
41
|
-
} catch (e) {
|
|
42
|
-
reject(e);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
46
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
// src/index.ts
|
|
51
|
-
var src_exports = {};
|
|
52
|
-
__export(src_exports, {
|
|
53
|
-
defineProxyService: () => defineProxyService,
|
|
54
|
-
flattenPromise: () => flattenPromise
|
|
55
|
-
});
|
|
56
|
-
module.exports = __toCommonJS(src_exports);
|
|
57
|
-
|
|
58
|
-
// src/isBackground.ts
|
|
59
|
-
var import_webextension_polyfill = __toESM(require("webextension-polyfill"), 1);
|
|
60
|
-
function isBackground() {
|
|
61
|
-
if (!canAccessExtensionApi())
|
|
62
|
-
return false;
|
|
63
|
-
const manifest = import_webextension_polyfill.default.runtime.getManifest();
|
|
64
|
-
if (!manifest.background)
|
|
65
|
-
return false;
|
|
66
|
-
return manifest.manifest_version === 3 ? isBackgroundServiceWorker() : isBackgroundPage();
|
|
67
|
-
}
|
|
68
|
-
function canAccessExtensionApi() {
|
|
69
|
-
var _a;
|
|
70
|
-
return !!((_a = import_webextension_polyfill.default.runtime) == null ? void 0 : _a.id);
|
|
71
|
-
}
|
|
72
|
-
var KNOWN_BACKGROUND_PAGE_PATHNAMES = [
|
|
73
|
-
// Firefox
|
|
74
|
-
"/_generated_background_page.html"
|
|
75
|
-
];
|
|
76
|
-
function isBackgroundPage() {
|
|
77
|
-
return typeof window !== "undefined" && KNOWN_BACKGROUND_PAGE_PATHNAMES.includes(location.pathname);
|
|
78
|
-
}
|
|
79
|
-
function isBackgroundServiceWorker() {
|
|
80
|
-
return typeof window === "undefined";
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// src/defineProxyService.ts
|
|
84
|
-
var import_messaging = require("@webext-core/messaging");
|
|
85
|
-
var import_get_value = __toESM(require("get-value"), 1);
|
|
86
|
-
function defineProxyService(name, init, config) {
|
|
87
|
-
let service;
|
|
88
|
-
const messageKey = `proxy-service.${name}`;
|
|
89
|
-
const { onMessage, sendMessage } = (0, import_messaging.defineExtensionMessaging)(config);
|
|
90
|
-
function createProxy(path) {
|
|
91
|
-
const wrapped = () => {
|
|
92
|
-
};
|
|
93
|
-
const proxy = new Proxy(wrapped, {
|
|
94
|
-
// Executed when the object is called as a function
|
|
95
|
-
apply(_target, _thisArg, args) {
|
|
96
|
-
return __async(this, null, function* () {
|
|
97
|
-
const res = yield sendMessage(messageKey, {
|
|
98
|
-
path,
|
|
99
|
-
args
|
|
100
|
-
});
|
|
101
|
-
return res;
|
|
102
|
-
});
|
|
103
|
-
},
|
|
104
|
-
// Executed when accessing a property on an object
|
|
105
|
-
get(target, propertyName, receiver) {
|
|
106
|
-
if (propertyName === "__proxy" || typeof propertyName === "symbol") {
|
|
107
|
-
return Reflect.get(target, propertyName, receiver);
|
|
108
|
-
}
|
|
109
|
-
return createProxy(path == null ? propertyName : `${path}.${propertyName}`);
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
proxy.__proxy = true;
|
|
113
|
-
return proxy;
|
|
114
|
-
}
|
|
115
|
-
return [
|
|
116
|
-
function registerService(...args) {
|
|
117
|
-
service = init(...args);
|
|
118
|
-
onMessage(messageKey, ({ data }) => {
|
|
119
|
-
const method = data.path == null ? service : (0, import_get_value.default)(service != null ? service : {}, data.path);
|
|
120
|
-
if (method)
|
|
121
|
-
return Promise.resolve(method.bind(service)(...data.args));
|
|
122
|
-
});
|
|
123
|
-
return service;
|
|
124
|
-
},
|
|
125
|
-
function getService() {
|
|
126
|
-
if (!isBackground())
|
|
127
|
-
return createProxy();
|
|
128
|
-
if (service == null) {
|
|
129
|
-
throw Error(
|
|
130
|
-
`Failed to get an instance of ${name}: in background, but registerService has not been called. Did you forget to call registerService?`
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
return service;
|
|
134
|
-
}
|
|
135
|
-
];
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// src/flattenPromise.ts
|
|
139
|
-
var import_get_value2 = __toESM(require("get-value"), 1);
|
|
140
|
-
function flattenPromise(promise) {
|
|
141
|
-
function createProxy(location2) {
|
|
142
|
-
const wrapped = () => {
|
|
143
|
-
};
|
|
144
|
-
const proxy = new Proxy(wrapped, {
|
|
145
|
-
apply(_target, _thisArg, args) {
|
|
146
|
-
return __async(this, null, function* () {
|
|
147
|
-
const t = yield promise;
|
|
148
|
-
const thisArg = (location2 == null ? void 0 : location2.parentPath) ? (0, import_get_value2.default)(t, location2.parentPath) : t;
|
|
149
|
-
const fn = location2 ? (0, import_get_value2.default)(t, location2.propertyPath) : t;
|
|
150
|
-
return fn.apply(thisArg, args);
|
|
151
|
-
});
|
|
152
|
-
},
|
|
153
|
-
// Executed when accessing a property on an object
|
|
154
|
-
get(target, propertyName, receiver) {
|
|
155
|
-
if (propertyName === "__proxy" || typeof propertyName === "symbol") {
|
|
156
|
-
return Reflect.get(target, propertyName, receiver);
|
|
157
|
-
}
|
|
158
|
-
return createProxy({
|
|
159
|
-
propertyPath: location2 == null ? propertyName : `${location2.propertyPath}.${propertyName}`,
|
|
160
|
-
parentPath: location2 == null ? void 0 : location2.propertyPath
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
proxy.__proxy = true;
|
|
165
|
-
return proxy;
|
|
166
|
-
}
|
|
167
|
-
return createProxy();
|
|
168
|
-
}
|
|
169
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
170
|
-
0 && (module.exports = {
|
|
171
|
-
defineProxyService,
|
|
172
|
-
flattenPromise
|
|
173
|
-
});
|