@amalgm/browser 0.1.0 → 0.1.2-main.34176149752
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/PURPOSE.md +28 -0
- package/README.md +27 -0
- package/dist/src/drivers/electron/native/adblock/index.js +6 -1
- package/dist/src/drivers/electron/native/adblock/index.js.map +1 -1
- package/dist/src/electron-preload.cjs +113 -0
- package/dist/src/electron.cjs +13553 -0
- package/dist/src/electron.d.cts +14 -0
- package/dist/src/runtime-selector.js +7 -13
- package/dist/src/runtime-selector.js.map +1 -1
- package/package.json +109 -20
package/PURPOSE.md
CHANGED
|
@@ -50,6 +50,29 @@ public Browser ports. It does not own a second browser implementation.
|
|
|
50
50
|
|
|
51
51
|
## Axioms
|
|
52
52
|
|
|
53
|
+
Consumer assembly derives exact same-branch dependency pins from the declared
|
|
54
|
+
package manifests and registry candidate records. One pending composition per
|
|
55
|
+
branch preserves human edits; complete consumer checks for the exact merge tree govern its
|
|
56
|
+
merge, and publication never implies installed adoption.
|
|
57
|
+
|
|
58
|
+
Managed package delivery starts from a clean, exact main or preview source
|
|
59
|
+
commit. The workflow occurrence supplies only its generated version and source
|
|
60
|
+
record; tests run against those candidate inputs before packing. Every native
|
|
61
|
+
gate and publication use that same tarball and integrity. A candidate tag makes
|
|
62
|
+
bytes available to release assembly; it never promotes an installed runtime.
|
|
63
|
+
Release tooling remains available inside each owner repository so a developer
|
|
64
|
+
or CI job never needs access to another private product repository.
|
|
65
|
+
Registry credentials are available only to the final protected publication job,
|
|
66
|
+
after every native examination proves the exact candidate bytes.
|
|
67
|
+
Native consumers install the archive as a dependency, so SDK development
|
|
68
|
+
dependencies never become an end-user installation requirement.
|
|
69
|
+
The repository token creates only its own dependency proposals and explicitly
|
|
70
|
+
dispatches checks and delivery; every admitted gate proves the actual checkout,
|
|
71
|
+
including the exact two-parent merge commit that becomes managed source.
|
|
72
|
+
|
|
73
|
+
Managed releases bind to one exact published Core version and build from the
|
|
74
|
+
locked dependency graph on the supported Node toolchain.
|
|
75
|
+
|
|
53
76
|
1. Browser owns browser state and never depends on Chat, Agents, Engine,
|
|
54
77
|
Realtime, or an application renderer to define it.
|
|
55
78
|
2. Every state change passes through `BrowserService`; drivers execute actions
|
|
@@ -115,3 +138,8 @@ they cannot inspect one another. Named auth bundles are separate, explicit
|
|
|
115
138
|
snapshots. Captures, input coordinates, and recordings all address the same
|
|
116
139
|
verified page, while large artifacts leave the API through the injected store.
|
|
117
140
|
Engine and Realtime can compose and relay Browser without becoming Browser.
|
|
141
|
+
|
|
142
|
+
The Browser build supplies its Electron CommonJS adapter and companion preload as
|
|
143
|
+
SDK-owned artifacts; a UI copies those bytes without rebuilding Browser behavior.
|
|
144
|
+
Desktop bridge discovery uses one host-selected machine namespace and a validated
|
|
145
|
+
Core binding; neither a shared user root nor an unknown lane selects another host.
|
package/README.md
CHANGED
|
@@ -118,3 +118,30 @@ adapter contracts, migration fixtures, package installation, and tarball
|
|
|
118
118
|
hygiene. The opt-in suites use real bundled Chromium and real Electron.
|
|
119
119
|
|
|
120
120
|
The complete documentation index is [docs/README.md](./docs/README.md).
|
|
121
|
+
|
|
122
|
+
## Managed package delivery
|
|
123
|
+
|
|
124
|
+
Managed npm delivery uses `.github/workflows/publish-package.yml` after the
|
|
125
|
+
exact main/preview owner checks pass. The occurrence generates a unique
|
|
126
|
+
prerelease version and records its source SHA; it reruns the owner suite, packs
|
|
127
|
+
once, and installs that tarball on Linux, macOS and Windows before publication.
|
|
128
|
+
The `candidate-main`/`candidate-preview` tags are release-assembly inputs and
|
|
129
|
+
never select installed runtimes. `package.json` declares this owner's gates,
|
|
130
|
+
CLI probes, peer-only exports and lifecycle permissions. The standalone runner
|
|
131
|
+
under `scripts/release/` is intentionally copied across owners to preserve
|
|
132
|
+
private repository access boundaries. The final publish step uses the `NPM_TOKEN`
|
|
133
|
+
secret in the `npm-release` environment. Where npm trusted publishing is
|
|
134
|
+
configured for this repository's `publish-package.yml` and that environment,
|
|
135
|
+
the token can be omitted. Authentication does not replace native certification,
|
|
136
|
+
exact source records or artifact integrity; private source repositories do not
|
|
137
|
+
receive npm's public-source provenance.
|
|
138
|
+
|
|
139
|
+
Managed dependency reconciliation reads this owner’s declared manifests and
|
|
140
|
+
updates exact same-branch registry candidates in one pending composition PR per
|
|
141
|
+
branch. The repository token explicitly dispatches the owner checks. Every declared gate must
|
|
142
|
+
pass for the exact merge tree; an atomic expected-base update prevents merging
|
|
143
|
+
with untested concurrent source. Human additions or amendments are preserved.
|
|
144
|
+
The half-hour CI reconciliation recovers missed dispatch hints. Assembly runs
|
|
145
|
+
no dependency code or lifecycle hooks, and repeated owner checks do not publish
|
|
146
|
+
another candidate for unchanged source. Repository policy must allow GitHub Actions to create pull requests; no
|
|
147
|
+
cross-repository credential or paid auto-merge feature is required.
|
|
@@ -24,7 +24,12 @@ export class NativeAdBlocker {
|
|
|
24
24
|
this.allowlist = new AdBlockAllowlist(options.settingsPath);
|
|
25
25
|
}
|
|
26
26
|
cosmeticPreloadPath() {
|
|
27
|
-
|
|
27
|
+
const generatedName = typeof __AMALGM_BROWSER_ADBLOCK_PRELOAD__ === 'string'
|
|
28
|
+
? __AMALGM_BROWSER_ADBLOCK_PRELOAD__
|
|
29
|
+
: 'preload.js';
|
|
30
|
+
return this.disabled
|
|
31
|
+
? null
|
|
32
|
+
: this.options.preloadPath || path.join(import.meta.dirname, generatedName);
|
|
28
33
|
}
|
|
29
34
|
install(session) {
|
|
30
35
|
if (this.installed === session)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/drivers/electron/native/adblock/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAsB,MAAM,qBAAqB,CAAC;AAClE,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC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,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACxE,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC;YAAE,OAAO;QAC1C,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,EAAE;YAC5C,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACjC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QACvE,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;IACX,CAAC;IAEO,UAAU,CAAC,OAAe;QAChC,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAAC,IAAI,KAAK;YAAE,YAAY,CAAC,KAAK,CAAC,CAAC;QAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACtG,CAAC;CACF"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// src/drivers/electron/native/adblock/preload.ts
|
|
4
|
+
var import_electron = require("electron");
|
|
5
|
+
var COSMETIC_INJECTION_CHANNEL = "@ghostery/adblocker/inject-cosmetic-filters";
|
|
6
|
+
var MUTATION_OBSERVER_CHANNEL = "@ghostery/adblocker/is-mutation-observer-enabled";
|
|
7
|
+
var IGNORED_TAGS = /* @__PURE__ */ new Set(["br", "head", "link", "meta", "script", "style", "s"]);
|
|
8
|
+
var MUTATION_DEBOUNCE_MS = 25;
|
|
9
|
+
var MUTATION_MAX_WAIT_MS = 1e3;
|
|
10
|
+
var MUTATION_ELEMENT_LIMIT = 512;
|
|
11
|
+
if (window === window.top && !window.location.href.startsWith("devtools://")) {
|
|
12
|
+
const knownClasses = /* @__PURE__ */ new Set();
|
|
13
|
+
const knownHrefs = /* @__PURE__ */ new Set();
|
|
14
|
+
const knownIds = /* @__PURE__ */ new Set();
|
|
15
|
+
const pendingElements = /* @__PURE__ */ new Set();
|
|
16
|
+
let observer = null;
|
|
17
|
+
let debounceTimer = null;
|
|
18
|
+
let maxWaitTimer = null;
|
|
19
|
+
const inject = (features) => {
|
|
20
|
+
void import_electron.ipcRenderer.invoke(COSMETIC_INJECTION_CHANNEL, window.location.href, features).catch(() => void 0);
|
|
21
|
+
};
|
|
22
|
+
const clearTimers = () => {
|
|
23
|
+
if (debounceTimer) clearTimeout(debounceTimer);
|
|
24
|
+
if (maxWaitTimer) clearTimeout(maxWaitTimer);
|
|
25
|
+
debounceTimer = null;
|
|
26
|
+
maxWaitTimer = null;
|
|
27
|
+
};
|
|
28
|
+
const addNewValue = (value, known, additions) => {
|
|
29
|
+
if (!value || known.has(value)) return;
|
|
30
|
+
known.add(value);
|
|
31
|
+
additions.push(value);
|
|
32
|
+
};
|
|
33
|
+
const collectFeatures = (roots) => {
|
|
34
|
+
const classes = [];
|
|
35
|
+
const hrefs = [];
|
|
36
|
+
const ids = [];
|
|
37
|
+
const visited = /* @__PURE__ */ new Set();
|
|
38
|
+
for (const root of roots) {
|
|
39
|
+
const elements = [
|
|
40
|
+
root,
|
|
41
|
+
...Array.from(root.querySelectorAll("[id], [class], [href]"))
|
|
42
|
+
];
|
|
43
|
+
for (const element of elements) {
|
|
44
|
+
if (visited.has(element)) continue;
|
|
45
|
+
visited.add(element);
|
|
46
|
+
if (IGNORED_TAGS.has(element.tagName.toLowerCase())) continue;
|
|
47
|
+
addNewValue(element.getAttribute("id"), knownIds, ids);
|
|
48
|
+
addNewValue(element.getAttribute("href"), knownHrefs, hrefs);
|
|
49
|
+
for (const className of Array.from(element.classList)) {
|
|
50
|
+
addNewValue(className, knownClasses, classes);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (classes.length || hrefs.length || ids.length) {
|
|
55
|
+
inject({ classes, hrefs, ids, lifecycle: "dom-update" });
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const flushPendingElements = () => {
|
|
59
|
+
clearTimers();
|
|
60
|
+
if (!pendingElements.size) return;
|
|
61
|
+
const elements = [...pendingElements];
|
|
62
|
+
pendingElements.clear();
|
|
63
|
+
collectFeatures(elements);
|
|
64
|
+
};
|
|
65
|
+
const scheduleFlush = () => {
|
|
66
|
+
if (!maxWaitTimer) {
|
|
67
|
+
maxWaitTimer = setTimeout(flushPendingElements, MUTATION_MAX_WAIT_MS);
|
|
68
|
+
}
|
|
69
|
+
if (debounceTimer) clearTimeout(debounceTimer);
|
|
70
|
+
debounceTimer = setTimeout(flushPendingElements, MUTATION_DEBOUNCE_MS);
|
|
71
|
+
};
|
|
72
|
+
const queueElement = (node) => {
|
|
73
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
74
|
+
pendingElements.add(node);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
const startMonitoring = () => {
|
|
78
|
+
if (observer || !document.documentElement) return;
|
|
79
|
+
observer = new MutationObserver((mutations) => {
|
|
80
|
+
for (const mutation of mutations) {
|
|
81
|
+
if (mutation.type === "attributes") {
|
|
82
|
+
queueElement(mutation.target);
|
|
83
|
+
} else {
|
|
84
|
+
mutation.addedNodes.forEach(queueElement);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (pendingElements.size > MUTATION_ELEMENT_LIMIT) {
|
|
88
|
+
flushPendingElements();
|
|
89
|
+
} else if (pendingElements.size) {
|
|
90
|
+
scheduleFlush();
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
observer.observe(document.documentElement, {
|
|
94
|
+
attributes: true,
|
|
95
|
+
attributeFilter: ["class", "id", "href"],
|
|
96
|
+
childList: true,
|
|
97
|
+
subtree: true
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
inject();
|
|
101
|
+
window.addEventListener("DOMContentLoaded", () => {
|
|
102
|
+
if (document.documentElement) collectFeatures([document.documentElement]);
|
|
103
|
+
void import_electron.ipcRenderer.invoke(MUTATION_OBSERVER_CHANNEL).then((enabled) => {
|
|
104
|
+
if (enabled) startMonitoring();
|
|
105
|
+
}).catch(() => void 0);
|
|
106
|
+
}, { once: true, passive: true });
|
|
107
|
+
window.addEventListener("unload", () => {
|
|
108
|
+
observer?.disconnect();
|
|
109
|
+
observer = null;
|
|
110
|
+
pendingElements.clear();
|
|
111
|
+
clearTimers();
|
|
112
|
+
}, { once: true, passive: true });
|
|
113
|
+
}
|