@luckylillia-dev/plugin-aiimgdetector 0.0.0-stage → 1.0.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.
Files changed (99) hide show
  1. package/README.md +2 -2
  2. package/assets/demo.png +0 -0
  3. package/assets/icon.svg +15 -0
  4. package/assets/synthid-login-check.jpg +0 -0
  5. package/docs/details.md +45 -0
  6. package/docs/publishing.md +66 -0
  7. package/docs/synthid.md +80 -0
  8. package/lib/image.js +90 -0
  9. package/lib/index.js +207 -0
  10. package/lib/provenance.js +21 -0
  11. package/lib/synthid-auth.js +100 -0
  12. package/lib/synthid-browser.js +451 -0
  13. package/lib/synthid-http-runtime/chromium-css-property-catalog.mjs +7 -0
  14. package/lib/synthid-http-runtime/complete-protocol.mjs +88 -0
  15. package/lib/synthid-http-runtime/entry.d.mts +41 -0
  16. package/lib/synthid-http-runtime/entry.mjs +6 -0
  17. package/lib/synthid-http-runtime/event-listener-diagnostics.mjs +141 -0
  18. package/lib/synthid-http-runtime/independent-request-reference.mjs +49 -0
  19. package/lib/synthid-http-runtime/jsdom-event-clock-compat.mjs +76 -0
  20. package/lib/synthid-http-runtime/lifecycle-client.mjs +165 -0
  21. package/lib/synthid-http-runtime/lifecycle-web-session.mjs +114 -0
  22. package/lib/synthid-http-runtime/lifecycle-worker.mjs +363 -0
  23. package/lib/synthid-http-runtime/node-platform-failure-diagnostics.mjs +108 -0
  24. package/lib/synthid-http-runtime/realm-activation-diagnostic.js +31 -0
  25. package/lib/synthid-http-runtime/realm-focus-diagnostic.js +9 -0
  26. package/lib/synthid-http-runtime/realm-init.js +34 -0
  27. package/lib/synthid-http-runtime/realm-pointer-diagnostic.js +49 -0
  28. package/lib/synthid-http-runtime/runtime-anchor-href-translate.mjs +242 -0
  29. package/lib/synthid-http-runtime/runtime-child-web-compat.mjs +103 -0
  30. package/lib/synthid-http-runtime/runtime-chrome-csi.mjs +216 -0
  31. package/lib/synthid-http-runtime/runtime-clock-precision-control.mjs +51 -0
  32. package/lib/synthid-http-runtime/runtime-css-properties-compat.mjs +165 -0
  33. package/lib/synthid-http-runtime/runtime-detached-frame-compat.mjs +214 -0
  34. package/lib/synthid-http-runtime/runtime-javascript-bindings.mjs +69 -0
  35. package/lib/synthid-http-runtime/runtime-navigator-compat.mjs +99 -0
  36. package/lib/synthid-http-runtime/runtime-permissions-binding.mjs +64 -0
  37. package/lib/synthid-http-runtime/runtime-permissions-control.mjs +143 -0
  38. package/lib/synthid-http-runtime/runtime-web-compat.mjs +639 -0
  39. package/lib/synthid-http-runtime/runtime-webidl-callable-control.mjs +151 -0
  40. package/lib/synthid-http-runtime/runtime-webidl-realm-compat.mjs +132 -0
  41. package/lib/synthid-http-runtime/runtime-window-state-compat.mjs +128 -0
  42. package/lib/synthid-http-runtime/scripting-parser.mjs +13 -0
  43. package/lib/synthid-http-runtime/web-session.mjs +64 -0
  44. package/lib/synthid-http-runtime/webidl-brand-errors-preload.mjs +49 -0
  45. package/lib/synthid-http-runtime/webidl-callable-source-catalog.mjs +4491 -0
  46. package/lib/synthid-http-runtime/webidl-realm-catalog.mjs +124 -0
  47. package/lib/synthid-http.js +314 -0
  48. package/lib/synthid-manual.js +365 -0
  49. package/lib/synthid-page.js +101 -0
  50. package/lib/synthid-result.js +189 -0
  51. package/lib/synthid.js +540 -0
  52. package/lib/vision.js +41 -0
  53. package/package.json +84 -4
  54. package/src/image.ts +74 -0
  55. package/src/index.ts +203 -0
  56. package/src/provenance.ts +40 -0
  57. package/src/synthid-auth.ts +83 -0
  58. package/src/synthid-browser.ts +426 -0
  59. package/src/synthid-http-runtime/chromium-css-property-catalog.mjs +7 -0
  60. package/src/synthid-http-runtime/complete-protocol.mjs +88 -0
  61. package/src/synthid-http-runtime/entry.d.mts +41 -0
  62. package/src/synthid-http-runtime/entry.mjs +6 -0
  63. package/src/synthid-http-runtime/event-listener-diagnostics.mjs +141 -0
  64. package/src/synthid-http-runtime/independent-request-reference.mjs +49 -0
  65. package/src/synthid-http-runtime/jsdom-event-clock-compat.mjs +76 -0
  66. package/src/synthid-http-runtime/lifecycle-client.mjs +165 -0
  67. package/src/synthid-http-runtime/lifecycle-web-session.mjs +114 -0
  68. package/src/synthid-http-runtime/lifecycle-worker.mjs +363 -0
  69. package/src/synthid-http-runtime/node-platform-failure-diagnostics.mjs +108 -0
  70. package/src/synthid-http-runtime/realm-activation-diagnostic.js +31 -0
  71. package/src/synthid-http-runtime/realm-focus-diagnostic.js +9 -0
  72. package/src/synthid-http-runtime/realm-init.js +34 -0
  73. package/src/synthid-http-runtime/realm-pointer-diagnostic.js +49 -0
  74. package/src/synthid-http-runtime/runtime-anchor-href-translate.mjs +242 -0
  75. package/src/synthid-http-runtime/runtime-child-web-compat.mjs +103 -0
  76. package/src/synthid-http-runtime/runtime-chrome-csi.mjs +216 -0
  77. package/src/synthid-http-runtime/runtime-clock-precision-control.mjs +51 -0
  78. package/src/synthid-http-runtime/runtime-css-properties-compat.mjs +165 -0
  79. package/src/synthid-http-runtime/runtime-detached-frame-compat.mjs +214 -0
  80. package/src/synthid-http-runtime/runtime-javascript-bindings.mjs +69 -0
  81. package/src/synthid-http-runtime/runtime-navigator-compat.mjs +99 -0
  82. package/src/synthid-http-runtime/runtime-permissions-binding.mjs +64 -0
  83. package/src/synthid-http-runtime/runtime-permissions-control.mjs +143 -0
  84. package/src/synthid-http-runtime/runtime-web-compat.mjs +639 -0
  85. package/src/synthid-http-runtime/runtime-webidl-callable-control.mjs +151 -0
  86. package/src/synthid-http-runtime/runtime-webidl-realm-compat.mjs +132 -0
  87. package/src/synthid-http-runtime/runtime-window-state-compat.mjs +128 -0
  88. package/src/synthid-http-runtime/scripting-parser.mjs +13 -0
  89. package/src/synthid-http-runtime/web-session.mjs +64 -0
  90. package/src/synthid-http-runtime/webidl-brand-errors-preload.mjs +49 -0
  91. package/src/synthid-http-runtime/webidl-callable-source-catalog.mjs +4491 -0
  92. package/src/synthid-http-runtime/webidl-realm-catalog.mjs +124 -0
  93. package/src/synthid-http.ts +290 -0
  94. package/src/synthid-manual.ts +388 -0
  95. package/src/synthid-page.ts +103 -0
  96. package/src/synthid-result.ts +177 -0
  97. package/src/synthid.ts +514 -0
  98. package/src/vision.ts +57 -0
  99. package/webui/index.js +279 -0
