codex-overleaf-link 2.2.0 → 2.3.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/README.md +25 -23
- package/extension/bootstrap/manifest.template.json +1 -1
- package/extension/runtime-manifest.json +5 -71
- package/extension/src/background.js +53 -69
- package/extension/src/backgroundUpdateCoordinator.js +128 -66
- package/extension/src/content/applyResultFormatters.js +2 -3
- package/extension/src/content/contentRuntime.js +650 -1449
- package/extension/src/content/contextTray.js +4 -6
- package/extension/src/content/diagnosticsController.js +1 -2
- package/extension/src/content/diffReviewPanel.js +14 -13
- package/extension/src/content/generated/content.bundle.js +41370 -0
- package/extension/src/content/generated/content.bundle.meta.json +102 -0
- package/extension/src/content/legacyGlobalRegistry.js +129 -0
- package/extension/src/content/markdownText.js +5 -7
- package/extension/src/content/modelPicker.js +1 -1
- package/extension/src/content/modelPickerSupport.js +10 -5
- package/extension/src/content/moduleRegistryKernel.js +125 -0
- package/extension/src/content/nativeCompatibilityController.js +313 -0
- package/extension/src/content/otWarmMirror.js +7 -5
- package/extension/src/content/pageBridgeClient.js +224 -0
- package/extension/src/content/panelMaintenance.js +8 -3
- package/extension/src/content/postNavigationSettlementPersistence.js +100 -0
- package/extension/src/content/projectProviderSelection.js +4 -12
- package/extension/src/content/projectSessionCleanup.js +3 -3
- package/extension/src/content/providerSettingsCoordinator.js +59 -26
- package/extension/src/content/providerSettingsDialog.js +30 -18
- package/extension/src/content/recentProjects.js +15 -23
- package/extension/src/content/runGuidanceController.js +1 -1
- package/extension/src/content/runQueueScheduler.js +129 -29
- package/extension/src/content/runSettlementPersistence.js +51 -0
- package/extension/src/content/runTimelineView.js +11 -8
- package/extension/src/content/scopedPersistenceCoordinator.js +100 -0
- package/extension/src/content/scopedPersistenceDetachedCommit.js +47 -0
- package/extension/src/content/scopedPersistencePanelState.js +111 -0
- package/extension/src/content/sessionManager.js +15 -12
- package/extension/src/content/sessionPersistence.js +67 -8
- package/extension/src/content/updateNotice.js +10 -4
- package/extension/src/content/writebackOrchestrator.js +91 -23
- package/extension/src/contentScript.js +5 -1
- package/extension/src/page/trackedChangesLifecycle.js +6 -1
- package/extension/src/pageBridge.js +47 -98
- package/extension/src/shared/agentTranscript.js +8 -5
- package/extension/src/shared/compatibility.js +1 -1
- package/extension/src/shared/governanceRules.js +1 -1
- package/extension/src/shared/managedUpdateProjection.js +337 -0
- package/extension/src/shared/nativeRequestIdentity.js +60 -0
- package/extension/src/shared/otText.js +0 -19
- package/extension/src/shared/pageRpcContract.js +136 -0
- package/extension/src/shared/runExecutionSnapshot.js +177 -0
- package/extension/src/shared/runExecutionSnapshotCodec.js +168 -0
- package/extension/src/shared/runInputQueue.js +81 -34
- package/extension/src/shared/scopedPersistenceBrowserAdapter.js +79 -0
- package/extension/src/shared/scopedPersistenceQueuePolicy.js +181 -0
- package/extension/src/shared/scopedPersistenceTransaction.js +238 -0
- package/extension/src/shared/sessionState.js +64 -48
- package/extension/src/shared/settlementFacts.js +351 -0
- package/extension/src/shared/storageDb.js +19 -5
- package/extension/src/shared/storageMigration.js +275 -61
- package/extension/src/shared/storageSessionClaims.js +60 -0
- package/extension/src/shared/updateConsent.js +4 -0
- package/extension/src/shared/updateRevocationIntent.js +109 -0
- package/extension/src/shared/writebackEvidenceProjection.js +150 -0
- package/extension/src/shared/writebackOperationEvidence.js +143 -0
- package/extension/src/shared/writebackSettlement.js +705 -0
- package/native-host/src/codexRuntimeIdentity.js +1 -1
- package/native-host/src/codexSessionRunner.js +7 -13
- package/native-host/src/index.js +3 -69
- package/native-host/src/managedInstall.js +50 -8
- package/native-host/src/mirrorWorkspace.js +15 -8
- package/native-host/src/nativeTransportEnvelope.js +148 -0
- package/native-host/src/taskRunnerRuntime.js +3 -3
- package/package.json +13 -5
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"entry": "extension/entries/content-entry.mjs",
|
|
4
|
+
"output": "extension/src/content/generated/content.bundle.js",
|
|
5
|
+
"sourceDigest": "83c5f2bc9eb28735ba091c432476e505b311cfba37d53aa205049ea70ef2d2fc",
|
|
6
|
+
"outputDigest": "582a7804b46491dd34cd9f6f24304597f4e946e79870e323b9868a825b4666dd",
|
|
7
|
+
"byteLength": 2277820,
|
|
8
|
+
"inputs": [
|
|
9
|
+
"extension/entries/content-entry.mjs",
|
|
10
|
+
"extension/src/content/activeTurnControl.js",
|
|
11
|
+
"extension/src/content/applyResultFormatters.js",
|
|
12
|
+
"extension/src/content/composerAttachments.js",
|
|
13
|
+
"extension/src/content/composerPanel.js",
|
|
14
|
+
"extension/src/content/contentRuntime.js",
|
|
15
|
+
"extension/src/content/contextTray.js",
|
|
16
|
+
"extension/src/content/diagnosticsController.js",
|
|
17
|
+
"extension/src/content/diagnosticsPanel.js",
|
|
18
|
+
"extension/src/content/diffReviewPanel.js",
|
|
19
|
+
"extension/src/content/legacyGlobalRegistry.js",
|
|
20
|
+
"extension/src/content/localSkillsPanel.js",
|
|
21
|
+
"extension/src/content/markdownDomRenderer.js",
|
|
22
|
+
"extension/src/content/markdownText.js",
|
|
23
|
+
"extension/src/content/mathText.js",
|
|
24
|
+
"extension/src/content/mirrorHealth.js",
|
|
25
|
+
"extension/src/content/modelPicker.js",
|
|
26
|
+
"extension/src/content/modelPickerSupport.js",
|
|
27
|
+
"extension/src/content/moduleRegistryKernel.js",
|
|
28
|
+
"extension/src/content/nativeChannel.js",
|
|
29
|
+
"extension/src/content/nativeCompatibilityController.js",
|
|
30
|
+
"extension/src/content/otWarmMirror.js",
|
|
31
|
+
"extension/src/content/otWarmMirrorController.js",
|
|
32
|
+
"extension/src/content/pageBridgeClient.js",
|
|
33
|
+
"extension/src/content/panelMaintenance.js",
|
|
34
|
+
"extension/src/content/panelRenderer.js",
|
|
35
|
+
"extension/src/content/pendingInputView.js",
|
|
36
|
+
"extension/src/content/postNavigationSettlementPersistence.js",
|
|
37
|
+
"extension/src/content/projectProviderSelection.js",
|
|
38
|
+
"extension/src/content/projectSessionCleanup.js",
|
|
39
|
+
"extension/src/content/projectSettingsCoordinator.js",
|
|
40
|
+
"extension/src/content/providerSettingsCoordinator.js",
|
|
41
|
+
"extension/src/content/providerSettingsDialog.js",
|
|
42
|
+
"extension/src/content/recentProjects.js",
|
|
43
|
+
"extension/src/content/reviewHunks.js",
|
|
44
|
+
"extension/src/content/runController.js",
|
|
45
|
+
"extension/src/content/runGuidanceController.js",
|
|
46
|
+
"extension/src/content/runGuidanceView.js",
|
|
47
|
+
"extension/src/content/runQueueScheduler.js",
|
|
48
|
+
"extension/src/content/runSettlementPersistence.js",
|
|
49
|
+
"extension/src/content/runTimelineView.js",
|
|
50
|
+
"extension/src/content/scopedPersistenceCoordinator.js",
|
|
51
|
+
"extension/src/content/scopedPersistenceDetachedCommit.js",
|
|
52
|
+
"extension/src/content/scopedPersistencePanelState.js",
|
|
53
|
+
"extension/src/content/sessionManager.js",
|
|
54
|
+
"extension/src/content/sessionMenuView.js",
|
|
55
|
+
"extension/src/content/sessionPanel.js",
|
|
56
|
+
"extension/src/content/sessionPersistence.js",
|
|
57
|
+
"extension/src/content/settingsPanel.js",
|
|
58
|
+
"extension/src/content/themeController.js",
|
|
59
|
+
"extension/src/content/updateIdle.js",
|
|
60
|
+
"extension/src/content/updateNotice.js",
|
|
61
|
+
"extension/src/content/writebackController.js",
|
|
62
|
+
"extension/src/content/writebackOrchestrator.js",
|
|
63
|
+
"extension/src/shared/agentTranscript.js",
|
|
64
|
+
"extension/src/shared/auditRecords.js",
|
|
65
|
+
"extension/src/shared/compatibility.js",
|
|
66
|
+
"extension/src/shared/compileAdapter.js",
|
|
67
|
+
"extension/src/shared/failureReasons.js",
|
|
68
|
+
"extension/src/shared/governanceRules.js",
|
|
69
|
+
"extension/src/shared/i18n.js",
|
|
70
|
+
"extension/src/shared/lineReferences.js",
|
|
71
|
+
"extension/src/shared/managedUpdateProjection.js",
|
|
72
|
+
"extension/src/shared/models.js",
|
|
73
|
+
"extension/src/shared/otText.js",
|
|
74
|
+
"extension/src/shared/pageRpcContract.js",
|
|
75
|
+
"extension/src/shared/pathRedaction.js",
|
|
76
|
+
"extension/src/shared/projectFiles.js",
|
|
77
|
+
"extension/src/shared/providerProfiles.js",
|
|
78
|
+
"extension/src/shared/reviewing.js",
|
|
79
|
+
"extension/src/shared/runExecutionSnapshot.js",
|
|
80
|
+
"extension/src/shared/runExecutionSnapshotCodec.js",
|
|
81
|
+
"extension/src/shared/runInputQueue.js",
|
|
82
|
+
"extension/src/shared/scopedPersistenceBrowserAdapter.js",
|
|
83
|
+
"extension/src/shared/scopedPersistenceQueuePolicy.js",
|
|
84
|
+
"extension/src/shared/scopedPersistenceTransaction.js",
|
|
85
|
+
"extension/src/shared/sensitiveScan.js",
|
|
86
|
+
"extension/src/shared/sessionState.js",
|
|
87
|
+
"extension/src/shared/settlementFacts.js",
|
|
88
|
+
"extension/src/shared/staleGuard.js",
|
|
89
|
+
"extension/src/shared/storageDb.js",
|
|
90
|
+
"extension/src/shared/storageKeys.js",
|
|
91
|
+
"extension/src/shared/storageMigration.js",
|
|
92
|
+
"extension/src/shared/storageRunActions.js",
|
|
93
|
+
"extension/src/shared/storageSessionClaims.js",
|
|
94
|
+
"extension/src/shared/summary.js",
|
|
95
|
+
"extension/src/shared/undoOperations.js",
|
|
96
|
+
"extension/src/shared/writebackEvidenceProjection.js",
|
|
97
|
+
"extension/src/shared/writebackOperationEvidence.js",
|
|
98
|
+
"extension/src/shared/writebackSettlement.js",
|
|
99
|
+
"extension/vendor/katex/katex.min.js",
|
|
100
|
+
"extension/vendor/markdown-it/markdown-it.min.js"
|
|
101
|
+
]
|
|
102
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
(function initCodexOverleafLegacyGlobalRegistry(root, factory) {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const api = factory();
|
|
5
|
+
if (typeof module === 'object' && module.exports) {
|
|
6
|
+
module.exports = api;
|
|
7
|
+
}
|
|
8
|
+
if (root) {
|
|
9
|
+
root.CodexOverleafLegacyGlobalRegistry = api;
|
|
10
|
+
}
|
|
11
|
+
})(typeof window !== 'undefined' ? window : globalThis, function legacyGlobalRegistryFactory() {
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
const REQUIRED_MODULES = Object.freeze([
|
|
15
|
+
'ActiveTurnControl',
|
|
16
|
+
'AgentTranscript',
|
|
17
|
+
'ApplyResultFormatters',
|
|
18
|
+
'AuditRecords',
|
|
19
|
+
'Compatibility',
|
|
20
|
+
'ComposerAttachments',
|
|
21
|
+
'ComposerPanel',
|
|
22
|
+
'ContentRuntime',
|
|
23
|
+
'ContextTray',
|
|
24
|
+
'DiagnosticsController',
|
|
25
|
+
'DiagnosticsPanel',
|
|
26
|
+
'DiffReviewPanel',
|
|
27
|
+
'FailureReasons',
|
|
28
|
+
'GovernanceRules',
|
|
29
|
+
'I18n',
|
|
30
|
+
'LineReferences',
|
|
31
|
+
'LocalSkillsPanel',
|
|
32
|
+
'MarkdownText',
|
|
33
|
+
'MirrorHealth',
|
|
34
|
+
'ModelPicker',
|
|
35
|
+
'NativeChannel',
|
|
36
|
+
'NativeCompatibilityController',
|
|
37
|
+
'OtWarmMirror',
|
|
38
|
+
'OtWarmMirrorController',
|
|
39
|
+
'PageBridgeClient',
|
|
40
|
+
'PageRpcContract',
|
|
41
|
+
'PanelMaintenance',
|
|
42
|
+
'PanelRenderer',
|
|
43
|
+
'PendingInputView',
|
|
44
|
+
'PostNavigationSettlementPersistence',
|
|
45
|
+
'ProjectFiles',
|
|
46
|
+
'ProjectProviderSelection',
|
|
47
|
+
'ProjectSettingsCoordinator',
|
|
48
|
+
'ProviderSettingsCoordinator',
|
|
49
|
+
'RecentProjects',
|
|
50
|
+
'ReviewHunks',
|
|
51
|
+
'RunController',
|
|
52
|
+
'RunExecutionSnapshot',
|
|
53
|
+
'RunGuidanceController',
|
|
54
|
+
'RunInputQueue',
|
|
55
|
+
'RunQueueScheduler',
|
|
56
|
+
'RunSettlementPersistence',
|
|
57
|
+
'RunTimelineView',
|
|
58
|
+
'ScopedPersistenceCoordinator',
|
|
59
|
+
'ScopedPersistenceTransaction',
|
|
60
|
+
'SensitiveScan',
|
|
61
|
+
'SessionManager',
|
|
62
|
+
'SessionPanel',
|
|
63
|
+
'SessionPersistence',
|
|
64
|
+
'SessionState',
|
|
65
|
+
'SettingsPanel',
|
|
66
|
+
'StorageDb',
|
|
67
|
+
'StorageKeys',
|
|
68
|
+
'StorageMigration',
|
|
69
|
+
'Summary',
|
|
70
|
+
'Theme',
|
|
71
|
+
'UndoOperations',
|
|
72
|
+
'UpdateIdle',
|
|
73
|
+
'UpdateNotice',
|
|
74
|
+
'WritebackController',
|
|
75
|
+
'WritebackOrchestrator',
|
|
76
|
+
'WritebackSettlement'
|
|
77
|
+
]);
|
|
78
|
+
|
|
79
|
+
const SUPPORT_MODULES = Object.freeze([
|
|
80
|
+
'CompileAdapter',
|
|
81
|
+
'MarkdownDomRenderer',
|
|
82
|
+
'MathText',
|
|
83
|
+
'ModelPickerSupport',
|
|
84
|
+
'ProjectSessionCleanup',
|
|
85
|
+
'ProviderProfiles',
|
|
86
|
+
'ProviderSettingsDialog',
|
|
87
|
+
'RunGuidanceView',
|
|
88
|
+
'SessionMenuView'
|
|
89
|
+
]);
|
|
90
|
+
|
|
91
|
+
function create(root) {
|
|
92
|
+
if (!root || typeof root !== 'object') {
|
|
93
|
+
throw new TypeError('Codex Overleaf content startup requires a browser global.');
|
|
94
|
+
}
|
|
95
|
+
const modules = {};
|
|
96
|
+
const missing = [];
|
|
97
|
+
for (const name of [...REQUIRED_MODULES, ...SUPPORT_MODULES]) {
|
|
98
|
+
const value = root[`CodexOverleaf${name}`];
|
|
99
|
+
if (!value) {
|
|
100
|
+
missing.push(`CodexOverleaf${name}`);
|
|
101
|
+
} else {
|
|
102
|
+
modules[name] = value;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (missing.length) {
|
|
106
|
+
const error = new Error(`Codex Overleaf content dependencies are missing: ${missing.join(', ')}`);
|
|
107
|
+
error.code = 'content_dependency_missing';
|
|
108
|
+
error.missing = missing;
|
|
109
|
+
throw error;
|
|
110
|
+
}
|
|
111
|
+
const vendor = Object.freeze({
|
|
112
|
+
katex: root.katex || null,
|
|
113
|
+
markdownit: root.markdownit || null
|
|
114
|
+
});
|
|
115
|
+
return Object.freeze({
|
|
116
|
+
root,
|
|
117
|
+
chromeApi: root.chrome,
|
|
118
|
+
document: root.document,
|
|
119
|
+
modules: Object.freeze(modules),
|
|
120
|
+
vendor
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return Object.freeze({
|
|
125
|
+
create,
|
|
126
|
+
requiredModules: REQUIRED_MODULES,
|
|
127
|
+
supportModules: SUPPORT_MODULES
|
|
128
|
+
});
|
|
129
|
+
});
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
(function initCodexOverleafMarkdownText() {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
const LineReferences = window.CodexOverleafLineReferences;
|
|
5
|
-
|
|
6
4
|
// Markdown / assistant-text rendering — block + inline markdown, the
|
|
7
5
|
// assistant-visible sanitizers, and line-reference resolution/buttons carved
|
|
8
6
|
// out of contentRuntime.js (v1.4.5 structural-debt phase 1). The code below
|
|
@@ -10,8 +8,10 @@
|
|
|
10
8
|
// are factory-injected so behavior is unchanged.
|
|
11
9
|
function create(deps = {}) {
|
|
12
10
|
const {
|
|
11
|
+
LineReferences,
|
|
12
|
+
MathText,
|
|
13
13
|
tx,
|
|
14
|
-
callPageBridge,
|
|
14
|
+
callPageBridge, getCurrentProjectId,
|
|
15
15
|
getCurrentProjectReferenceFiles,
|
|
16
16
|
showPluginToast
|
|
17
17
|
} = deps;
|
|
@@ -63,9 +63,7 @@
|
|
|
63
63
|
|
|
64
64
|
function buildMarkdownInlineNodes(value) {
|
|
65
65
|
const source = String(value || '');
|
|
66
|
-
const mathText =
|
|
67
|
-
? window.CodexOverleafMathText
|
|
68
|
-
: null;
|
|
66
|
+
const mathText = MathText;
|
|
69
67
|
if (!mathText?.buildMathNodes) {
|
|
70
68
|
return buildMarkdownInlineNodesWithoutMath(source);
|
|
71
69
|
}
|
|
@@ -287,7 +285,7 @@
|
|
|
287
285
|
button.disabled = true;
|
|
288
286
|
button.dataset.status = 'pending';
|
|
289
287
|
try {
|
|
290
|
-
const result = await callPageBridge('jumpToPosition', params);
|
|
288
|
+
const result = await callPageBridge('jumpToPosition', { ...params, runProjectId: getCurrentProjectId?.() || '' });
|
|
291
289
|
if (result?.ok === false) {
|
|
292
290
|
button.dataset.status = 'failed';
|
|
293
291
|
button.title = tx('Could not open that referenced line.', '无法打开引用的行。');
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
(function initCodexOverleafModelPickerSupport(root) {
|
|
1
|
+
(function initCodexOverleafModelPickerSupport(root, factory) {
|
|
2
|
+
if (typeof module === 'object' && module.exports) {
|
|
3
|
+
module.exports = factory(require('../shared/models'));
|
|
4
|
+
} else {
|
|
5
|
+
root.CodexOverleafModuleRegistry.define('ModelPickerSupport', ['Models'], factory);
|
|
6
|
+
}
|
|
7
|
+
})(typeof window !== 'undefined' ? window : globalThis, function modelPickerSupportFactory(Models) {
|
|
2
8
|
'use strict';
|
|
3
9
|
|
|
4
10
|
function normalizeModelOptionId(id) {
|
|
@@ -37,7 +43,7 @@
|
|
|
37
43
|
}
|
|
38
44
|
|
|
39
45
|
function getModelCatalog({ getPanel } = {}) {
|
|
40
|
-
const shared =
|
|
46
|
+
const shared = Models;
|
|
41
47
|
if (Array.isArray(shared?.FALLBACK_MODELS) && typeof shared?.normalizeDiscoveredModels === 'function') {
|
|
42
48
|
return shared;
|
|
43
49
|
}
|
|
@@ -110,6 +116,5 @@
|
|
|
110
116
|
retainSelectedModel,
|
|
111
117
|
shouldUseBuiltInFallback
|
|
112
118
|
};
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
})(typeof window !== 'undefined' ? window : globalThis);
|
|
119
|
+
return api;
|
|
120
|
+
});
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
(function initCodexOverleafModuleRegistry(root, factory) {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const api = factory(root);
|
|
5
|
+
if (typeof module === 'object' && module.exports) {
|
|
6
|
+
module.exports = api;
|
|
7
|
+
}
|
|
8
|
+
if (root) {
|
|
9
|
+
root.CodexOverleafModuleRegistry = api;
|
|
10
|
+
}
|
|
11
|
+
})(typeof window !== 'undefined' ? window : globalThis, function moduleRegistryFactory(root) {
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
const definitions = new Map();
|
|
15
|
+
const instances = new Map();
|
|
16
|
+
|
|
17
|
+
function define(name, dependencies, factory) {
|
|
18
|
+
name = normalizeName(name);
|
|
19
|
+
if (definitions.has(name) || instances.has(name)) {
|
|
20
|
+
throw new Error(`Codex Overleaf module is already defined: ${name}`);
|
|
21
|
+
}
|
|
22
|
+
if (!Array.isArray(dependencies) || typeof factory !== 'function') {
|
|
23
|
+
throw new TypeError(`Codex Overleaf module ${name} has an invalid definition.`);
|
|
24
|
+
}
|
|
25
|
+
definitions.set(name, {
|
|
26
|
+
dependencies: dependencies.map(normalizeName),
|
|
27
|
+
factory
|
|
28
|
+
});
|
|
29
|
+
Object.defineProperty(root, `CodexOverleaf${name}`, {
|
|
30
|
+
configurable: true,
|
|
31
|
+
enumerable: false,
|
|
32
|
+
get() {
|
|
33
|
+
return resolve(name);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function resolve(name, stack = []) {
|
|
39
|
+
name = normalizeName(name);
|
|
40
|
+
if (instances.has(name)) {
|
|
41
|
+
return instances.get(name);
|
|
42
|
+
}
|
|
43
|
+
const definition = definitions.get(name);
|
|
44
|
+
if (!definition) {
|
|
45
|
+
const legacyValue = readLegacyValue(name);
|
|
46
|
+
if (legacyValue) {
|
|
47
|
+
return legacyValue;
|
|
48
|
+
}
|
|
49
|
+
throw moduleError('content_dependency_missing', `Codex Overleaf module is not defined: ${name}`, {
|
|
50
|
+
moduleName: name,
|
|
51
|
+
resolutionStack: stack
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
if (stack.includes(name)) {
|
|
55
|
+
const cycle = [...stack.slice(stack.indexOf(name)), name];
|
|
56
|
+
throw moduleError('content_dependency_cycle', `Codex Overleaf module dependency cycle: ${cycle.join(' -> ')}`, {
|
|
57
|
+
cycle
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
const nextStack = [...stack, name];
|
|
61
|
+
const args = definition.dependencies.map(dependency => resolve(dependency, nextStack));
|
|
62
|
+
const value = definition.factory(...args);
|
|
63
|
+
if (!value) {
|
|
64
|
+
throw moduleError('content_dependency_invalid_export', `Codex Overleaf module returned no export: ${name}`, {
|
|
65
|
+
moduleName: name
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
instances.set(name, value);
|
|
69
|
+
definitions.delete(name);
|
|
70
|
+
Object.defineProperty(root, `CodexOverleaf${name}`, {
|
|
71
|
+
configurable: true,
|
|
72
|
+
enumerable: false,
|
|
73
|
+
value,
|
|
74
|
+
writable: false
|
|
75
|
+
});
|
|
76
|
+
return value;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function resolveAll(names) {
|
|
80
|
+
const resolved = {};
|
|
81
|
+
const failures = [];
|
|
82
|
+
for (const name of names || []) {
|
|
83
|
+
try {
|
|
84
|
+
resolved[name] = resolve(name);
|
|
85
|
+
} catch (error) {
|
|
86
|
+
failures.push(error);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (failures.length) {
|
|
90
|
+
const error = moduleError(
|
|
91
|
+
'content_dependency_resolution_failed',
|
|
92
|
+
failures.map(item => item.message).join('; '),
|
|
93
|
+
{ failures }
|
|
94
|
+
);
|
|
95
|
+
throw error;
|
|
96
|
+
}
|
|
97
|
+
return resolved;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function readLegacyValue(name) {
|
|
101
|
+
const descriptor = Object.getOwnPropertyDescriptor(root, `CodexOverleaf${name}`);
|
|
102
|
+
if (!descriptor || typeof descriptor.get === 'function') {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
return descriptor.value || null;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function normalizeName(value) {
|
|
109
|
+
const name = String(value || '').trim();
|
|
110
|
+
if (!/^[A-Z][A-Za-z0-9_$]*$/.test(name)) {
|
|
111
|
+
throw new TypeError(`Invalid Codex Overleaf module name: ${name || '(empty)'}`);
|
|
112
|
+
}
|
|
113
|
+
return name;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function moduleError(code, message, detail) {
|
|
117
|
+
return Object.assign(new Error(message), { code, detail });
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return Object.freeze({
|
|
121
|
+
define,
|
|
122
|
+
resolve,
|
|
123
|
+
resolveAll
|
|
124
|
+
});
|
|
125
|
+
});
|