@mountaya/studio 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/dist/agent/index.cjs +2561 -2815
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +766 -786
- package/dist/agent/index.d.ts +766 -786
- package/dist/agent/index.js +2553 -2790
- package/dist/agent/index.js.map +1 -1
- package/dist/chunk-3Oi_Zrtm.js +9 -0
- package/dist/chunk-3Oi_Zrtm.js.map +1 -0
- package/dist/chunk-B18OPIu_.js +6 -0
- package/dist/chunk-B18OPIu_.js.map +1 -0
- package/dist/chunk-B5Uz3Qct.cjs +15 -0
- package/dist/chunk-B5Uz3Qct.cjs.map +1 -0
- package/dist/chunk-BBEJwkd3.d.cts +839 -0
- package/dist/chunk-BIEc_SkR.cjs +29 -0
- package/dist/chunk-BIEc_SkR.cjs.map +1 -0
- package/dist/chunk-BKMFOe-N.js +171 -0
- package/dist/chunk-BKMFOe-N.js.map +1 -0
- package/dist/chunk-BP4uy7E1.d.ts +11583 -0
- package/dist/chunk-BSHTsFiB.js +1403 -0
- package/dist/chunk-BSHTsFiB.js.map +1 -0
- package/dist/chunk-BTUUABGI.js +17 -0
- package/dist/chunk-BTUUABGI.js.map +1 -0
- package/dist/chunk-BaPiaz5X.cjs +115 -0
- package/dist/chunk-BaPiaz5X.cjs.map +1 -0
- package/dist/chunk-BeCVpkYr.cjs +542 -0
- package/dist/chunk-BeCVpkYr.cjs.map +1 -0
- package/dist/chunk-BgngsvK8.cjs +6202 -0
- package/dist/chunk-BgngsvK8.cjs.map +1 -0
- package/dist/chunk-BhInd7CJ.d.cts +253 -0
- package/dist/chunk-Bn6ZbxkS.cjs +27 -0
- package/dist/chunk-By9ZnkVI.js +60 -0
- package/dist/chunk-By9ZnkVI.js.map +1 -0
- package/dist/chunk-BzqPhxsz.cjs +367 -0
- package/dist/chunk-BzqPhxsz.cjs.map +1 -0
- package/dist/chunk-C2mMX81q.d.ts +443 -0
- package/dist/chunk-C2rr9Q0V.cjs +1402 -0
- package/dist/chunk-C2rr9Q0V.cjs.map +1 -0
- package/dist/{directorThreads-CqmvsV8b.d.cts → chunk-CDJCbwIQ.d.cts} +20 -22
- package/dist/chunk-CLGvBOVH.d.cts +1654 -0
- package/dist/chunk-COdw1dc6.d.ts +525 -0
- package/dist/chunk-CQCJnT2i.d.ts +511 -0
- package/dist/chunk-CSyHY67q.cjs +353 -0
- package/dist/chunk-CSyHY67q.cjs.map +1 -0
- package/dist/chunk-CiK1Iqrv.js +950 -0
- package/dist/chunk-CiK1Iqrv.js.map +1 -0
- package/dist/chunk-CmJBgSwZ.cjs +24 -0
- package/dist/chunk-CmJBgSwZ.cjs.map +1 -0
- package/dist/chunk-CnrsRK2u.cjs +83 -0
- package/dist/chunk-CnrsRK2u.cjs.map +1 -0
- package/dist/chunk-Co782_9r.js +326 -0
- package/dist/chunk-Co782_9r.js.map +1 -0
- package/dist/chunk-Csr3KDpZ.cjs +32 -0
- package/dist/chunk-Csr3KDpZ.cjs.map +1 -0
- package/dist/chunk-CwkmccXv.js +89 -0
- package/dist/chunk-CwkmccXv.js.map +1 -0
- package/dist/chunk-D0Q4iL9B.cjs +255 -0
- package/dist/chunk-D0Q4iL9B.cjs.map +1 -0
- package/dist/chunk-DFwiSzUS.cjs +72 -0
- package/dist/chunk-DFwiSzUS.cjs.map +1 -0
- package/dist/chunk-DIFayl2P.d.cts +443 -0
- package/dist/chunk-DIGF58ux.d.cts +525 -0
- package/dist/chunk-DKuuuld5.js +101 -0
- package/dist/chunk-DKuuuld5.js.map +1 -0
- package/dist/chunk-DMePkFEo.js +5054 -0
- package/dist/chunk-DMePkFEo.js.map +1 -0
- package/dist/chunk-DO5SIBgu.js +305 -0
- package/dist/chunk-DO5SIBgu.js.map +1 -0
- package/dist/chunk-DOQ_7eE5.d.ts +6662 -0
- package/dist/{tabs-B2nRO4p_.d.ts → chunk-DThaaNeb.d.cts} +2 -2
- package/dist/{tabs-B2nRO4p_.d.cts → chunk-DThaaNeb.d.ts} +2 -2
- package/dist/{directorThreads-CqmvsV8b.d.ts → chunk-DUQzjUJy.d.ts} +20 -22
- package/dist/chunk-DX37IPhV.cjs +1903 -0
- package/dist/chunk-DX37IPhV.cjs.map +1 -0
- package/dist/chunk-Damps5Tk.cjs +155 -0
- package/dist/chunk-Damps5Tk.cjs.map +1 -0
- package/dist/chunk-DbK5PhpJ.d.ts +1654 -0
- package/dist/chunk-De0vAASv.d.ts +253 -0
- package/dist/chunk-DhSZ7YZt.d.cts +6662 -0
- package/dist/chunk-DjEvqvPA.cjs +43 -0
- package/dist/chunk-DjEvqvPA.cjs.map +1 -0
- package/dist/{saveFile-j-1kkApx.d.cts → chunk-DkwDzwvu.d.cts} +7 -9
- package/dist/{saveFile-j-1kkApx.d.ts → chunk-DkwDzwvu.d.ts} +7 -9
- package/dist/chunk-Dmszv9If.js +71 -0
- package/dist/chunk-Dmszv9If.js.map +1 -0
- package/dist/chunk-Dp_ftNWY.d.cts +511 -0
- package/dist/chunk-DsHQySz0.js +31 -0
- package/dist/chunk-DsHQySz0.js.map +1 -0
- package/dist/chunk-DwoUyHHh.js +281 -0
- package/dist/chunk-DwoUyHHh.js.map +1 -0
- package/dist/chunk-IaIDQflj.d.cts +2315 -0
- package/dist/chunk-IaIDQflj.d.ts +2315 -0
- package/dist/chunk-cVXLsZfL.d.ts +839 -0
- package/dist/chunk-mIaCX9EJ.d.cts +11583 -0
- package/dist/chunk-nJQxbOwQ.cjs +8962 -0
- package/dist/chunk-nJQxbOwQ.cjs.map +1 -0
- package/dist/chunk-o9jaxhCO.js +8852 -0
- package/dist/chunk-o9jaxhCO.js.map +1 -0
- package/dist/chunk-p-Tt_Lwz.js +14 -0
- package/dist/chunk-p-Tt_Lwz.js.map +1 -0
- package/dist/engines/index.cjs +2046 -3401
- package/dist/engines/index.cjs.map +1 -1
- package/dist/engines/index.d.cts +1510 -1550
- package/dist/engines/index.d.ts +1510 -1550
- package/dist/engines/index.js +2039 -3380
- package/dist/engines/index.js.map +1 -1
- package/dist/handlers/index.cjs +47 -93
- package/dist/handlers/index.cjs.map +1 -1
- package/dist/handlers/index.d.cts +61 -103
- package/dist/handlers/index.d.ts +61 -103
- package/dist/handlers/index.js +27 -36
- package/dist/handlers/index.js.map +1 -1
- package/dist/index.cjs +3347 -4398
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -7297
- package/dist/index.d.ts +8 -7297
- package/dist/index.js +2997 -3187
- package/dist/index.js.map +1 -1
- package/dist/plugins/index.cjs +482 -949
- package/dist/plugins/index.cjs.map +1 -1
- package/dist/plugins/index.d.cts +44 -61
- package/dist/plugins/index.d.ts +44 -61
- package/dist/plugins/index.js +471 -915
- package/dist/plugins/index.js.map +1 -1
- package/dist/seams/index.cjs +77 -140
- package/dist/seams/index.cjs.map +1 -1
- package/dist/seams/index.d.cts +125 -158
- package/dist/seams/index.d.ts +125 -158
- package/dist/seams/index.js +41 -71
- package/dist/seams/index.js.map +1 -1
- package/dist/strings/fr/index.cjs +2130 -2116
- package/dist/strings/fr/index.cjs.map +1 -1
- package/dist/strings/fr/index.d.cts +3 -5
- package/dist/strings/fr/index.d.ts +3 -5
- package/dist/strings/fr/index.js +2125 -2114
- package/dist/strings/fr/index.js.map +1 -1
- package/dist/strings/index.cjs +2331 -2625
- package/dist/strings/index.cjs.map +1 -1
- package/dist/strings/index.d.cts +3 -731
- package/dist/strings/index.d.ts +3 -731
- package/dist/strings/index.js +2324 -2615
- package/dist/strings/index.js.map +1 -1
- package/dist/testing/index.cjs +214 -276
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.d.cts +61 -121
- package/dist/testing/index.d.ts +61 -121
- package/dist/testing/index.js +208 -273
- package/dist/testing/index.js.map +1 -1
- package/dist/time/index.cjs +23 -23
- package/dist/time/index.cjs.map +1 -1
- package/dist/time/index.d.cts +5 -7
- package/dist/time/index.d.ts +5 -7
- package/dist/time/index.js +18 -21
- package/dist/time/index.js.map +1 -1
- package/package.json +14 -15
- package/src/agent/rules/stateDelta.ts +1 -0
- package/src/agent/stores/agentThreads.ts +1 -4
- package/src/bus/rules/bus.ts +1 -2
- package/src/bus/rules/defineRegistry.ts +3 -5
- package/src/bus/rules/types.ts +6 -7
- package/src/chrome/stores/uiStore.ts +4 -2
- package/src/embed/rules/fieldDependencies.ts +2 -0
- package/src/embed/rules/safetyRules.ts +2 -0
- package/src/embed/rules/tableCode.ts +4 -3
- package/src/index.ts +6 -27
- package/src/itinerary/rules/import.ts +6 -8
- package/src/plugins/contracts/plugin.ts +4 -2
- package/src/seams/rules/formatters.ts +5 -3
- package/src/testing/index.ts +1 -5
- package/src/viewer/rules/platformViewer.ts +1 -0
- package/dist/bus-BwiNiXdH.d.ts +0 -514
- package/dist/bus-DzmhPwdK.d.cts +0 -514
- package/dist/chainModel-B23pEP_1.d.cts +0 -127
- package/dist/chainModel-B23pEP_1.d.ts +0 -127
- package/dist/chunk-2HFY7ETU.js +0 -5721
- package/dist/chunk-2HFY7ETU.js.map +0 -1
- package/dist/chunk-355TOXSB.js +0 -72
- package/dist/chunk-355TOXSB.js.map +0 -1
- package/dist/chunk-4ZCUZVSV.js +0 -10275
- package/dist/chunk-4ZCUZVSV.js.map +0 -1
- package/dist/chunk-6HEKY3NF.js +0 -95
- package/dist/chunk-6HEKY3NF.js.map +0 -1
- package/dist/chunk-7GFLGGBX.cjs +0 -8
- package/dist/chunk-7GFLGGBX.cjs.map +0 -1
- package/dist/chunk-7NBRCENN.cjs +0 -19
- package/dist/chunk-7NBRCENN.cjs.map +0 -1
- package/dist/chunk-AF5GCXE3.js +0 -8
- package/dist/chunk-AF5GCXE3.js.map +0 -1
- package/dist/chunk-CJDIFRGZ.cjs +0 -2005
- package/dist/chunk-CJDIFRGZ.cjs.map +0 -1
- package/dist/chunk-CNPZY7N3.js +0 -349
- package/dist/chunk-CNPZY7N3.js.map +0 -1
- package/dist/chunk-DZJHTWSF.cjs +0 -45
- package/dist/chunk-DZJHTWSF.cjs.map +0 -1
- package/dist/chunk-EABIHHWA.js +0 -42
- package/dist/chunk-EABIHHWA.js.map +0 -1
- package/dist/chunk-EKZWV6RS.cjs +0 -415
- package/dist/chunk-EKZWV6RS.cjs.map +0 -1
- package/dist/chunk-EOKRXXAC.cjs +0 -24
- package/dist/chunk-EOKRXXAC.cjs.map +0 -1
- package/dist/chunk-F73W2ZTJ.js +0 -1126
- package/dist/chunk-F73W2ZTJ.js.map +0 -1
- package/dist/chunk-H4DVOZ5O.js +0 -1897
- package/dist/chunk-H4DVOZ5O.js.map +0 -1
- package/dist/chunk-HI52PBFT.cjs +0 -10314
- package/dist/chunk-HI52PBFT.cjs.map +0 -1
- package/dist/chunk-IDBXFBLG.cjs +0 -1225
- package/dist/chunk-IDBXFBLG.cjs.map +0 -1
- package/dist/chunk-LBWTJZUJ.js +0 -297
- package/dist/chunk-LBWTJZUJ.js.map +0 -1
- package/dist/chunk-NCLA6DKD.cjs +0 -310
- package/dist/chunk-NCLA6DKD.cjs.map +0 -1
- package/dist/chunk-O4MC5DPD.js +0 -19
- package/dist/chunk-O4MC5DPD.js.map +0 -1
- package/dist/chunk-OP37FKW6.cjs +0 -98
- package/dist/chunk-OP37FKW6.cjs.map +0 -1
- package/dist/chunk-OQSYFH3Z.cjs +0 -5945
- package/dist/chunk-OQSYFH3Z.cjs.map +0 -1
- package/dist/chunk-PACIO4NS.cjs +0 -26
- package/dist/chunk-PACIO4NS.cjs.map +0 -1
- package/dist/chunk-PSZ2R3TC.cjs +0 -75
- package/dist/chunk-PSZ2R3TC.cjs.map +0 -1
- package/dist/chunk-QFO5CZG2.cjs +0 -136
- package/dist/chunk-QFO5CZG2.cjs.map +0 -1
- package/dist/chunk-QL63MUEW.cjs +0 -140
- package/dist/chunk-QL63MUEW.cjs.map +0 -1
- package/dist/chunk-RFUPPVZO.js +0 -17
- package/dist/chunk-RFUPPVZO.js.map +0 -1
- package/dist/chunk-RPG2LWMP.js +0 -23
- package/dist/chunk-RPG2LWMP.js.map +0 -1
- package/dist/chunk-TIBXK6B7.cjs +0 -12
- package/dist/chunk-TIBXK6B7.cjs.map +0 -1
- package/dist/chunk-UU65VNEV.js +0 -381
- package/dist/chunk-UU65VNEV.js.map +0 -1
- package/dist/chunk-VGX6TR2I.js +0 -209
- package/dist/chunk-VGX6TR2I.js.map +0 -1
- package/dist/chunk-WUTDDBVP.js +0 -130
- package/dist/chunk-WUTDDBVP.js.map +0 -1
- package/dist/chunk-WVQQLKCI.cjs +0 -224
- package/dist/chunk-WVQQLKCI.cjs.map +0 -1
- package/dist/chunk-WZYXG3SE.js +0 -111
- package/dist/chunk-WZYXG3SE.js.map +0 -1
- package/dist/chunk-XDI2X3KE.js +0 -6
- package/dist/chunk-XDI2X3KE.js.map +0 -1
- package/dist/chunk-XKHLRIC7.cjs +0 -381
- package/dist/chunk-XKHLRIC7.cjs.map +0 -1
- package/dist/context-DNtd2WUv.d.cts +0 -11666
- package/dist/context-DgB72Bur.d.ts +0 -11666
- package/dist/en-Bu4Ti9Ev.d.cts +0 -2315
- package/dist/en-Bu4Ti9Ev.d.ts +0 -2315
- package/dist/shareLink-B6hlt942.d.ts +0 -144
- package/dist/shareLink-C7rIMb7x.d.ts +0 -527
- package/dist/shareLink-CnTxxXjp.d.cts +0 -144
- package/dist/shareLink-DyZVYH2V.d.cts +0 -527
- package/dist/studioPlugin-C3C7VjMy.d.ts +0 -847
- package/dist/studioPlugin-Cf3OBNUv.d.cts +0 -847
- package/dist/types-BzJRV6UI.d.cts +0 -845
- package/dist/types-BzJRV6UI.d.ts +0 -845
- package/dist/zoneForm-CdYNtnnA.d.cts +0 -320
- package/dist/zoneForm-mG85yt5e.d.ts +0 -320
package/dist/plugins/index.cjs
CHANGED
|
@@ -1,966 +1,497 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
n.default = e;
|
|
23
|
-
return Object.freeze(n);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
var z__namespace = /*#__PURE__*/_interopNamespace(z);
|
|
27
|
-
|
|
28
|
-
var studioPluginSlotSchema = z__namespace.enum([
|
|
29
|
-
"itinerary.menu",
|
|
30
|
-
"map.contextMenu",
|
|
31
|
-
"map.controls",
|
|
32
|
-
"profile.header",
|
|
33
|
-
"profile.plot",
|
|
34
|
-
"segment.menu",
|
|
35
|
-
"waypoint.menu",
|
|
36
|
-
"zone.menu"
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, {
|
|
3
|
+
__esModule: { value: true },
|
|
4
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
5
|
+
});
|
|
6
|
+
const require_rolldown_runtime = require("../chunk-Bn6ZbxkS.cjs");
|
|
7
|
+
const require_ids = require("../chunk-CmJBgSwZ.cjs");
|
|
8
|
+
const require_listeners = require("../chunk-BIEc_SkR.cjs");
|
|
9
|
+
let zod = require("zod");
|
|
10
|
+
zod = require_rolldown_runtime.__toESM(zod);
|
|
11
|
+
let _mountaya_elements_errors = require("@mountaya/elements/errors");
|
|
12
|
+
const studioPluginSlotSchema = zod.enum([
|
|
13
|
+
"itinerary.menu",
|
|
14
|
+
"map.contextMenu",
|
|
15
|
+
"map.controls",
|
|
16
|
+
"profile.header",
|
|
17
|
+
"profile.plot",
|
|
18
|
+
"segment.menu",
|
|
19
|
+
"waypoint.menu",
|
|
20
|
+
"zone.menu"
|
|
37
21
|
]);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return gate.when === void 0 || gate.when(ctx) === true;
|
|
57
|
-
} catch (fault) {
|
|
58
|
-
const faulted = typeof gate === "object" && gate !== null ? gate : contribution;
|
|
59
|
-
if (!faultedGates.has(faulted)) {
|
|
60
|
-
faultedGates.add(faulted);
|
|
61
|
-
chunkPACIO4NS_cjs.surfaceFault(fault);
|
|
62
|
-
}
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
22
|
+
const isStudioContributionAvailable = (contribution, ctx) => {
|
|
23
|
+
const gate = contribution.gate;
|
|
24
|
+
if (gate === void 0) return true;
|
|
25
|
+
try {
|
|
26
|
+
for (const capability of gate.capabilities ?? []) if (!ctx.capabilities.has(capability)) return false;
|
|
27
|
+
for (const entitlement of gate.entitlements ?? []) if (!ctx.viewer.hasEntitlement(entitlement)) return false;
|
|
28
|
+
return gate.when === void 0 || gate.when(ctx) === true;
|
|
29
|
+
} catch (fault) {
|
|
30
|
+
const faulted = typeof gate === "object" && gate !== null ? gate : contribution;
|
|
31
|
+
if (!faultedGates.has(faulted)) {
|
|
32
|
+
faultedGates.add(faulted);
|
|
33
|
+
require_listeners.surfaceFault(fault);
|
|
34
|
+
}
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
65
37
|
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
return contributions.filter((contribution) => isStudioContributionAvailable(contribution, ctx));
|
|
38
|
+
const faultedGates = /* @__PURE__ */ new WeakSet();
|
|
39
|
+
const availableStudioContributions = (contributions, ctx) => {
|
|
40
|
+
if (contributions.every((contribution) => isStudioContributionAvailable(contribution, ctx))) return contributions;
|
|
41
|
+
return contributions.filter((contribution) => isStudioContributionAvailable(contribution, ctx));
|
|
72
42
|
};
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
`plugin install refused: ${defects.map((defect) => `${defect.pluginId} ${defect.code}${defect.subject === void 0 ? "" : ` (${defect.subject})`}`).join(", ")}`,
|
|
84
|
-
options
|
|
85
|
-
);
|
|
86
|
-
this.defects = defects;
|
|
87
|
-
}
|
|
43
|
+
const orderOf = ({ order }) => order !== void 0 && Number.isFinite(order) ? order : 0;
|
|
44
|
+
const sortStudioContributions = (contributions) => [...contributions].sort((left, right) => orderOf(left) - orderOf(right) || (left.sequence ?? 0) - (right.sequence ?? 0));
|
|
45
|
+
const STUDIO_PLUGIN_ERROR_NAME = "StudioPluginError";
|
|
46
|
+
var StudioPluginError = class extends _mountaya_elements_errors.MountayaElementsError {
|
|
47
|
+
name = STUDIO_PLUGIN_ERROR_NAME;
|
|
48
|
+
defects;
|
|
49
|
+
constructor(defects, options) {
|
|
50
|
+
super(`plugin install refused: ${defects.map((defect) => `${defect.pluginId} ${defect.code}${defect.subject === void 0 ? "" : ` (${defect.subject})`}`).join(", ")}`, options);
|
|
51
|
+
this.defects = defects;
|
|
52
|
+
}
|
|
88
53
|
};
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
"tool_name_not_namespaced",
|
|
106
|
-
"tool_name_taken"
|
|
54
|
+
const isStudioPluginError = (error) => typeof error === "object" && error !== null && error.name === STUDIO_PLUGIN_ERROR_NAME && Array.isArray(error.defects);
|
|
55
|
+
const studioPluginToolPrefix = (pluginId) => `${pluginId}.`;
|
|
56
|
+
const isStudioPluginToolName = (pluginId, name) => name.startsWith(studioPluginToolPrefix(pluginId));
|
|
57
|
+
const qualifyStudioContributionId = (pluginId, contributionId) => `${pluginId}:${contributionId}`;
|
|
58
|
+
const studioPluginDefectCodeSchema = zod.enum([
|
|
59
|
+
"contribution_empty",
|
|
60
|
+
"contribution_id_duplicate",
|
|
61
|
+
"contribution_id_invalid",
|
|
62
|
+
"plugin_id_invalid",
|
|
63
|
+
"plugin_id_reserved",
|
|
64
|
+
"plugin_id_taken",
|
|
65
|
+
"slot_unknown",
|
|
66
|
+
"tool_key_mismatch",
|
|
67
|
+
"tool_name_empty",
|
|
68
|
+
"tool_name_not_namespaced",
|
|
69
|
+
"tool_name_taken"
|
|
107
70
|
]);
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
return typeof value;
|
|
117
|
-
}
|
|
71
|
+
const isRecord = (value) => typeof value === "object" && value !== null;
|
|
72
|
+
const printed = (value) => {
|
|
73
|
+
if (typeof value === "string") return value;
|
|
74
|
+
try {
|
|
75
|
+
return String(value);
|
|
76
|
+
} catch {
|
|
77
|
+
return typeof value;
|
|
78
|
+
}
|
|
118
79
|
};
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
if (typeof name !== "string") {
|
|
166
|
-
defect("tool_key_mismatch", key);
|
|
167
|
-
continue;
|
|
168
|
-
}
|
|
169
|
-
if (key !== name) {
|
|
170
|
-
defect("tool_key_mismatch", key);
|
|
171
|
-
}
|
|
172
|
-
if (!isStudioPluginToolName(pluginId, name)) {
|
|
173
|
-
defect("tool_name_not_namespaced", name);
|
|
174
|
-
} else if (name === studioPluginToolPrefix(pluginId)) {
|
|
175
|
-
defect("tool_name_empty", name);
|
|
176
|
-
}
|
|
177
|
-
if (scope.tools.has(name)) {
|
|
178
|
-
defect("tool_name_taken", name);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
return defects;
|
|
80
|
+
const validateStudioPlugin = (plugin, scope) => {
|
|
81
|
+
const declaration = plugin;
|
|
82
|
+
const members = isRecord(declaration) ? declaration : {};
|
|
83
|
+
const defects = [];
|
|
84
|
+
const pluginId = typeof members.id === "string" ? members.id : "";
|
|
85
|
+
const defect = (code, subject) => {
|
|
86
|
+
defects.push(subject === void 0 ? {
|
|
87
|
+
code,
|
|
88
|
+
pluginId
|
|
89
|
+
} : {
|
|
90
|
+
code,
|
|
91
|
+
pluginId,
|
|
92
|
+
subject
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
if (!require_ids.studioPluginIdPattern.test(pluginId)) defect("plugin_id_invalid");
|
|
96
|
+
const vendor = pluginId.split(".")[0];
|
|
97
|
+
if (require_ids.RESERVED_PLUGIN_NAMESPACES.some((reserved) => reserved === vendor)) defect("plugin_id_reserved");
|
|
98
|
+
if (scope.installed.has(pluginId)) defect("plugin_id_taken");
|
|
99
|
+
const seen = /* @__PURE__ */ new Set();
|
|
100
|
+
const declared = members.contributions ?? [];
|
|
101
|
+
const contributions = Array.isArray(declared) ? declared : [declared];
|
|
102
|
+
for (const entry of contributions) {
|
|
103
|
+
const contribution = isRecord(entry) ? entry : {};
|
|
104
|
+
const subject = printed(contribution.id);
|
|
105
|
+
if (!studioPluginSlotSchema.safeParse(contribution.slot).success) defect("slot_unknown", printed(contribution.slot));
|
|
106
|
+
if (typeof contribution.id !== "string" || !require_ids.studioContributionIdPattern.test(contribution.id)) defect("contribution_id_invalid", subject);
|
|
107
|
+
else if (seen.has(contribution.id)) defect("contribution_id_duplicate", subject);
|
|
108
|
+
if (typeof contribution.id === "string") seen.add(contribution.id);
|
|
109
|
+
const hasView = contribution.view !== void 0 && contribution.view !== null;
|
|
110
|
+
const hasAction = typeof contribution.label === "string" && contribution.label.trim() !== "" && typeof contribution.run === "function";
|
|
111
|
+
if (!hasView && !hasAction) defect("contribution_empty", subject);
|
|
112
|
+
}
|
|
113
|
+
if (members.tools !== void 0 && members.tools !== null && !isRecord(members.tools)) defect("tool_key_mismatch", printed(members.tools));
|
|
114
|
+
for (const [key, tool] of Object.entries(isRecord(members.tools) ? members.tools : {})) {
|
|
115
|
+
const name = isRecord(tool) ? tool.name : void 0;
|
|
116
|
+
if (typeof name !== "string") {
|
|
117
|
+
defect("tool_key_mismatch", key);
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
if (key !== name) defect("tool_key_mismatch", key);
|
|
121
|
+
if (!isStudioPluginToolName(pluginId, name)) defect("tool_name_not_namespaced", name);
|
|
122
|
+
else if (name === studioPluginToolPrefix(pluginId)) defect("tool_name_empty", name);
|
|
123
|
+
if (scope.tools.has(name)) defect("tool_name_taken", name);
|
|
124
|
+
}
|
|
125
|
+
return defects;
|
|
182
126
|
};
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
"waypoint.menu": NO_CONTRIBUTIONS,
|
|
194
|
-
"zone.menu": NO_CONTRIBUTIONS
|
|
127
|
+
const NO_CONTRIBUTIONS = Object.freeze([]);
|
|
128
|
+
const emptyIndex = () => ({
|
|
129
|
+
"itinerary.menu": NO_CONTRIBUTIONS,
|
|
130
|
+
"map.contextMenu": NO_CONTRIBUTIONS,
|
|
131
|
+
"map.controls": NO_CONTRIBUTIONS,
|
|
132
|
+
"profile.header": NO_CONTRIBUTIONS,
|
|
133
|
+
"profile.plot": NO_CONTRIBUTIONS,
|
|
134
|
+
"segment.menu": NO_CONTRIBUTIONS,
|
|
135
|
+
"waypoint.menu": NO_CONTRIBUTIONS,
|
|
136
|
+
"zone.menu": NO_CONTRIBUTIONS
|
|
195
137
|
});
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
};
|
|
138
|
+
const refusalsFor = (onRefused) => {
|
|
139
|
+
if (onRefused !== void 0) return {
|
|
140
|
+
reporter: onRefused,
|
|
141
|
+
settle: () => void 0
|
|
142
|
+
};
|
|
143
|
+
let first;
|
|
144
|
+
return {
|
|
145
|
+
reporter: (error) => {
|
|
146
|
+
first ??= { error };
|
|
147
|
+
},
|
|
148
|
+
settle: () => {
|
|
149
|
+
if (first !== void 0) throw first.error;
|
|
150
|
+
}
|
|
151
|
+
};
|
|
211
152
|
};
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
153
|
+
const declaredId = (plugin) => typeof plugin === "object" && plugin !== null && "id" in plugin && typeof plugin.id === "string" ? plugin.id : void 0;
|
|
154
|
+
const noRefusalsTold = () => ({
|
|
155
|
+
byId: /* @__PURE__ */ new Map(),
|
|
156
|
+
unnamed: /* @__PURE__ */ new Map()
|
|
157
|
+
});
|
|
158
|
+
const unnamedSubject = (member) => {
|
|
159
|
+
if (typeof member === "function") return Function;
|
|
160
|
+
return typeof member === "object" && member !== null ? Object : member;
|
|
219
161
|
};
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
return "";
|
|
228
|
-
}
|
|
162
|
+
const refusalWords = (error) => {
|
|
163
|
+
if (error instanceof Error) return `${error.name}: ${error.message}`;
|
|
164
|
+
try {
|
|
165
|
+
return String(error);
|
|
166
|
+
} catch {
|
|
167
|
+
return "";
|
|
168
|
+
}
|
|
229
169
|
};
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
170
|
+
const noteRefusal = (told, before, member, error) => {
|
|
171
|
+
const id = declaredId(member);
|
|
172
|
+
const words = refusalWords(error);
|
|
173
|
+
if (id === void 0) {
|
|
174
|
+
const subject = unnamedSubject(member);
|
|
175
|
+
const stated = told.unnamed.get(subject) ?? /* @__PURE__ */ new Set();
|
|
176
|
+
told.unnamed.set(subject, stated.add(words));
|
|
177
|
+
return before.unnamed.get(subject)?.has(words) === true;
|
|
178
|
+
}
|
|
179
|
+
const held = before.byId.get(id);
|
|
180
|
+
told.byId.set(id, words);
|
|
181
|
+
return held === words || held === null;
|
|
242
182
|
};
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
}
|
|
251
|
-
if (!noteRefusal(told, before, member, error)) {
|
|
252
|
-
onRefused(error, plugin);
|
|
253
|
-
}
|
|
183
|
+
const declaredListReporter = (onRefused, told, before, surface) => (error, plugin) => {
|
|
184
|
+
const member = plugin;
|
|
185
|
+
if (typeof member !== "object" || member === null) {
|
|
186
|
+
if (surface !== void 0 && !noteRefusal(told, before, member, error)) surface(error);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
if (!noteRefusal(told, before, member, error)) onRefused(error, plugin);
|
|
254
190
|
};
|
|
255
|
-
|
|
191
|
+
const isStillKept = (held, listed) => listed !== void 0 && (!held.listedAsGiven || listed === held.tool);
|
|
256
192
|
var StudioPluginEngine = class {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
this.told = told;
|
|
558
|
-
if (changed) {
|
|
559
|
-
this.notify();
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
refusals.settle();
|
|
563
|
-
}
|
|
564
|
-
/**
|
|
565
|
-
* reconcile brings one declaration of a declared list in under its id: installed where the id
|
|
566
|
-
* is new, replaced where its reference changed, and left where it is the one installed.
|
|
567
|
-
*
|
|
568
|
-
* @returns Whether a slot may have changed: a plugin was installed, replaced, or lost to a
|
|
569
|
-
* sink that refused its replacement.
|
|
570
|
-
*/
|
|
571
|
-
reconcile(id, plugin, onRefused) {
|
|
572
|
-
const current = this.plugins.get(id);
|
|
573
|
-
if (current === plugin) {
|
|
574
|
-
this.declared.add(id);
|
|
575
|
-
return false;
|
|
576
|
-
}
|
|
577
|
-
if (current === void 0) {
|
|
578
|
-
if (!this.take(plugin, onRefused)) {
|
|
579
|
-
return false;
|
|
580
|
-
}
|
|
581
|
-
this.declared.add(id);
|
|
582
|
-
return true;
|
|
583
|
-
}
|
|
584
|
-
let defects;
|
|
585
|
-
try {
|
|
586
|
-
defects = validateStudioPlugin(plugin, this.scope(id, true));
|
|
587
|
-
} catch (error) {
|
|
588
|
-
this.report(error, plugin, onRefused);
|
|
589
|
-
return false;
|
|
590
|
-
}
|
|
591
|
-
if (defects.length > 0) {
|
|
592
|
-
this.report(new StudioPluginError(defects), plugin, onRefused);
|
|
593
|
-
return false;
|
|
594
|
-
}
|
|
595
|
-
this.drop(id);
|
|
596
|
-
if (this.take(plugin, onRefused)) {
|
|
597
|
-
this.declared.add(id);
|
|
598
|
-
}
|
|
599
|
-
return true;
|
|
600
|
-
}
|
|
601
|
-
/**
|
|
602
|
-
* run invokes a contribution's verb and reports how it ended. It ALWAYS resolves.
|
|
603
|
-
*
|
|
604
|
-
* It re-checks two things the caller cannot, because a menu can outlive both: that the entry is
|
|
605
|
-
* still installed (a plugin uninstalled, or its declaration replaced, while the dropdown was
|
|
606
|
-
* open) and that its gate still passes (an entitlement that lapsed mid-session). Neither is a
|
|
607
|
-
* throw: a stale click is a no-op with a reason, not a crash.
|
|
608
|
-
*
|
|
609
|
-
* `onError` is how the thrown value reaches a caller that has to report it. The outcome alone
|
|
610
|
-
* cannot carry one, and an observer is registered per ENGINE rather than per call, so a
|
|
611
|
-
* binding wanting to hand the failure to a host seam beside the contribution it came from
|
|
612
|
-
* passes this. It is called at most once, before the promise resolves. An `onError` that itself
|
|
613
|
-
* throws leaves the outcome `threw`, and its fault is surfaced on a microtask.
|
|
614
|
-
*/
|
|
615
|
-
async run(entry, ctx, target, onError) {
|
|
616
|
-
const start = performance.now();
|
|
617
|
-
const report = (outcome, error) => {
|
|
618
|
-
this.emit({
|
|
619
|
-
...error === void 0 ? {} : { error },
|
|
620
|
-
latencyMs: performance.now() - start,
|
|
621
|
-
outcome,
|
|
622
|
-
pluginId: entry.pluginId,
|
|
623
|
-
qualifiedId: entry.qualifiedId,
|
|
624
|
-
slot: entry.slot
|
|
625
|
-
});
|
|
626
|
-
return outcome;
|
|
627
|
-
};
|
|
628
|
-
if (!this.index[entry.slot].some((live) => live === entry)) {
|
|
629
|
-
return report("unknown");
|
|
630
|
-
}
|
|
631
|
-
if (!isStudioContributionAvailable(entry, ctx)) {
|
|
632
|
-
return report("gated");
|
|
633
|
-
}
|
|
634
|
-
const verb = entry.run;
|
|
635
|
-
if (verb === void 0) {
|
|
636
|
-
return report("inert");
|
|
637
|
-
}
|
|
638
|
-
try {
|
|
639
|
-
await verb(ctx, target);
|
|
640
|
-
} catch (error) {
|
|
641
|
-
try {
|
|
642
|
-
onError?.(error);
|
|
643
|
-
} catch (fault) {
|
|
644
|
-
chunkPACIO4NS_cjs.surfaceFault(fault);
|
|
645
|
-
}
|
|
646
|
-
return report("threw", error);
|
|
647
|
-
}
|
|
648
|
-
return report("ran");
|
|
649
|
-
}
|
|
650
|
-
/**
|
|
651
|
-
* dispose uninstalls everything and drops every listener and observer.
|
|
652
|
-
*
|
|
653
|
-
* It leaves an EMPTY engine rather than a poisoned one (installing into it afterwards works),
|
|
654
|
-
* because the alternative breaks React's StrictMode, where an effect's cleanup runs between
|
|
655
|
-
* two runs of the effect itself.
|
|
656
|
-
*
|
|
657
|
-
* An empty engine was told of nothing: a list declared after it is told of its refusals as a
|
|
658
|
-
* list stated for the first time is.
|
|
659
|
-
*/
|
|
660
|
-
dispose() {
|
|
661
|
-
const had = this.plugins.size > 0;
|
|
662
|
-
for (const id of [...this.plugins.keys()]) {
|
|
663
|
-
this.drop(id);
|
|
664
|
-
}
|
|
665
|
-
this.told = noRefusalsTold();
|
|
666
|
-
if (had) {
|
|
667
|
-
this.notify();
|
|
668
|
-
}
|
|
669
|
-
this.listeners.clear();
|
|
670
|
-
this.observers.clear();
|
|
671
|
-
}
|
|
672
|
-
/**
|
|
673
|
-
* adopt is install without the notification: validate, register with rollback, then index.
|
|
674
|
-
*
|
|
675
|
-
* The order is the atomicity. Validation reads and changes nothing; tool registration is the
|
|
676
|
-
* only step that can fail, and it unwinds its own partial work; indexing is pure mutation of
|
|
677
|
-
* state this object owns and cannot throw. So a refused install leaves the bus and every slot
|
|
678
|
-
* exactly as they were.
|
|
679
|
-
*
|
|
680
|
-
* A sink that keeps a name it is asked for is the one exception, and {@link register} states
|
|
681
|
-
* what becomes of that name.
|
|
682
|
-
*/
|
|
683
|
-
adopt(plugin) {
|
|
684
|
-
const defects = validateStudioPlugin(plugin, this.scope(declaredId(plugin) ?? "", false));
|
|
685
|
-
if (defects.length > 0) {
|
|
686
|
-
throw new StudioPluginError(defects);
|
|
687
|
-
}
|
|
688
|
-
const sink = this.sink;
|
|
689
|
-
const declaredTools = Object.values(plugin.tools ?? {}).map((tool) => tool.name);
|
|
690
|
-
const registered = sink === void 0 ? declaredTools : this.register(plugin, sink);
|
|
691
|
-
for (const name of registered) {
|
|
692
|
-
this.toolNames.set(name, plugin.id);
|
|
693
|
-
}
|
|
694
|
-
this.plugins.set(plugin.id, plugin);
|
|
695
|
-
this.snapshot = null;
|
|
696
|
-
const touched = /* @__PURE__ */ new Set();
|
|
697
|
-
const resolved = (plugin.contributions ?? []).map((contribution) => {
|
|
698
|
-
touched.add(contribution.slot);
|
|
699
|
-
return {
|
|
700
|
-
...contribution,
|
|
701
|
-
pluginId: plugin.id,
|
|
702
|
-
qualifiedId: qualifyStudioContributionId(plugin.id, contribution.id),
|
|
703
|
-
sequence: this.sequence++
|
|
704
|
-
};
|
|
705
|
-
});
|
|
706
|
-
this.entries.set(plugin.id, resolved);
|
|
707
|
-
this.rebuild(touched);
|
|
708
|
-
}
|
|
709
|
-
/**
|
|
710
|
-
* register puts one plugin's tools on a sink, unwinding its own partial work if one is refused.
|
|
711
|
-
*
|
|
712
|
-
* The only step of an adoption that can fail, which is why it is the only one with a rollback
|
|
713
|
-
* (see {@link install}'s note on atomicity). `instanceof Error` here is the narrow question "is
|
|
714
|
-
* this already a throwable with a message", not the class-identity check `isStudioPluginError`
|
|
715
|
-
* exists to avoid: the value is the sink's, and wrapping one that is already an error would
|
|
716
|
-
* bury the bus's own message one `cause` deeper.
|
|
717
|
-
*
|
|
718
|
-
* The rollback asks the sink for each name back through {@link withdraw}, as an uninstall
|
|
719
|
-
* does. A name the sink keeps is remembered as the plugin's own, so the declaration put right
|
|
720
|
-
* meets its tool where the refusal left it.
|
|
721
|
-
*
|
|
722
|
-
* A name the sink kept from the plugin's earlier install ({@link unreleased}) is adopted
|
|
723
|
-
* where it stands, and only while the sink still lists it: the sink is read once, when the
|
|
724
|
-
* first such name is met. A kept name the sink does not list then is forgotten and its tool is
|
|
725
|
-
* registered as any other. So is a kept name under which the sink lists another tool, where
|
|
726
|
-
* the sink lists what it is given ({@link isStillKept}): its owner registered that tool since,
|
|
727
|
-
* the sink is offered the plugin's and answers for the name itself. A sink that throws from
|
|
728
|
-
* that read refuses the plugin, as one that throws from `register` does.
|
|
729
|
-
*/
|
|
730
|
-
register(plugin, sink) {
|
|
731
|
-
const kept = this.unreleased.get(sink);
|
|
732
|
-
const registered = [];
|
|
733
|
-
const adopted = [];
|
|
734
|
-
let listed;
|
|
735
|
-
try {
|
|
736
|
-
for (const tool of Object.values(plugin.tools ?? {})) {
|
|
737
|
-
const held = kept?.get(tool.name);
|
|
738
|
-
if (held?.pluginId === plugin.id) {
|
|
739
|
-
listed ??= new Map(sink.registered().map((entry) => [entry.name, entry]));
|
|
740
|
-
if (isStillKept(held, listed.get(tool.name))) {
|
|
741
|
-
if (held.tool !== tool) {
|
|
742
|
-
throw new errors.MountayaElementsError(
|
|
743
|
-
`plugin ${plugin.id} cannot register ${tool.name}: the tool sink kept that name from an earlier install and would not release it. Install the declaration that registered it, or stop reserving the plugin's vendor segment on the sink.`
|
|
744
|
-
);
|
|
745
|
-
}
|
|
746
|
-
adopted.push(held);
|
|
747
|
-
continue;
|
|
748
|
-
}
|
|
749
|
-
kept?.delete(tool.name);
|
|
750
|
-
}
|
|
751
|
-
sink.register(tool);
|
|
752
|
-
this.placed.set(tool.name, tool);
|
|
753
|
-
registered.push(tool.name);
|
|
754
|
-
}
|
|
755
|
-
} catch (error) {
|
|
756
|
-
for (const name of registered) {
|
|
757
|
-
this.withdraw(name, plugin.id, sink);
|
|
758
|
-
}
|
|
759
|
-
throw error instanceof Error ? error : new errors.MountayaElementsError(`plugin ${plugin.id} failed to register a tool`, {
|
|
760
|
-
cause: error
|
|
761
|
-
});
|
|
762
|
-
}
|
|
763
|
-
for (const { tool } of adopted) {
|
|
764
|
-
this.placed.set(tool.name, tool);
|
|
765
|
-
kept?.delete(tool.name);
|
|
766
|
-
}
|
|
767
|
-
return [...adopted.map(({ tool }) => tool.name), ...registered];
|
|
768
|
-
}
|
|
769
|
-
/**
|
|
770
|
-
* take is {@link adopt} with the refusal routed rather than thrown. Reports whether it landed.
|
|
771
|
-
*
|
|
772
|
-
* The one place the two postures meet: with a reporter a refusal is one plugin's problem, and
|
|
773
|
-
* without one it is the caller's. Everything above that wants "apply what you can" goes through
|
|
774
|
-
* here, and the atomicity `adopt` guarantees is untouched either way.
|
|
775
|
-
*/
|
|
776
|
-
take(plugin, onRefused) {
|
|
777
|
-
try {
|
|
778
|
-
this.adopt(plugin);
|
|
779
|
-
} catch (error) {
|
|
780
|
-
this.report(error, plugin, onRefused);
|
|
781
|
-
return false;
|
|
782
|
-
}
|
|
783
|
-
return true;
|
|
784
|
-
}
|
|
785
|
-
/** report hands a refusal to the reporter, or rethrows it when there is none. */
|
|
786
|
-
report(error, plugin, onRefused) {
|
|
787
|
-
if (onRefused === void 0) {
|
|
788
|
-
throw error;
|
|
789
|
-
}
|
|
790
|
-
try {
|
|
791
|
-
onRefused(error, plugin);
|
|
792
|
-
} catch (fault) {
|
|
793
|
-
chunkPACIO4NS_cjs.surfaceFault(fault);
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
/** drop is uninstall without the notification. Reports whether the plugin was there. */
|
|
797
|
-
drop(pluginId) {
|
|
798
|
-
this.declared.delete(pluginId);
|
|
799
|
-
if (!this.plugins.has(pluginId)) {
|
|
800
|
-
return false;
|
|
801
|
-
}
|
|
802
|
-
const touched = new Set(
|
|
803
|
-
(this.entries.get(pluginId) ?? []).map((entry) => entry.slot)
|
|
804
|
-
);
|
|
805
|
-
this.plugins.delete(pluginId);
|
|
806
|
-
this.entries.delete(pluginId);
|
|
807
|
-
this.snapshot = null;
|
|
808
|
-
this.rebuild(touched);
|
|
809
|
-
for (const [name, owner] of [...this.toolNames]) {
|
|
810
|
-
if (owner === pluginId) {
|
|
811
|
-
this.toolNames.delete(name);
|
|
812
|
-
if (this.sink !== void 0) {
|
|
813
|
-
this.withdraw(name, pluginId, this.sink);
|
|
814
|
-
}
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
return true;
|
|
818
|
-
}
|
|
819
|
-
/**
|
|
820
|
-
* withdraw asks a sink for one name back, and remembers a name the sink would not give up.
|
|
821
|
-
*
|
|
822
|
-
* Only a name this registry put there ({@link placed}) is asked for: a name the sink holds
|
|
823
|
-
* for somebody else was never this registry's to take back.
|
|
824
|
-
*
|
|
825
|
-
* `unregister` answers false for a name the sink never held and for one it refuses to release,
|
|
826
|
-
* so the sink is asked whether it still lists the name. A tool left there stays in service
|
|
827
|
-
* with no installed plugin behind it, and is remembered with the tool this registry handed
|
|
828
|
-
* over: see {@link unreleased}. The sink is read by name, since it may hand back another object
|
|
829
|
-
* than it was given.
|
|
830
|
-
*
|
|
831
|
-
* A fault the sink throws here is surfaced on a microtask and leaves through no caller: an
|
|
832
|
-
* uninstall, a reconciliation and a move between sinks each finish what they were doing.
|
|
833
|
-
*/
|
|
834
|
-
withdraw(name, pluginId, sink) {
|
|
835
|
-
const tool = this.placed.get(name);
|
|
836
|
-
if (tool === void 0) {
|
|
837
|
-
return;
|
|
838
|
-
}
|
|
839
|
-
this.placed.delete(name);
|
|
840
|
-
let listed;
|
|
841
|
-
try {
|
|
842
|
-
if (sink.unregister(name)) {
|
|
843
|
-
return;
|
|
844
|
-
}
|
|
845
|
-
listed = sink.registered().find((held) => held.name === name);
|
|
846
|
-
} catch (fault) {
|
|
847
|
-
chunkPACIO4NS_cjs.surfaceFault(fault);
|
|
848
|
-
return;
|
|
849
|
-
}
|
|
850
|
-
if (listed === void 0) {
|
|
851
|
-
return;
|
|
852
|
-
}
|
|
853
|
-
const kept = this.unreleased.get(sink) ?? /* @__PURE__ */ new Map();
|
|
854
|
-
kept.set(name, { listedAsGiven: listed === tool, pluginId, tool });
|
|
855
|
-
this.unreleased.set(sink, kept);
|
|
856
|
-
}
|
|
857
|
-
/**
|
|
858
|
-
* rebuild re-materialises exactly the slots named, and nothing else.
|
|
859
|
-
*
|
|
860
|
-
* Only the touched ones, which is what makes "installing a `segment.menu` plugin leaves
|
|
861
|
-
* `at('map.controls')` referentially identical" true: the property a memo keyed on a slot's
|
|
862
|
-
* array depends on.
|
|
863
|
-
*/
|
|
864
|
-
rebuild(slots) {
|
|
865
|
-
for (const slot of slots) {
|
|
866
|
-
const found = [];
|
|
867
|
-
for (const entries of this.entries.values()) {
|
|
868
|
-
for (const entry of entries) {
|
|
869
|
-
if (entry.slot === slot) {
|
|
870
|
-
found.push(entry);
|
|
871
|
-
}
|
|
872
|
-
}
|
|
873
|
-
}
|
|
874
|
-
this.setSlot(
|
|
875
|
-
slot,
|
|
876
|
-
found.length === 0 ? NO_CONTRIBUTIONS : Object.freeze(sortStudioContributions(found))
|
|
877
|
-
);
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
/**
|
|
881
|
-
* setSlot writes one slot of the index.
|
|
882
|
-
*
|
|
883
|
-
* The second localized cast, and it is the mapped type's: writing through a key whose type is
|
|
884
|
-
* the whole union makes TypeScript demand a value assignable to EVERY member's value type at
|
|
885
|
-
* once, which nothing is. Moving the index to a `Map` would trade this cast for one in `at`,
|
|
886
|
-
* the wrong side of the trade, since `at` is the member every render touches.
|
|
887
|
-
*/
|
|
888
|
-
setSlot(slot, entries) {
|
|
889
|
-
this.index[slot] = entries;
|
|
890
|
-
}
|
|
891
|
-
/**
|
|
892
|
-
* The collision scope a declaration of `pluginId` is validated against: the ids installed, and
|
|
893
|
-
* every tool name already taken.
|
|
894
|
-
*
|
|
895
|
-
* `replacing` takes the installed plugin of that id back out of it: its id and the names it
|
|
896
|
-
* brought, including the ones the sink is holding for it. That is what lets a replacement be
|
|
897
|
-
* validated while its incumbent is still installed. Without it every re-declaration under an
|
|
898
|
-
* unchanged id would read as `plugin_id_taken` plus one `tool_name_taken` per verb.
|
|
899
|
-
*
|
|
900
|
-
* A name the sink kept from an earlier install of the same id is the plugin's own either way,
|
|
901
|
-
* and taken for every other plugin: see {@link unreleased}. It is the plugin's own only while
|
|
902
|
-
* what the sink lists under it is still the tool it kept ({@link isStillKept}): a name its
|
|
903
|
-
* owner gave another tool since is taken, for this plugin as for any other.
|
|
904
|
-
*/
|
|
905
|
-
scope(pluginId, replacing) {
|
|
906
|
-
const own = /* @__PURE__ */ new Set();
|
|
907
|
-
const tools = /* @__PURE__ */ new Set();
|
|
908
|
-
const kept = this.sink === void 0 ? void 0 : this.unreleased.get(this.sink);
|
|
909
|
-
const listed = this.sink?.registered() ?? [];
|
|
910
|
-
const listedByName = new Map(listed.map((tool) => [tool.name, tool]));
|
|
911
|
-
for (const [name, held] of kept ?? []) {
|
|
912
|
-
if (held.pluginId === pluginId && isStillKept(held, listedByName.get(name))) {
|
|
913
|
-
own.add(name);
|
|
914
|
-
}
|
|
915
|
-
}
|
|
916
|
-
for (const [name, owner] of this.toolNames) {
|
|
917
|
-
if (replacing && owner === pluginId) {
|
|
918
|
-
own.add(name);
|
|
919
|
-
} else {
|
|
920
|
-
tools.add(name);
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
|
-
for (const tool of listed) {
|
|
924
|
-
if (!own.has(tool.name)) {
|
|
925
|
-
tools.add(tool.name);
|
|
926
|
-
}
|
|
927
|
-
}
|
|
928
|
-
const installed = new Set(this.plugins.keys());
|
|
929
|
-
if (replacing) {
|
|
930
|
-
installed.delete(pluginId);
|
|
931
|
-
}
|
|
932
|
-
return { installed, tools };
|
|
933
|
-
}
|
|
934
|
-
/**
|
|
935
|
-
* notify advances the version FIRST, so a listener reading `at` already sees the new list.
|
|
936
|
-
*
|
|
937
|
-
* Every listener is told, by the one rule the package's engines share (`notifyListeners`). A
|
|
938
|
-
* listener that throws skips no listener after it and never leaves through the `install` or
|
|
939
|
-
* `sync` that had already changed the state, which would break, from the outside, the
|
|
940
|
-
* atomicity this class guarantees. Its fault is surfaced on a microtask.
|
|
941
|
-
*/
|
|
942
|
-
notify() {
|
|
943
|
-
this.revision += 1;
|
|
944
|
-
chunkPACIO4NS_cjs.notifyListeners(this.listeners);
|
|
945
|
-
}
|
|
946
|
-
/** emit reports one run to every observer, by the rule {@link notify} follows. */
|
|
947
|
-
emit(event) {
|
|
948
|
-
chunkPACIO4NS_cjs.notifyListeners(this.observers, event);
|
|
949
|
-
}
|
|
193
|
+
listeners = /* @__PURE__ */ new Set();
|
|
194
|
+
observers = /* @__PURE__ */ new Set();
|
|
195
|
+
plugins = /* @__PURE__ */ new Map();
|
|
196
|
+
entries = /* @__PURE__ */ new Map();
|
|
197
|
+
toolNames = /* @__PURE__ */ new Map();
|
|
198
|
+
placed = /* @__PURE__ */ new Map();
|
|
199
|
+
unreleased = /* @__PURE__ */ new WeakMap();
|
|
200
|
+
declared = /* @__PURE__ */ new Set();
|
|
201
|
+
told = noRefusalsTold();
|
|
202
|
+
index = emptyIndex();
|
|
203
|
+
sequence = 0;
|
|
204
|
+
revision = 0;
|
|
205
|
+
snapshot = null;
|
|
206
|
+
sink;
|
|
207
|
+
constructor(options = {}) {
|
|
208
|
+
this.sink = options.tools;
|
|
209
|
+
const told = noRefusalsTold();
|
|
210
|
+
const onRefused = options.onRefused === void 0 ? void 0 : declaredListReporter(options.onRefused, told, this.told, void 0);
|
|
211
|
+
try {
|
|
212
|
+
for (const plugin of options.install ?? []) if (this.take(plugin, onRefused)) this.declared.add(plugin.id);
|
|
213
|
+
this.told = told;
|
|
214
|
+
} catch (error) {
|
|
215
|
+
this.dispose();
|
|
216
|
+
throw error;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
at(slot) {
|
|
220
|
+
return this.index[slot];
|
|
221
|
+
}
|
|
222
|
+
installed = () => {
|
|
223
|
+
this.snapshot ??= Object.freeze([...this.plugins.values()]);
|
|
224
|
+
return this.snapshot;
|
|
225
|
+
};
|
|
226
|
+
version = () => this.revision;
|
|
227
|
+
subscribe = (listener) => {
|
|
228
|
+
this.listeners.add(listener);
|
|
229
|
+
return () => {
|
|
230
|
+
this.listeners.delete(listener);
|
|
231
|
+
};
|
|
232
|
+
};
|
|
233
|
+
observe(observer) {
|
|
234
|
+
this.observers.add(observer);
|
|
235
|
+
return () => {
|
|
236
|
+
this.observers.delete(observer);
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
attachTools(sink, onRefused) {
|
|
240
|
+
const outgoing = this.sink;
|
|
241
|
+
if (outgoing !== void 0) for (const [name, owner] of [...this.toolNames]) this.withdraw(name, owner, outgoing);
|
|
242
|
+
this.sink = sink ?? void 0;
|
|
243
|
+
if (sink === null) return;
|
|
244
|
+
const refusals = refusalsFor(onRefused);
|
|
245
|
+
let dropped = false;
|
|
246
|
+
for (const plugin of [...this.plugins.values()]) try {
|
|
247
|
+
this.register(plugin, sink);
|
|
248
|
+
} catch (error) {
|
|
249
|
+
const stated = this.declared.has(plugin.id);
|
|
250
|
+
this.drop(plugin.id);
|
|
251
|
+
dropped = true;
|
|
252
|
+
this.report(error, plugin, refusals.reporter);
|
|
253
|
+
if (onRefused !== void 0 && stated) this.told.byId.set(plugin.id, null);
|
|
254
|
+
}
|
|
255
|
+
if (dropped) this.notify();
|
|
256
|
+
refusals.settle();
|
|
257
|
+
}
|
|
258
|
+
install(plugin) {
|
|
259
|
+
this.adopt(plugin);
|
|
260
|
+
this.notify();
|
|
261
|
+
}
|
|
262
|
+
uninstall(pluginId) {
|
|
263
|
+
if (!this.drop(pluginId)) return false;
|
|
264
|
+
this.notify();
|
|
265
|
+
return true;
|
|
266
|
+
}
|
|
267
|
+
sync(plugins, onRefused) {
|
|
268
|
+
const next = /* @__PURE__ */ new Map();
|
|
269
|
+
for (const plugin of plugins) next.set(declaredId(plugin) ?? {}, plugin);
|
|
270
|
+
const told = noRefusalsTold();
|
|
271
|
+
const refusals = refusalsFor(onRefused === void 0 ? void 0 : declaredListReporter(onRefused, told, this.told, require_listeners.surfaceFault));
|
|
272
|
+
let changed = false;
|
|
273
|
+
try {
|
|
274
|
+
for (const id of [...this.declared]) if (!next.has(id)) {
|
|
275
|
+
this.drop(id);
|
|
276
|
+
changed = true;
|
|
277
|
+
}
|
|
278
|
+
for (const [id, plugin] of next) {
|
|
279
|
+
if (typeof id !== "string") {
|
|
280
|
+
this.take(plugin, refusals.reporter);
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
if (this.reconcile(id, plugin, refusals.reporter)) changed = true;
|
|
284
|
+
}
|
|
285
|
+
} finally {
|
|
286
|
+
this.told = told;
|
|
287
|
+
if (changed) this.notify();
|
|
288
|
+
}
|
|
289
|
+
refusals.settle();
|
|
290
|
+
}
|
|
291
|
+
reconcile(id, plugin, onRefused) {
|
|
292
|
+
const current = this.plugins.get(id);
|
|
293
|
+
if (current === plugin) {
|
|
294
|
+
this.declared.add(id);
|
|
295
|
+
return false;
|
|
296
|
+
}
|
|
297
|
+
if (current === void 0) {
|
|
298
|
+
if (!this.take(plugin, onRefused)) return false;
|
|
299
|
+
this.declared.add(id);
|
|
300
|
+
return true;
|
|
301
|
+
}
|
|
302
|
+
let defects;
|
|
303
|
+
try {
|
|
304
|
+
defects = validateStudioPlugin(plugin, this.scope(id, true));
|
|
305
|
+
} catch (error) {
|
|
306
|
+
this.report(error, plugin, onRefused);
|
|
307
|
+
return false;
|
|
308
|
+
}
|
|
309
|
+
if (defects.length > 0) {
|
|
310
|
+
this.report(new StudioPluginError(defects), plugin, onRefused);
|
|
311
|
+
return false;
|
|
312
|
+
}
|
|
313
|
+
this.drop(id);
|
|
314
|
+
if (this.take(plugin, onRefused)) this.declared.add(id);
|
|
315
|
+
return true;
|
|
316
|
+
}
|
|
317
|
+
async run(entry, ctx, target, onError) {
|
|
318
|
+
const start = performance.now();
|
|
319
|
+
const report = (outcome, error) => {
|
|
320
|
+
this.emit({
|
|
321
|
+
...error === void 0 ? {} : { error },
|
|
322
|
+
latencyMs: performance.now() - start,
|
|
323
|
+
outcome,
|
|
324
|
+
pluginId: entry.pluginId,
|
|
325
|
+
qualifiedId: entry.qualifiedId,
|
|
326
|
+
slot: entry.slot
|
|
327
|
+
});
|
|
328
|
+
return outcome;
|
|
329
|
+
};
|
|
330
|
+
if (!this.index[entry.slot].some((live) => live === entry)) return report("unknown");
|
|
331
|
+
if (!isStudioContributionAvailable(entry, ctx)) return report("gated");
|
|
332
|
+
const verb = entry.run;
|
|
333
|
+
if (verb === void 0) return report("inert");
|
|
334
|
+
try {
|
|
335
|
+
await verb(ctx, target);
|
|
336
|
+
} catch (error) {
|
|
337
|
+
try {
|
|
338
|
+
onError?.(error);
|
|
339
|
+
} catch (fault) {
|
|
340
|
+
require_listeners.surfaceFault(fault);
|
|
341
|
+
}
|
|
342
|
+
return report("threw", error);
|
|
343
|
+
}
|
|
344
|
+
return report("ran");
|
|
345
|
+
}
|
|
346
|
+
dispose() {
|
|
347
|
+
const had = this.plugins.size > 0;
|
|
348
|
+
for (const id of [...this.plugins.keys()]) this.drop(id);
|
|
349
|
+
this.told = noRefusalsTold();
|
|
350
|
+
if (had) this.notify();
|
|
351
|
+
this.listeners.clear();
|
|
352
|
+
this.observers.clear();
|
|
353
|
+
}
|
|
354
|
+
adopt(plugin) {
|
|
355
|
+
const defects = validateStudioPlugin(plugin, this.scope(declaredId(plugin) ?? "", false));
|
|
356
|
+
if (defects.length > 0) throw new StudioPluginError(defects);
|
|
357
|
+
const sink = this.sink;
|
|
358
|
+
const declaredTools = Object.values(plugin.tools ?? {}).map((tool) => tool.name);
|
|
359
|
+
const registered = sink === void 0 ? declaredTools : this.register(plugin, sink);
|
|
360
|
+
for (const name of registered) this.toolNames.set(name, plugin.id);
|
|
361
|
+
this.plugins.set(plugin.id, plugin);
|
|
362
|
+
this.snapshot = null;
|
|
363
|
+
const touched = /* @__PURE__ */ new Set();
|
|
364
|
+
const resolved = (plugin.contributions ?? []).map((contribution) => {
|
|
365
|
+
touched.add(contribution.slot);
|
|
366
|
+
return {
|
|
367
|
+
...contribution,
|
|
368
|
+
pluginId: plugin.id,
|
|
369
|
+
qualifiedId: qualifyStudioContributionId(plugin.id, contribution.id),
|
|
370
|
+
sequence: this.sequence++
|
|
371
|
+
};
|
|
372
|
+
});
|
|
373
|
+
this.entries.set(plugin.id, resolved);
|
|
374
|
+
this.rebuild(touched);
|
|
375
|
+
}
|
|
376
|
+
register(plugin, sink) {
|
|
377
|
+
const kept = this.unreleased.get(sink);
|
|
378
|
+
const registered = [];
|
|
379
|
+
const adopted = [];
|
|
380
|
+
let listed;
|
|
381
|
+
try {
|
|
382
|
+
for (const tool of Object.values(plugin.tools ?? {})) {
|
|
383
|
+
const held = kept?.get(tool.name);
|
|
384
|
+
if (held?.pluginId === plugin.id) {
|
|
385
|
+
listed ??= new Map(sink.registered().map((entry) => [entry.name, entry]));
|
|
386
|
+
if (isStillKept(held, listed.get(tool.name))) {
|
|
387
|
+
if (held.tool !== tool) throw new _mountaya_elements_errors.MountayaElementsError(`plugin ${plugin.id} cannot register ${tool.name}: the tool sink kept that name from an earlier install and would not release it. Install the declaration that registered it, or stop reserving the plugin's vendor segment on the sink.`);
|
|
388
|
+
adopted.push(held);
|
|
389
|
+
continue;
|
|
390
|
+
}
|
|
391
|
+
kept?.delete(tool.name);
|
|
392
|
+
}
|
|
393
|
+
sink.register(tool);
|
|
394
|
+
this.placed.set(tool.name, tool);
|
|
395
|
+
registered.push(tool.name);
|
|
396
|
+
}
|
|
397
|
+
} catch (error) {
|
|
398
|
+
for (const name of registered) this.withdraw(name, plugin.id, sink);
|
|
399
|
+
throw error instanceof Error ? error : new _mountaya_elements_errors.MountayaElementsError(`plugin ${plugin.id} failed to register a tool`, { cause: error });
|
|
400
|
+
}
|
|
401
|
+
for (const { tool } of adopted) {
|
|
402
|
+
this.placed.set(tool.name, tool);
|
|
403
|
+
kept?.delete(tool.name);
|
|
404
|
+
}
|
|
405
|
+
return [...adopted.map(({ tool }) => tool.name), ...registered];
|
|
406
|
+
}
|
|
407
|
+
take(plugin, onRefused) {
|
|
408
|
+
try {
|
|
409
|
+
this.adopt(plugin);
|
|
410
|
+
} catch (error) {
|
|
411
|
+
this.report(error, plugin, onRefused);
|
|
412
|
+
return false;
|
|
413
|
+
}
|
|
414
|
+
return true;
|
|
415
|
+
}
|
|
416
|
+
report(error, plugin, onRefused) {
|
|
417
|
+
if (onRefused === void 0) throw error;
|
|
418
|
+
try {
|
|
419
|
+
onRefused(error, plugin);
|
|
420
|
+
} catch (fault) {
|
|
421
|
+
require_listeners.surfaceFault(fault);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
drop(pluginId) {
|
|
425
|
+
this.declared.delete(pluginId);
|
|
426
|
+
if (!this.plugins.has(pluginId)) return false;
|
|
427
|
+
const touched = new Set((this.entries.get(pluginId) ?? []).map((entry) => entry.slot));
|
|
428
|
+
this.plugins.delete(pluginId);
|
|
429
|
+
this.entries.delete(pluginId);
|
|
430
|
+
this.snapshot = null;
|
|
431
|
+
this.rebuild(touched);
|
|
432
|
+
for (const [name, owner] of [...this.toolNames]) if (owner === pluginId) {
|
|
433
|
+
this.toolNames.delete(name);
|
|
434
|
+
if (this.sink !== void 0) this.withdraw(name, pluginId, this.sink);
|
|
435
|
+
}
|
|
436
|
+
return true;
|
|
437
|
+
}
|
|
438
|
+
withdraw(name, pluginId, sink) {
|
|
439
|
+
const tool = this.placed.get(name);
|
|
440
|
+
if (tool === void 0) return;
|
|
441
|
+
this.placed.delete(name);
|
|
442
|
+
let listed;
|
|
443
|
+
try {
|
|
444
|
+
if (sink.unregister(name)) return;
|
|
445
|
+
listed = sink.registered().find((held) => held.name === name);
|
|
446
|
+
} catch (fault) {
|
|
447
|
+
require_listeners.surfaceFault(fault);
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
if (listed === void 0) return;
|
|
451
|
+
const kept = this.unreleased.get(sink) ?? /* @__PURE__ */ new Map();
|
|
452
|
+
kept.set(name, {
|
|
453
|
+
listedAsGiven: listed === tool,
|
|
454
|
+
pluginId,
|
|
455
|
+
tool
|
|
456
|
+
});
|
|
457
|
+
this.unreleased.set(sink, kept);
|
|
458
|
+
}
|
|
459
|
+
rebuild(slots) {
|
|
460
|
+
for (const slot of slots) {
|
|
461
|
+
const found = [];
|
|
462
|
+
for (const entries of this.entries.values()) for (const entry of entries) if (entry.slot === slot) found.push(entry);
|
|
463
|
+
this.setSlot(slot, found.length === 0 ? NO_CONTRIBUTIONS : Object.freeze(sortStudioContributions(found)));
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
setSlot(slot, entries) {
|
|
467
|
+
this.index[slot] = entries;
|
|
468
|
+
}
|
|
469
|
+
scope(pluginId, replacing) {
|
|
470
|
+
const own = /* @__PURE__ */ new Set();
|
|
471
|
+
const tools = /* @__PURE__ */ new Set();
|
|
472
|
+
const kept = this.sink === void 0 ? void 0 : this.unreleased.get(this.sink);
|
|
473
|
+
const listed = this.sink?.registered() ?? [];
|
|
474
|
+
const listedByName = new Map(listed.map((tool) => [tool.name, tool]));
|
|
475
|
+
for (const [name, held] of kept ?? []) if (held.pluginId === pluginId && isStillKept(held, listedByName.get(name))) own.add(name);
|
|
476
|
+
for (const [name, owner] of this.toolNames) if (replacing && owner === pluginId) own.add(name);
|
|
477
|
+
else tools.add(name);
|
|
478
|
+
for (const tool of listed) if (!own.has(tool.name)) tools.add(tool.name);
|
|
479
|
+
const installed = new Set(this.plugins.keys());
|
|
480
|
+
if (replacing) installed.delete(pluginId);
|
|
481
|
+
return {
|
|
482
|
+
installed,
|
|
483
|
+
tools
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
notify() {
|
|
487
|
+
this.revision += 1;
|
|
488
|
+
require_listeners.notifyListeners(this.listeners);
|
|
489
|
+
}
|
|
490
|
+
emit(event) {
|
|
491
|
+
require_listeners.notifyListeners(this.observers, event);
|
|
492
|
+
}
|
|
950
493
|
};
|
|
951
|
-
|
|
952
|
-
Object.defineProperty(exports, "RESERVED_PLUGIN_NAMESPACES", {
|
|
953
|
-
enumerable: true,
|
|
954
|
-
get: function () { return chunkTIBXK6B7_cjs.RESERVED_PLUGIN_NAMESPACES; }
|
|
955
|
-
});
|
|
956
|
-
Object.defineProperty(exports, "studioContributionIdPattern", {
|
|
957
|
-
enumerable: true,
|
|
958
|
-
get: function () { return chunkTIBXK6B7_cjs.studioContributionIdPattern; }
|
|
959
|
-
});
|
|
960
|
-
Object.defineProperty(exports, "studioPluginIdPattern", {
|
|
961
|
-
enumerable: true,
|
|
962
|
-
get: function () { return chunkTIBXK6B7_cjs.studioPluginIdPattern; }
|
|
963
|
-
});
|
|
494
|
+
exports.RESERVED_PLUGIN_NAMESPACES = require_ids.RESERVED_PLUGIN_NAMESPACES;
|
|
964
495
|
exports.StudioPluginEngine = StudioPluginEngine;
|
|
965
496
|
exports.StudioPluginError = StudioPluginError;
|
|
966
497
|
exports.availableStudioContributions = availableStudioContributions;
|
|
@@ -969,9 +500,11 @@ exports.isStudioPluginError = isStudioPluginError;
|
|
|
969
500
|
exports.isStudioPluginToolName = isStudioPluginToolName;
|
|
970
501
|
exports.qualifyStudioContributionId = qualifyStudioContributionId;
|
|
971
502
|
exports.sortStudioContributions = sortStudioContributions;
|
|
503
|
+
exports.studioContributionIdPattern = require_ids.studioContributionIdPattern;
|
|
972
504
|
exports.studioPluginDefectCodeSchema = studioPluginDefectCodeSchema;
|
|
505
|
+
exports.studioPluginIdPattern = require_ids.studioPluginIdPattern;
|
|
973
506
|
exports.studioPluginSlotSchema = studioPluginSlotSchema;
|
|
974
507
|
exports.studioPluginToolPrefix = studioPluginToolPrefix;
|
|
975
508
|
exports.validateStudioPlugin = validateStudioPlugin;
|
|
976
|
-
|
|
509
|
+
|
|
977
510
|
//# sourceMappingURL=index.cjs.map
|