@agimon-ai/po-core 0.0.0-alpha.49 → 0.0.0-alpha.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/headlessHub.cjs +37 -14
- package/dist/headlessHub.cjs.map +1 -1
- package/dist/headlessHub.d.mts +10 -3
- package/dist/headlessHub.d.mts.map +1 -1
- package/dist/headlessHub.mjs +37 -14
- package/dist/headlessHub.mjs.map +1 -1
- package/dist/src/web/types/webPlugin.d.mts +4 -0
- package/dist/src/web/types/webPlugin.d.mts.map +1 -1
- package/package.json +4 -4
package/dist/headlessHub.cjs
CHANGED
|
@@ -85,6 +85,7 @@ function createHeadlessHub(options) {
|
|
|
85
85
|
const subscriptions = /* @__PURE__ */ new Set();
|
|
86
86
|
const sessionCleanups = /* @__PURE__ */ new Map();
|
|
87
87
|
const presentationCleanups = /* @__PURE__ */ new Map();
|
|
88
|
+
const compositionRefreshers = /* @__PURE__ */ new Map();
|
|
88
89
|
/** Profile icons by session, kept out of summaries because each can be hundreds of kilobytes. */
|
|
89
90
|
const avatarIcons = /* @__PURE__ */ new Map();
|
|
90
91
|
const sessionShutdowns = /* @__PURE__ */ new Map();
|
|
@@ -572,6 +573,7 @@ function createHeadlessHub(options) {
|
|
|
572
573
|
sessionCleanups.delete(sessionId);
|
|
573
574
|
presentationCleanups.get(sessionId)?.();
|
|
574
575
|
presentationCleanups.delete(sessionId);
|
|
576
|
+
compositionRefreshers.delete(sessionId);
|
|
575
577
|
avatarIcons.delete(sessionId);
|
|
576
578
|
directEvents.clearSession?.(sessionId);
|
|
577
579
|
}
|
|
@@ -605,7 +607,7 @@ function createHeadlessHub(options) {
|
|
|
605
607
|
});
|
|
606
608
|
return promise;
|
|
607
609
|
};
|
|
608
|
-
const register = (session) => {
|
|
610
|
+
const register = (session, publishCompositions) => {
|
|
609
611
|
if (closed) throw new Error("The headless hub is closed.");
|
|
610
612
|
if (sessions.has(session.id)) throw new Error(`Session '${session.id}' is already registered.`);
|
|
611
613
|
if (sessionShutdowns.get(session.id)?.pending) throw new Error(`Session '${session.id}' is still shutting down.`);
|
|
@@ -719,22 +721,29 @@ function createHeadlessHub(options) {
|
|
|
719
721
|
});
|
|
720
722
|
let registered = false;
|
|
721
723
|
const root = () => session.workspaceId && workspaces.get(session.workspaceId)?.root || session.cwd;
|
|
722
|
-
let
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
724
|
+
let selectedMode;
|
|
725
|
+
let publishedMode;
|
|
726
|
+
const applyCompositions = (force = false) => {
|
|
727
|
+
const mode = selectedMode;
|
|
728
|
+
if (!force && mode === publishedMode) return false;
|
|
729
|
+
let next;
|
|
726
730
|
try {
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
webComposition,
|
|
731
|
-
nativeComposition
|
|
732
|
-
};
|
|
733
|
-
return true;
|
|
731
|
+
if (publishCompositions) next = publishCompositions();
|
|
732
|
+
else if (options.publishSessionCompositions && mode !== void 0) next = options.publishSessionCompositions(session.id, root(), mode);
|
|
733
|
+
else return false;
|
|
734
734
|
} catch (error) {
|
|
735
|
-
options.onNotice?.(`session ${session.id} plugins for major mode "${
|
|
735
|
+
options.onNotice?.(`session ${session.id} plugins${mode === void 0 ? "" : ` for major mode "${mode}"`} could not be published (${error instanceof Error ? error.message : String(error)})`);
|
|
736
736
|
return false;
|
|
737
737
|
}
|
|
738
|
+
publishedMode = mode;
|
|
739
|
+
const { webComposition, nativeComposition } = next;
|
|
740
|
+
if (JSON.stringify([webComposition, nativeComposition]) === JSON.stringify([current.webComposition, current.nativeComposition])) return false;
|
|
741
|
+
current = {
|
|
742
|
+
...current,
|
|
743
|
+
webComposition,
|
|
744
|
+
nativeComposition
|
|
745
|
+
};
|
|
746
|
+
return true;
|
|
738
747
|
};
|
|
739
748
|
const applyProfile = (profileName) => {
|
|
740
749
|
let identity;
|
|
@@ -762,7 +771,8 @@ function createHeadlessHub(options) {
|
|
|
762
771
|
};
|
|
763
772
|
const applySelection = (selection) => {
|
|
764
773
|
if (closed || sessions.get(session.id)?.host !== session.host) return;
|
|
765
|
-
|
|
774
|
+
selectedMode = selection.majorMode;
|
|
775
|
+
const compositionsChanged = applyCompositions();
|
|
766
776
|
const profileChanged = applyProfile(selection.profile);
|
|
767
777
|
if (!compositionsChanged && !profileChanged) return;
|
|
768
778
|
sessions.set(session.id, current);
|
|
@@ -785,6 +795,15 @@ function createHeadlessHub(options) {
|
|
|
785
795
|
session: current
|
|
786
796
|
});
|
|
787
797
|
});
|
|
798
|
+
compositionRefreshers.set(session.id, () => {
|
|
799
|
+
if (closed || sessions.get(session.id)?.host !== session.host) return;
|
|
800
|
+
if (!applyCompositions(true)) return;
|
|
801
|
+
sessions.set(session.id, current);
|
|
802
|
+
if (registered) emit({
|
|
803
|
+
kind: "upsert",
|
|
804
|
+
session: current
|
|
805
|
+
});
|
|
806
|
+
});
|
|
788
807
|
presentationCleanups.set(session.id, () => {
|
|
789
808
|
stopPresentation();
|
|
790
809
|
stopSelection?.();
|
|
@@ -1151,6 +1170,9 @@ function createHeadlessHub(options) {
|
|
|
1151
1170
|
for (const key of mounts.map(mountKey)) compositionRevisions.set(key, (compositionRevisions.get(key) ?? 0) + 1);
|
|
1152
1171
|
emit({ kind: "compositions" });
|
|
1153
1172
|
},
|
|
1173
|
+
refreshSessionCompositions() {
|
|
1174
|
+
for (const refresh of compositionRefreshers.values()) refresh();
|
|
1175
|
+
},
|
|
1154
1176
|
registerWorkspace(workspace) {
|
|
1155
1177
|
workspaces.set(workspace.id, workspace);
|
|
1156
1178
|
emit({
|
|
@@ -1327,6 +1349,7 @@ function createHeadlessHub(options) {
|
|
|
1327
1349
|
subscriptions.clear();
|
|
1328
1350
|
for (const cleanup of presentationCleanups.values()) cleanup();
|
|
1329
1351
|
presentationCleanups.clear();
|
|
1352
|
+
compositionRefreshers.clear();
|
|
1330
1353
|
const failures = [];
|
|
1331
1354
|
pluginRegistry.dispose();
|
|
1332
1355
|
editPresence.clear();
|