browser-module-runtime 0.0.7 → 0.0.8

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 CHANGED
@@ -5,7 +5,7 @@ A framework-neutral browser module runtime with a native ESM linker, independent
5
5
  ## Install
6
6
 
7
7
  ```sh
8
- npm install browser-module-runtime@0.0.7
8
+ npm install browser-module-runtime@0.0.8
9
9
  ```
10
10
 
11
11
  ## Define, import and update modules
@@ -59,7 +59,7 @@ await handle.dispose();
59
59
  ### Public exports
60
60
 
61
61
  - `browser-module-runtime`: runtime, build pipeline, cache and resolver utilities
62
- - `browser-module-runtime/html`: `registerHTML` and generic `<runtime-render>` integration
62
+ - `browser-module-runtime/html`: `createHTMLRuntime` and generic `<runtime-render>` integration
63
63
  - `browser-module-runtime/packages`: package policy utilities
64
64
  - `browser-module-runtime/cache`: compile-cache implementations
65
65
 
@@ -68,8 +68,8 @@ await handle.dispose();
68
68
  ### Scoped HTML (development branch)
69
69
 
70
70
  ```js
71
- import {registerHTML} from 'browser-module-runtime/html';
72
- registerHTML(runtime,{scope:'app',root:document}); // No initial scan or observer
71
+ import {createHTMLRuntime} from 'browser-module-runtime/html';
72
+ createHTMLRuntime(runtime,{scope:'app',root:document}); // No initial scan or observer
73
73
  ```
74
74
 
