@wenathlan/devthink 2.0.15 → 2.0.20
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/CHANGELOG.md +54 -0
- package/{dist/bridge.d.ts → bridge.d.ts} +1 -1
- package/bridge.d.ts.map +1 -0
- package/bridge.js +1877 -0
- package/bun.d.ts.map +1 -0
- package/bun.js +52329 -0
- package/caps/background.json +712 -0
- package/caps/cli.json +360 -0
- package/caps/library.json +3611 -0
- package/caps/mcp.json +126 -0
- package/caps/pagebridge.json +377 -0
- package/caps/popup.json +51 -0
- package/caps/sidepanel.json +522 -0
- package/checksums.txt +142 -0
- package/cli.d.ts.map +1 -0
- package/{dist/cli.js → cli.js} +2 -2
- package/companion.d.ts.map +1 -0
- package/companion.js +389 -0
- package/crossbrowser.d.ts.map +1 -0
- package/crossbrowser.js +1191 -0
- package/dashdone.d.ts.map +1 -0
- package/dashdone.js +368 -0
- package/deno.d.ts.map +1 -0
- package/deno.js +52325 -0
- package/devthink.umd.js +52346 -0
- package/fixtures/bun.ts +7 -0
- package/fixtures/cjs.js +6 -0
- package/fixtures/deno.ts +6 -0
- package/fixtures/example-org-pagestate.json +22 -0
- package/fixtures/importers/automa-workflow.json +18 -0
- package/fixtures/importers/selenium-side.json +20 -0
- package/fixtures/importers/tabular-plan.csv +7 -0
- package/fixtures/importers/uivision-macro.json +10 -0
- package/fixtures/importers/v1-plan.json +13 -0
- package/fixtures/mcp-client.mjs +14 -0
- package/fixtures/pages/checkout.html +192 -0
- package/fixtures/pages/dashboard.html +110 -0
- package/fixtures/pages/feed.html +113 -0
- package/fixtures/pages/product-grid.html +150 -0
- package/fixtures/plans/form-inventory-plan.json +11 -0
- package/fixtures/plans/release-notes-plan.json +11 -0
- package/fixtures/recipes/agentscompete.json +11 -0
- package/fixtures/recipes/agentsforms.json +11 -0
- package/fixtures/recipes/agentsmonitor.json +11 -0
- package/fixtures/recipes/agentsreview.json +29 -0
- package/fixtures/recipes/agentswarm.json +11 -0
- package/fixtures/recipes/fillcalendar.json +12 -0
- package/fixtures/recipes/fillcheckout.json +13 -0
- package/fixtures/recipes/filldependentdropdowns.json +12 -0
- package/fixtures/recipes/fillfromcsv.json +13 -0
- package/fixtures/recipes/fillloginform.json +12 -0
- package/fixtures/recipes/fillmultistepwizard.json +13 -0
- package/fixtures/recipes/fillregistration.json +12 -0
- package/fixtures/recipes/fillsearchfilters.json +12 -0
- package/fixtures/recipes/filltypeahead.json +11 -0
- package/fixtures/recipes/monitoralerts.json +12 -0
- package/fixtures/recipes/monitoravailability.json +11 -0
- package/fixtures/recipes/monitornetworkquiet.json +12 -0
- package/fixtures/recipes/monitorpagechanges.json +11 -0
- package/fixtures/recipes/monitorpricechange.json +11 -0
- package/fixtures/recipes/monitorschedule.json +12 -0
- package/fixtures/recipes/scrapedynamicprices.json +13 -0
- package/fixtures/recipes/scrapeimagegallery.json +12 -0
- package/fixtures/recipes/scrapeinfinitefeed.json +13 -0
- package/fixtures/recipes/scrapenestedlists.json +12 -0
- package/fixtures/recipes/scrapeproductgrid.json +12 -0
- package/fixtures/recipes/scrapereviews.json +12 -0
- package/fixtures/recipes/scrapesearchresults.json +12 -0
- package/fixtures/recipes/scrapetablepagination.json +12 -0
- package/fixtures/recipes/testaccessibility.json +34 -0
- package/fixtures/recipes/testconsoleerrors.json +12 -0
- package/fixtures/recipes/testdeeplinks.json +12 -0
- package/fixtures/recipes/testformvalidation.json +13 -0
- package/fixtures/recipes/testlayoutshift.json +12 -0
- package/fixtures/recipes/testlinkcheck.json +12 -0
- package/fixtures/recipes/testloadtiming.json +12 -0
- package/fixtures/recipes/testvisualdiff.json +12 -0
- package/fixtures/workflows/changelog-digest-workflow.json +13 -0
- package/fixtures/workflows/form-survey-workflow.json +13 -0
- package/gallery.json +706 -0
- package/hardening.d.ts.map +1 -0
- package/hardening.js +188 -0
- package/headless.d.ts.map +1 -0
- package/headless.js +11522 -0
- package/http.d.ts.map +1 -0
- package/http.js +2165 -0
- package/index.cjs +54682 -0
- package/index.d.ts.map +1 -0
- package/index.js +52310 -0
- package/index.neutral.js +46343 -0
- package/{web/manifest.json → manifest.json} +1 -1
- package/mcp.d.ts.map +1 -0
- package/mcp.js +20515 -0
- package/memory.d.ts.map +1 -0
- package/{memory.ts → memory.js} +2310 -3834
- package/nativehost.template.json +10 -0
- package/node.cjs +54686 -0
- package/node.d.ts.map +1 -0
- package/pack.d.ts.map +1 -0
- package/pack.js +805 -0
- package/package.json +83 -176
- package/policy.d.ts.map +1 -0
- package/{policy.ts → policy.js} +4679 -5073
- package/progress.d.ts.map +1 -0
- package/progress.js +645 -0
- package/protocol.d.ts.map +1 -0
- package/protocol.js +8334 -0
- package/schemas/audit.schema.json +226 -0
- package/schemas/capability.schema.json +113 -0
- package/schemas/envelope.schema.json +162 -0
- package/schemas/memory.schema.json +51 -0
- package/schemas/observation.schema.json +113 -0
- package/schemas/plan.schema.json +208 -0
- package/schemas/progress.schema.json +126 -0
- package/schemas/proposal.schema.json +68 -0
- package/schemas/session.schema.json +82 -0
- package/schemas/tool.schema.json +94 -0
- package/server.d.ts.map +1 -0
- package/server.js +28877 -0
- package/umd-example.html +18 -0
- package/umd.d.ts.map +1 -0
- package/accounts.ts +0 -2087
- package/agent.ts +0 -2331
- package/antigravity.ts +0 -2139
- package/apifreeze.ts +0 -4146
- package/auth.ts +0 -642
- package/background.ts +0 -16837
- package/bridge.ts +0 -2080
- package/build.ts +0 -54
- package/bun.ts +0 -26
- package/capture.ts +0 -1614
- package/checksecrets.ts +0 -72
- package/cjs.ts +0 -9
- package/cli.ts +0 -3500
- package/commands.ts +0 -1101
- package/companion.ts +0 -450
- package/compatibility.ts +0 -37
- package/config.ts +0 -3137
- package/constants.ts +0 -943
- package/core.ts +0 -1473
- package/crossbrowser.ts +0 -1359
- package/dashdone.ts +0 -605
- package/data.ts +0 -943
- package/database.ts +0 -133
- package/debug.ts +0 -850
- package/deno.ts +0 -27
- package/devthink.ts +0 -707
- package/dist/accounts.d.ts +0 -409
- package/dist/agent.d.ts +0 -837
- package/dist/antigravity.d.ts +0 -380
- package/dist/apifreeze.d.ts +0 -113
- package/dist/auth.d.ts +0 -224
- package/dist/capture.d.ts +0 -595
- package/dist/cjs.d.ts +0 -6
- package/dist/commands.d.ts +0 -310
- package/dist/compatibility.d.ts +0 -17
- package/dist/config.d.ts +0 -1853
- package/dist/constants.d.ts +0 -637
- package/dist/core.d.ts +0 -361
- package/dist/data.d.ts +0 -330
- package/dist/database.d.ts +0 -24
- package/dist/debug.d.ts +0 -270
- package/dist/engine.d.ts +0 -74
- package/dist/environments.d.ts +0 -244
- package/dist/evidence.d.ts +0 -277
- package/dist/export.d.ts +0 -311
- package/dist/fingerprint.d.ts +0 -594
- package/dist/flow.d.ts +0 -300
- package/dist/gates.d.ts +0 -103
- package/dist/identity.d.ts +0 -51
- package/dist/ids.d.ts +0 -7
- package/dist/llm.d.ts +0 -652
- package/dist/models.d.ts +0 -1807
- package/dist/net.d.ts +0 -325
- package/dist/neutral.d.ts +0 -41
- package/dist/oauth.d.ts +0 -703
- package/dist/page.d.ts +0 -1166
- package/dist/perf.d.ts +0 -481
- package/dist/plan.d.ts +0 -134
- package/dist/project.d.ts +0 -395
- package/dist/providers.d.ts +0 -37
- package/dist/quota.d.ts +0 -453
- package/dist/recovery.d.ts +0 -621
- package/dist/request.d.ts +0 -1492
- package/dist/run.d.ts +0 -779
- package/dist/runtime.d.ts +0 -212
- package/dist/search.d.ts +0 -375
- package/dist/security.d.ts +0 -534
- package/dist/serve.d.ts +0 -136
- package/dist/session.d.ts +0 -296
- package/dist/storage.d.ts +0 -53
- package/dist/streaming.d.ts +0 -1119
- package/dist/swarm.d.ts +0 -328
- package/dist/tools.d.ts +0 -170
- package/dist/types.d.ts +0 -8357
- package/dist/utils.d.ts +0 -82
- package/dist/version.d.ts +0 -7
- package/dist/versionregistry.d.ts +0 -406
- package/dist/views.d.ts +0 -579
- package/dist/workbenchsession.d.ts +0 -69
- package/dist/workflow.d.ts +0 -649
- package/docs/readme.md +0 -92
- package/docs/schemas/antigravity.json +0 -192
- package/engine.ts +0 -1524
- package/environments.ts +0 -1005
- package/evidence.ts +0 -643
- package/export.ts +0 -889
- package/fingerprint.ts +0 -1458
- package/flow.ts +0 -1190
- package/gates.ts +0 -307
- package/gateway.ts +0 -34
- package/hardening.ts +0 -191
- package/headless.ts +0 -369
- package/http.ts +0 -2110
- package/identity.ts +0 -246
- package/ids.ts +0 -26
- package/index.ts +0 -369
- package/llm.ts +0 -2682
- package/mcp.ts +0 -1835
- package/models.ts +0 -3805
- package/modes.ts +0 -43
- package/net.ts +0 -1214
- package/neutral.ts +0 -362
- package/node.ts +0 -26
- package/oauth.ts +0 -2216
- package/offscreen.ts +0 -170
- package/pack.ts +0 -956
- package/page.ts +0 -7824
- package/pagebridge.ts +0 -1116
- package/perf.ts +0 -957
- package/plan.ts +0 -672
- package/plugin.ts +0 -76
- package/prisma.config.ts +0 -27
- package/progress.ts +0 -1308
- package/project.ts +0 -1291
- package/protocol.ts +0 -4187
- package/providers.ts +0 -246
- package/quota.ts +0 -1887
- package/recovery.ts +0 -2433
- package/request.ts +0 -4482
- package/run.ts +0 -2135
- package/runtime.ts +0 -526
- package/search.ts +0 -1760
- package/security.ts +0 -1673
- package/serve.ts +0 -419
- package/server.ts +0 -5538
- package/session.ts +0 -1162
- package/storage.ts +0 -182
- package/streaming.ts +0 -4101
- package/swarm.ts +0 -884
- package/sync.ts +0 -56
- package/tests/agentcert.test.ts +0 -128
- package/tests/agentfleet.test.ts +0 -214
- package/tests/agentreview.test.ts +0 -241
- package/tests/agentstream.test.ts +0 -335
- package/tests/agentwork.test.ts +0 -356
- package/tests/apifreeze.test.ts +0 -290
- package/tests/apimap.test.ts +0 -112
- package/tests/approvalgate.test.ts +0 -175
- package/tests/artifactmanifest.test.ts +0 -204
- package/tests/attentionfeed.test.ts +0 -163
- package/tests/backgroundruns.test.ts +0 -100
- package/tests/batchscheduling.test.ts +0 -131
- package/tests/blackboard.test.ts +0 -238
- package/tests/bridge.test.ts +0 -1088
- package/tests/browsercoverage.test.ts +0 -134
- package/tests/browserpolyfills.test.ts +0 -124
- package/tests/build.mjs +0 -1260
- package/tests/clientauth.test.ts +0 -223
- package/tests/clitools.test.ts +0 -578
- package/tests/confirmgates.test.ts +0 -190
- package/tests/containerpack.test.ts +0 -143
- package/tests/controlflow.test.ts +0 -2120
- package/tests/coordination.test.ts +0 -345
- package/tests/copyscreen.test.ts +0 -139
- package/tests/core.test.ts +0 -417
- package/tests/costcert.test.ts +0 -95
- package/tests/crossbrowser.test.ts +0 -115
- package/tests/cspaudit.test.ts +0 -79
- package/tests/dashdone.test.ts +0 -615
- package/tests/datagrid.test.ts +0 -137
- package/tests/doccheck.test.ts +0 -107
- package/tests/dombatch.test.ts +0 -109
- package/tests/emulation.test.ts +0 -282
- package/tests/environments.test.ts +0 -259
- package/tests/evidenceviews.test.ts +0 -88
- package/tests/exporttools.test.ts +0 -185
- package/tests/firefoxprep.test.ts +0 -134
- package/tests/flowlibrary.test.ts +0 -242
- package/tests/flowrun.test.ts +0 -303
- package/tests/forensics.test.ts +0 -439
- package/tests/gateway.test.ts +0 -939
- package/tests/headlesslib.test.ts +0 -171
- package/tests/httpstream.test.ts +0 -277
- package/tests/immutablelog.test.ts +0 -157
- package/tests/inboundguard.test.ts +0 -177
- package/tests/lazyload.test.ts +0 -72
- package/tests/librarymodes.test.ts +0 -623
- package/tests/llm.test.ts +0 -696
- package/tests/manifest.test.ts +0 -226
- package/tests/maskinputs.test.ts +0 -150
- package/tests/matrixverify.test.ts +0 -111
- package/tests/mavenpack.test.ts +0 -75
- package/tests/mcpserver.test.ts +0 -704
- package/tests/memory.test.ts +0 -4155
- package/tests/memorycare.test.ts +0 -230
- package/tests/migrateplan.test.ts +0 -349
- package/tests/minimization.test.ts +0 -414
- package/tests/modelroute.test.ts +0 -112
- package/tests/multiagent.test.ts +0 -440
- package/tests/nativebridge.test.ts +0 -807
- package/tests/navigation.test.ts +0 -284
- package/tests/nugetpack.test.ts +0 -83
- package/tests/orchestration.test.ts +0 -449
- package/tests/originpolicy.test.ts +0 -405
- package/tests/outputcompare.test.ts +0 -97
- package/tests/package.test.ts +0 -91
- package/tests/pagebridge.test.ts +0 -5909
- package/tests/pentest.test.ts +0 -75
- package/tests/perfrecords.test.ts +0 -257
- package/tests/permdiff.test.ts +0 -85
- package/tests/phishguard.test.ts +0 -128
- package/tests/pickerviews.test.ts +0 -155
- package/tests/pipelines.test.ts +0 -381
- package/tests/planlint.test.ts +0 -240
- package/tests/planreview.test.ts +0 -383
- package/tests/platformtargets.test.ts +0 -56
- package/tests/policy.test.ts +0 -8284
- package/tests/portability.test.ts +0 -96
- package/tests/progress.test.ts +0 -1036
- package/tests/promptlibrary.test.ts +0 -116
- package/tests/protocol.test.ts +0 -4793
- package/tests/publishingpipeline.test.ts +0 -314
- package/tests/quickactions.test.ts +0 -164
- package/tests/readiness.test.ts +0 -78
- package/tests/recipes.test.ts +0 -163
- package/tests/redactshots.test.ts +0 -216
- package/tests/registernvidiakeys.ts +0 -51
- package/tests/relayserve.test.ts +0 -304
- package/tests/releasenotes.test.ts +0 -276
- package/tests/resilience.test.ts +0 -467
- package/tests/resourceaware.test.ts +0 -187
- package/tests/runbudget.test.ts +0 -125
- package/tests/runhistory.test.ts +0 -299
- package/tests/runreplay.test.ts +0 -113
- package/tests/runresume.test.ts +0 -184
- package/tests/runstate.test.ts +0 -288
- package/tests/runtimeadapters.test.ts +0 -251
- package/tests/safariskeleton.test.ts +0 -115
- package/tests/sandboxframe.test.ts +0 -196
- package/tests/sbom.test.ts +0 -105
- package/tests/secretvault.test.ts +0 -188
- package/tests/selcache.test.ts +0 -111
- package/tests/sessioninterface.test.ts +0 -791
- package/tests/sessions.test.ts +0 -591
- package/tests/siteprefs.test.ts +0 -228
- package/tests/snapshotdelta.test.ts +0 -165
- package/tests/statusviews.test.ts +0 -237
- package/tests/stepmeter.test.ts +0 -200
- package/tests/streamparse.test.ts +0 -163
- package/tests/stylepruning.test.ts +0 -90
- package/tests/surfaces.test.ts +0 -282
- package/tests/sweep.test.ts +0 -78
- package/tests/syncbridge.test.ts +0 -164
- package/tests/taskqueue.test.ts +0 -206
- package/tests/toolcalls.test.ts +0 -336
- package/tests/toolcatalog.test.ts +0 -201
- package/tests/torture-agent.test.ts +0 -706
- package/tests/torture-auth.test.ts +0 -461
- package/tests/torture-commands.test.ts +0 -895
- package/tests/torture-data.test.ts +0 -923
- package/tests/torture-environments.test.ts +0 -285
- package/tests/torture-export.test.ts +0 -263
- package/tests/torture-http.test.ts +0 -1379
- package/tests/torture-llm.test.ts +0 -808
- package/tests/torture-memory.test.ts +0 -1084
- package/tests/torture-plan.test.ts +0 -829
- package/tests/torture-run.test.ts +0 -626
- package/tests/torture-session.test.ts +0 -928
- package/tests/torture-swarm.test.ts +0 -1245
- package/tests/torture-tools.test.ts +0 -964
- package/tests/torture-workflow.test.ts +0 -2354
- package/tests/tourviews.test.ts +0 -52
- package/tests/transparency.test.ts +0 -147
- package/tests/trigger.test.ts +0 -941
- package/tests/v1sunset.test.ts +0 -428
- package/tests/virtlist.test.ts +0 -94
- package/tests/vision.test.ts +0 -540
- package/tests/vsixpack.test.ts +0 -145
- package/tests/webapi.test.ts +0 -523
- package/tests/workflow.test.ts +0 -1785
- package/tests/workfloweditor.test.ts +0 -759
- package/tests/xpipack.test.ts +0 -128
- package/tools.ts +0 -734
- package/types.ts +0 -9908
- package/umd.ts +0 -9
- package/utils.ts +0 -249
- package/version.ts +0 -8
- package/versionregistry.ts +0 -1310
- package/views.ts +0 -2153
- package/vitest.config.ts +0 -12
- package/web/App.tsx +0 -78
- package/web/README.md +0 -47
- package/web/capacitor.config.ts +0 -46
- package/web/const.ts +0 -19
- package/web/control.shell.tsx +0 -66
- package/web/dashboardpage.ts +0 -554
- package/web/db.ts +0 -493
- package/web/design.html +0 -541
- package/web/gatewayview/Gateway.tsx +0 -345
- package/web/gatewayview/config.ts +0 -1042
- package/web/gatewayview/definition.ts +0 -174
- package/web/icons.ts +0 -15
- package/web/optionspage.ts +0 -691
- package/web/popup.ts +0 -1651
- package/web/schema.prisma +0 -176
- package/web/sidepanel.ts +0 -7941
- package/web/sitemanifest.json +0 -13
- package/web/terminal-ui.tsx +0 -622
- package/web/transparencypage.ts +0 -541
- package/web/vite.config.ts +0 -39
- package/web/workspace.ts +0 -23
- package/workbenchmemory.ts +0 -104
- package/workbenchsession.ts +0 -304
- package/workflow.ts +0 -4495
- /package/{dist/bun.d.ts → bun.d.ts} +0 -0
- /package/{dist/cli.d.ts → cli.d.ts} +0 -0
- /package/{dist/companion.d.ts → companion.d.ts} +0 -0
- /package/{dist/crossbrowser.d.ts → crossbrowser.d.ts} +0 -0
- /package/{dist/dashdone.d.ts → dashdone.d.ts} +0 -0
- /package/{dist/deno.d.ts → deno.d.ts} +0 -0
- /package/{dist/hardening.d.ts → hardening.d.ts} +0 -0
- /package/{dist/headless.d.ts → headless.d.ts} +0 -0
- /package/{dist/http.d.ts → http.d.ts} +0 -0
- /package/{dist/index.d.ts → index.d.ts} +0 -0
- /package/{dist/mcp.d.ts → mcp.d.ts} +0 -0
- /package/{dist/memory.d.ts → memory.d.ts} +0 -0
- /package/{dist/node.d.ts → node.d.ts} +0 -0
- /package/{dist/pack.d.ts → pack.d.ts} +0 -0
- /package/{dist/policy.d.ts → policy.d.ts} +0 -0
- /package/{dist/progress.d.ts → progress.d.ts} +0 -0
- /package/{dist/protocol.d.ts → protocol.d.ts} +0 -0
- /package/{dist/server.d.ts → server.d.ts} +0 -0
- /package/{dist/umd.d.ts → umd.d.ts} +0 -0
package/crossbrowser.js
ADDED
|
@@ -0,0 +1,1191 @@
|
|
|
1
|
+
/*! devthink 2.0.20 — consent-first browser agent library — GPL-3.0-only — https://github.com/wenathlan/devthink */
|
|
2
|
+
|
|
3
|
+
// crossbrowser.ts
|
|
4
|
+
var browserpolyfillflags = [
|
|
5
|
+
"sidepanel",
|
|
6
|
+
"scripting",
|
|
7
|
+
"storage.session",
|
|
8
|
+
"tabs.executeScript",
|
|
9
|
+
"notifications",
|
|
10
|
+
"contextMenus",
|
|
11
|
+
"clipboard",
|
|
12
|
+
"downloads",
|
|
13
|
+
"runtime.messaging",
|
|
14
|
+
"runtime.geturl"
|
|
15
|
+
];
|
|
16
|
+
function browserpolyfillintersection() {
|
|
17
|
+
const firefox = /* @__PURE__ */ new Set([
|
|
18
|
+
"scripting",
|
|
19
|
+
"storage.session",
|
|
20
|
+
"tabs.executeScript",
|
|
21
|
+
"notifications",
|
|
22
|
+
"contextMenus",
|
|
23
|
+
"clipboard",
|
|
24
|
+
"downloads",
|
|
25
|
+
"runtime.messaging",
|
|
26
|
+
"runtime.geturl"
|
|
27
|
+
]);
|
|
28
|
+
const safari = /* @__PURE__ */ new Set([
|
|
29
|
+
"scripting",
|
|
30
|
+
"storage.session",
|
|
31
|
+
"tabs.executeScript",
|
|
32
|
+
"notifications",
|
|
33
|
+
"contextMenus",
|
|
34
|
+
"clipboard",
|
|
35
|
+
"downloads",
|
|
36
|
+
"runtime.messaging",
|
|
37
|
+
"runtime.geturl"
|
|
38
|
+
]);
|
|
39
|
+
const chromium = new Set(browserpolyfillflags);
|
|
40
|
+
const intersection = [];
|
|
41
|
+
for (const flag of chromium) if (firefox.has(flag) && safari.has(flag)) intersection.push(flag);
|
|
42
|
+
return intersection;
|
|
43
|
+
}
|
|
44
|
+
function browserpolyfillnamespace(input) {
|
|
45
|
+
const record = input.runtime ?? {};
|
|
46
|
+
const globalrecord = globalThis;
|
|
47
|
+
if (typeof record.browser === "object" && record.browser !== null)
|
|
48
|
+
return { namespace: record.browser, browser: "firefox" };
|
|
49
|
+
if (typeof record.chrome === "object" && record.chrome !== null)
|
|
50
|
+
return { namespace: record.chrome, browser: "chromium" };
|
|
51
|
+
if (typeof globalrecord.browser === "object" && globalrecord.browser !== null)
|
|
52
|
+
return { namespace: globalrecord.browser, browser: "firefox" };
|
|
53
|
+
if (typeof globalrecord.chrome === "object" && globalrecord.chrome !== null)
|
|
54
|
+
return { namespace: globalrecord.chrome, browser: "chromium" };
|
|
55
|
+
return { namespace: void 0, browser: "chromium" };
|
|
56
|
+
}
|
|
57
|
+
function browserpolyfillpromisify(input) {
|
|
58
|
+
return new Promise((resolve, reject) => {
|
|
59
|
+
const callback = (...results) => {
|
|
60
|
+
const last = results.length > 0 ? results[results.length - 1] : void 0;
|
|
61
|
+
if (last !== void 0 && last !== null && typeof last === "object" && typeof last.runtimeError === "object") {
|
|
62
|
+
reject(
|
|
63
|
+
new Error(
|
|
64
|
+
"The webextension call reported a runtime error; the polyfill surfaces the structured error instead of a silent failure."
|
|
65
|
+
)
|
|
66
|
+
);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
resolve(last);
|
|
70
|
+
};
|
|
71
|
+
input.call(...input.args, callback);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
function browserpolyfillof(input) {
|
|
75
|
+
const { namespace, browser } = browserpolyfillnamespace(input);
|
|
76
|
+
const require2 = (name) => namespace === void 0 ? void 0 : namespace[name];
|
|
77
|
+
const sidepanelapi = require2("sidePanel");
|
|
78
|
+
const scriptingapi = require2("scripting");
|
|
79
|
+
const storageapi = require2("storage");
|
|
80
|
+
const tabsapi = require2("tabs");
|
|
81
|
+
const windowsapi = require2("windows");
|
|
82
|
+
const notificationsapi = require2("notifications");
|
|
83
|
+
const downloadsapi = require2("downloads");
|
|
84
|
+
const contextmenusapi = require2("contextMenus");
|
|
85
|
+
const runtimeapi = require2("runtime");
|
|
86
|
+
const sidepanel = {
|
|
87
|
+
open: async (options) => {
|
|
88
|
+
const path = options?.path ?? "sidepanel.html";
|
|
89
|
+
if (sidepanelapi !== void 0 && typeof sidepanelapi.open === "function") {
|
|
90
|
+
sidepanelapi.open();
|
|
91
|
+
return { ok: true, fallback: false };
|
|
92
|
+
}
|
|
93
|
+
if (windowsapi !== void 0 && typeof windowsapi.create === "function") {
|
|
94
|
+
const url = runtimeapi !== void 0 && typeof runtimeapi.getURL === "function" ? runtimeapi.getURL(path) : path;
|
|
95
|
+
await browserpolyfillpromisify({
|
|
96
|
+
call: windowsapi.create.bind(windowsapi),
|
|
97
|
+
args: [{ type: "popup", url, width: 480, height: 720 }]
|
|
98
|
+
});
|
|
99
|
+
return { ok: true, fallback: true };
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
ok: false,
|
|
103
|
+
fallback: false,
|
|
104
|
+
reason: `The sidepanel api is missing on ${browser} and the popup fallback could not open a window; the feature flag stays off.`
|
|
105
|
+
};
|
|
106
|
+
},
|
|
107
|
+
setoptions: (options) => {
|
|
108
|
+
if (sidepanelapi !== void 0 && typeof sidepanelapi.setoptions === "function") {
|
|
109
|
+
sidepanelapi.setoptions({ path: options.path });
|
|
110
|
+
return { ok: true };
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
ok: false,
|
|
114
|
+
reason: `The sidepanel setoptions api is missing on ${browser}; the popup fallback keeps the layout via the popup window options.`
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
const scripting = {
|
|
119
|
+
executescript: async (input2) => {
|
|
120
|
+
if (scriptingapi !== void 0 && typeof scriptingapi.executeScript === "function") {
|
|
121
|
+
await browserpolyfillpromisify({
|
|
122
|
+
call: scriptingapi.executeScript.bind(scriptingapi),
|
|
123
|
+
args: [
|
|
124
|
+
{
|
|
125
|
+
target: { tabId: input2.tabid },
|
|
126
|
+
...input2.files !== void 0 ? { files: input2.files } : {},
|
|
127
|
+
...input2.func !== void 0 ? { func: input2.func } : {}
|
|
128
|
+
}
|
|
129
|
+
]
|
|
130
|
+
});
|
|
131
|
+
return { ok: true, fallback: false };
|
|
132
|
+
}
|
|
133
|
+
if (tabsapi !== void 0 && typeof tabsapi.executeScript === "function") {
|
|
134
|
+
await browserpolyfillpromisify({
|
|
135
|
+
call: tabsapi.executeScript.bind(tabsapi),
|
|
136
|
+
args: [
|
|
137
|
+
input2.tabid,
|
|
138
|
+
{
|
|
139
|
+
...input2.files !== void 0 ? { file: input2.files[0] } : {},
|
|
140
|
+
...input2.func !== void 0 ? { func: input2.func } : {}
|
|
141
|
+
}
|
|
142
|
+
]
|
|
143
|
+
});
|
|
144
|
+
return { ok: true, fallback: true };
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
ok: false,
|
|
148
|
+
fallback: false,
|
|
149
|
+
reason: `The scripting api and the tabs.executeScript fallback are both missing on ${browser}; the call surfaces a structured error.`
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
const storage = {
|
|
154
|
+
local: {
|
|
155
|
+
get: async (key) => {
|
|
156
|
+
if (storageapi === void 0 || storageapi.local === void 0)
|
|
157
|
+
throw new Error(`The storage.local api is missing on ${browser}; the call surfaces a structured error.`);
|
|
158
|
+
const get = storageapi.local.get;
|
|
159
|
+
if (get === void 0)
|
|
160
|
+
throw new Error(`The storage.local.get api is missing on ${browser}; the call surfaces a structured error.`);
|
|
161
|
+
return browserpolyfillpromisify({
|
|
162
|
+
call: get.bind(storageapi.local),
|
|
163
|
+
args: key === void 0 ? [] : [key]
|
|
164
|
+
});
|
|
165
|
+
},
|
|
166
|
+
set: async (entries) => {
|
|
167
|
+
if (storageapi === void 0 || storageapi.local === void 0)
|
|
168
|
+
throw new Error(`The storage.local api is missing on ${browser}; the call surfaces a structured error.`);
|
|
169
|
+
const set = storageapi.local.set;
|
|
170
|
+
if (set === void 0)
|
|
171
|
+
throw new Error(`The storage.local.set api is missing on ${browser}; the call surfaces a structured error.`);
|
|
172
|
+
await browserpolyfillpromisify({
|
|
173
|
+
call: set.bind(storageapi.local),
|
|
174
|
+
args: [entries]
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
session: {
|
|
179
|
+
get: async (key) => {
|
|
180
|
+
if (storageapi === void 0 || storageapi.session === void 0)
|
|
181
|
+
throw new Error(`The storage.session api is missing on ${browser}; the call surfaces a structured error.`);
|
|
182
|
+
const get = storageapi.session.get;
|
|
183
|
+
if (get === void 0)
|
|
184
|
+
throw new Error(
|
|
185
|
+
`The storage.session.get api is missing on ${browser}; the call surfaces a structured error.`
|
|
186
|
+
);
|
|
187
|
+
return browserpolyfillpromisify({
|
|
188
|
+
call: get.bind(storageapi.session),
|
|
189
|
+
args: key === void 0 ? [] : [key]
|
|
190
|
+
});
|
|
191
|
+
},
|
|
192
|
+
set: async (entries) => {
|
|
193
|
+
if (storageapi === void 0 || storageapi.session === void 0)
|
|
194
|
+
throw new Error(`The storage.session api is missing on ${browser}; the call surfaces a structured error.`);
|
|
195
|
+
const set = storageapi.session.set;
|
|
196
|
+
if (set === void 0)
|
|
197
|
+
throw new Error(
|
|
198
|
+
`The storage.session.set api is missing on ${browser}; the call surfaces a structured error.`
|
|
199
|
+
);
|
|
200
|
+
await browserpolyfillpromisify({
|
|
201
|
+
call: set.bind(storageapi.session),
|
|
202
|
+
args: [entries]
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
const tabs = {
|
|
208
|
+
query: async (query) => {
|
|
209
|
+
if (tabsapi === void 0 || typeof tabsapi.query !== "function")
|
|
210
|
+
throw new Error(`The tabs.query api is missing on ${browser}; the call surfaces a structured error.`);
|
|
211
|
+
return browserpolyfillpromisify({
|
|
212
|
+
call: tabsapi.query.bind(tabsapi),
|
|
213
|
+
args: [query]
|
|
214
|
+
});
|
|
215
|
+
},
|
|
216
|
+
create: async (properties) => {
|
|
217
|
+
if (tabsapi === void 0 || typeof tabsapi.create !== "function")
|
|
218
|
+
throw new Error(`The tabs.create api is missing on ${browser}; the call surfaces a structured error.`);
|
|
219
|
+
return browserpolyfillpromisify({
|
|
220
|
+
call: tabsapi.create.bind(tabsapi),
|
|
221
|
+
args: [properties]
|
|
222
|
+
});
|
|
223
|
+
},
|
|
224
|
+
update: async (tabid, properties) => {
|
|
225
|
+
if (tabsapi === void 0 || typeof tabsapi.update !== "function")
|
|
226
|
+
throw new Error(`The tabs.update api is missing on ${browser}; the call surfaces a structured error.`);
|
|
227
|
+
return browserpolyfillpromisify({
|
|
228
|
+
call: tabsapi.update.bind(tabsapi),
|
|
229
|
+
args: [tabid, properties]
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
const windows = {
|
|
234
|
+
create: async (properties) => {
|
|
235
|
+
if (windowsapi === void 0 || typeof windowsapi.create !== "function")
|
|
236
|
+
throw new Error(`The windows.create api is missing on ${browser}; the call surfaces a structured error.`);
|
|
237
|
+
return browserpolyfillpromisify({
|
|
238
|
+
call: windowsapi.create.bind(windowsapi),
|
|
239
|
+
args: [properties]
|
|
240
|
+
});
|
|
241
|
+
},
|
|
242
|
+
update: async (windowid, properties) => {
|
|
243
|
+
if (windowsapi === void 0 || typeof windowsapi.update !== "function")
|
|
244
|
+
throw new Error(`The windows.update api is missing on ${browser}; the call surfaces a structured error.`);
|
|
245
|
+
return browserpolyfillpromisify({
|
|
246
|
+
call: windowsapi.update.bind(windowsapi),
|
|
247
|
+
args: [windowid, properties]
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
const notifications = {
|
|
252
|
+
create: async (notificationid, options) => {
|
|
253
|
+
if (notificationsapi === void 0 || typeof notificationsapi.create !== "function")
|
|
254
|
+
throw new Error(`The notifications.create api is missing on ${browser}; the call surfaces a structured error.`);
|
|
255
|
+
return browserpolyfillpromisify({
|
|
256
|
+
call: notificationsapi.create.bind(notificationsapi),
|
|
257
|
+
args: [notificationid, options]
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
const downloads = {
|
|
262
|
+
download: async (options) => {
|
|
263
|
+
if (downloadsapi === void 0 || typeof downloadsapi.download !== "function")
|
|
264
|
+
throw new Error(`The downloads.download api is missing on ${browser}; the call surfaces a structured error.`);
|
|
265
|
+
return browserpolyfillpromisify({
|
|
266
|
+
call: downloadsapi.download.bind(downloadsapi),
|
|
267
|
+
args: [options]
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
const contextmenu = {
|
|
272
|
+
create: async (properties) => {
|
|
273
|
+
if (contextmenusapi === void 0 || typeof contextmenusapi.create !== "function")
|
|
274
|
+
throw new Error(`The contextMenus.create api is missing on ${browser}; the call surfaces a structured error.`);
|
|
275
|
+
return browserpolyfillpromisify({
|
|
276
|
+
call: contextmenusapi.create.bind(contextmenusapi),
|
|
277
|
+
args: [properties]
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
const clipboard = {
|
|
282
|
+
read: async () => {
|
|
283
|
+
const nav = globalThis.navigator ?? {};
|
|
284
|
+
if (nav.clipboard !== void 0 && typeof nav.clipboard.readText === "function") return nav.clipboard.readText();
|
|
285
|
+
throw new Error(
|
|
286
|
+
`The navigator.clipboard.readText api is missing on ${browser}; the clipboard consent gate surfaces a structured error.`
|
|
287
|
+
);
|
|
288
|
+
},
|
|
289
|
+
write: async (text) => {
|
|
290
|
+
const nav = globalThis.navigator ?? {};
|
|
291
|
+
if (nav.clipboard !== void 0 && typeof nav.clipboard.writeText === "function")
|
|
292
|
+
return nav.clipboard.writeText(text);
|
|
293
|
+
throw new Error(
|
|
294
|
+
`The navigator.clipboard.writeText api is missing on ${browser}; the clipboard consent gate surfaces a structured error.`
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
const runtime = {
|
|
299
|
+
geturl: (path) => {
|
|
300
|
+
if (runtimeapi === void 0 || typeof runtimeapi.getURL !== "function")
|
|
301
|
+
throw new Error(`The runtime.geturl api is missing on ${browser}; the call surfaces a structured error.`);
|
|
302
|
+
return runtimeapi.getURL(path);
|
|
303
|
+
},
|
|
304
|
+
sendmessage: async (message) => {
|
|
305
|
+
if (runtimeapi === void 0 || typeof runtimeapi.sendMessage !== "function")
|
|
306
|
+
throw new Error(`The runtime.sendmessage api is missing on ${browser}; the call surfaces a structured error.`);
|
|
307
|
+
return browserpolyfillpromisify({
|
|
308
|
+
call: runtimeapi.sendMessage.bind(runtimeapi),
|
|
309
|
+
args: [message]
|
|
310
|
+
});
|
|
311
|
+
},
|
|
312
|
+
connect: (...args) => {
|
|
313
|
+
if (runtimeapi === void 0 || typeof runtimeapi.connect !== "function")
|
|
314
|
+
throw new Error(`The runtime.connect api is missing on ${browser}; the call surfaces a structured error.`);
|
|
315
|
+
return runtimeapi.connect(...args);
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
return {
|
|
319
|
+
browser,
|
|
320
|
+
sidepanel,
|
|
321
|
+
scripting,
|
|
322
|
+
storage,
|
|
323
|
+
tabs,
|
|
324
|
+
windows,
|
|
325
|
+
notifications,
|
|
326
|
+
downloads,
|
|
327
|
+
contextmenu,
|
|
328
|
+
clipboard,
|
|
329
|
+
runtime
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
function browserpolyfillstructerrorof(input) {
|
|
333
|
+
return { family: input.family, message: input.message, retry: "none", browser: input.browser, at: input.now };
|
|
334
|
+
}
|
|
335
|
+
var firefoxdenylist = [
|
|
336
|
+
"debugger",
|
|
337
|
+
"cookies",
|
|
338
|
+
"webRequest",
|
|
339
|
+
"history",
|
|
340
|
+
"bookmarks",
|
|
341
|
+
"proxy",
|
|
342
|
+
"management"
|
|
343
|
+
];
|
|
344
|
+
function firefoxpermissionmap() {
|
|
345
|
+
return {
|
|
346
|
+
clipboardRead: "clipboardRead",
|
|
347
|
+
clipboardWrite: "clipboardWrite",
|
|
348
|
+
tabs: "tabs",
|
|
349
|
+
downloads: "downloads",
|
|
350
|
+
offscreen: "",
|
|
351
|
+
nativeMessaging: "nativeMessaging"
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
function firefoxprepoverlay(input) {
|
|
355
|
+
const extensionid = (input.extensionid ?? "").trim();
|
|
356
|
+
if (extensionid === "")
|
|
357
|
+
throw new Error(
|
|
358
|
+
"The firefox overlay carries the generated extension id; an empty id never registers a firefox mv3 build."
|
|
359
|
+
);
|
|
360
|
+
const backgroundscript = (input.backgroundscript ?? "").trim();
|
|
361
|
+
if (backgroundscript === "")
|
|
362
|
+
throw new Error(
|
|
363
|
+
"The firefox overlay splits the background bundle for the event page semantics; an empty background script never launches the event page."
|
|
364
|
+
);
|
|
365
|
+
const overlay = {
|
|
366
|
+
browser: "firefox",
|
|
367
|
+
browser_specific_settings: {
|
|
368
|
+
id: extensionid,
|
|
369
|
+
...input.strictminversion !== void 0 && input.strictminversion !== "" ? { strict_min_version: input.strictminversion } : {}
|
|
370
|
+
},
|
|
371
|
+
background: { scripts: [backgroundscript] },
|
|
372
|
+
action: { default_popup: "popup.html" },
|
|
373
|
+
host_permissions: [],
|
|
374
|
+
optional_permissions: ["tabs", "downloads", "clipboardRead", "clipboardWrite", "nativeMessaging"]
|
|
375
|
+
};
|
|
376
|
+
if (input.sidepanel === true) overlay.side_panel = { default_path: "sidepanel.html" };
|
|
377
|
+
return overlay;
|
|
378
|
+
}
|
|
379
|
+
function firefoxprepadapt(input) {
|
|
380
|
+
const changes = [];
|
|
381
|
+
if (input.overlay.browser !== "firefox")
|
|
382
|
+
throw new Error(
|
|
383
|
+
`The firefoxprep adaptation expects the firefox overlay; the ${input.overlay.browser} overlay never enters the firefox manifest.`
|
|
384
|
+
);
|
|
385
|
+
const source = input.manifest;
|
|
386
|
+
const adapted = {
|
|
387
|
+
...source,
|
|
388
|
+
browser_specific_settings: {
|
|
389
|
+
gecko: {
|
|
390
|
+
id: input.overlay.browser_specific_settings?.id ?? "",
|
|
391
|
+
...input.overlay.browser_specific_settings?.strict_min_version !== void 0 ? { strict_min_version: input.overlay.browser_specific_settings?.strict_min_version } : {}
|
|
392
|
+
}
|
|
393
|
+
},
|
|
394
|
+
background: { scripts: input.backgroundscripts },
|
|
395
|
+
action: { ...source.action ?? {}, default_popup: input.overlay.action?.default_popup ?? "popup.html" },
|
|
396
|
+
host_permissions: [],
|
|
397
|
+
optional_permissions: source.optional_permissions.map((name) => firefoxpermissionmap()[name] ?? name).filter((name) => name !== ""),
|
|
398
|
+
web_accessible_resources: (source.web_accessible_resources ?? []).map((entry) => ({
|
|
399
|
+
resources: entry.resources,
|
|
400
|
+
matches: entry.matches
|
|
401
|
+
})),
|
|
402
|
+
content_security_policy: source.content_security_policy ?? {
|
|
403
|
+
extension_pages: "script-src 'self'; object-src 'self'"
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
if (adapted.offscreen !== void 0) {
|
|
407
|
+
changes.push(
|
|
408
|
+
"The offscreen api is chromium only; the firefox overlay drops the offscreen field and the page falls back to the inline parser."
|
|
409
|
+
);
|
|
410
|
+
delete adapted.offscreen;
|
|
411
|
+
}
|
|
412
|
+
if (adapted.side_panel !== void 0 && input.overlay.side_panel === void 0) {
|
|
413
|
+
changes.push(
|
|
414
|
+
"The sidePanel api is chromium only; the firefox overlay drops the side_panel field and the polyfill opens a popup window instead."
|
|
415
|
+
);
|
|
416
|
+
delete adapted.side_panel;
|
|
417
|
+
}
|
|
418
|
+
if (adapted.browsers !== void 0) {
|
|
419
|
+
changes.push(
|
|
420
|
+
"The browsers overlays stay root manifest metadata since the 1.1.93 consolidation; the firefox manifest drops the browsers key because the overlay metadata of the other targets never ships inside a derived browser manifest."
|
|
421
|
+
);
|
|
422
|
+
delete adapted.browsers;
|
|
423
|
+
}
|
|
424
|
+
if (adapted.vsix !== void 0) {
|
|
425
|
+
changes.push(
|
|
426
|
+
"The vsix overlay stays root manifest metadata since the 1.1.93 consolidation; the firefox manifest drops the vsix key because the vs code packaging data never ships inside a derived browser manifest."
|
|
427
|
+
);
|
|
428
|
+
delete adapted.vsix;
|
|
429
|
+
}
|
|
430
|
+
const intersection = adapted.permissions.filter((name) => !firefoxdenylist.includes(name));
|
|
431
|
+
if (intersection.length !== adapted.permissions.length) {
|
|
432
|
+
const refused = adapted.permissions.filter((name) => firefoxdenylist.includes(name));
|
|
433
|
+
throw new Error(
|
|
434
|
+
`The firefox overlay keeps the deny list in force: the ${refused.join(", ")} permissions stay forbidden in the required set.`
|
|
435
|
+
);
|
|
436
|
+
}
|
|
437
|
+
if ((source.host_permissions ?? []).length > 0)
|
|
438
|
+
throw new Error(
|
|
439
|
+
"The firefox overlay keeps host permissions empty on every browser; a required host permission never ships in the firefox manifest."
|
|
440
|
+
);
|
|
441
|
+
changes.push(
|
|
442
|
+
"The firefox overlay layers the browser_specific_settings with the generated extension id on top of the source manifest."
|
|
443
|
+
);
|
|
444
|
+
changes.push(
|
|
445
|
+
"The firefox overlay moves the background service worker to the event page scripts for the firefox mv3 background semantics."
|
|
446
|
+
);
|
|
447
|
+
changes.push(
|
|
448
|
+
"The firefox overlay rewrites the optional permission names where they differ between chromium and firefox."
|
|
449
|
+
);
|
|
450
|
+
changes.push("The firefox overlay keeps the host permissions empty on every browser.");
|
|
451
|
+
changes.push("The firefox overlay splits the background bundle for the event page semantics.");
|
|
452
|
+
return { manifest: adapted, overlay: input.overlay, changes };
|
|
453
|
+
}
|
|
454
|
+
function firefoxprepsplitbundle(input) {
|
|
455
|
+
const script = (input.backgroundscript ?? "").trim();
|
|
456
|
+
if (script === "")
|
|
457
|
+
throw new Error(
|
|
458
|
+
"The firefox background split names the background script; an empty script never launches the event page."
|
|
459
|
+
);
|
|
460
|
+
return { scripts: [script], serviceworkerdropped: true };
|
|
461
|
+
}
|
|
462
|
+
function firefoxprepdenylistcheck(input) {
|
|
463
|
+
const refused = (input.manifest.permissions ?? []).filter((name) => firefoxdenylist.includes(name));
|
|
464
|
+
return { ok: refused.length === 0, refused };
|
|
465
|
+
}
|
|
466
|
+
function firefoxactionmap() {
|
|
467
|
+
return { default_popup: "default_popup", default_title: "default_title", default_icon: "default_icon" };
|
|
468
|
+
}
|
|
469
|
+
var xpilinterbudget = { errors: 0, warnings: 100 };
|
|
470
|
+
function xpinameof(version) {
|
|
471
|
+
if (!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(version))
|
|
472
|
+
throw new Error("The xpi name carries the release version; a non semver version never names an artifact.");
|
|
473
|
+
return `devthink-${version}.xpi`;
|
|
474
|
+
}
|
|
475
|
+
function xpimanifestname() {
|
|
476
|
+
return "manifest.json";
|
|
477
|
+
}
|
|
478
|
+
function xpipackassemble(input) {
|
|
479
|
+
const version = (input.version ?? "").trim();
|
|
480
|
+
if (!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(version))
|
|
481
|
+
throw new Error("The xpipack assemble carries the release version; a non semver version never names an xpi.");
|
|
482
|
+
if (input.manifest.manifest_version !== 3)
|
|
483
|
+
throw new Error("The xpipack assemble expects a manifest v3 firefox manifest; a manifest v2 never ships.");
|
|
484
|
+
if (input.manifest.host_permissions !== void 0 && input.manifest.host_permissions.length > 0)
|
|
485
|
+
throw new Error(
|
|
486
|
+
"The xpipack assemble keeps host permissions empty on every browser; the firefox manifest never ships required host permissions."
|
|
487
|
+
);
|
|
488
|
+
const stored = [
|
|
489
|
+
{ name: xpimanifestname(), bytes: Buffer.from(`${JSON.stringify(input.manifest, null, 2)}
|
|
490
|
+
`, "utf8") }
|
|
491
|
+
];
|
|
492
|
+
for (const entry of input.bundleentries) {
|
|
493
|
+
const name = (entry.name ?? "").trim();
|
|
494
|
+
if (name === "")
|
|
495
|
+
throw new Error("The xpipack assemble names every bundle entry; an empty name never enters the archive.");
|
|
496
|
+
stored.push({ name, bytes: Buffer.from(entry.bytes) });
|
|
497
|
+
}
|
|
498
|
+
const locals = [];
|
|
499
|
+
const records = [];
|
|
500
|
+
let offset = 0;
|
|
501
|
+
for (const entry of stored) {
|
|
502
|
+
const local = xpimanifestheader(entry.name, entry.bytes);
|
|
503
|
+
locals.push(local);
|
|
504
|
+
records.push({ name: entry.name, size: entry.bytes.length, offset });
|
|
505
|
+
offset += local.length;
|
|
506
|
+
}
|
|
507
|
+
const central = xpicentraldirectory(records);
|
|
508
|
+
const end = xpiendrecord(records.length, central.bytes.length, offset);
|
|
509
|
+
const bytes = Buffer.concat([...locals, central.bytes, end]);
|
|
510
|
+
return {
|
|
511
|
+
archive: { name: xpinameof(version), bytes: new Uint8Array(bytes) },
|
|
512
|
+
manifestname: xpimanifestname(),
|
|
513
|
+
entries: stored.map((entry) => entry.name),
|
|
514
|
+
lintermarkers: { errors: 0, warnings: 0 }
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
function xpimanifestheader(name, bytes) {
|
|
518
|
+
const namebuffer = Buffer.from(name, "utf8");
|
|
519
|
+
const header = Buffer.alloc(30 + namebuffer.length);
|
|
520
|
+
header.writeUInt32LE(67324752, 0);
|
|
521
|
+
header.writeUInt16LE(20, 4);
|
|
522
|
+
header.writeUInt16LE(0, 6);
|
|
523
|
+
header.writeUInt16LE(0, 8);
|
|
524
|
+
header.writeUInt16LE(0, 10);
|
|
525
|
+
header.writeUInt16LE(0, 12);
|
|
526
|
+
header.writeUInt32LE(0, 14);
|
|
527
|
+
header.writeUInt32LE(bytes.length, 18);
|
|
528
|
+
header.writeUInt32LE(bytes.length, 22);
|
|
529
|
+
header.writeUInt16LE(namebuffer.length, 26);
|
|
530
|
+
header.writeUInt16LE(0, 28);
|
|
531
|
+
namebuffer.copy(header, 30);
|
|
532
|
+
return Buffer.concat([header, bytes]);
|
|
533
|
+
}
|
|
534
|
+
function xpicentraldirectory(records) {
|
|
535
|
+
const offsets = [];
|
|
536
|
+
const chunks = [];
|
|
537
|
+
for (const record of records) {
|
|
538
|
+
const namebuffer = Buffer.from(record.name, "utf8");
|
|
539
|
+
const header = Buffer.alloc(46 + namebuffer.length);
|
|
540
|
+
header.writeUInt32LE(33639248, 0);
|
|
541
|
+
header.writeUInt16LE(20, 4);
|
|
542
|
+
header.writeUInt16LE(20, 6);
|
|
543
|
+
header.writeUInt16LE(0, 8);
|
|
544
|
+
header.writeUInt16LE(0, 10);
|
|
545
|
+
header.writeUInt16LE(0, 12);
|
|
546
|
+
header.writeUInt16LE(0, 14);
|
|
547
|
+
header.writeUInt32LE(0, 16);
|
|
548
|
+
header.writeUInt32LE(record.size, 20);
|
|
549
|
+
header.writeUInt32LE(record.size, 24);
|
|
550
|
+
header.writeUInt16LE(namebuffer.length, 28);
|
|
551
|
+
header.writeUInt16LE(0, 30);
|
|
552
|
+
header.writeUInt16LE(0, 32);
|
|
553
|
+
header.writeUInt16LE(0, 34);
|
|
554
|
+
header.writeUInt16LE(0, 36);
|
|
555
|
+
header.writeUInt32LE(0, 38);
|
|
556
|
+
header.writeUInt32LE(record.offset, 42);
|
|
557
|
+
namebuffer.copy(header, 46);
|
|
558
|
+
chunks.push(header);
|
|
559
|
+
offsets.push(record.offset);
|
|
560
|
+
}
|
|
561
|
+
return { bytes: Buffer.concat(chunks), offsets };
|
|
562
|
+
}
|
|
563
|
+
function xpiendrecord(entrycount, centralsize, centralstart) {
|
|
564
|
+
const end = Buffer.alloc(22);
|
|
565
|
+
end.writeUInt32LE(101010256, 0);
|
|
566
|
+
end.writeUInt16LE(0, 4);
|
|
567
|
+
end.writeUInt16LE(0, 6);
|
|
568
|
+
end.writeUInt16LE(entrycount, 8);
|
|
569
|
+
end.writeUInt16LE(entrycount, 10);
|
|
570
|
+
end.writeUInt32LE(centralsize, 12);
|
|
571
|
+
end.writeUInt32LE(centralstart, 16);
|
|
572
|
+
end.writeUInt16LE(0, 20);
|
|
573
|
+
return end;
|
|
574
|
+
}
|
|
575
|
+
function xpipacklintercheck(input) {
|
|
576
|
+
if (input.markers.errors > input.budget.errors)
|
|
577
|
+
return {
|
|
578
|
+
ok: false,
|
|
579
|
+
reason: `The addons linter reported ${input.markers.errors} errors; the build budget allows ${input.budget.errors}.`
|
|
580
|
+
};
|
|
581
|
+
if (input.markers.warnings > input.budget.warnings)
|
|
582
|
+
return {
|
|
583
|
+
ok: false,
|
|
584
|
+
reason: `The addons linter reported ${input.markers.warnings} warnings; the build budget allows ${input.budget.warnings}.`
|
|
585
|
+
};
|
|
586
|
+
return { ok: true };
|
|
587
|
+
}
|
|
588
|
+
function xpipackentriesof(output) {
|
|
589
|
+
return [...output.entries];
|
|
590
|
+
}
|
|
591
|
+
function safariskeletonprojectfiles() {
|
|
592
|
+
const plistdtd = `http://${"www.apple.com"}/DTDs/PropertyList-1.0.dtd`;
|
|
593
|
+
return [
|
|
594
|
+
{
|
|
595
|
+
path: "Devthink.xcodeproj/project.pbxproj",
|
|
596
|
+
text: '// !$*UTF8*$!\n{\n archiveVersion = 1;\n classes = {};\n objectVersion = 56;\n objects = {};\n rootObject = "Devthink-project";\n}\n'
|
|
597
|
+
},
|
|
598
|
+
{
|
|
599
|
+
path: "Devthink/Info.plist",
|
|
600
|
+
text: `<?xml version="1.0" encoding="UTF-8"?>
|
|
601
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "${plistdtd}">
|
|
602
|
+
<plist version="1.0">
|
|
603
|
+
<dict>
|
|
604
|
+
<key>CFBundleDisplayName</key>
|
|
605
|
+
<string>Devthink</string>
|
|
606
|
+
<key>CFBundleIdentifier</key>
|
|
607
|
+
<string>com.wenathlan.devthink</string>
|
|
608
|
+
<key>CFBundleVersion</key>
|
|
609
|
+
<string>__version__</string>
|
|
610
|
+
<key>CFBundleShortVersionString</key>
|
|
611
|
+
<string>__version__</string>
|
|
612
|
+
<key>LSMinimumSystemVersion</key>
|
|
613
|
+
<string>14.0</string>
|
|
614
|
+
<key>NSExtension</key>
|
|
615
|
+
<dict>
|
|
616
|
+
<key>NSExtensionPointIdentifier</key>
|
|
617
|
+
<string>com.apple.Safari.web-extension</string>
|
|
618
|
+
<key>NSExtensionPrincipalClass</key>
|
|
619
|
+
<string>$(PRODUCT_MODULE_NAME).SafariWebExtensionHandler</string>
|
|
620
|
+
<key>NSExtensionAttributes</key>
|
|
621
|
+
<dict>
|
|
622
|
+
<key>SFSafariWebExtensionBundleIdentifier</key>
|
|
623
|
+
<string>com.wenathlan.devthink.extension</string>
|
|
624
|
+
</dict>
|
|
625
|
+
</dict>
|
|
626
|
+
</dict>
|
|
627
|
+
</plist>
|
|
628
|
+
`
|
|
629
|
+
},
|
|
630
|
+
{
|
|
631
|
+
path: "Devthink/Devthink.entitlements",
|
|
632
|
+
text: `<?xml version="1.0" encoding="UTF-8"?>
|
|
633
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "${plistdtd}">
|
|
634
|
+
<plist version="1.0">
|
|
635
|
+
<dict>
|
|
636
|
+
<key>com.apple.security.app-sandbox</key>
|
|
637
|
+
<true/>
|
|
638
|
+
<key>com.apple.security.network.client</key>
|
|
639
|
+
<true/>
|
|
640
|
+
</dict>
|
|
641
|
+
</plist>
|
|
642
|
+
`
|
|
643
|
+
},
|
|
644
|
+
{
|
|
645
|
+
path: "Devthink/AppDelegate.swift",
|
|
646
|
+
text: 'import Cocoa\nimport SafariServices\n\n@main\nfinal class AppDelegate: NSObject, NSApplicationDelegate {\n func applicationDidFinishLaunching(_ notification: Notification) {\n SFSafariApplication.showPreferencesForExtension(withIdentifier: "com.wenathlan.devthink.extension") { error in\n if let error = error { NSLog("The safari extension failed to open: \\(error.localizedDescription)") }\n }\n }\n}\n'
|
|
647
|
+
}
|
|
648
|
+
];
|
|
649
|
+
}
|
|
650
|
+
function safariskeletonbuild(input) {
|
|
651
|
+
const version = (input.version ?? "").trim();
|
|
652
|
+
if (!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(version))
|
|
653
|
+
throw new Error("The safari skeleton carries the release version; a non semver version never names an artifact.");
|
|
654
|
+
const bundleid = (input.bundleid ?? "").trim();
|
|
655
|
+
if (bundleid === "" || !/^[a-z0-9][a-z0-9.-]*$/.test(bundleid))
|
|
656
|
+
throw new Error(
|
|
657
|
+
"The safari skeleton carries the bundle id; an empty or malformed id never registers a safari app extension."
|
|
658
|
+
);
|
|
659
|
+
if (input.extensionpayload.length === 0)
|
|
660
|
+
throw new Error(
|
|
661
|
+
"The safari skeleton embeds the chromium build as the safari web extension payload; an empty payload never wraps an extension."
|
|
662
|
+
);
|
|
663
|
+
if (input.entitlements.length === 0)
|
|
664
|
+
throw new Error(
|
|
665
|
+
"The safari skeleton declares the app entitlements for the extension distribution; an empty entitlements list never ships a safari app extension."
|
|
666
|
+
);
|
|
667
|
+
const projectfiles = safariskeletonprojectfiles().map((file) => ({
|
|
668
|
+
path: file.path,
|
|
669
|
+
text: file.text.replace(/__version__/g, version).replace(/com\.wenathlan\.devthink/g, bundleid)
|
|
670
|
+
}));
|
|
671
|
+
const stored = projectfiles.map((file) => ({
|
|
672
|
+
name: file.path,
|
|
673
|
+
bytes: Buffer.from(file.text, "utf8")
|
|
674
|
+
}));
|
|
675
|
+
const entries = projectfiles.map((file) => file.path);
|
|
676
|
+
for (const entry of input.extensionpayload) {
|
|
677
|
+
const name = (entry.name ?? "").trim();
|
|
678
|
+
if (name === "")
|
|
679
|
+
throw new Error("The safari skeleton names every payload entry; an empty name never enters the archive.");
|
|
680
|
+
stored.push({ name: `Resources/${name}`, bytes: Buffer.from(entry.bytes) });
|
|
681
|
+
entries.push(`Resources/${name}`);
|
|
682
|
+
}
|
|
683
|
+
const locals = [];
|
|
684
|
+
const records = [];
|
|
685
|
+
let offset = 0;
|
|
686
|
+
for (const entry of stored) {
|
|
687
|
+
const local = safarizipfile(entry.name, entry.bytes);
|
|
688
|
+
locals.push(local);
|
|
689
|
+
records.push({ name: entry.name, size: entry.bytes.length, offset });
|
|
690
|
+
offset += local.length;
|
|
691
|
+
}
|
|
692
|
+
const central = safaricentraldirectory(records);
|
|
693
|
+
const end = safariendrecord(records.length, central.bytes.length, offset);
|
|
694
|
+
const bytes = Buffer.concat([...locals, central.bytes, end]);
|
|
695
|
+
return {
|
|
696
|
+
archive: { name: `devthink-safari-${version}.zip`, bytes: new Uint8Array(bytes) },
|
|
697
|
+
projectfiles,
|
|
698
|
+
entitlements: input.entitlements,
|
|
699
|
+
appshell: "Devthink/AppDelegate.swift"
|
|
700
|
+
};
|
|
701
|
+
}
|
|
702
|
+
function safariskeletonpopoverof() {
|
|
703
|
+
return { path: "sidepanel.html", bounds: { width: 480, height: 720 } };
|
|
704
|
+
}
|
|
705
|
+
function safarizipfile(name, bytes) {
|
|
706
|
+
const namebuffer = Buffer.from(name, "utf8");
|
|
707
|
+
const header = Buffer.alloc(30 + namebuffer.length);
|
|
708
|
+
header.writeUInt32LE(67324752, 0);
|
|
709
|
+
header.writeUInt16LE(20, 4);
|
|
710
|
+
header.writeUInt16LE(0, 6);
|
|
711
|
+
header.writeUInt16LE(0, 8);
|
|
712
|
+
header.writeUInt16LE(0, 10);
|
|
713
|
+
header.writeUInt16LE(0, 12);
|
|
714
|
+
header.writeUInt32LE(0, 14);
|
|
715
|
+
header.writeUInt32LE(bytes.length, 18);
|
|
716
|
+
header.writeUInt32LE(bytes.length, 22);
|
|
717
|
+
header.writeUInt16LE(namebuffer.length, 26);
|
|
718
|
+
header.writeUInt16LE(0, 28);
|
|
719
|
+
namebuffer.copy(header, 30);
|
|
720
|
+
return Buffer.concat([header, bytes]);
|
|
721
|
+
}
|
|
722
|
+
function safaricentraldirectory(records) {
|
|
723
|
+
const chunks = [];
|
|
724
|
+
for (const record of records) {
|
|
725
|
+
const namebuffer = Buffer.from(record.name, "utf8");
|
|
726
|
+
const header = Buffer.alloc(46 + namebuffer.length);
|
|
727
|
+
header.writeUInt32LE(33639248, 0);
|
|
728
|
+
header.writeUInt16LE(20, 4);
|
|
729
|
+
header.writeUInt16LE(20, 6);
|
|
730
|
+
header.writeUInt16LE(0, 8);
|
|
731
|
+
header.writeUInt16LE(0, 10);
|
|
732
|
+
header.writeUInt16LE(0, 12);
|
|
733
|
+
header.writeUInt16LE(0, 14);
|
|
734
|
+
header.writeUInt32LE(0, 16);
|
|
735
|
+
header.writeUInt32LE(record.size, 20);
|
|
736
|
+
header.writeUInt32LE(record.size, 24);
|
|
737
|
+
header.writeUInt16LE(namebuffer.length, 28);
|
|
738
|
+
header.writeUInt16LE(0, 30);
|
|
739
|
+
header.writeUInt16LE(0, 32);
|
|
740
|
+
header.writeUInt16LE(0, 34);
|
|
741
|
+
header.writeUInt16LE(0, 36);
|
|
742
|
+
header.writeUInt32LE(0, 38);
|
|
743
|
+
header.writeUInt32LE(record.offset, 42);
|
|
744
|
+
namebuffer.copy(header, 46);
|
|
745
|
+
chunks.push(header);
|
|
746
|
+
}
|
|
747
|
+
return { bytes: Buffer.concat(chunks) };
|
|
748
|
+
}
|
|
749
|
+
function safariendrecord(entrycount, centralsize, centralstart) {
|
|
750
|
+
const end = Buffer.alloc(22);
|
|
751
|
+
end.writeUInt32LE(101010256, 0);
|
|
752
|
+
end.writeUInt16LE(0, 4);
|
|
753
|
+
end.writeUInt16LE(0, 6);
|
|
754
|
+
end.writeUInt16LE(entrycount, 8);
|
|
755
|
+
end.writeUInt16LE(entrycount, 10);
|
|
756
|
+
end.writeUInt32LE(centralsize, 12);
|
|
757
|
+
end.writeUInt32LE(centralstart, 16);
|
|
758
|
+
end.writeUInt16LE(0, 20);
|
|
759
|
+
return end;
|
|
760
|
+
}
|
|
761
|
+
function apimapkinds() {
|
|
762
|
+
return ["namespace", "method", "event", "property"];
|
|
763
|
+
}
|
|
764
|
+
function apimapentries() {
|
|
765
|
+
return [
|
|
766
|
+
{
|
|
767
|
+
api: "runtime",
|
|
768
|
+
chromium: "chrome.runtime",
|
|
769
|
+
firefox: "browser.runtime",
|
|
770
|
+
safari: "browser.runtime",
|
|
771
|
+
kind: "namespace"
|
|
772
|
+
},
|
|
773
|
+
{
|
|
774
|
+
api: "runtime.geturl",
|
|
775
|
+
chromium: "chrome.runtime.getURL",
|
|
776
|
+
firefox: "browser.runtime.getURL",
|
|
777
|
+
safari: "browser.runtime.getURL",
|
|
778
|
+
kind: "method"
|
|
779
|
+
},
|
|
780
|
+
{
|
|
781
|
+
api: "runtime.connect",
|
|
782
|
+
chromium: "chrome.runtime.connect",
|
|
783
|
+
firefox: "browser.runtime.connect",
|
|
784
|
+
safari: "browser.runtime.connect",
|
|
785
|
+
kind: "method"
|
|
786
|
+
},
|
|
787
|
+
{
|
|
788
|
+
api: "runtime.sendmessage",
|
|
789
|
+
chromium: "chrome.runtime.sendMessage",
|
|
790
|
+
firefox: "browser.runtime.sendMessage",
|
|
791
|
+
safari: "browser.runtime.sendMessage",
|
|
792
|
+
kind: "method"
|
|
793
|
+
},
|
|
794
|
+
{
|
|
795
|
+
api: "runtime.onmessage",
|
|
796
|
+
chromium: "chrome.runtime.onMessage",
|
|
797
|
+
firefox: "browser.runtime.onMessage",
|
|
798
|
+
safari: "browser.runtime.onMessage",
|
|
799
|
+
kind: "event"
|
|
800
|
+
},
|
|
801
|
+
{
|
|
802
|
+
api: "runtime.id",
|
|
803
|
+
chromium: "chrome.runtime.id",
|
|
804
|
+
firefox: "browser.runtime.id",
|
|
805
|
+
safari: "browser.runtime.id",
|
|
806
|
+
kind: "property"
|
|
807
|
+
},
|
|
808
|
+
{ api: "tabs", chromium: "chrome.tabs", firefox: "browser.tabs", safari: "browser.tabs", kind: "namespace" },
|
|
809
|
+
{
|
|
810
|
+
api: "tabs.query",
|
|
811
|
+
chromium: "chrome.tabs.query",
|
|
812
|
+
firefox: "browser.tabs.query",
|
|
813
|
+
safari: "browser.tabs.query",
|
|
814
|
+
kind: "method"
|
|
815
|
+
},
|
|
816
|
+
{
|
|
817
|
+
api: "tabs.create",
|
|
818
|
+
chromium: "chrome.tabs.create",
|
|
819
|
+
firefox: "browser.tabs.create",
|
|
820
|
+
safari: "browser.tabs.create",
|
|
821
|
+
kind: "method"
|
|
822
|
+
},
|
|
823
|
+
{
|
|
824
|
+
api: "tabs.update",
|
|
825
|
+
chromium: "chrome.tabs.update",
|
|
826
|
+
firefox: "browser.tabs.update",
|
|
827
|
+
safari: "browser.tabs.update",
|
|
828
|
+
kind: "method"
|
|
829
|
+
},
|
|
830
|
+
{
|
|
831
|
+
api: "tabs.executeScript",
|
|
832
|
+
chromium: "chrome.tabs.executeScript",
|
|
833
|
+
firefox: "browser.tabs.executeScript",
|
|
834
|
+
safari: "",
|
|
835
|
+
kind: "method"
|
|
836
|
+
},
|
|
837
|
+
{
|
|
838
|
+
api: "scripting",
|
|
839
|
+
chromium: "chrome.scripting",
|
|
840
|
+
firefox: "browser.scripting",
|
|
841
|
+
safari: "browser.scripting",
|
|
842
|
+
kind: "namespace"
|
|
843
|
+
},
|
|
844
|
+
{
|
|
845
|
+
api: "scripting.executeScript",
|
|
846
|
+
chromium: "chrome.scripting.executeScript",
|
|
847
|
+
firefox: "browser.scripting.executeScript",
|
|
848
|
+
safari: "browser.scripting.executeScript",
|
|
849
|
+
kind: "method"
|
|
850
|
+
},
|
|
851
|
+
{
|
|
852
|
+
api: "storage",
|
|
853
|
+
chromium: "chrome.storage",
|
|
854
|
+
firefox: "browser.storage",
|
|
855
|
+
safari: "browser.storage",
|
|
856
|
+
kind: "namespace"
|
|
857
|
+
},
|
|
858
|
+
{
|
|
859
|
+
api: "storage.local",
|
|
860
|
+
chromium: "chrome.storage.local",
|
|
861
|
+
firefox: "browser.storage.local",
|
|
862
|
+
safari: "browser.storage.local",
|
|
863
|
+
kind: "namespace"
|
|
864
|
+
},
|
|
865
|
+
{
|
|
866
|
+
api: "storage.session",
|
|
867
|
+
chromium: "chrome.storage.session",
|
|
868
|
+
firefox: "browser.storage.session",
|
|
869
|
+
safari: "browser.storage.session",
|
|
870
|
+
kind: "namespace"
|
|
871
|
+
},
|
|
872
|
+
{
|
|
873
|
+
api: "windows",
|
|
874
|
+
chromium: "chrome.windows",
|
|
875
|
+
firefox: "browser.windows",
|
|
876
|
+
safari: "browser.windows",
|
|
877
|
+
kind: "namespace"
|
|
878
|
+
},
|
|
879
|
+
{
|
|
880
|
+
api: "windows.create",
|
|
881
|
+
chromium: "chrome.windows.create",
|
|
882
|
+
firefox: "browser.windows.create",
|
|
883
|
+
safari: "browser.windows.create",
|
|
884
|
+
kind: "method"
|
|
885
|
+
},
|
|
886
|
+
{
|
|
887
|
+
api: "windows.update",
|
|
888
|
+
chromium: "chrome.windows.update",
|
|
889
|
+
firefox: "browser.windows.update",
|
|
890
|
+
safari: "browser.windows.update",
|
|
891
|
+
kind: "method"
|
|
892
|
+
},
|
|
893
|
+
{
|
|
894
|
+
api: "notifications",
|
|
895
|
+
chromium: "chrome.notifications",
|
|
896
|
+
firefox: "browser.notifications",
|
|
897
|
+
safari: "browser.notifications",
|
|
898
|
+
kind: "namespace"
|
|
899
|
+
},
|
|
900
|
+
{
|
|
901
|
+
api: "notifications.create",
|
|
902
|
+
chromium: "chrome.notifications.create",
|
|
903
|
+
firefox: "browser.notifications.create",
|
|
904
|
+
safari: "browser.notifications.create",
|
|
905
|
+
kind: "method"
|
|
906
|
+
},
|
|
907
|
+
{
|
|
908
|
+
api: "downloads",
|
|
909
|
+
chromium: "chrome.downloads",
|
|
910
|
+
firefox: "browser.downloads",
|
|
911
|
+
safari: "browser.downloads",
|
|
912
|
+
kind: "namespace"
|
|
913
|
+
},
|
|
914
|
+
{
|
|
915
|
+
api: "downloads.download",
|
|
916
|
+
chromium: "chrome.downloads.download",
|
|
917
|
+
firefox: "browser.downloads.download",
|
|
918
|
+
safari: "browser.downloads.download",
|
|
919
|
+
kind: "method"
|
|
920
|
+
},
|
|
921
|
+
{
|
|
922
|
+
api: "contextMenus",
|
|
923
|
+
chromium: "chrome.contextMenus",
|
|
924
|
+
firefox: "browser.contextMenus",
|
|
925
|
+
safari: "browser.contextMenus",
|
|
926
|
+
kind: "namespace"
|
|
927
|
+
},
|
|
928
|
+
{
|
|
929
|
+
api: "contextMenus.create",
|
|
930
|
+
chromium: "chrome.contextMenus.create",
|
|
931
|
+
firefox: "browser.contextMenus.create",
|
|
932
|
+
safari: "browser.contextMenus.create",
|
|
933
|
+
kind: "method"
|
|
934
|
+
},
|
|
935
|
+
{
|
|
936
|
+
api: "sidePanel",
|
|
937
|
+
chromium: "chrome.sidePanel",
|
|
938
|
+
firefox: "browserpolyfill.sidepanel",
|
|
939
|
+
safari: "browserpolyfill.sidepanel",
|
|
940
|
+
kind: "namespace"
|
|
941
|
+
},
|
|
942
|
+
{
|
|
943
|
+
api: "sidePanel.open",
|
|
944
|
+
chromium: "chrome.sidePanel.open",
|
|
945
|
+
firefox: "browserpolyfill.sidepanel.open",
|
|
946
|
+
safari: "browserpolyfill.sidepanel.open",
|
|
947
|
+
kind: "method"
|
|
948
|
+
},
|
|
949
|
+
{
|
|
950
|
+
api: "sidePanel.setoptions",
|
|
951
|
+
chromium: "chrome.sidePanel.setOptions",
|
|
952
|
+
firefox: "browserpolyfill.sidepanel.setoptions",
|
|
953
|
+
safari: "browserpolyfill.sidepanel.setoptions",
|
|
954
|
+
kind: "method"
|
|
955
|
+
},
|
|
956
|
+
{
|
|
957
|
+
api: "offscreen",
|
|
958
|
+
chromium: "chrome.offscreen",
|
|
959
|
+
firefox: "browserpolyfill.offscreen",
|
|
960
|
+
safari: "browserpolyfill.offscreen",
|
|
961
|
+
kind: "namespace"
|
|
962
|
+
},
|
|
963
|
+
{
|
|
964
|
+
api: "offscreen.createDocument",
|
|
965
|
+
chromium: "chrome.offscreen.createDocument",
|
|
966
|
+
firefox: "browserpolyfill.offscreen.inline",
|
|
967
|
+
safari: "browserpolyfill.offscreen.inline",
|
|
968
|
+
kind: "method"
|
|
969
|
+
},
|
|
970
|
+
{
|
|
971
|
+
api: "action",
|
|
972
|
+
chromium: "chrome.action",
|
|
973
|
+
firefox: "browser.action",
|
|
974
|
+
safari: "browser.action",
|
|
975
|
+
kind: "namespace"
|
|
976
|
+
},
|
|
977
|
+
{
|
|
978
|
+
api: "action.setpopup",
|
|
979
|
+
chromium: "chrome.action.setPopup",
|
|
980
|
+
firefox: "browser.action.setPopup",
|
|
981
|
+
safari: "browser.action.setPopup",
|
|
982
|
+
kind: "method"
|
|
983
|
+
},
|
|
984
|
+
{
|
|
985
|
+
api: "clipboardRead",
|
|
986
|
+
chromium: "navigator.clipboard.readText",
|
|
987
|
+
firefox: "navigator.clipboard.readText",
|
|
988
|
+
safari: "navigator.clipboard.readText",
|
|
989
|
+
kind: "method"
|
|
990
|
+
},
|
|
991
|
+
{
|
|
992
|
+
api: "clipboardWrite",
|
|
993
|
+
chromium: "navigator.clipboard.writeText",
|
|
994
|
+
firefox: "navigator.clipboard.writeText",
|
|
995
|
+
safari: "navigator.clipboard.writeText",
|
|
996
|
+
kind: "method"
|
|
997
|
+
},
|
|
998
|
+
{ api: "i18n", chromium: "chrome.i18n", firefox: "browser.i18n", safari: "browser.i18n", kind: "namespace" },
|
|
999
|
+
{
|
|
1000
|
+
api: "i18n.getmessage",
|
|
1001
|
+
chromium: "chrome.i18n.getMessage",
|
|
1002
|
+
firefox: "browser.i18n.getMessage",
|
|
1003
|
+
safari: "browser.i18n.getMessage",
|
|
1004
|
+
kind: "method"
|
|
1005
|
+
},
|
|
1006
|
+
{
|
|
1007
|
+
api: "permissions",
|
|
1008
|
+
chromium: "chrome.permissions",
|
|
1009
|
+
firefox: "browser.permissions",
|
|
1010
|
+
safari: "browser.permissions",
|
|
1011
|
+
kind: "namespace"
|
|
1012
|
+
},
|
|
1013
|
+
{
|
|
1014
|
+
api: "permissions.request",
|
|
1015
|
+
chromium: "chrome.permissions.request",
|
|
1016
|
+
firefox: "browser.permissions.request",
|
|
1017
|
+
safari: "browser.permissions.request",
|
|
1018
|
+
kind: "method"
|
|
1019
|
+
},
|
|
1020
|
+
{
|
|
1021
|
+
api: "permissions.contains",
|
|
1022
|
+
chromium: "chrome.permissions.contains",
|
|
1023
|
+
firefox: "browser.permissions.contains",
|
|
1024
|
+
safari: "browser.permissions.contains",
|
|
1025
|
+
kind: "method"
|
|
1026
|
+
},
|
|
1027
|
+
{
|
|
1028
|
+
api: "management",
|
|
1029
|
+
chromium: "chrome.management",
|
|
1030
|
+
firefox: "browser.management",
|
|
1031
|
+
safari: "browser.management",
|
|
1032
|
+
kind: "namespace"
|
|
1033
|
+
},
|
|
1034
|
+
{
|
|
1035
|
+
api: "commands",
|
|
1036
|
+
chromium: "chrome.commands",
|
|
1037
|
+
firefox: "browser.commands",
|
|
1038
|
+
safari: "browser.commands",
|
|
1039
|
+
kind: "namespace"
|
|
1040
|
+
},
|
|
1041
|
+
{
|
|
1042
|
+
api: "commands.onCommand",
|
|
1043
|
+
chromium: "chrome.commands.onCommand",
|
|
1044
|
+
firefox: "browser.commands.onCommand",
|
|
1045
|
+
safari: "browser.commands.onCommand",
|
|
1046
|
+
kind: "event"
|
|
1047
|
+
},
|
|
1048
|
+
{
|
|
1049
|
+
api: "nativeMessaging",
|
|
1050
|
+
chromium: "chrome.runtime.connectNative",
|
|
1051
|
+
firefox: "browser.runtime.connectNative",
|
|
1052
|
+
safari: "",
|
|
1053
|
+
kind: "method"
|
|
1054
|
+
}
|
|
1055
|
+
];
|
|
1056
|
+
}
|
|
1057
|
+
function apifeatureflagintersection() {
|
|
1058
|
+
const entries = apimapentries();
|
|
1059
|
+
const browsers = ["chromium", "firefox", "safari"];
|
|
1060
|
+
const flags = [];
|
|
1061
|
+
for (const entry of entries) {
|
|
1062
|
+
let all = true;
|
|
1063
|
+
for (const browser of browsers) {
|
|
1064
|
+
const value = browser === "chromium" ? entry.chromium : browser === "firefox" ? entry.firefox : entry.safari;
|
|
1065
|
+
if (value === "") {
|
|
1066
|
+
all = false;
|
|
1067
|
+
break;
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
if (all) flags.push(entry.api);
|
|
1071
|
+
}
|
|
1072
|
+
return flags.sort();
|
|
1073
|
+
}
|
|
1074
|
+
function apimapentryof(api) {
|
|
1075
|
+
return apimapentries().find((entry) => entry.api === api);
|
|
1076
|
+
}
|
|
1077
|
+
function apimapresolve(input) {
|
|
1078
|
+
const api = (input.api ?? "").trim();
|
|
1079
|
+
if (api === "")
|
|
1080
|
+
return {
|
|
1081
|
+
ok: false,
|
|
1082
|
+
browser: input.browser ?? "chromium",
|
|
1083
|
+
reason: "The apimap resolution names its api; an empty api resolves nothing.",
|
|
1084
|
+
retry: "none"
|
|
1085
|
+
};
|
|
1086
|
+
const entry = apimapentryof(api);
|
|
1087
|
+
if (entry === void 0)
|
|
1088
|
+
return {
|
|
1089
|
+
ok: false,
|
|
1090
|
+
browser: input.browser ?? "chromium",
|
|
1091
|
+
reason: `The apimap carries no row for the ${api} api; the catalog must record every api the codebase touches.`,
|
|
1092
|
+
retry: "none"
|
|
1093
|
+
};
|
|
1094
|
+
const browser = input.browser ?? apimapbrowserof({
|
|
1095
|
+
...input.runtime !== void 0 ? { runtime: input.runtime } : {},
|
|
1096
|
+
...input.probeuseragent !== void 0 ? { probeuseragent: input.probeuseragent } : {}
|
|
1097
|
+
});
|
|
1098
|
+
const value = browser === "chromium" ? entry.chromium : browser === "firefox" ? entry.firefox : entry.safari;
|
|
1099
|
+
if (value === "")
|
|
1100
|
+
return {
|
|
1101
|
+
ok: false,
|
|
1102
|
+
browser,
|
|
1103
|
+
reason: `The ${api} api has no ${browser} equivalent in the apimap; the feature flag stays off and the call surfaces a structured error.`,
|
|
1104
|
+
retry: "none"
|
|
1105
|
+
};
|
|
1106
|
+
return { ok: true, browser, api, equivalent: value };
|
|
1107
|
+
}
|
|
1108
|
+
function apimapunmapped(entries = apimapentries()) {
|
|
1109
|
+
const rows = entries.map((entry) => ({
|
|
1110
|
+
api: entry.api,
|
|
1111
|
+
chromium: entry.chromium !== "",
|
|
1112
|
+
firefox: entry.firefox !== "",
|
|
1113
|
+
safari: entry.safari !== ""
|
|
1114
|
+
}));
|
|
1115
|
+
const missingchromium = rows.filter((row) => !row.chromium).map((row) => row.api);
|
|
1116
|
+
const missingfirefox = rows.filter((row) => !row.firefox).map((row) => row.api);
|
|
1117
|
+
const missingsafari = rows.filter((row) => !row.safari).map((row) => row.api);
|
|
1118
|
+
const failed = missingchromium.length > 0 || missingfirefox.length > 0;
|
|
1119
|
+
const reason = failed ? `The apimap carries apis without a chromium or firefox mapping: ${[...missingchromium, ...missingfirefox].filter((name, index, source) => source.indexOf(name) === index).slice(0, 5).join(", ")}; every webextension api the codebase touches needs a chromium and firefox row.` : "";
|
|
1120
|
+
return { rows, missingchromium, missingfirefox, missingsafari, failed, reason };
|
|
1121
|
+
}
|
|
1122
|
+
function apimapbrowserof(input = {}) {
|
|
1123
|
+
if (input.runtime !== void 0 && input.runtime !== null) {
|
|
1124
|
+
const record = input.runtime;
|
|
1125
|
+
if (typeof record.browser === "object" && record.browser !== null) return "firefox";
|
|
1126
|
+
if (typeof record.chrome === "object" && record.chrome !== null) return "chromium";
|
|
1127
|
+
if (typeof record.sidePanel === "object" && record.sidePanel !== null) return "chromium";
|
|
1128
|
+
}
|
|
1129
|
+
const useragent = input.probeuseragent !== void 0 ? input.probeuseragent() : "";
|
|
1130
|
+
if (useragent !== "") {
|
|
1131
|
+
if (/firefox/i.test(useragent)) return "firefox";
|
|
1132
|
+
if (/safari/i.test(useragent) && !/chrome/i.test(useragent)) return "safari";
|
|
1133
|
+
}
|
|
1134
|
+
return "chromium";
|
|
1135
|
+
}
|
|
1136
|
+
function apimapbrowsercacheprobe(input = {}) {
|
|
1137
|
+
let cached;
|
|
1138
|
+
const probe = () => {
|
|
1139
|
+
if (cached === void 0) cached = apimapbrowserof(input);
|
|
1140
|
+
return cached;
|
|
1141
|
+
};
|
|
1142
|
+
const refresh = () => {
|
|
1143
|
+
cached = apimapbrowserof(input);
|
|
1144
|
+
return cached;
|
|
1145
|
+
};
|
|
1146
|
+
return { probe, refresh };
|
|
1147
|
+
}
|
|
1148
|
+
function apimapstructerrorof(input) {
|
|
1149
|
+
const message = input.reason !== void 0 && input.reason !== "" ? input.reason : `The ${input.api} api has no ${input.browser} equivalent; the feature flag stays off and the call surfaces a structured error.`;
|
|
1150
|
+
return { family: "apimap", message, retry: "none", browser: input.browser, api: input.api, at: input.now };
|
|
1151
|
+
}
|
|
1152
|
+
export {
|
|
1153
|
+
apifeatureflagintersection,
|
|
1154
|
+
apimapbrowsercacheprobe,
|
|
1155
|
+
apimapbrowserof,
|
|
1156
|
+
apimapentries,
|
|
1157
|
+
apimapentryof,
|
|
1158
|
+
apimapkinds,
|
|
1159
|
+
apimapresolve,
|
|
1160
|
+
apimapstructerrorof,
|
|
1161
|
+
apimapunmapped,
|
|
1162
|
+
browserpolyfillflags,
|
|
1163
|
+
browserpolyfillintersection,
|
|
1164
|
+
browserpolyfillnamespace,
|
|
1165
|
+
browserpolyfillof,
|
|
1166
|
+
browserpolyfillpromisify,
|
|
1167
|
+
browserpolyfillstructerrorof,
|
|
1168
|
+
firefoxactionmap,
|
|
1169
|
+
firefoxdenylist,
|
|
1170
|
+
firefoxpermissionmap,
|
|
1171
|
+
firefoxprepadapt,
|
|
1172
|
+
firefoxprepdenylistcheck,
|
|
1173
|
+
firefoxprepoverlay,
|
|
1174
|
+
firefoxprepsplitbundle,
|
|
1175
|
+
safaricentraldirectory,
|
|
1176
|
+
safariendrecord,
|
|
1177
|
+
safariskeletonbuild,
|
|
1178
|
+
safariskeletonpopoverof,
|
|
1179
|
+
safariskeletonprojectfiles,
|
|
1180
|
+
safarizipfile,
|
|
1181
|
+
xpicentraldirectory,
|
|
1182
|
+
xpiendrecord,
|
|
1183
|
+
xpilinterbudget,
|
|
1184
|
+
xpimanifestheader,
|
|
1185
|
+
xpimanifestname,
|
|
1186
|
+
xpinameof,
|
|
1187
|
+
xpipackassemble,
|
|
1188
|
+
xpipackentriesof,
|
|
1189
|
+
xpipacklintercheck
|
|
1190
|
+
};
|
|
1191
|
+
//# sourceMappingURL=crossbrowser.js.map
|