@@ -0,0 +1,143 @@
1
+ // Optional abstract Permissions bindings for owned isolated JSDOM realms.
2
+ import WindowModule from 'jsdom/lib/jsdom/browser/Window.js';
3
+ import webIdlUtils from 'jsdom/lib/jsdom/living/generated/utils.js';
4
+ import jsdomPackage from 'jsdom/package.json' with { type: 'json' };
5
+ import { installRuntimePermissionsBinding } from './runtime-permissions-binding.mjs';
6
+
7
+ const own = Object.getOwnPropertyDescriptor, define = Object.defineProperty;
8
+ const apply = Reflect.apply, hasOwn = Object.prototype.hasOwnProperty;
9
+ const getPrototype = Object.getPrototypeOf, freeze = Object.freeze;
10
+ const MAX_REALMS = 32, LIMIT = 1000000;
11
+ const activeRealms = new WeakSet();
12
+ let activeChildHook = false;
13
+ const data = (object, key) => {
14
+ const descriptor = own(object, key);
15
+ return descriptor && apply(hasOwn, descriptor, ['value']) ? descriptor.value : undefined;
16
+ };
17
+ const isObject = value => value !== null && (typeof value === 'object' || typeof value === 'function');
18
+ const sameFactory = (left, right) => !!left && !!right && left.value === right.value &&
19
+ left.writable === right.writable && left.enumerable === right.enumerable && left.configurable === right.configurable;
20
+ const errorCodes = new Set(['INVALID_OPTIONS', 'UNSUPPORTED_JSDOM', 'UNSUPPORTED_REALM',
21
+ 'ALREADY_INSTALLED', 'CHILD_HOOK_ALREADY_INSTALLED', 'INSTALL_FAILED']);
22
+ export class RuntimePermissionsControlError extends Error {
23
+ constructor(code) {
24
+ const safe = errorCodes.has(code) ? code : 'INSTALL_FAILED';
25
+ super('Runtime Permissions control failed: ' + safe);
26
+ this.name = 'RuntimePermissionsControlError'; this.code = safe;
27
+ }
28
+ }
29
+
30
+ /** Install before observers; dispose before earlier createWindow hooks.
31
+ * Adds no Permissions instance, navigator.permissions object, or grant. */
32
+ export function installRuntimePermissionsControl(window, options = {}) {
33
+ if (!isObject(window) || !options || typeof options !== 'object') throw new RuntimePermissionsControlError('INVALID_OPTIONS');
34
+ const descriptor = own(options, 'children');
35
+ if (descriptor && !apply(hasOwn, descriptor, ['value'])) throw new RuntimePermissionsControlError('INVALID_OPTIONS');
36
+ const children = descriptor?.value === undefined ? false : descriptor.value;
37
+ if (typeof children !== 'boolean') throw new RuntimePermissionsControlError('INVALID_OPTIONS');
38
+ if (jsdomPackage.version !== '26.1.0') throw new RuntimePermissionsControlError('UNSUPPORTED_JSDOM');
39
+ if (activeRealms.has(window)) throw new RuntimePermissionsControlError('ALREADY_INSTALLED');
40
+ if (children && activeChildHook) throw new RuntimePermissionsControlError('CHILD_HOOK_ALREADY_INSTALLED');
41
+ const previousFactory = children ? own(WindowModule, 'createWindow') : undefined;
42
+ if (children && (!previousFactory?.writable || typeof previousFactory.value !== 'function')) throw new RuntimePermissionsControlError('UNSUPPORTED_JSDOM');
43
+ const records = [];
44
+ let disposed = false, installedFactory;
45
+ const stats = {
46
+ installedRealms: 0, installedBindings: 0, existingBindingsPreserved: 0,
47
+ observedChildren: 0, skippedFactories: 0, unsupportedChildren: 0,
48
+ childFailures: 0, realmLimitReached: false, snapshotFailures: 0,
49
+ removedBindings: 0, cleanupConflicts: 0, cleanupFailures: 0,
50
+ childFactoryRestored: false, childFactoryRestoreConflict: false,
51
+ };
52
+ const increment = key => { if (stats[key] < LIMIT) stats[key]++; };
53
+ const snapshot = () => ({
54
+ schemaVersion: 1, diagnosticOnly: true, abstractInterface: true,
55
+ instancesProvisioned: 0, sourceRenderingModified: false, queryCallsAvailable: false,
56
+ childrenEnabled: children, maximumRealms: MAX_REALMS, counterLimit: LIMIT,
57
+ installedRealms: stats.installedRealms, installedBindings: stats.installedBindings,
58
+ existingBindingsPreserved: stats.existingBindingsPreserved,
59
+ observedChildren: stats.observedChildren, skippedFactories: stats.skippedFactories,
60
+ unsupportedChildren: stats.unsupportedChildren, childFailures: stats.childFailures,
61
+ realmLimitReached: stats.realmLimitReached, snapshotFailures: stats.snapshotFailures,
62
+ removedBindings: stats.removedBindings, cleanupConflicts: stats.cleanupConflicts,
63
+ cleanupFailures: stats.cleanupFailures, childFactoryRestored: stats.childFactoryRestored,
64
+ childFactoryRestoreConflict: stats.childFactoryRestoreConflict, disposed,
65
+ });
66
+ function readBinding(record) {
67
+ const report = apply(record.snapshot, record.control, []);
68
+ if (!report || report.abstractInterface !== true || report.instancesProvisioned !== 0 || report.sourceRenderingModified !== false) throw new Error('INVALID_BINDING_REPORT');
69
+ for (const key of ['bindingInstalled', 'existingBindingPreserved', 'disposed', 'bindingRemoved', 'cleanupConflict']) {
70
+ if (typeof report[key] !== 'boolean') throw new Error('INVALID_BINDING_REPORT');
71
+ }
72
+ return report;
73
+ }
74
+ function installRealm(realm) {
75
+ if (records.length >= MAX_REALMS) { stats.realmLimitReached = true; return; }
76
+ if (!isObject(realm)) throw new RuntimePermissionsControlError('UNSUPPORTED_REALM');
77
+ if (activeRealms.has(realm)) throw new RuntimePermissionsControlError('ALREADY_INSTALLED');
78
+ const RealmFunction = data(realm, 'Function'), registry = data(realm, webIdlUtils.ctorRegistrySymbol);
79
+ if (typeof RealmFunction !== 'function' || RealmFunction === Function || !isObject(registry) || getPrototype(registry) !== null)
80
+ throw new RuntimePermissionsControlError('UNSUPPORTED_REALM');
81
+ const control = installRuntimePermissionsBinding(realm);
82
+ const record = { realm, control, snapshot: data(control, 'snapshot'), dispose: data(control, 'dispose') };
83
+ let report;
84
+ try {
85
+ if (typeof record.snapshot !== 'function' || typeof record.dispose !== 'function') throw new Error('INVALID_BINDING_REPORT');
86
+ report = readBinding(record);
87
+ } catch {
88
+ try { if (typeof record.dispose === 'function') apply(record.dispose, control, []); } catch {}
89
+ throw new RuntimePermissionsControlError('INSTALL_FAILED');
90
+ }
91
+ records[records.length] = record; activeRealms.add(realm); increment('installedRealms');
92
+ if (report.bindingInstalled) increment('installedBindings');
93
+ if (report.existingBindingPreserved) increment('existingBindingsPreserved');
94
+ }
95
+ function dispose() {
96
+ if (disposed) return snapshot();
97
+ disposed = true;
98
+ if (installedFactory) {
99
+ try {
100
+ if (!sameFactory(own(WindowModule, 'createWindow'), installedFactory)) stats.childFactoryRestoreConflict = true;
101
+ else { define(WindowModule, 'createWindow', previousFactory); stats.childFactoryRestored = true; }
102
+ } catch { stats.childFactoryRestoreConflict = true; }
103
+ activeChildHook = false;
104
+ }
105
+ for (let index = records.length - 1; index >= 0; index--) {
106
+ const record = records[index];
107
+ try { apply(record.dispose, record.control, []); } catch { increment('cleanupFailures'); }
108
+ try {
109
+ const report = readBinding(record);
110
+ if (report.bindingRemoved) increment('removedBindings');
111
+ if (report.cleanupConflict) increment('cleanupConflicts');
112
+ } catch { increment('snapshotFailures'); }
113
+ activeRealms.delete(record.realm);
114
+ }
115
+ records.length = 0;
116
+ return snapshot();
117
+ }
118
+ try {
119
+ installRealm(window);
120
+ if (children) {
121
+ const original = previousFactory.value;
122
+ const wrapper = function createWindowWithPermissionsBinding(factoryOptions) {
123
+ const child = apply(original, this, arguments);
124
+ if (disposed) return child;
125
+ if (!isObject(factoryOptions) || !own(factoryOptions, 'parentOrigin')) { increment('skippedFactories'); return child; }
126
+ increment('observedChildren');
127
+ if (data(factoryOptions, 'runScripts') !== 'outside-only') { increment('unsupportedChildren'); return child; }
128
+ if (records.length >= MAX_REALMS) { stats.realmLimitReached = true; return child; }
129
+ try {
130
+ const realm = data(child, '_globalProxy');
131
+ if (!realm) increment('unsupportedChildren'); else installRealm(realm);
132
+ } catch { increment('childFailures'); }
133
+ return child;
134
+ };
135
+ installedFactory = { ...previousFactory, value: wrapper };
136
+ define(WindowModule, 'createWindow', installedFactory); activeChildHook = true;
137
+ }
138
+ return freeze({ snapshot, dispose });
139
+ } catch (error) {
140
+ dispose();
141
+ throw error instanceof RuntimePermissionsControlError ? error : new RuntimePermissionsControlError('INSTALL_FAILED');
142
+ }
143
+ }