@fairfox/polly 0.88.1 → 0.89.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/dist/cli/polly.js +4 -4
- package/dist/cli/polly.js.map +2 -2
- package/dist/gallery/gallery.css +51 -59
- package/dist/gallery/gallery.js +1155 -1047
- package/dist/src/actions/index.js +5 -78
- package/dist/src/actions/index.js.map +2 -2
- package/dist/src/background/index.js +126 -152
- package/dist/src/background/index.js.map +4 -4
- package/dist/src/background/message-router.js +126 -152
- package/dist/src/background/message-router.js.map +4 -4
- package/dist/src/client/index.js +186 -259
- package/dist/src/client/index.js.map +5 -5
- package/dist/src/elysia/index.js +21 -35
- package/dist/src/elysia/index.js.map +2 -2
- package/dist/src/index.js +218 -246
- package/dist/src/index.js.map +10 -10
- package/dist/src/mesh.js +49 -61
- package/dist/src/mesh.js.map +4 -4
- package/dist/src/peer.js +23 -52
- package/dist/src/peer.js.map +2 -2
- package/dist/src/polly-ui/Button.d.ts +7 -0
- package/dist/src/polly-ui/Collapsible.d.ts +3 -1
- package/dist/src/polly-ui/Layout.d.ts +16 -1
- package/dist/src/polly-ui/index.css +47 -59
- package/dist/src/polly-ui/index.js +112 -124
- package/dist/src/polly-ui/index.js.map +13 -13
- package/dist/src/polly-ui/markdown.js +72 -145
- package/dist/src/polly-ui/markdown.js.map +2 -2
- package/dist/src/polly-ui/styles.css +47 -59
- package/dist/src/polly-ui/theme.css +10 -0
- package/dist/src/shared/adapters/index.js +31 -44
- package/dist/src/shared/adapters/index.js.map +2 -2
- package/dist/src/shared/lib/context-helpers.js +126 -152
- package/dist/src/shared/lib/context-helpers.js.map +4 -4
- package/dist/src/shared/lib/errors.js +1 -74
- package/dist/src/shared/lib/errors.js.map +2 -2
- package/dist/src/shared/lib/guards.js +1 -74
- package/dist/src/shared/lib/guards.js.map +2 -2
- package/dist/src/shared/lib/message-bus.js +126 -152
- package/dist/src/shared/lib/message-bus.js.map +4 -4
- package/dist/src/shared/lib/resource.js +16 -27
- package/dist/src/shared/lib/resource.js.map +5 -5
- package/dist/src/shared/lib/state.js +13 -26
- package/dist/src/shared/lib/state.js.map +2 -2
- package/dist/src/shared/lib/test-helpers.js +1 -74
- package/dist/src/shared/lib/test-helpers.js.map +2 -2
- package/dist/src/shared/state/app-state.js +35 -46
- package/dist/src/shared/state/app-state.js.map +5 -5
- package/dist/src/shared/types/messages.js +1 -74
- package/dist/src/shared/types/messages.js.map +2 -2
- package/dist/tools/bdd/src/cli.js +11 -15
- package/dist/tools/bdd/src/cli.js.map +2 -2
- package/dist/tools/bdd/src/index.js +11 -19
- package/dist/tools/bdd/src/index.js.map +2 -2
- package/dist/tools/gallery/src/cli.js +1 -18
- package/dist/tools/gallery/src/cli.js.map +2 -2
- package/dist/tools/init/src/cli.js +1 -18
- package/dist/tools/init/src/cli.js.map +2 -2
- package/dist/tools/mutate/src/cli.js +8 -25
- package/dist/tools/mutate/src/cli.js.map +2 -2
- package/dist/tools/mutate/src/index.js +8 -26
- package/dist/tools/mutate/src/index.js.map +2 -2
- package/dist/tools/quality/src/cli.js +39 -46
- package/dist/tools/quality/src/cli.js.map +3 -3
- package/dist/tools/quality/src/css/check-layout.d.ts +5 -3
- package/dist/tools/quality/src/index.js +39 -47
- package/dist/tools/quality/src/index.js.map +3 -3
- package/dist/tools/test/src/adapters/index.js +4 -77
- package/dist/tools/test/src/adapters/index.js.map +2 -2
- package/dist/tools/test/src/browser/index.js +1 -74
- package/dist/tools/test/src/browser/index.js.map +2 -2
- package/dist/tools/test/src/browser/run.js +5 -22
- package/dist/tools/test/src/browser/run.js.map +2 -2
- package/dist/tools/test/src/contrast/index.js +1 -74
- package/dist/tools/test/src/contrast/index.js.map +2 -2
- package/dist/tools/test/src/coverage-policy/cli.js +13 -25
- package/dist/tools/test/src/coverage-policy/cli.js.map +2 -2
- package/dist/tools/test/src/coverage-policy/index.js +11 -23
- package/dist/tools/test/src/coverage-policy/index.js.map +2 -2
- package/dist/tools/test/src/e2e-mesh/index.js +18 -43
- package/dist/tools/test/src/e2e-mesh/index.js.map +2 -2
- package/dist/tools/test/src/e2e-relay/index.js +615 -623
- package/dist/tools/test/src/e2e-relay/index.js.map +2 -2
- package/dist/tools/test/src/index.js +30 -103
- package/dist/tools/test/src/index.js.map +5 -5
- package/dist/tools/test/src/test-utils.js +1 -74
- package/dist/tools/test/src/test-utils.js.map +2 -2
- package/dist/tools/test/src/tiers/cli.js +1 -18
- package/dist/tools/test/src/tiers/cli.js.map +2 -2
- package/dist/tools/test/src/tiers/worker.js +11 -15
- package/dist/tools/test/src/tiers/worker.js.map +2 -2
- package/dist/tools/test/src/visual/index.js +1112 -1134
- package/dist/tools/test/src/visual/index.js.map +3 -3
- package/dist/tools/verify/src/cli.js +103 -169
- package/dist/tools/verify/src/cli.js.map +2 -2
- package/dist/tools/verify/src/config.js +1 -74
- package/dist/tools/verify/src/config.js.map +2 -2
- package/dist/tools/verify/src/stryker/index.js +1 -19
- package/dist/tools/verify/src/stryker/index.js.map +2 -2
- package/dist/tools/visualize/src/cli.js +69 -85
- package/dist/tools/visualize/src/cli.js.map +2 -2
- package/package.json +1 -1
package/dist/src/index.js
CHANGED
|
@@ -18,7 +18,7 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
18
18
|
return cached;
|
|
19
19
|
}
|
|
20
20
|
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
21
|
-
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
21
|
+
const to = isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
22
22
|
if (mod && typeof mod === "object" || typeof mod === "function") {
|
|
23
23
|
for (let key of __getOwnPropNames(mod))
|
|
24
24
|
if (!__hasOwnProp.call(to, key))
|
|
@@ -62,14 +62,17 @@ var __export = (target, all) => {
|
|
|
62
62
|
set: __exportSetter.bind(all, name)
|
|
63
63
|
});
|
|
64
64
|
};
|
|
65
|
-
var __esm = (fn, res) => () =>
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
65
|
+
var __esm = (fn, res, err) => () => {
|
|
66
|
+
if (fn)
|
|
67
|
+
try {
|
|
68
|
+
res = fn(fn = 0);
|
|
69
|
+
} catch (e) {
|
|
70
|
+
err = [e];
|
|
71
|
+
}
|
|
72
|
+
if (err)
|
|
73
|
+
throw err[0];
|
|
74
|
+
return res;
|
|
75
|
+
};
|
|
73
76
|
|
|
74
77
|
// src/shared/lib/idb-helpers.ts
|
|
75
78
|
function openIDB(options, openFn = defaultOpenFn) {
|
|
@@ -167,14 +170,6 @@ var init_idb_helpers = __esm(() => {
|
|
|
167
170
|
});
|
|
168
171
|
|
|
169
172
|
// src/shared/lib/storage-adapter.ts
|
|
170
|
-
var exports_storage_adapter = {};
|
|
171
|
-
__export(exports_storage_adapter, {
|
|
172
|
-
ChromeStorageAdapter: () => ChromeStorageAdapter2,
|
|
173
|
-
IndexedDBAdapter: () => IndexedDBAdapter,
|
|
174
|
-
MemoryStorageAdapter: () => MemoryStorageAdapter,
|
|
175
|
-
createStorageAdapter: () => createStorageAdapter
|
|
176
|
-
});
|
|
177
|
-
|
|
178
173
|
class IndexedDBAdapter {
|
|
179
174
|
dbName;
|
|
180
175
|
storeName = "state";
|
|
@@ -306,14 +301,6 @@ var init_storage_adapter = __esm(() => {
|
|
|
306
301
|
});
|
|
307
302
|
|
|
308
303
|
// src/shared/lib/sync-adapter.ts
|
|
309
|
-
var exports_sync_adapter = {};
|
|
310
|
-
__export(exports_sync_adapter, {
|
|
311
|
-
BroadcastChannelSyncAdapter: () => BroadcastChannelSyncAdapter,
|
|
312
|
-
ChromeRuntimeSyncAdapter: () => ChromeRuntimeSyncAdapter,
|
|
313
|
-
NoOpSyncAdapter: () => NoOpSyncAdapter,
|
|
314
|
-
createSyncAdapter: () => createSyncAdapter
|
|
315
|
-
});
|
|
316
|
-
|
|
317
304
|
class NoOpSyncAdapter {
|
|
318
305
|
broadcast(_message) {}
|
|
319
306
|
onMessage(_callback) {
|
|
@@ -442,16 +429,6 @@ function createSyncAdapter() {
|
|
|
442
429
|
}
|
|
443
430
|
|
|
444
431
|
// src/shared/lib/constraints.ts
|
|
445
|
-
var exports_constraints = {};
|
|
446
|
-
__export(exports_constraints, {
|
|
447
|
-
checkPostconditions: () => checkPostconditions,
|
|
448
|
-
checkPreconditions: () => checkPreconditions,
|
|
449
|
-
clearConstraints: () => clearConstraints,
|
|
450
|
-
getRegisteredConstraints: () => getRegisteredConstraints,
|
|
451
|
-
isRuntimeConstraintsEnabled: () => isRuntimeConstraintsEnabled,
|
|
452
|
-
registerConstraint: () => registerConstraint,
|
|
453
|
-
registerConstraints: () => registerConstraints
|
|
454
|
-
});
|
|
455
432
|
function registerConstraint(field, messageType, constraint) {
|
|
456
433
|
if (!registry.has(field)) {
|
|
457
434
|
registry.set(field, new Map);
|
|
@@ -508,9 +485,6 @@ function checkPostconditions(messageType, state) {
|
|
|
508
485
|
function clearConstraints() {
|
|
509
486
|
registry.clear();
|
|
510
487
|
}
|
|
511
|
-
function getRegisteredConstraints() {
|
|
512
|
-
return new Map(registry);
|
|
513
|
-
}
|
|
514
488
|
function isRuntimeConstraintsEnabled() {
|
|
515
489
|
if (typeof process !== "undefined" && process.env) {
|
|
516
490
|
return process.env["POLLY_RUNTIME_CONSTRAINTS"] === "true";
|
|
@@ -820,42 +794,42 @@ function createStateAdapters(options = {}) {
|
|
|
820
794
|
if (options.sync) {
|
|
821
795
|
sync = options.sync;
|
|
822
796
|
} else if (options.singleTab) {
|
|
823
|
-
|
|
824
|
-
sync = new
|
|
797
|
+
;
|
|
798
|
+
sync = new NoOpSyncAdapter;
|
|
825
799
|
} else {
|
|
826
800
|
sync = createSyncAdapter();
|
|
827
801
|
}
|
|
828
802
|
return { storage, sync };
|
|
829
803
|
}
|
|
830
804
|
function createChromeAdapters() {
|
|
831
|
-
|
|
832
|
-
|
|
805
|
+
init_storage_adapter();
|
|
806
|
+
;
|
|
833
807
|
return {
|
|
834
|
-
storage: new
|
|
835
|
-
sync: new
|
|
808
|
+
storage: new ChromeStorageAdapter2,
|
|
809
|
+
sync: new ChromeRuntimeSyncAdapter
|
|
836
810
|
};
|
|
837
811
|
}
|
|
838
812
|
function createWebAdapters(options = {}) {
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
const storage = new
|
|
842
|
-
const sync = options.singleTab ? new
|
|
813
|
+
init_storage_adapter();
|
|
814
|
+
;
|
|
815
|
+
const storage = new IndexedDBAdapter(options.dbName);
|
|
816
|
+
const sync = options.singleTab ? new NoOpSyncAdapter : new BroadcastChannelSyncAdapter(options.channelName);
|
|
843
817
|
return { storage, sync };
|
|
844
818
|
}
|
|
845
819
|
function createNodeAdapters() {
|
|
846
|
-
|
|
847
|
-
|
|
820
|
+
init_storage_adapter();
|
|
821
|
+
;
|
|
848
822
|
return {
|
|
849
|
-
storage: new
|
|
850
|
-
sync: new
|
|
823
|
+
storage: new MemoryStorageAdapter,
|
|
824
|
+
sync: new NoOpSyncAdapter
|
|
851
825
|
};
|
|
852
826
|
}
|
|
853
827
|
function createMockAdapters() {
|
|
854
|
-
|
|
855
|
-
|
|
828
|
+
init_storage_adapter();
|
|
829
|
+
;
|
|
856
830
|
return {
|
|
857
|
-
storage: new
|
|
858
|
-
sync: new
|
|
831
|
+
storage: new MemoryStorageAdapter,
|
|
832
|
+
sync: new NoOpSyncAdapter
|
|
859
833
|
};
|
|
860
834
|
}
|
|
861
835
|
|
|
@@ -877,6 +851,84 @@ function createChromeAdapters2(context, options) {
|
|
|
877
851
|
})
|
|
878
852
|
};
|
|
879
853
|
}
|
|
854
|
+
// src/shared/lib/access.ts
|
|
855
|
+
function anyone() {
|
|
856
|
+
return () => true;
|
|
857
|
+
}
|
|
858
|
+
function nobody() {
|
|
859
|
+
return () => false;
|
|
860
|
+
}
|
|
861
|
+
function onlyPeer(peerId) {
|
|
862
|
+
return (identity) => identity.peerId === peerId;
|
|
863
|
+
}
|
|
864
|
+
function anyOfPeers(peerIds) {
|
|
865
|
+
const set = new Set(peerIds);
|
|
866
|
+
return (identity) => set.has(identity.peerId);
|
|
867
|
+
}
|
|
868
|
+
function and(a, b) {
|
|
869
|
+
return (identity) => a(identity) && b(identity);
|
|
870
|
+
}
|
|
871
|
+
function or(a, b) {
|
|
872
|
+
return (identity) => a(identity) || b(identity);
|
|
873
|
+
}
|
|
874
|
+
function not(a) {
|
|
875
|
+
return (identity) => !a(identity);
|
|
876
|
+
}
|
|
877
|
+
function publicAccess() {
|
|
878
|
+
return {
|
|
879
|
+
read: anyone(),
|
|
880
|
+
write: anyone()
|
|
881
|
+
};
|
|
882
|
+
}
|
|
883
|
+
function ownerAccess(peerId) {
|
|
884
|
+
const pred = onlyPeer(peerId);
|
|
885
|
+
return { read: pred, write: pred };
|
|
886
|
+
}
|
|
887
|
+
function groupAccess(peerIds) {
|
|
888
|
+
const pred = anyOfPeers(peerIds);
|
|
889
|
+
return { read: pred, write: pred };
|
|
890
|
+
}
|
|
891
|
+
function readOnlyExcept(writer) {
|
|
892
|
+
return {
|
|
893
|
+
read: anyone(),
|
|
894
|
+
write: writer
|
|
895
|
+
};
|
|
896
|
+
}
|
|
897
|
+
// src/shared/lib/blob-ref.ts
|
|
898
|
+
function isBlobRef(value) {
|
|
899
|
+
if (typeof value !== "object" || value === null)
|
|
900
|
+
return false;
|
|
901
|
+
const v = value;
|
|
902
|
+
return typeof v["hash"] === "string" && /^[0-9a-f]{64}$/.test(v["hash"]) && typeof v["size"] === "number" && Number.isInteger(v["size"]) && v["size"] >= 0 && typeof v["filename"] === "string" && typeof v["mimeType"] === "string";
|
|
903
|
+
}
|
|
904
|
+
async function computeBlobHash(bytes) {
|
|
905
|
+
const buffer = new ArrayBuffer(bytes.byteLength);
|
|
906
|
+
const copy = new Uint8Array(buffer);
|
|
907
|
+
copy.set(bytes);
|
|
908
|
+
const digest = await crypto.subtle.digest("SHA-256", buffer);
|
|
909
|
+
const view = new Uint8Array(digest);
|
|
910
|
+
let hex = "";
|
|
911
|
+
for (const byte of view) {
|
|
912
|
+
hex += byte.toString(16).padStart(2, "0");
|
|
913
|
+
}
|
|
914
|
+
return hex;
|
|
915
|
+
}
|
|
916
|
+
async function createBlobRef({
|
|
917
|
+
bytes,
|
|
918
|
+
filename,
|
|
919
|
+
mimeType
|
|
920
|
+
}) {
|
|
921
|
+
const hash = await computeBlobHash(bytes);
|
|
922
|
+
return {
|
|
923
|
+
hash,
|
|
924
|
+
size: bytes.byteLength,
|
|
925
|
+
filename,
|
|
926
|
+
mimeType
|
|
927
|
+
};
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
// src/index.ts
|
|
931
|
+
init_constraints();
|
|
880
932
|
|
|
881
933
|
// src/shared/types/messages.ts
|
|
882
934
|
var ALL_CONTEXTS = [
|
|
@@ -898,89 +950,6 @@ var defaultSettings = {
|
|
|
898
950
|
refreshInterval: 60000
|
|
899
951
|
};
|
|
900
952
|
|
|
901
|
-
// src/shared/lib/errors.ts
|
|
902
|
-
class ExtensionError extends Error {
|
|
903
|
-
code;
|
|
904
|
-
context;
|
|
905
|
-
constructor(message, code, context) {
|
|
906
|
-
super(message);
|
|
907
|
-
this.code = code;
|
|
908
|
-
this.context = context;
|
|
909
|
-
this.name = this.constructor.name;
|
|
910
|
-
Error.captureStackTrace?.(this, this.constructor);
|
|
911
|
-
}
|
|
912
|
-
}
|
|
913
|
-
|
|
914
|
-
class TimeoutError extends ExtensionError {
|
|
915
|
-
timeoutMs;
|
|
916
|
-
constructor(message, timeoutMs, context) {
|
|
917
|
-
super(message, "TIMEOUT_ERROR", { ...context, timeoutMs });
|
|
918
|
-
this.timeoutMs = timeoutMs;
|
|
919
|
-
}
|
|
920
|
-
}
|
|
921
|
-
|
|
922
|
-
class ConnectionError extends ExtensionError {
|
|
923
|
-
constructor(message, context) {
|
|
924
|
-
super(message, "CONNECTION_ERROR", context);
|
|
925
|
-
}
|
|
926
|
-
}
|
|
927
|
-
|
|
928
|
-
class MessageRouterError extends ExtensionError {
|
|
929
|
-
constructor(message, context) {
|
|
930
|
-
super(message, "MESSAGE_ROUTER_ERROR", context);
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
class HandlerError extends ExtensionError {
|
|
935
|
-
messageType;
|
|
936
|
-
constructor(message, messageType, context) {
|
|
937
|
-
super(message, "HANDLER_ERROR", { ...context, messageType });
|
|
938
|
-
this.messageType = messageType;
|
|
939
|
-
}
|
|
940
|
-
}
|
|
941
|
-
|
|
942
|
-
class APIError extends ExtensionError {
|
|
943
|
-
statusCode;
|
|
944
|
-
constructor(message, statusCode, context) {
|
|
945
|
-
super(message, "API_ERROR", { ...context, statusCode });
|
|
946
|
-
this.statusCode = statusCode;
|
|
947
|
-
}
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
class OffscreenError extends ExtensionError {
|
|
951
|
-
constructor(message, context) {
|
|
952
|
-
super(message, "OFFSCREEN_ERROR", context);
|
|
953
|
-
}
|
|
954
|
-
}
|
|
955
|
-
|
|
956
|
-
class ErrorHandler {
|
|
957
|
-
logger;
|
|
958
|
-
constructor(logger2) {
|
|
959
|
-
this.logger = logger2;
|
|
960
|
-
}
|
|
961
|
-
throw(error) {
|
|
962
|
-
this.logger.error(error.message, error, error.context);
|
|
963
|
-
throw error;
|
|
964
|
-
}
|
|
965
|
-
reject(error) {
|
|
966
|
-
this.logger.error(error.message, error, error.context);
|
|
967
|
-
return error;
|
|
968
|
-
}
|
|
969
|
-
wrap(error, message, code, context) {
|
|
970
|
-
const originalError = error instanceof Error ? error : new Error(String(error));
|
|
971
|
-
const wrappedError = new ExtensionError(`${message}: ${originalError.message}`, code, {
|
|
972
|
-
...context,
|
|
973
|
-
originalError: originalError.message,
|
|
974
|
-
originalStack: originalError.stack
|
|
975
|
-
});
|
|
976
|
-
if (originalError.stack) {
|
|
977
|
-
wrappedError.stack = originalError.stack;
|
|
978
|
-
}
|
|
979
|
-
this.logger.error(wrappedError.message, wrappedError, wrappedError.context);
|
|
980
|
-
return wrappedError;
|
|
981
|
-
}
|
|
982
|
-
}
|
|
983
|
-
|
|
984
953
|
// src/shared/lib/context-specific-helpers.ts
|
|
985
954
|
function createContentScriptHelpers() {
|
|
986
955
|
return {
|
|
@@ -1083,8 +1052,8 @@ function createDevToolsHelpers() {
|
|
|
1083
1052
|
function createPopupHelpers(adapters) {
|
|
1084
1053
|
return {
|
|
1085
1054
|
async getCurrentTab() {
|
|
1086
|
-
const
|
|
1087
|
-
return
|
|
1055
|
+
const tabs = await adapters.tabs.query({ active: true, currentWindow: true });
|
|
1056
|
+
return tabs[0];
|
|
1088
1057
|
},
|
|
1089
1058
|
closePopup() {
|
|
1090
1059
|
window.close();
|
|
@@ -1147,8 +1116,8 @@ function createOptionsHelpers(adapters) {
|
|
|
1147
1116
|
function createSidePanelHelpers(adapters) {
|
|
1148
1117
|
return {
|
|
1149
1118
|
async getCurrentTab() {
|
|
1150
|
-
const
|
|
1151
|
-
return
|
|
1119
|
+
const tabs = await adapters.tabs.query({ active: true, currentWindow: true });
|
|
1120
|
+
return tabs[0];
|
|
1152
1121
|
},
|
|
1153
1122
|
isVisible() {
|
|
1154
1123
|
return document.visibilityState === "visible";
|
|
@@ -1179,6 +1148,89 @@ function createBackgroundHelpers(adapters) {
|
|
|
1179
1148
|
};
|
|
1180
1149
|
}
|
|
1181
1150
|
|
|
1151
|
+
// src/shared/lib/errors.ts
|
|
1152
|
+
class ExtensionError extends Error {
|
|
1153
|
+
code;
|
|
1154
|
+
context;
|
|
1155
|
+
constructor(message, code, context) {
|
|
1156
|
+
super(message);
|
|
1157
|
+
this.code = code;
|
|
1158
|
+
this.context = context;
|
|
1159
|
+
this.name = this.constructor.name;
|
|
1160
|
+
Error.captureStackTrace?.(this, this.constructor);
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
class TimeoutError extends ExtensionError {
|
|
1165
|
+
timeoutMs;
|
|
1166
|
+
constructor(message, timeoutMs, context) {
|
|
1167
|
+
super(message, "TIMEOUT_ERROR", { ...context, timeoutMs });
|
|
1168
|
+
this.timeoutMs = timeoutMs;
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
class ConnectionError extends ExtensionError {
|
|
1173
|
+
constructor(message, context) {
|
|
1174
|
+
super(message, "CONNECTION_ERROR", context);
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
class MessageRouterError extends ExtensionError {
|
|
1179
|
+
constructor(message, context) {
|
|
1180
|
+
super(message, "MESSAGE_ROUTER_ERROR", context);
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
class HandlerError extends ExtensionError {
|
|
1185
|
+
messageType;
|
|
1186
|
+
constructor(message, messageType, context) {
|
|
1187
|
+
super(message, "HANDLER_ERROR", { ...context, messageType });
|
|
1188
|
+
this.messageType = messageType;
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
class APIError extends ExtensionError {
|
|
1193
|
+
statusCode;
|
|
1194
|
+
constructor(message, statusCode, context) {
|
|
1195
|
+
super(message, "API_ERROR", { ...context, statusCode });
|
|
1196
|
+
this.statusCode = statusCode;
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
class OffscreenError extends ExtensionError {
|
|
1201
|
+
constructor(message, context) {
|
|
1202
|
+
super(message, "OFFSCREEN_ERROR", context);
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
class ErrorHandler {
|
|
1207
|
+
logger;
|
|
1208
|
+
constructor(logger) {
|
|
1209
|
+
this.logger = logger;
|
|
1210
|
+
}
|
|
1211
|
+
throw(error) {
|
|
1212
|
+
this.logger.error(error.message, error, error.context);
|
|
1213
|
+
throw error;
|
|
1214
|
+
}
|
|
1215
|
+
reject(error) {
|
|
1216
|
+
this.logger.error(error.message, error, error.context);
|
|
1217
|
+
return error;
|
|
1218
|
+
}
|
|
1219
|
+
wrap(error, message, code, context) {
|
|
1220
|
+
const originalError = error instanceof Error ? error : new Error(String(error));
|
|
1221
|
+
const wrappedError = new ExtensionError(`${message}: ${originalError.message}`, code, {
|
|
1222
|
+
...context,
|
|
1223
|
+
originalError: originalError.message,
|
|
1224
|
+
originalStack: originalError.stack
|
|
1225
|
+
});
|
|
1226
|
+
if (originalError.stack) {
|
|
1227
|
+
wrappedError.stack = originalError.stack;
|
|
1228
|
+
}
|
|
1229
|
+
this.logger.error(wrappedError.message, wrappedError, wrappedError.context);
|
|
1230
|
+
return wrappedError;
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1182
1234
|
// src/shared/lib/handler-execution-tracker.ts
|
|
1183
1235
|
class HandlerExecutionTracker {
|
|
1184
1236
|
executions = new Map;
|
|
@@ -1353,8 +1405,8 @@ class MessageBus {
|
|
|
1353
1405
|
return this.send(payload, { ...options, target: "content", tabId });
|
|
1354
1406
|
}
|
|
1355
1407
|
async sendToAllTabs(payload, options) {
|
|
1356
|
-
const
|
|
1357
|
-
return Promise.all(
|
|
1408
|
+
const tabs = await this.adapters.tabs.query({});
|
|
1409
|
+
return Promise.all(tabs.map((tab) => tab.id ? this.sendToContentScript(tab.id, payload, options) : Promise.resolve(undefined)));
|
|
1358
1410
|
}
|
|
1359
1411
|
async sendToPopup(payload, options) {
|
|
1360
1412
|
return this.send(payload, { ...options, target: "popup" });
|
|
@@ -1505,10 +1557,10 @@ class MessageBus {
|
|
|
1505
1557
|
globalExecutionTracker.track(message.id, message.payload.type);
|
|
1506
1558
|
if (this.stateAccessor) {
|
|
1507
1559
|
try {
|
|
1508
|
-
|
|
1509
|
-
if (
|
|
1560
|
+
await Promise.resolve().then(() => init_constraints());
|
|
1561
|
+
if (isRuntimeConstraintsEnabled()) {
|
|
1510
1562
|
const currentState = this.stateAccessor();
|
|
1511
|
-
|
|
1563
|
+
checkPreconditions(message.payload.type, currentState);
|
|
1512
1564
|
}
|
|
1513
1565
|
} catch (error) {
|
|
1514
1566
|
if (error instanceof Error) {
|
|
@@ -1526,10 +1578,10 @@ class MessageBus {
|
|
|
1526
1578
|
const data = await handler(message.payload, message);
|
|
1527
1579
|
if (this.stateAccessor) {
|
|
1528
1580
|
try {
|
|
1529
|
-
|
|
1530
|
-
if (
|
|
1581
|
+
await Promise.resolve().then(() => init_constraints());
|
|
1582
|
+
if (isRuntimeConstraintsEnabled()) {
|
|
1531
1583
|
const currentState = this.stateAccessor();
|
|
1532
|
-
|
|
1584
|
+
checkPostconditions(message.payload.type, currentState);
|
|
1533
1585
|
}
|
|
1534
1586
|
} catch (error) {
|
|
1535
1587
|
if (error instanceof Error && error.message.includes("Postcondition")) {
|
|
@@ -1699,6 +1751,8 @@ function runInContext(context, contexts, fn, adapters) {
|
|
|
1699
1751
|
Promise.resolve(fn(bus)).catch(() => {});
|
|
1700
1752
|
}
|
|
1701
1753
|
}
|
|
1754
|
+
// src/shared/lib/resource.ts
|
|
1755
|
+
import { effect as effect2, signal as signal2 } from "@preact/signals";
|
|
1702
1756
|
|
|
1703
1757
|
// src/shared/lib/state.ts
|
|
1704
1758
|
init_storage_adapter();
|
|
@@ -1878,9 +1932,9 @@ function reconcileWithDefaults(defaults, stored) {
|
|
|
1878
1932
|
}
|
|
1879
1933
|
return stored;
|
|
1880
1934
|
}
|
|
1881
|
-
async function loadFromStorage(key, sig, entry,
|
|
1935
|
+
async function loadFromStorage(key, sig, entry, storage, validator) {
|
|
1882
1936
|
try {
|
|
1883
|
-
const result = await
|
|
1937
|
+
const result = await storage.get([key, `${key}:clock`]);
|
|
1884
1938
|
if (result[key] !== undefined) {
|
|
1885
1939
|
const storedValue = reconcileWithDefaults(sig.peek(), result[key]);
|
|
1886
1940
|
if (validator) {
|
|
@@ -1900,9 +1954,9 @@ async function loadFromStorage(key, sig, entry, storage2, validator) {
|
|
|
1900
1954
|
console.warn(`[Polly] Failed to load state from storage: ${key}`, error);
|
|
1901
1955
|
}
|
|
1902
1956
|
}
|
|
1903
|
-
function persistToStorage(key, value, clock,
|
|
1957
|
+
function persistToStorage(key, value, clock, storage) {
|
|
1904
1958
|
try {
|
|
1905
|
-
|
|
1959
|
+
storage.set({
|
|
1906
1960
|
[key]: value,
|
|
1907
1961
|
[`${key}:clock`]: clock
|
|
1908
1962
|
});
|
|
@@ -1936,7 +1990,6 @@ function clearStateRegistry() {
|
|
|
1936
1990
|
}
|
|
1937
1991
|
|
|
1938
1992
|
// src/shared/lib/resource.ts
|
|
1939
|
-
import { effect as effect2, signal as signal2 } from "@preact/signals";
|
|
1940
1993
|
function $resource(_name, options) {
|
|
1941
1994
|
const { source, fetcher, initialValue } = options;
|
|
1942
1995
|
const data = signal2(initialValue);
|
|
@@ -1976,7 +2029,6 @@ function $resource(_name, options) {
|
|
|
1976
2029
|
}
|
|
1977
2030
|
return { data, status, error, refetch };
|
|
1978
2031
|
}
|
|
1979
|
-
|
|
1980
2032
|
// src/shared/lib/test-helpers.ts
|
|
1981
2033
|
class TestRunner {
|
|
1982
2034
|
suite;
|
|
@@ -2106,94 +2158,6 @@ async function quickTest(name, fn) {
|
|
|
2106
2158
|
console.error(`❌ ${name}: ${error instanceof Error ? error.message : String(error)} (${duration}ms)`);
|
|
2107
2159
|
}
|
|
2108
2160
|
}
|
|
2109
|
-
|
|
2110
|
-
// src/shared/state/app-state.ts
|
|
2111
|
-
import { signal as signal3 } from "@preact/signals";
|
|
2112
|
-
var settings = $sharedState("app-settings", defaultSettings);
|
|
2113
|
-
var currentTab = $syncedState("current-tab", null);
|
|
2114
|
-
var uiState = signal3({
|
|
2115
|
-
sidebarOpen: false,
|
|
2116
|
-
selectedPanel: "main"
|
|
2117
|
-
});
|
|
2118
|
-
// src/shared/lib/access.ts
|
|
2119
|
-
function anyone() {
|
|
2120
|
-
return () => true;
|
|
2121
|
-
}
|
|
2122
|
-
function nobody() {
|
|
2123
|
-
return () => false;
|
|
2124
|
-
}
|
|
2125
|
-
function onlyPeer(peerId) {
|
|
2126
|
-
return (identity) => identity.peerId === peerId;
|
|
2127
|
-
}
|
|
2128
|
-
function anyOfPeers(peerIds) {
|
|
2129
|
-
const set = new Set(peerIds);
|
|
2130
|
-
return (identity) => set.has(identity.peerId);
|
|
2131
|
-
}
|
|
2132
|
-
function and(a, b) {
|
|
2133
|
-
return (identity) => a(identity) && b(identity);
|
|
2134
|
-
}
|
|
2135
|
-
function or(a, b) {
|
|
2136
|
-
return (identity) => a(identity) || b(identity);
|
|
2137
|
-
}
|
|
2138
|
-
function not(a) {
|
|
2139
|
-
return (identity) => !a(identity);
|
|
2140
|
-
}
|
|
2141
|
-
function publicAccess() {
|
|
2142
|
-
return {
|
|
2143
|
-
read: anyone(),
|
|
2144
|
-
write: anyone()
|
|
2145
|
-
};
|
|
2146
|
-
}
|
|
2147
|
-
function ownerAccess(peerId) {
|
|
2148
|
-
const pred = onlyPeer(peerId);
|
|
2149
|
-
return { read: pred, write: pred };
|
|
2150
|
-
}
|
|
2151
|
-
function groupAccess(peerIds) {
|
|
2152
|
-
const pred = anyOfPeers(peerIds);
|
|
2153
|
-
return { read: pred, write: pred };
|
|
2154
|
-
}
|
|
2155
|
-
function readOnlyExcept(writer) {
|
|
2156
|
-
return {
|
|
2157
|
-
read: anyone(),
|
|
2158
|
-
write: writer
|
|
2159
|
-
};
|
|
2160
|
-
}
|
|
2161
|
-
// src/shared/lib/blob-ref.ts
|
|
2162
|
-
function isBlobRef(value) {
|
|
2163
|
-
if (typeof value !== "object" || value === null)
|
|
2164
|
-
return false;
|
|
2165
|
-
const v = value;
|
|
2166
|
-
return typeof v["hash"] === "string" && /^[0-9a-f]{64}$/.test(v["hash"]) && typeof v["size"] === "number" && Number.isInteger(v["size"]) && v["size"] >= 0 && typeof v["filename"] === "string" && typeof v["mimeType"] === "string";
|
|
2167
|
-
}
|
|
2168
|
-
async function computeBlobHash(bytes) {
|
|
2169
|
-
const buffer = new ArrayBuffer(bytes.byteLength);
|
|
2170
|
-
const copy = new Uint8Array(buffer);
|
|
2171
|
-
copy.set(bytes);
|
|
2172
|
-
const digest = await crypto.subtle.digest("SHA-256", buffer);
|
|
2173
|
-
const view = new Uint8Array(digest);
|
|
2174
|
-
let hex = "";
|
|
2175
|
-
for (const byte of view) {
|
|
2176
|
-
hex += byte.toString(16).padStart(2, "0");
|
|
2177
|
-
}
|
|
2178
|
-
return hex;
|
|
2179
|
-
}
|
|
2180
|
-
async function createBlobRef({
|
|
2181
|
-
bytes,
|
|
2182
|
-
filename,
|
|
2183
|
-
mimeType
|
|
2184
|
-
}) {
|
|
2185
|
-
const hash = await computeBlobHash(bytes);
|
|
2186
|
-
return {
|
|
2187
|
-
hash,
|
|
2188
|
-
size: bytes.byteLength,
|
|
2189
|
-
filename,
|
|
2190
|
-
mimeType
|
|
2191
|
-
};
|
|
2192
|
-
}
|
|
2193
|
-
|
|
2194
|
-
// src/index.ts
|
|
2195
|
-
init_constraints();
|
|
2196
|
-
|
|
2197
2161
|
// src/shared/lib/validation.ts
|
|
2198
2162
|
function checkPrimitiveType(val, type) {
|
|
2199
2163
|
if (type === "array")
|
|
@@ -2243,6 +2207,14 @@ function validatePartial(_validator) {
|
|
|
2243
2207
|
return true;
|
|
2244
2208
|
};
|
|
2245
2209
|
}
|
|
2210
|
+
// src/shared/state/app-state.ts
|
|
2211
|
+
import { signal as signal3 } from "@preact/signals";
|
|
2212
|
+
var settings = $sharedState("app-settings", defaultSettings);
|
|
2213
|
+
var currentTab = $syncedState("current-tab", null);
|
|
2214
|
+
var uiState = signal3({
|
|
2215
|
+
sidebarOpen: false,
|
|
2216
|
+
selectedPanel: "main"
|
|
2217
|
+
});
|
|
2246
2218
|
export {
|
|
2247
2219
|
$persistedState,
|
|
2248
2220
|
$resource,
|
|
@@ -2290,4 +2262,4 @@ export {
|
|
|
2290
2262
|
validateShape
|
|
2291
2263
|
};
|
|
2292
2264
|
|
|
2293
|
-
//# debugId=
|
|
2265
|
+
//# debugId=9822059EEC1DD59B64756E2164756E21
|