arcane-os 0.5.13 → 0.5.14
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 +16 -0
- package/browser-runtime/ai/browser-wasm-llm-provider.mjs +11 -10
- package/browser-runtime/ai/browser-wllama-runtime.mjs +2 -1
- package/browser-runtime/ai/model-controller.mjs +6 -5
- package/browser-runtime/ai/speech-worker-client.mjs +45 -3
- package/browser-runtime/event-manager.mjs +2 -1
- package/browser-runtime/logging.mjs +58 -0
- package/docs/reference/README.md +8 -7
- package/docs/reference/ai/browser-speech.md +46 -1
- package/docs/reference/inventory/package-api.json +30 -2
- package/docs/reference/runtime-modules.md +18 -0
- package/docs/reference/sdk-api.md +94 -8
- package/package.json +3 -2
- package/runtime/arcane/components/app-bar.html +3 -1
- package/runtime/arcane/components/chat.html +22 -20
- package/runtime/arcane/components/dashboard-config.html +3 -1
- package/runtime/arcane/components/data-maintenance.html +4 -2
- package/runtime/arcane/components/data-view.html +3 -1
- package/runtime/arcane/components/directory-picker.html +3 -1
- package/runtime/arcane/components/file-manager.html +11 -9
- package/runtime/arcane/components/header.html +5 -3
- package/runtime/arcane/components/markdown-document.html +3 -1
- package/runtime/arcane/components/markdown-editor.html +4 -2
- package/runtime/arcane/components/modal.html +3 -1
- package/runtime/arcane/components/screen-capture.html +4 -2
- package/runtime/arcane/components/speech.html +10 -8
- package/runtime/arcane/components/table.html +3 -1
- package/runtime/arcane/components/voice-transcription.html +8 -6
- package/runtime/arcane/entities/Chat.js +5 -4
- package/runtime/arcane/entities/User.js +2 -1
- package/runtime/arcane/modules/AI.js +442 -292
- package/runtime/arcane/modules/AIProviderRuntime.js +359 -82
- package/runtime/arcane/modules/CommunicationAppController.js +2 -1
- package/runtime/arcane/modules/ComponentContracts.js +3 -2
- package/runtime/arcane/modules/ConversationTimebox.js +2 -1
- package/runtime/arcane/modules/DBOPFS.js +5 -4
- package/runtime/arcane/modules/Errors.js +3 -14
- package/runtime/arcane/modules/HTMLImport.js +4 -3
- package/runtime/arcane/modules/LocalAIReadinessController.js +2 -1
- package/runtime/arcane/modules/MD.js +3 -2
- package/runtime/arcane/modules/MailOutbox.mjs +2 -1
- package/runtime/arcane/modules/PersistentAIChatSession.js +2 -1
- package/runtime/arcane/modules/ScreenCapture.js +2 -1
- package/runtime/arcane/modules/ThemeBootstrap.js +3 -2
- package/runtime/arcane/modules/ToolCallRouter.js +2 -1
- package/src/import-map.mjs +65 -10
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { arcaneLogging } from 'arcane-os/logging';
|
|
1
2
|
import ArcaneCommunicationBridge from './ArcaneCommunicationBridge.js';
|
|
2
3
|
import CommunicationHub from './CommunicationHub.js?v=2';
|
|
3
4
|
import CommunicationPreferences from './CommunicationPreferences.js';
|
|
@@ -360,7 +361,7 @@ export default class CommunicationAppController{
|
|
|
360
361
|
hub.dispose();
|
|
361
362
|
}
|
|
362
363
|
}catch(error){
|
|
363
|
-
|
|
364
|
+
arcaneLogging.error('The communication hub could not be disposed cleanly.',error);
|
|
364
365
|
}
|
|
365
366
|
}
|
|
366
367
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { arcaneLogging } from 'arcane-os/logging';
|
|
1
2
|
import {
|
|
2
3
|
createArcaneEventSource,
|
|
3
4
|
projectArcaneDOMEvent
|
|
@@ -713,7 +714,7 @@ function createSTTActivationController({
|
|
|
713
714
|
try{
|
|
714
715
|
onChange();
|
|
715
716
|
}catch(error){
|
|
716
|
-
|
|
717
|
+
arcaneLogging.error('Unable to render STT activation state:',error);
|
|
717
718
|
}
|
|
718
719
|
}
|
|
719
720
|
}
|
|
@@ -724,7 +725,7 @@ function createSTTActivationController({
|
|
|
724
725
|
if(nextAction){
|
|
725
726
|
void request(nextAction).catch(
|
|
726
727
|
function reportSTTActivationRequestFailure(error){
|
|
727
|
-
|
|
728
|
+
arcaneLogging.error('The STT activation request could not settle.',error);
|
|
728
729
|
}
|
|
729
730
|
);
|
|
730
731
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { arcaneLogging } from 'arcane-os/logging';
|
|
1
2
|
import {createArcaneEventSource} from 'arcane-os/event-manager';
|
|
2
3
|
|
|
3
4
|
const CONVERSATION_TIMEBOX_TOOL_NAME='conversation_timebox';
|
|
@@ -168,7 +169,7 @@ function conversationTimeboxSubmissionKey(context={}){
|
|
|
168
169
|
}
|
|
169
170
|
|
|
170
171
|
function reportConversationTimeboxListenerError(error){
|
|
171
|
-
|
|
172
|
+
arcaneLogging.error('A conversation timebox listener failed.',error);
|
|
172
173
|
}
|
|
173
174
|
|
|
174
175
|
function conversationTimeboxError(message,code,reason,ErrorType=Error){
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { arcaneLogging } from 'arcane-os/logging';
|
|
1
2
|
import Is from "../../node_modules/strong-type/index.js";
|
|
2
3
|
import {openApplicationDataDirectory} from './AppDataScope.js';
|
|
3
4
|
import {
|
|
@@ -458,7 +459,7 @@ class DBOPFS {
|
|
|
458
459
|
);
|
|
459
460
|
}
|
|
460
461
|
}catch(error){
|
|
461
|
-
|
|
462
|
+
arcaneLogging.error(`Error writing file '${fileName}' to table '${tableName}':`,error)
|
|
462
463
|
throw error
|
|
463
464
|
}
|
|
464
465
|
|
|
@@ -603,7 +604,7 @@ class DBOPFS {
|
|
|
603
604
|
const fileName=entries[index][0]
|
|
604
605
|
|
|
605
606
|
if(result.status!=='fulfilled'){
|
|
606
|
-
|
|
607
|
+
arcaneLogging.error(`Failed to set file '${fileName}':`,result.reason)
|
|
607
608
|
}
|
|
608
609
|
}
|
|
609
610
|
);
|
|
@@ -742,7 +743,7 @@ class DBOPFS {
|
|
|
742
743
|
await table.removeEntry(fileName)
|
|
743
744
|
}catch(error){
|
|
744
745
|
if(error.name!=='NotFoundError'){
|
|
745
|
-
|
|
746
|
+
arcaneLogging.error(error)
|
|
746
747
|
throw error
|
|
747
748
|
}
|
|
748
749
|
}
|
|
@@ -784,7 +785,7 @@ class DBOPFS {
|
|
|
784
785
|
delete this.#tables[tableName]
|
|
785
786
|
delete this.#tableHandles[tableName]
|
|
786
787
|
}catch(error){
|
|
787
|
-
|
|
788
|
+
arcaneLogging.error(error)
|
|
788
789
|
}
|
|
789
790
|
|
|
790
791
|
return true
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import waitForComponent from './WaitForComponent.js';
|
|
2
|
+
import { arcaneLogging,readArcaneDeveloperMode } from 'arcane-os/logging';
|
|
2
3
|
import {
|
|
3
4
|
arcaneEvents,
|
|
4
5
|
createArcaneEventSource
|
|
@@ -154,18 +155,6 @@ async function sendWithWindowMail(target,...args){
|
|
|
154
155
|
return target.mail.send(...args);
|
|
155
156
|
}
|
|
156
157
|
|
|
157
|
-
function defaultDeveloperModeStatus(target){
|
|
158
|
-
try{
|
|
159
|
-
if(target?.user?.ready!==true){
|
|
160
|
-
return null;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
return target.user.developer===true;
|
|
164
|
-
}catch{
|
|
165
|
-
return false;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
158
|
function appendDeveloperDetail(document,list,label,value){
|
|
170
159
|
if(value===null||value===undefined||value===''){
|
|
171
160
|
return;
|
|
@@ -340,7 +329,7 @@ class Errors {
|
|
|
340
329
|
this.now=options.now||Date.now;
|
|
341
330
|
this.schedule=options.schedule||globalThis.setTimeout.bind(globalThis);
|
|
342
331
|
this.cancel=options.cancel||globalThis.clearTimeout.bind(globalThis);
|
|
343
|
-
this.logger=options.logger||
|
|
332
|
+
this.logger=options.logger||arcaneLogging;
|
|
344
333
|
this.storage=options.storage===undefined
|
|
345
334
|
? defaultStorage(target)
|
|
346
335
|
: options.storage;
|
|
@@ -352,7 +341,7 @@ class Errors {
|
|
|
352
341
|
|| sendWithWindowMail.bind(null,target);
|
|
353
342
|
this.isDeveloperMode=typeof options.isDeveloperMode==='function'
|
|
354
343
|
? options.isDeveloperMode
|
|
355
|
-
:
|
|
344
|
+
: readArcaneDeveloperMode.bind(null,target);
|
|
356
345
|
this.presentDeveloperIncident=typeof options.presentDeveloperIncident==='function'
|
|
357
346
|
? options.presentDeveloperIncident
|
|
358
347
|
: presentDeveloperIncidentModal.bind(null,target);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { arcaneLogging } from 'arcane-os/logging';
|
|
1
2
|
import {
|
|
2
3
|
createArcaneEventSource,
|
|
3
4
|
projectArcaneDOMEvent
|
|
@@ -299,7 +300,7 @@ class HTMLImport extends HTMLElement {
|
|
|
299
300
|
let resolvedHref='';
|
|
300
301
|
const operationId=`html-import-load-${this.#events.instanceId}-${generation}`;
|
|
301
302
|
if(!href){
|
|
302
|
-
|
|
303
|
+
arcaneLogging.log('no href provided for html-import tag',this);
|
|
303
304
|
this.#loadController=null;
|
|
304
305
|
return;
|
|
305
306
|
}
|
|
@@ -319,7 +320,7 @@ class HTMLImport extends HTMLElement {
|
|
|
319
320
|
await this.#destroyImportedHost();
|
|
320
321
|
return;
|
|
321
322
|
}
|
|
322
|
-
|
|
323
|
+
arcaneLogging.error('Error loading HTML component:',err);
|
|
323
324
|
const detail={
|
|
324
325
|
code:'HTML_IMPORT_FAILED',
|
|
325
326
|
href,
|
|
@@ -369,7 +370,7 @@ class HTMLImport extends HTMLElement {
|
|
|
369
370
|
}
|
|
370
371
|
|
|
371
372
|
#reportImportedDestroyError(error,{events,href,operationId}){
|
|
372
|
-
|
|
373
|
+
arcaneLogging.error('Error destroying imported HTML component:',error);
|
|
373
374
|
if(!events||events.disposed)return;
|
|
374
375
|
const detail={
|
|
375
376
|
code:'HTML_IMPORT_IMPORTED_COMPONENT_DESTROY_REJECTED',
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { arcaneLogging } from 'arcane-os/logging';
|
|
1
2
|
import {
|
|
2
3
|
checkLocalAIReadiness,
|
|
3
4
|
deriveLocalAIRequirements
|
|
@@ -287,7 +288,7 @@ export function createLocalAIReadinessController({
|
|
|
287
288
|
function retry(){
|
|
288
289
|
void check().catch(function ignoreDestroyedLocalAIRetry(error){
|
|
289
290
|
if(error?.name!=='AbortError'){
|
|
290
|
-
|
|
291
|
+
arcaneLogging.error('Local AI readiness retry failed.',error);
|
|
291
292
|
}
|
|
292
293
|
});
|
|
293
294
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { arcaneLogging } from 'arcane-os/logging';
|
|
1
2
|
import { marked } from './Marked.min.js';
|
|
2
3
|
import Is from '../../node_modules/strong-type/index.js';
|
|
3
4
|
|
|
@@ -45,7 +46,7 @@ class MD {
|
|
|
45
46
|
|
|
46
47
|
set raw(value=''){
|
|
47
48
|
if(!is.string(value)){
|
|
48
|
-
|
|
49
|
+
arcaneLogging.trace('MD.raw must be a string.');
|
|
49
50
|
return this.#raw;
|
|
50
51
|
}
|
|
51
52
|
this.#raw = value;
|
|
@@ -55,7 +56,7 @@ class MD {
|
|
|
55
56
|
|
|
56
57
|
append(value=''){
|
|
57
58
|
if(!is.string(value)){
|
|
58
|
-
|
|
59
|
+
arcaneLogging.trace('MD.append must be a string.');
|
|
59
60
|
return this.#raw;
|
|
60
61
|
}
|
|
61
62
|
this.#raw += value;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { arcaneLogging } from 'arcane-os/logging';
|
|
1
2
|
export const MAIL_OUTBOX_PROTOCOL='arcane-mail-outbox/1';
|
|
2
3
|
export const MAIL_OUTBOX_TABLE='mail_outbox';
|
|
3
4
|
export const MAIL_OUTBOX_IDEMPOTENCY_WINDOW_MS=24*60*60*1000;
|
|
@@ -34,7 +35,7 @@ function reportMailOutboxObserverError(error){
|
|
|
34
35
|
return;
|
|
35
36
|
}
|
|
36
37
|
}catch{}
|
|
37
|
-
try{
|
|
38
|
+
try{arcaneLogging.error?.(error);}catch{}
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
function fail(message,code='MAIL_OUTBOX_INVALID',ErrorType=Error,cause){
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { arcaneLogging } from 'arcane-os/logging';
|
|
1
2
|
import ChatEntity from '../entities/Chat.js';
|
|
2
3
|
import ConfiguredAIChatSession,{
|
|
3
4
|
normalizeStructuralToolCall
|
|
@@ -475,7 +476,7 @@ class PersistentAIChatSession{
|
|
|
475
476
|
error instanceof Error?error:new Error('The saved chat history is invalid.'),
|
|
476
477
|
'AI_CHAT_INCOHERENT_PERSISTENCE',
|
|
477
478
|
);
|
|
478
|
-
|
|
479
|
+
arcaneLogging.error('Arcane saved chat history is readable but not actionable.',error);
|
|
479
480
|
}
|
|
480
481
|
const storedSystem=storedMessages.find(message=>message.role==='system');
|
|
481
482
|
const initialMessages=storedMessages
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { arcaneLogging } from 'arcane-os/logging';
|
|
1
2
|
import {createArcaneEventSource} from 'arcane-os/event-manager';
|
|
2
3
|
import GifEncoder from './GifEncoder.js';
|
|
3
4
|
|
|
@@ -252,7 +253,7 @@ function supportedRecorderType(Recorder){
|
|
|
252
253
|
|
|
253
254
|
function reportDetachedError(error){
|
|
254
255
|
if(typeof globalThis.reportError==='function')globalThis.reportError(error);
|
|
255
|
-
else
|
|
256
|
+
else arcaneLogging.error?.(error);
|
|
256
257
|
}
|
|
257
258
|
|
|
258
259
|
function monotonicNow(){
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { arcaneLogging } from 'arcane-os/logging';
|
|
1
2
|
import {loadAndApplyTheme} from './ThemeManager.js';
|
|
2
3
|
import {createArcaneEventSource} from 'arcane-os/event-manager';
|
|
3
4
|
|
|
@@ -43,7 +44,7 @@ function installAppearanceListener(ready){
|
|
|
43
44
|
Promise.resolve(ready).then(function reloadTheme(result){
|
|
44
45
|
return result?.manager?.load?.();
|
|
45
46
|
}).catch(function reportThemeReloadFailure(error){
|
|
46
|
-
|
|
47
|
+
arcaneLogging.warn(
|
|
47
48
|
'[Arcane theme] Unable to apply the changed host appearance.',
|
|
48
49
|
error
|
|
49
50
|
);
|
|
@@ -80,7 +81,7 @@ export function bootstrapArcaneTheme(options={}){
|
|
|
80
81
|
}
|
|
81
82
|
|
|
82
83
|
const ready=loadAndApplyTheme(options).catch(error=>{
|
|
83
|
-
|
|
84
|
+
arcaneLogging.warn('[Arcane theme] Unable to load the saved appearance; using the system theme.',error);
|
|
84
85
|
return {manager:null,state:null,error};
|
|
85
86
|
});
|
|
86
87
|
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { arcaneLogging } from 'arcane-os/logging';
|
|
1
2
|
function parseArguments(value,name=''){
|
|
2
3
|
let parsed=value;
|
|
3
4
|
if(typeof parsed==='string'){
|
|
4
5
|
try{
|
|
5
6
|
parsed=JSON.parse(parsed);
|
|
6
7
|
}catch(error){
|
|
7
|
-
|
|
8
|
+
arcaneLogging.warn(error);
|
|
8
9
|
throw new Error(`Tool ${name} returned invalid JSON arguments.`);
|
|
9
10
|
}
|
|
10
11
|
}
|
package/src/import-map.mjs
CHANGED
|
@@ -844,8 +844,7 @@ function applyReferenceEdits(source,edits){
|
|
|
844
844
|
return result;
|
|
845
845
|
}
|
|
846
846
|
|
|
847
|
-
function stringReferenceEdit(source,token,version){
|
|
848
|
-
const urlEdits=assetUrlVersionEdits(token.value,version);
|
|
847
|
+
function stringReferenceEdit(source,token,version,urlEdits=assetUrlVersionEdits(token.value,version)){
|
|
849
848
|
if(urlEdits.length===0)return null;
|
|
850
849
|
const quote=source[token.start];
|
|
851
850
|
const positions=[];
|
|
@@ -1091,31 +1090,67 @@ function importMapReferenceEdits(source,version,onReference){
|
|
|
1091
1090
|
const valueIndex=cursor+2;
|
|
1092
1091
|
const value=tokens[valueIndex];
|
|
1093
1092
|
if(!value)return [];
|
|
1094
|
-
properties.push({key:key.value,valueIndex,value});
|
|
1095
1093
|
let end=valueIndex;
|
|
1096
1094
|
if(value.type==='punctuator'&&(value.value==='{'||value.value==='[')){
|
|
1097
1095
|
end=matchingToken(tokens,valueIndex,value.value,value.value==='{'?'}':']');
|
|
1098
1096
|
if(end<0)return [];
|
|
1099
1097
|
}
|
|
1098
|
+
properties.push({key:key.value,keyToken:key,valueIndex,value,end:tokens[end].end});
|
|
1100
1099
|
cursor=end+1;
|
|
1101
1100
|
if(tokens[cursor]?.value===',')cursor+=1;
|
|
1102
1101
|
else if(tokens[cursor]?.value!=='}')return [];
|
|
1103
1102
|
}
|
|
1104
1103
|
return properties;
|
|
1105
1104
|
}
|
|
1105
|
+
function addAlias(property,keys,value,aliases,alias=versionImportMapSpecifier(property.key,version)){
|
|
1106
|
+
if(alias===property.key||keys.has(alias))return;
|
|
1107
|
+
const keyEdit=stringReferenceEdit(source,property.keyToken,version,importMapUrlVersionEdits(property.key,version));
|
|
1108
|
+
if(!keyEdit)return;
|
|
1109
|
+
keys.add(alias);
|
|
1110
|
+
aliases.push(`${keyEdit.value}: ${value}`);
|
|
1111
|
+
}
|
|
1112
|
+
function prependAliases(start,aliases,selectedEdits){
|
|
1113
|
+
if(aliases.length===0)return;
|
|
1114
|
+
// Authored keys retain priority even when different spellings normalize to one URL.
|
|
1115
|
+
const offset=tokens[start].end;
|
|
1116
|
+
selectedEdits.push({start:offset,end:offset,value:`${aliases.join(', ')}, `});
|
|
1117
|
+
}
|
|
1106
1118
|
function addImports(start){
|
|
1107
|
-
|
|
1119
|
+
const selectedEdits=[];
|
|
1120
|
+
const aliases=[];
|
|
1121
|
+
const properties=objectProperties(start);
|
|
1122
|
+
const keys=new Set(properties.map(function importKey(property){return property.key;}));
|
|
1123
|
+
for(const property of properties){
|
|
1124
|
+
if(property.value.value==='null'&&property.value.type==='identifier'){
|
|
1125
|
+
addAlias(property,keys,'null',aliases);
|
|
1126
|
+
continue;
|
|
1127
|
+
}
|
|
1108
1128
|
if(property.value.type!=='string')continue;
|
|
1109
|
-
if(property.key.endsWith('/')
|
|
1129
|
+
if(property.key.endsWith('/'))continue;
|
|
1110
1130
|
reportAssetReference(onReference,property.value.value,'import');
|
|
1111
|
-
const edit=
|
|
1112
|
-
|
|
1131
|
+
const edit=property.value.value.split(/[?#]/u)[0].endsWith('/')
|
|
1132
|
+
?null:stringReferenceEdit(source,property.value,version);
|
|
1133
|
+
if(edit)selectedEdits.push(edit);
|
|
1134
|
+
addAlias(property,keys,edit?.value??source.slice(property.value.start,property.value.end),aliases);
|
|
1113
1135
|
}
|
|
1136
|
+
prependAliases(start,aliases,selectedEdits);
|
|
1137
|
+
return selectedEdits;
|
|
1114
1138
|
}
|
|
1115
1139
|
for(const property of objectProperties(0)){
|
|
1116
|
-
if(property.key==='imports')addImports(property.valueIndex);
|
|
1140
|
+
if(property.key==='imports')edits.push(...addImports(property.valueIndex));
|
|
1117
1141
|
if(property.key==='scopes'){
|
|
1118
|
-
|
|
1142
|
+
const scopes=objectProperties(property.valueIndex);
|
|
1143
|
+
const aliases=[];
|
|
1144
|
+
const keys=new Set(scopes.map(function scopeKey(scope){return scope.key;}));
|
|
1145
|
+
for(const scope of scopes){
|
|
1146
|
+
const scopeEdits=addImports(scope.valueIndex);
|
|
1147
|
+
edits.push(...scopeEdits);
|
|
1148
|
+
const value=applyReferenceEdits(source.slice(scope.value.start,scope.end),scopeEdits.map(function scopeRelativeEdit(edit){
|
|
1149
|
+
return {...edit,start:edit.start-scope.value.start,end:edit.end-scope.value.start};
|
|
1150
|
+
}));
|
|
1151
|
+
if(!scope.key.endsWith('/'))addAlias(scope,keys,value,aliases,versionImportMapUrl(scope.key,version));
|
|
1152
|
+
}
|
|
1153
|
+
prependAliases(property.valueIndex,aliases,edits);
|
|
1119
1154
|
}
|
|
1120
1155
|
}
|
|
1121
1156
|
return edits;
|
|
@@ -1138,6 +1173,24 @@ function registerSpecifier(registry,specifier,target){
|
|
|
1138
1173
|
registry.set(specifier,{specifier,target});
|
|
1139
1174
|
}
|
|
1140
1175
|
|
|
1176
|
+
function versionImportMapSpecifier(specifier,version){
|
|
1177
|
+
if(specifier.endsWith('/')||!/^(?:\.{1,2}\/|\/|[A-Za-z][A-Za-z0-9+.-]*:\/\/)/u.test(specifier))return specifier;
|
|
1178
|
+
return versionImportMapUrl(specifier,version);
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
function versionImportMapUrl(value,version){
|
|
1182
|
+
return applyReferenceEdits(value,importMapUrlVersionEdits(value,version));
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
function importMapUrlVersionEdits(value,version){
|
|
1186
|
+
// Absolute map keys can match a relative import resolved against the document.
|
|
1187
|
+
const authority=/^(?:[A-Za-z][A-Za-z0-9+.-]*:)?\/\/[^/?#]*/u.exec(value)?.[0];
|
|
1188
|
+
const offset=authority?.length??0;
|
|
1189
|
+
return assetUrlVersionEdits(value.slice(offset),version).map(function absoluteKeyEdit(edit){
|
|
1190
|
+
return {...edit,start:edit.start+offset,end:edit.end+offset};
|
|
1191
|
+
});
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1141
1194
|
function validateInventory(files){
|
|
1142
1195
|
if(!Array.isArray(files))throw new TypeError('buildImportMap files must be an array.');
|
|
1143
1196
|
const exact=new Set();
|
|
@@ -1215,7 +1268,9 @@ export async function buildImportMap({files,signal,version=SDK_VERSION}={}){
|
|
|
1215
1268
|
}
|
|
1216
1269
|
const imports={};
|
|
1217
1270
|
for(const entry of [...namedRegistry.values()].sort((left,right)=>compareText(left.specifier,right.specifier))){
|
|
1218
|
-
|
|
1271
|
+
const target=versionAssetUrl(entry.target,version);
|
|
1272
|
+
imports[entry.specifier]=target;
|
|
1273
|
+
imports[versionImportMapSpecifier(entry.specifier,version)]=target;
|
|
1219
1274
|
}
|
|
1220
1275
|
return {
|
|
1221
1276
|
imports,
|