solid-tag-runtime 0.0.8 → 0.0.11

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/html.d.ts CHANGED
@@ -1,17 +1,31 @@
1
1
  import { SolidTagRuntimeError } from "./index.js";
2
2
  import type { ModuleFormat, ModuleNamespaceLike, SolidTagRuntime } from "./index.js";
3
3
 
4
- export interface HTMLModuleScriptElement {
4
+ export interface HTMLAttributeElementLike {
5
5
  textContent?: string | null;
6
6
  baseURI?: string;
7
7
  ownerDocument?: HTMLDocumentLike | null;
8
- parentNode?: { removeChild?(element: any): unknown } | null;
8
+ parentNode?: {
9
+ removeChild?(element: any): unknown;
10
+ insertBefore?(element: any, reference: any): unknown;
11
+ } | null;
9
12
  remove?(): void;
13
+ replaceWith?(...nodes: any[]): void;
10
14
  getAttribute(name: string): string | null;
11
15
  hasAttribute?(name: string): boolean;
12
16
  setAttribute?(name: string, value: string): void;
13
17
  }
14
18
 
19
+ export interface HTMLModuleScriptElement extends HTMLAttributeElementLike {}
20
+
21
+ export interface SolidRenderElement extends HTMLAttributeElementLike, HTMLAppendTarget {
22
+ props: Record<string, unknown>;
23
+ childNodes?: ArrayLike<any> | Iterable<any>;
24
+ attributes?: ArrayLike<{ name: string; value: string }> | Iterable<{ name: string; value: string }>;
25
+ replaceChildren?(...nodes: any[]): void;
26
+ dispatchEvent?(event: unknown): boolean;
27
+ }
28
+
15
29
  export interface HTMLAppendTarget {
16
30
  append?(...nodes: any[]): void;
17
31
  appendChild?(element: any): unknown;
@@ -21,6 +35,8 @@ export interface HTMLDocumentLike extends HTMLModuleRoot, HTMLAppendTarget {
21
35
  body?: HTMLAppendTarget;
22
36
  documentElement?: HTMLAppendTarget;
23
37
  createElement?(tagName: string): any;
38
+ createComment?(data: string): any;
39
+ createDocumentFragment?(): any;
24
40
  }
25
41
 
26
42
  export interface HTMLModuleRoot {
@@ -28,7 +44,9 @@ export interface HTMLModuleRoot {
28
44
  ownerDocument?: HTMLDocumentLike | null;
29
45
  body?: HTMLAppendTarget;
30
46
  documentElement?: HTMLAppendTarget;
31
- querySelectorAll(selector: string): Iterable<HTMLModuleScriptElement> | ArrayLike<HTMLModuleScriptElement>;
47
+ querySelectorAll(selector: string): Iterable<any> | ArrayLike<any>;
48
+ querySelector?(selector: string): any;
49
+ contains?(node: any): boolean;
32
50
  }
33
51
 
34
52
  export interface HTMLFetchResponse {
@@ -44,8 +62,9 @@ export interface HTMLMutationObserverLike {
44
62
  observe(
45
63
  target: unknown,
46
64
  options: {
47
- childList: boolean;
48
- subtree: boolean;
65
+ childList?: boolean;
66
+ subtree?: boolean;
67
+ attributes?: boolean;
49
68
  },
50
69
  ): void;
51
70
  disconnect(): void;
@@ -53,12 +72,44 @@ export interface HTMLMutationObserverLike {
53
72
 
54
73
  export interface HTMLMutationObserverConstructor {
55
74
  new (
56
- callback: (...args: unknown[]) => void,
75
+ callback: (...args: any[]) => void,
57
76
  ): HTMLMutationObserverLike;
58
77
  }
59
78
 
79
+ export interface HTMLMountRecord {
80
+ kind?: "container" | "range" | string;
81
+ target?: unknown;
82
+ updateProps?(props: Record<string, unknown>): void;
83
+ dispose?(): void | Promise<void>;
84
+ }
85
+
86
+ export interface HTMLRenderAdapter {
87
+ mountContainer(options: {
88
+ runtime: SolidTagRuntime;
89
+ target: any;
90
+ Component: Function;
91
+ props: Record<string, unknown>;
92
+ element?: HTMLAttributeElementLike | SolidRenderElement;
93
+ moduleId?: string;
94
+ }): HTMLMountRecord | Promise<HTMLMountRecord>;
95
+
96
+ mountRange(options: {
97
+ runtime: SolidTagRuntime;
98
+ parent: any;
99
+ before: any;
100
+ startMarker: any;
101
+ endMarker: any;
102
+ Component: Function;
103
+ props: Record<string, unknown>;
104
+ element?: HTMLModuleScriptElement;
105
+ moduleId?: string;
106
+ }): HTMLMountRecord | Promise<HTMLMountRecord>;
107
+ }
108
+
60
109
  export interface DefineScriptOptions {
61
110
  root?: HTMLModuleRoot;
111
+ /** Optional selector-resolution root for declarative render="...". */
112
+ renderRoot?: HTMLModuleRoot;
62
113
  baseUrl?: string;
63
114
  format?: ModuleFormat | "javascript";
64
115
  fetch?: HTMLFetch;
@@ -72,15 +123,28 @@ export interface HTMLModuleDefinition {
72
123
  id: string;
73
124
  format: ModuleFormat;
74
125
  entry: boolean;
126
+ /** undefined = no render, true = in-place, string = selector target. */
127
+ render?: true | string;
128
+ /** Named component export. Missing means default export. */
129
+ component?: string;
75
130
  sourceUrl?: string;
76
131
  inline: boolean;
77
132
  element: HTMLModuleScriptElement;
78
133
  }
79
134
 
135
+ export interface HTMLRenderedModule {
136
+ id: string;
137
+ namespace: ModuleNamespaceLike;
138
+ component: string;
139
+ mode: "selector" | "in-place";
140
+ target?: unknown;
141
+ element: HTMLModuleScriptElement;
142
+ }
143
+
80
144
  export interface RemoveHTMLElementOptions {
81
145
  /** Remove the runtime module as well as releasing HTML ownership. Default: true. */
82
146
  removeModule?: boolean;
83
- /** Remove the script element from the DOM. Default: true. */
147
+ /** Remove the script declaration/range from the DOM. Default: true. */
84
148
  removeFromDOM?: boolean;
85
149
  /** Invalidate runtime dependents when removing the module. Default: true. */
86
150
  invalidateDependents?: boolean;
@@ -96,6 +160,8 @@ export interface RemoveHTMLElementResult {
96
160
  export interface RegisterHTMLOptions extends DefineScriptOptions {
97
161
  selector?: string;
98
162
  executeEntries?: boolean;
163
+ /** Execute declarative render actions. Default: true. */
164
+ executeRenders?: boolean;
99
165
  }
100
166
 
101
167
  export interface RegisterHTMLResult {
@@ -105,6 +171,8 @@ export interface RegisterHTMLResult {
105
171
  id: string;
106
172
  namespace: ModuleNamespaceLike;
107
173
  }>;
174
+ renders: string[];
175
+ rendered: HTMLRenderedModule[];
108
176
  }
109
177
 
110
178
  export type HTMLRegistrationOrigin =
@@ -119,11 +187,15 @@ export type HTMLRegistrationOrigin =
119
187
  | "add-module"
120
188
  | "update-element"
121
189
  | "remove-element"
190
+ | "solid-render"
122
191
  | string;
123
192
 
193
+ export type HTMLRenderSource = "script-render" | "solid-render";
194
+ export type HTMLRenderMode = "selector" | "in-place" | "container";
195
+
124
196
  export type HTMLRuntimeEvent =
125
197
  | { htmlRuntimeId: string; scope?: string; timestamp: number; type: "element-discovered"; element: HTMLModuleScriptElement; moduleId?: string; origin: HTMLRegistrationOrigin; accepted: boolean }
126
- | { htmlRuntimeId: string; scope?: string; timestamp: number; type: "element-claimed"; element: HTMLModuleScriptElement; moduleId: string; format: ModuleFormat; entry: boolean; sourceUrl?: string; origin: HTMLRegistrationOrigin }
198
+ | { htmlRuntimeId: string; scope?: string; timestamp: number; type: "element-claimed"; element: HTMLModuleScriptElement; moduleId: string; format: ModuleFormat; entry: boolean; render?: true | string; component?: string; sourceUrl?: string; origin: HTMLRegistrationOrigin }
127
199
  | { htmlRuntimeId: string; scope?: string; timestamp: number; type: "element-loading"; element: HTMLModuleScriptElement; moduleId: string; sourceUrl: string; origin: HTMLRegistrationOrigin }
128
200
  | { htmlRuntimeId: string; scope?: string; timestamp: number; type: "element-loaded"; element: HTMLModuleScriptElement; moduleId: string; sourceUrl: string; origin: HTMLRegistrationOrigin; bytes: number; durationMs: number }
129
201
  | { htmlRuntimeId: string; scope?: string; timestamp: number; type: "element-registered"; element: HTMLModuleScriptElement; moduleId: string; definition: HTMLModuleDefinition; origin: HTMLRegistrationOrigin }
@@ -140,7 +212,12 @@ export type HTMLRuntimeEvent =
140
212
  | { htmlRuntimeId: string; scope?: string; timestamp: number; type: "append-target-changed"; previousTarget?: HTMLAppendTarget; target: HTMLAppendTarget }
141
213
  | { htmlRuntimeId: string; scope?: string; timestamp: number; type: "entry-executing"; element: HTMLModuleScriptElement; moduleId: string; origin: HTMLRegistrationOrigin }
142
214
  | { htmlRuntimeId: string; scope?: string; timestamp: number; type: "entry-executed"; element: HTMLModuleScriptElement; moduleId: string; namespace: ModuleNamespaceLike; origin: HTMLRegistrationOrigin }
143
- | { htmlRuntimeId: string; scope?: string; timestamp: number; type: "html-error"; operation: "discover" | "claim" | "fetch" | "register" | "update" | "remove" | "entry" | "root-change" | "observer" | string; error: unknown; element?: HTMLModuleScriptElement; moduleId?: string; origin?: HTMLRegistrationOrigin };
215
+ | { htmlRuntimeId: string; scope?: string; timestamp: number; type: "render-mounting"; element: HTMLModuleScriptElement | SolidRenderElement; moduleId?: string; component: string; mode: HTMLRenderMode; origin: HTMLRegistrationOrigin; source: HTMLRenderSource }
216
+ | { htmlRuntimeId: string; scope?: string; timestamp: number; type: "render-mounted"; element: HTMLModuleScriptElement | SolidRenderElement; moduleId?: string; component: string; mode: HTMLRenderMode; target?: unknown; origin: HTMLRegistrationOrigin; source: HTMLRenderSource }
217
+ | { htmlRuntimeId: string; scope?: string; timestamp: number; type: "render-disposing"; element: HTMLModuleScriptElement | SolidRenderElement; moduleId?: string; component: string; mode: HTMLRenderMode; reason: string; origin: HTMLRegistrationOrigin; source: HTMLRenderSource }
218
+ | { htmlRuntimeId: string; scope?: string; timestamp: number; type: "render-disposed"; element: HTMLModuleScriptElement | SolidRenderElement; moduleId?: string; component: string; mode: HTMLRenderMode; reason: string; origin: HTMLRegistrationOrigin; source: HTMLRenderSource }
219
+ | { htmlRuntimeId: string; scope?: string; timestamp: number; type: "html-warning"; code: "unresolved-runtime-scope"; operation: "render"; message: string; element: HTMLModuleScriptElement; moduleId?: string; requestedScope: string; registeredScopes: string[]; matchingScopeRegistered: boolean; origin: HTMLRegistrationOrigin }
220
+ | { htmlRuntimeId: string; scope?: string; timestamp: number; type: "html-error"; operation: "discover" | "claim" | "fetch" | "register" | "update" | "remove" | "entry" | "render" | "solid-render" | "root-change" | "observer" | string; error: unknown; element?: HTMLModuleScriptElement | SolidRenderElement; moduleId?: string; origin?: HTMLRegistrationOrigin };
144
221
 
145
222
  export type HTMLRuntimeEventType = HTMLRuntimeEvent["type"];
146
223
  export type HTMLRuntimeEventOfType<T extends HTMLRuntimeEventType> =
@@ -163,9 +240,12 @@ export interface AddHTMLModuleOptions extends DefineScriptOptions {
163
240
  source?: string;
164
241
  src?: string;
165
242
  entry?: boolean;
243
+ render?: true | string;
244
+ component?: string;
166
245
  type?: string;
167
246
  language?: string;
168
247
  executeEntries?: boolean;
248
+ executeRenders?: boolean;
169
249
  appendTo?: HTMLAppendTarget;
170
250
  document?: HTMLDocumentLike;
171
251
  createElement?: (tagName: string) => HTMLModuleScriptElement;
@@ -174,6 +254,8 @@ export interface AddHTMLModuleOptions extends DefineScriptOptions {
174
254
  export interface HTMLRuntimeOptions extends ObserveHTMLOptions {
175
255
  appendTo?: HTMLAppendTarget;
176
256
  createElement?: (tagName: string) => HTMLModuleScriptElement;
257
+ /** Override Solid mounting for tests/special hosts. */
258
+ renderAdapter?: HTMLRenderAdapter;
177
259
  }
178
260
 
179
261
  export interface SetHTMLRootOptions extends RegisterHTMLOptions {
@@ -190,11 +272,8 @@ export interface HTMLRuntimeController {
190
272
  readonly runtime: SolidTagRuntime;
191
273
  readonly scope?: string;
192
274
  readonly connected: boolean;
193
- /** Current configured/effective discovery root when available. */
194
275
  readonly root?: HTMLModuleRoot;
195
- /** Current effective target used by append()/addModule() when available. */
196
276
  readonly appendTarget?: HTMLAppendTarget;
197
- /** Result of the observer's initial scan. */
198
277
  readonly initial: RegisterHTMLResult;
199
278
 
200
279
  subscribe(listener: (event: HTMLRuntimeEvent) => void): () => boolean;
@@ -207,65 +286,22 @@ export interface HTMLRuntimeController {
207
286
  listener: (event: HTMLRuntimeEventOfType<T[number]>) => void,
208
287
  ): () => boolean;
209
288
 
210
- /** One-shot scan of matching scripts under the configured/root override. */
211
289
  register(options?: RegisterHTMLOptions): Promise<RegisterHTMLResult>;
212
-
213
- /** Start live addition observation. Returns this controller. */
214
290
  observe(options?: ObserveHTMLOptions): Promise<HTMLRuntimeController>;
215
-
216
- /** Wait for queued observer work and scan for newly discoverable scripts. */
217
291
  flush(options?: RegisterHTMLOptions): Promise<RegisterHTMLResult>;
218
292
  disconnect(): void;
293
+ /** Dispose HTML-owned mounts/registry state without disposing the core runtime. */
294
+ dispose(): Promise<void>;
219
295
 
220
- /**
221
- * Change the discovery/observation root. A connected observer is rebound to
222
- * the new node automatically.
223
- */
224
- setRoot(
225
- root: HTMLModuleRoot,
226
- options?: SetHTMLRootOptions,
227
- ): Promise<RegisterHTMLResult>;
228
-
229
- /** Change both the discovery root and append target to the selected root. */
230
- moveTo(
231
- root: HTMLModuleRoot,
232
- options?: SetHTMLRootOptions,
233
- ): Promise<RegisterHTMLResult>;
234
-
235
- /** Change only where append()/addModule() insert future elements. */
296
+ setRoot(root: HTMLModuleRoot, options?: SetHTMLRootOptions): Promise<RegisterHTMLResult>;
297
+ moveTo(root: HTMLModuleRoot, options?: SetHTMLRootOptions): Promise<RegisterHTMLResult>;
236
298
  setAppendTarget(target: HTMLAppendTarget): HTMLRuntimeController;
237
299
 
238
- /** Define one element without auto-running an entry. */
239
- defineElement(
240
- element: HTMLModuleScriptElement,
241
- options?: DefineScriptOptions,
242
- ): Promise<HTMLModuleDefinition>;
243
-
244
- /** Explicitly claim/register an existing element for this runtime. */
245
- registerElement(
246
- element: HTMLModuleScriptElement,
247
- options?: RegisterHTMLOptions,
248
- ): Promise<HTMLModuleDefinition>;
249
-
250
- /** Re-read and replace source for an element already owned by this controller. */
251
- updateElement(
252
- element: HTMLModuleScriptElement,
253
- options?: RegisterHTMLOptions,
254
- ): Promise<HTMLModuleDefinition>;
255
-
256
- /** Release an owned element and optionally remove its module and DOM node. */
257
- removeElement(
258
- element: HTMLModuleScriptElement,
259
- options?: RemoveHTMLElementOptions,
260
- ): Promise<RemoveHTMLElementResult>;
261
-
262
- /** Claim first, append a user-created element, then register it directly. */
263
- append(
264
- element: HTMLModuleScriptElement,
265
- options?: RegisterHTMLOptions & { appendTo?: HTMLAppendTarget },
266
- ): Promise<HTMLModuleDefinition>;
267
-
268
- /** Create a runtime script element and add it through the controller. */
300
+ defineElement(element: HTMLModuleScriptElement, options?: DefineScriptOptions): Promise<HTMLModuleDefinition>;
301
+ registerElement(element: HTMLModuleScriptElement, options?: RegisterHTMLOptions): Promise<HTMLModuleDefinition>;
302
+ updateElement(element: HTMLModuleScriptElement, options?: RegisterHTMLOptions): Promise<HTMLModuleDefinition>;
303
+ removeElement(element: HTMLModuleScriptElement, options?: RemoveHTMLElementOptions): Promise<RemoveHTMLElementResult>;
304
+ append(element: HTMLModuleScriptElement, options?: RegisterHTMLOptions & { appendTo?: HTMLAppendTarget }): Promise<HTMLModuleDefinition>;
269
305
  addModule(options: AddHTMLModuleOptions): Promise<HTMLModuleDefinition>;
270
306
 
271
307
  owns(element: HTMLModuleScriptElement): boolean;
@@ -273,7 +309,16 @@ export interface HTMLRuntimeController {
273
309
  getElement(id: string): HTMLModuleScriptElement | undefined;
274
310
  }
275
311
 
276
- /** Legacy observer shape is now the full HTML runtime controller. */
312
+ export interface CustomElementRegistryLike {
313
+ define(name: string, constructor: any): void;
314
+ get(name: string): any;
315
+ }
316
+
317
+ export interface RegisterSolidRenderElementOptions {
318
+ customElements?: CustomElementRegistryLike;
319
+ HTMLElement?: new (...args: any[]) => any;
320
+ }
321
+
277
322
  export type HTMLObserverController = HTMLRuntimeController;
278
323
 
279
324
  export declare class HTMLModuleError extends SolidTagRuntimeError {
@@ -287,6 +332,12 @@ export declare class HTMLModuleOwnershipError extends HTMLModuleError {
287
332
  requestedScope?: string;
288
333
  }
289
334
 
335
+ export declare class HTMLRenderError extends SolidTagRuntimeError {
336
+ element?: HTMLModuleScriptElement | SolidRenderElement;
337
+ moduleId?: string;
338
+ component?: string;
339
+ }
340
+
290
341
  export declare const htmlModuleSelector: string;
291
342
  export declare const htmlRuntimeScopeAttribute: "data-solid-runtime";
292
343
 
@@ -295,6 +346,10 @@ export declare function createHTMLRuntime(
295
346
  options?: HTMLRuntimeOptions,
296
347
  ): HTMLRuntimeController;
297
348
 
349
+ export declare function registerSolidRenderElement(
350
+ options?: RegisterSolidRenderElementOptions,
351
+ ): any | undefined;
352
+
298
353
  export declare function defineScript(
299
354
  runtime: SolidTagRuntime,
300
355
  element: HTMLModuleScriptElement,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solid-tag-runtime",
3
- "version": "0.0.8",
3
+ "version": "0.0.11",
4
4
  "description": "Runtime module system for JSX modules compiled with solid-tag and executed through @solidjs/html",
5
5
  "type": "module",
6
6
  "exports": {