75
75
  ```html
package/html.d.ts CHANGED
@@ -1,8 +1,6 @@
1
1
  import type {Runtime} from './index.js';
2
2
  import type {WebComponentOptions} from './web-components.js';
3
3
  export interface HTMLController {
4
- /** Scope name; `name` is a backwards compatible alias. */
5
- readonly name:string;
6
4
  readonly scope:string;
7
5
  readonly root:Document|Element;
8
6
  readonly appendTarget:Document|Element;
@@ -16,18 +14,12 @@ export interface HTMLController {
16
14
  appendAndRegister(script:HTMLScriptElement,target?:Document|Element):Promise<HTMLScriptElement>;
17
15
  /** Preferred explicit, repeatable processing of existing source declarations. */
18
16
  process():Promise<void>;
19
- /** @deprecated Use process(). */
20
- registerExisting():Promise<void>;
21
- /** @deprecated Use process(). */
22
- scan():Promise<void>;
23
- setRoot(root:Document|Element,options?:{processExisting?:boolean;registerExisting?:boolean}):Promise<Document|Element>;
24
- moveTo(root:Document|Element,options?:{processExisting?:boolean;registerExisting?:boolean}):Promise<Document|Element>;
17
+ setRoot(root:Document|Element,options?:{processExisting?:boolean}):Promise<Document|Element>;
18
+ moveTo(root:Document|Element,options?:{processExisting?:boolean}):Promise<Document|Element>;
25
19
  disconnect():Promise<void>;
26
20
  }
27
- export interface RegisterHTMLOptions {
21
+ export interface HTMLRuntimeOptions {
28
22
  scope?:string;
29
- /** Backward compatible alias for scope. */
30
- name?:string;
31
23
  root?:Document|Element;
32
24
  /** Whether an element without an explicit scope can be owned by this controller. */
33
25
  acceptUnscoped?:boolean;
@@ -35,9 +27,9 @@ export interface RegisterHTMLOptions {
35
27
  observe?:boolean;
36
28
  }
37
29
  /** Does not scan automatically. <runtime-render> itself is an autonomous custom element. */
38
- export declare function registerHTML(runtime:Runtime,options?:RegisterHTMLOptions):HTMLController;
30
+ export declare function createHTMLRuntime(runtime:Runtime,options?:HTMLRuntimeOptions):HTMLController;
39
31
 
40
32
  /** High-level one-shot HTML discovery. Registers the controller and processes existing inert scripts.
41
33
  * Returns the controller for subsequent root, observer and lifecycle operations.
42
34
  */
43
- export declare function processHTML(runtime:Runtime,options?:RegisterHTMLOptions):Promise<HTMLController>;
35
+ export declare function processHTML(runtime:Runtime,options?:HTMLRuntimeOptions):Promise<HTMLController>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browser-module-runtime",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
package/src/html/index.js CHANGED
@@ -118,14 +118,14 @@ function defineAutonomousElements(doc){
118
118
  }
119
119
  let sequence=0;
120
120
  /** Register a scoped HTML controller. Never scans automatically. */
121
- export function registerHTML(runtime,options={}){
122
- const {name,scope,root=globalThis.document,observe=false,acceptUnscoped=true}=options;
123
- if(!root)throw new TypeError('registerHTML requires a DOM root');
121
+ export function createHTMLRuntime(runtime,options={}){
122
+ const {scope="default",root=globalThis.document,observe=false,acceptUnscoped=true}=options;
123
+ if(!root)throw new TypeError('createHTMLRuntime requires a DOM root');
124
124
  const doc=rootDocument(root);
125
- if(!doc)throw new TypeError('registerHTML root must belong to a document');
125
+ if(!doc)throw new TypeError('createHTMLRuntime root must belong to a document');
126
126
  const registry=getScopeRegistry(doc);
127
127
  defineAutonomousElements(doc);
128
- const resolvedScope=scope||name||'default';
128
+ const resolvedScope=scope;
129
129
  let alive=true,observer=null,currentRoot=root,appendTarget=root,pending=Promise.resolve();
130
130
  const controller={id:++sequence,scope:resolvedScope,get root(){return currentRoot;},acceptUnscoped,runtime,get alive(){return alive;},defineElement};
131
131
  function defineElement(tag,config){return registerWebComponent(runtime,{...config,tag,document:doc});}
@@ -174,13 +174,11 @@ export function registerHTML(runtime,options={}){
174
174
  await registerScript(script);
175
175
  return script;
176
176
  }
177
- async function setRoot(nextRoot,{processExisting,registerExisting=false}={}){
178
- // processExisting is preferred; registerExisting remains a legacy alias.
179
- const shouldProcess=processExisting??registerExisting;
177
+ async function setRoot(nextRoot,{processExisting=false}={}){
180
178
  if(!alive)throw new Error('HTML controller is disconnected');
181
179
  if(rootDocument(nextRoot)!==doc)throw new Error('HTML root must remain in the same document');
182
180
  if(observer)observer.disconnect();currentRoot=nextRoot;registry.notify();enableObservation();
183
- if(shouldProcess)await scheduleScan();
181
+ if(processExisting)await scheduleScan();
184
182
  return nextRoot;
185
183
  }
186
184
  async function moveTo(nextRoot,opts){const moved=await setRoot(nextRoot,opts);appendTarget=nextRoot;return moved;}
@@ -191,15 +189,15 @@ export function registerHTML(runtime,options={}){
191
189
  }
192
190
  registry.add(controller);
193
191
  enableObservation();
194
- return {name:resolvedScope,scope:resolvedScope,runtime,defineElement,registerScript,appendScript,appendAndRegister,process:scheduleScan,registerExisting:scheduleScan,scan:scheduleScan,setRoot,moveTo,disconnect,get root(){return currentRoot;},get appendTarget(){return appendTarget;}};
192
+ return {scope:resolvedScope,runtime,defineElement,registerScript,appendScript,appendAndRegister,process:scheduleScan,setRoot,moveTo,disconnect,get root(){return currentRoot;},get appendTarget(){return appendTarget;}};
195
193
  }
196
194
 
197
195
  /** Create a scoped HTML controller and process existing source declarations once.
198
- * Unlike registerHTML(), this convenience function explicitly performs discovery.
196
+ * Unlike createHTMLRuntime(), this convenience function explicitly performs discovery.
199
197
  * Returns the controller so callers can use appendAndRegister(), setRoot() or disconnect().
200
198
  */
201
199
  export async function processHTML(runtime,options={}){
202
- const controller=registerHTML(runtime,options);
200
+ const controller=createHTMLRuntime(runtime,options);
203
201
  try{
204
202
  await controller.process();
205
203
  return controller;