arcane-os 0.52.1 → 0.54.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 +42 -0
- package/NOTICE +4 -1
- package/README.md +1 -1
- package/bin/arcane-test.mjs +2 -1
- package/browser-runtime/ai/browser-decisions.mjs +405 -0
- package/browser-runtime/ai/decision-runtime.mjs +281 -0
- package/browser-runtime/ai/decision-worker.mjs +67 -0
- package/browser-runtime/dependencies/event-pubsub/dependencies/strong-type/index.js +1151 -0
- package/browser-runtime/dependencies/event-pubsub/dependencies/strong-type/licence +21 -0
- package/browser-runtime/dependencies/event-pubsub/dependencies/strong-type/package.json +61 -0
- package/browser-runtime/dependencies/event-pubsub/index.js +2 -2
- package/browser-runtime/dependencies/event-pubsub/package.json +11 -4
- package/browser-runtime/dependencies/ws-share/WS.js +128 -0
- package/browser-runtime/dependencies/ws-share/licence.md +27 -0
- package/browser-runtime/dependencies/ws-share/package.json +64 -0
- package/browser-runtime/websocket-client.mjs +1 -0
- package/docs/event-manager.md +7 -4
- package/docs/reference/ai/browser-decisions.md +184 -0
- package/docs/reference/inventory/package-api.json +44 -2
- package/docs/reference/inventory/runtime-modules.json +17 -4
- package/docs/reference/protocols.md +76 -1
- package/docs/reference/runtime-modules.md +45 -2
- package/docs/reference/sdk-api.md +280 -6
- package/docs/reference/websocket-client.md +132 -0
- package/node_modules/event-pubsub/CHANGELOG.md +12 -1
- package/node_modules/event-pubsub/MIGRATION.md +8 -5
- package/node_modules/event-pubsub/README.md +75 -19
- package/node_modules/event-pubsub/SECURITY.md +3 -3
- package/node_modules/event-pubsub/index.js +2 -2
- package/node_modules/event-pubsub/package.json +11 -4
- package/package.json +9 -5
- package/runtime/arcane/modules/HTMLImport.js +81 -26
- package/runtime/arcane/modules/HTMLImportScript.js +3 -0
- package/src/import-map.mjs +416 -59
- package/src/index.mjs +2 -0
- package/src/packager/core.mjs +24 -6
- package/src/packager/native-modules.mjs +458 -0
- package/src/testing-loader.mjs +41 -20
- package/src/websocket.mjs +479 -0
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
createArcaneEventSource,
|
|
7
7
|
projectArcaneDOMEvent
|
|
8
8
|
} from 'arcane-os/event-manager';
|
|
9
|
+
import { createHTMLImportScript } from './HTMLImportScript.js';
|
|
9
10
|
|
|
10
11
|
const htmlImportHostRegistryKey=Symbol.for('arcane.html-import.hosts');
|
|
11
12
|
const htmlImportHostRegistry=globalThis[htmlImportHostRegistryKey] instanceof Map
|
|
@@ -18,6 +19,47 @@ let htmlImportScriptId=0;
|
|
|
18
19
|
|
|
19
20
|
const htmlImportModuleURL=new URL(import.meta.url);
|
|
20
21
|
|
|
22
|
+
function appendPackagedScript(executable, signal) {
|
|
23
|
+
return new Promise(function waitForPackagedScript(resolve, reject) {
|
|
24
|
+
function removeListeners() {
|
|
25
|
+
executable.removeEventListener('load', loaded);
|
|
26
|
+
executable.removeEventListener('error', failed);
|
|
27
|
+
signal.removeEventListener('abort', cancelled);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function loaded() {
|
|
31
|
+
removeListeners();
|
|
32
|
+
resolve(true);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function failed() {
|
|
36
|
+
removeListeners();
|
|
37
|
+
reject(new Error(`HTML import packaged script failed to load: ${executable.src}`));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function cancelled() {
|
|
41
|
+
removeListeners();
|
|
42
|
+
executable.remove();
|
|
43
|
+
resolve(false);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
executable.addEventListener('load', loaded, {once: true});
|
|
47
|
+
executable.addEventListener('error', failed, {once: true});
|
|
48
|
+
signal.addEventListener('abort', cancelled, {once: true});
|
|
49
|
+
if (signal.aborted) {
|
|
50
|
+
cancelled();
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
try {
|
|
55
|
+
document.head.appendChild(executable);
|
|
56
|
+
} catch (error) {
|
|
57
|
+
removeListeners();
|
|
58
|
+
reject(error);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
21
63
|
function cleanComponentResource(value,baseHref){
|
|
22
64
|
if(!is.string(value)||!value||value.startsWith('#')){
|
|
23
65
|
return value;
|
|
@@ -474,42 +516,55 @@ class HTMLImport extends HTMLElement {
|
|
|
474
516
|
try{
|
|
475
517
|
for(const script of scripts){
|
|
476
518
|
if(!this.#isCurrentConnection(generation,controller))return;
|
|
477
|
-
let source=script.textContent||'';
|
|
478
|
-
let sourceBaseHref=contentBaseHref;
|
|
479
519
|
const scriptSource=script.getAttribute('src');
|
|
480
|
-
if(scriptSource!==null){
|
|
481
|
-
const requestedScriptHref=cleanComponentResource(
|
|
482
|
-
new URL(scriptSource,contentBaseHref).href,
|
|
483
|
-
contentBaseHref
|
|
484
|
-
);
|
|
485
|
-
const response=await fetch(requestedScriptHref,{
|
|
486
|
-
cache:'default',
|
|
487
|
-
method:'GET',
|
|
488
|
-
signal:controller.signal
|
|
489
|
-
});
|
|
490
|
-
if(!response.ok){
|
|
491
|
-
throw new Error(`HTML import script request failed with status ${response.status}.`);
|
|
492
|
-
}
|
|
493
|
-
source=await response.text();
|
|
494
|
-
sourceBaseHref=response.url||requestedScriptHref;
|
|
495
|
-
if(!this.#isCurrentConnection(generation,controller))return;
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
const executableSource=resolveRelativeDynamicImports(
|
|
499
|
-
source,
|
|
500
|
-
sourceBaseHref
|
|
501
|
-
);
|
|
502
520
|
const executable=document.createElement('script');
|
|
503
521
|
const hostToken=`html-import-${Date.now()}-${htmlImportScriptId++}`;
|
|
522
|
+
const packaged=script.getAttribute('data-arcane-packaged-script')!==null;
|
|
523
|
+
const requestedScriptHref=scriptSource===null?null:cleanComponentResource(
|
|
524
|
+
new URL(scriptSource,contentBaseHref).href,
|
|
525
|
+
contentBaseHref
|
|
526
|
+
);
|
|
527
|
+
|
|
528
|
+
if(packaged){
|
|
529
|
+
if(requestedScriptHref===null){
|
|
530
|
+
throw new Error('The HTML import packaged script has no source URL.');
|
|
531
|
+
}
|
|
532
|
+
executable.src=requestedScriptHref;
|
|
533
|
+
}else{
|
|
534
|
+
let source=script.textContent||'';
|
|
535
|
+
let sourceBaseHref=contentBaseHref;
|
|
536
|
+
if(requestedScriptHref!==null){
|
|
537
|
+
const response=await fetch(requestedScriptHref,{
|
|
538
|
+
cache:'default',
|
|
539
|
+
method:'GET',
|
|
540
|
+
signal:controller.signal
|
|
541
|
+
});
|
|
542
|
+
if(!response.ok){
|
|
543
|
+
throw new Error(`HTML import script request failed with status ${response.status}.`);
|
|
544
|
+
}
|
|
545
|
+
source=await response.text();
|
|
546
|
+
sourceBaseHref=response.url||requestedScriptHref;
|
|
547
|
+
if(!this.#isCurrentConnection(generation,controller))return;
|
|
548
|
+
}
|
|
549
|
+
executable.textContent=createHTMLImportScript(resolveRelativeDynamicImports(
|
|
550
|
+
source,
|
|
551
|
+
sourceBaseHref
|
|
552
|
+
));
|
|
553
|
+
}
|
|
504
554
|
|
|
505
555
|
executable.dataset.arcaneHostToken=hostToken;
|
|
506
|
-
executable.textContent=`(()=>{const registry=globalThis[Symbol.for('arcane.html-import.hosts')];const token=document.currentScript&&document.currentScript.dataset.arcaneHostToken;const binding=registry instanceof Map&&token?registry.get(token):null;if(!binding?.host)throw new Error('HTML import host binding is unavailable.');binding.promise=(async function(){${executableSource}}).call(binding.host);})()`;
|
|
507
556
|
script.parentNode.removeChild(script);
|
|
508
557
|
|
|
509
558
|
const binding={host:this,promise:null};
|
|
510
559
|
htmlImportHostRegistry.set(hostToken,binding);
|
|
511
560
|
try{
|
|
512
|
-
|
|
561
|
+
if(packaged){
|
|
562
|
+
const loaded=await appendPackagedScript(executable,controller.signal);
|
|
563
|
+
// A started initializer still owns completion and any late teardown.
|
|
564
|
+
if(!loaded&&!binding.promise)return;
|
|
565
|
+
}else{
|
|
566
|
+
document.head.appendChild(executable);
|
|
567
|
+
}
|
|
513
568
|
if(!binding.promise||!is.function(binding.promise.then)){
|
|
514
569
|
throw new Error('The HTML import script did not start.');
|
|
515
570
|
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export function createHTMLImportScript(source) {
|
|
2
|
+
return `(()=>{const registry=globalThis[Symbol.for('arcane.html-import.hosts')];const token=document.currentScript&&document.currentScript.dataset.arcaneHostToken;const binding=registry instanceof Map&&token?registry.get(token):null;if(!binding?.host)throw new Error('HTML import host binding is unavailable.');binding.promise=(async function(){${source}\n}).call(binding.host);})()`;
|
|
3
|
+
}
|