solid-tag-runtime 0.0.1 → 0.0.3
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/ARCHITECTURE.md +336 -30
- package/README.md +181 -0
- package/html.d.ts +201 -0
- package/package.json +7 -1
- package/src/html.js +832 -0
package/html.d.ts
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { SolidTagRuntimeError } from "./index.js";
|
|
2
|
+
import type { ModuleFormat, ModuleNamespaceLike, SolidTagRuntime } from "./index.js";
|
|
3
|
+
|
|
4
|
+
export interface HTMLModuleScriptElement {
|
|
5
|
+
textContent?: string | null;
|
|
6
|
+
baseURI?: string;
|
|
7
|
+
ownerDocument?: HTMLDocumentLike;
|
|
8
|
+
getAttribute(name: string): string | null;
|
|
9
|
+
hasAttribute?(name: string): boolean;
|
|
10
|
+
setAttribute?(name: string, value: string): void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface HTMLAppendTarget {
|
|
14
|
+
append?(element: HTMLModuleScriptElement): void;
|
|
15
|
+
appendChild?(element: HTMLModuleScriptElement): unknown;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface HTMLDocumentLike extends HTMLModuleRoot, HTMLAppendTarget {
|
|
19
|
+
body?: HTMLAppendTarget;
|
|
20
|
+
documentElement?: HTMLAppendTarget;
|
|
21
|
+
createElement?(tagName: string): HTMLModuleScriptElement;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface HTMLModuleRoot {
|
|
25
|
+
baseURI?: string;
|
|
26
|
+
ownerDocument?: HTMLDocumentLike;
|
|
27
|
+
body?: HTMLAppendTarget;
|
|
28
|
+
documentElement?: HTMLAppendTarget;
|
|
29
|
+
querySelectorAll(selector: string): Iterable<HTMLModuleScriptElement> | ArrayLike<HTMLModuleScriptElement>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface HTMLFetchResponse {
|
|
33
|
+
ok?: boolean;
|
|
34
|
+
status?: number;
|
|
35
|
+
statusText?: string;
|
|
36
|
+
text(): Promise<string>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export type HTMLFetch = (url: string) => Promise<HTMLFetchResponse>;
|
|
40
|
+
|
|
41
|
+
export interface HTMLMutationObserverLike {
|
|
42
|
+
observe(
|
|
43
|
+
target: unknown,
|
|
44
|
+
options: {
|
|
45
|
+
childList: boolean;
|
|
46
|
+
subtree: boolean;
|
|
47
|
+
},
|
|
48
|
+
): void;
|
|
49
|
+
disconnect(): void;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface HTMLMutationObserverConstructor {
|
|
53
|
+
new (
|
|
54
|
+
callback: (...args: unknown[]) => void,
|
|
55
|
+
): HTMLMutationObserverLike;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface DefineScriptOptions {
|
|
59
|
+
root?: HTMLModuleRoot;
|
|
60
|
+
baseUrl?: string;
|
|
61
|
+
format?: ModuleFormat | "javascript";
|
|
62
|
+
fetch?: HTMLFetch;
|
|
63
|
+
/** Declarative ownership scope stored in data-solid-runtime. */
|
|
64
|
+
scope?: string;
|
|
65
|
+
/** Whether an HTML runtime may claim scripts without data-solid-runtime. Default: true. */
|
|
66
|
+
acceptUnscoped?: boolean;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface HTMLModuleDefinition {
|
|
70
|
+
id: string;
|
|
71
|
+
format: ModuleFormat;
|
|
72
|
+
entry: boolean;
|
|
73
|
+
sourceUrl?: string;
|
|
74
|
+
inline: boolean;
|
|
75
|
+
element: HTMLModuleScriptElement;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface RegisterHTMLOptions extends DefineScriptOptions {
|
|
79
|
+
selector?: string;
|
|
80
|
+
executeEntries?: boolean;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface RegisterHTMLResult {
|
|
84
|
+
modules: HTMLModuleDefinition[];
|
|
85
|
+
entries: string[];
|
|
86
|
+
executed: Array<{
|
|
87
|
+
id: string;
|
|
88
|
+
namespace: ModuleNamespaceLike;
|
|
89
|
+
}>;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface ObserveHTMLOptions extends RegisterHTMLOptions {
|
|
93
|
+
/** Register scripts already present when observation starts. Default: true. */
|
|
94
|
+
registerExisting?: boolean;
|
|
95
|
+
/** Observe descendant additions as well as direct children. Default: true. */
|
|
96
|
+
subtree?: boolean;
|
|
97
|
+
/** Override the platform MutationObserver constructor, useful for DOM-like hosts/tests. */
|
|
98
|
+
MutationObserver?: HTMLMutationObserverConstructor;
|
|
99
|
+
/** Called for asynchronous observer registration/import failures. */
|
|
100
|
+
onError?: (error: unknown) => void;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export interface AddHTMLModuleOptions extends DefineScriptOptions {
|
|
104
|
+
id?: string;
|
|
105
|
+
module?: string;
|
|
106
|
+
source?: string;
|
|
107
|
+
src?: string;
|
|
108
|
+
entry?: boolean;
|
|
109
|
+
type?: string;
|
|
110
|
+
language?: string;
|
|
111
|
+
executeEntries?: boolean;
|
|
112
|
+
appendTo?: HTMLAppendTarget;
|
|
113
|
+
document?: HTMLDocumentLike;
|
|
114
|
+
createElement?: (tagName: string) => HTMLModuleScriptElement;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface HTMLRuntimeOptions extends ObserveHTMLOptions {
|
|
118
|
+
appendTo?: HTMLAppendTarget;
|
|
119
|
+
createElement?: (tagName: string) => HTMLModuleScriptElement;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface HTMLRuntimeController {
|
|
123
|
+
readonly runtime: SolidTagRuntime;
|
|
124
|
+
readonly scope?: string;
|
|
125
|
+
readonly connected: boolean;
|
|
126
|
+
/** Result of the observer's initial scan. */
|
|
127
|
+
readonly initial: RegisterHTMLResult;
|
|
128
|
+
|
|
129
|
+
/** One-shot scan of matching scripts under the configured/root override. */
|
|
130
|
+
register(options?: RegisterHTMLOptions): Promise<RegisterHTMLResult>;
|
|
131
|
+
|
|
132
|
+
/** Start live addition observation. Returns this controller. */
|
|
133
|
+
observe(options?: ObserveHTMLOptions): Promise<HTMLRuntimeController>;
|
|
134
|
+
|
|
135
|
+
/** Wait for queued observer work and scan for newly discoverable scripts. */
|
|
136
|
+
flush(options?: RegisterHTMLOptions): Promise<RegisterHTMLResult>;
|
|
137
|
+
disconnect(): void;
|
|
138
|
+
|
|
139
|
+
/** Define one element without auto-running an entry. */
|
|
140
|
+
defineElement(
|
|
141
|
+
element: HTMLModuleScriptElement,
|
|
142
|
+
options?: DefineScriptOptions,
|
|
143
|
+
): Promise<HTMLModuleDefinition>;
|
|
144
|
+
|
|
145
|
+
/** Explicitly claim/register an existing element for this runtime. */
|
|
146
|
+
registerElement(
|
|
147
|
+
element: HTMLModuleScriptElement,
|
|
148
|
+
options?: RegisterHTMLOptions,
|
|
149
|
+
): Promise<HTMLModuleDefinition>;
|
|
150
|
+
|
|
151
|
+
/** Claim first, append a user-created element, then register it directly. */
|
|
152
|
+
append(
|
|
153
|
+
element: HTMLModuleScriptElement,
|
|
154
|
+
options?: RegisterHTMLOptions & { appendTo?: HTMLAppendTarget },
|
|
155
|
+
): Promise<HTMLModuleDefinition>;
|
|
156
|
+
|
|
157
|
+
/** Create a runtime script element and add it through the controller. */
|
|
158
|
+
addModule(options: AddHTMLModuleOptions): Promise<HTMLModuleDefinition>;
|
|
159
|
+
|
|
160
|
+
owns(element: HTMLModuleScriptElement): boolean;
|
|
161
|
+
getModuleId(element: HTMLModuleScriptElement): string | undefined;
|
|
162
|
+
getElement(id: string): HTMLModuleScriptElement | undefined;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** Legacy observer shape is now the full HTML runtime controller. */
|
|
166
|
+
export type HTMLObserverController = HTMLRuntimeController;
|
|
167
|
+
|
|
168
|
+
export declare class HTMLModuleError extends SolidTagRuntimeError {
|
|
169
|
+
element?: HTMLModuleScriptElement;
|
|
170
|
+
moduleId?: string;
|
|
171
|
+
sourceUrl?: string;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export declare class HTMLModuleOwnershipError extends HTMLModuleError {
|
|
175
|
+
ownerScope?: string;
|
|
176
|
+
requestedScope?: string;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export declare const htmlModuleSelector: string;
|
|
180
|
+
export declare const htmlRuntimeScopeAttribute: "data-solid-runtime";
|
|
181
|
+
|
|
182
|
+
export declare function createHTMLRuntime(
|
|
183
|
+
runtime: SolidTagRuntime,
|
|
184
|
+
options?: HTMLRuntimeOptions,
|
|
185
|
+
): HTMLRuntimeController;
|
|
186
|
+
|
|
187
|
+
export declare function defineScript(
|
|
188
|
+
runtime: SolidTagRuntime,
|
|
189
|
+
element: HTMLModuleScriptElement,
|
|
190
|
+
options?: DefineScriptOptions,
|
|
191
|
+
): Promise<HTMLModuleDefinition>;
|
|
192
|
+
|
|
193
|
+
export declare function registerHTML(
|
|
194
|
+
runtime: SolidTagRuntime,
|
|
195
|
+
options?: RegisterHTMLOptions,
|
|
196
|
+
): Promise<RegisterHTMLResult>;
|
|
197
|
+
|
|
198
|
+
export declare function observeHTML(
|
|
199
|
+
runtime: SolidTagRuntime,
|
|
200
|
+
options?: ObserveHTMLOptions,
|
|
201
|
+
): Promise<HTMLObserverController>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solid-tag-runtime",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
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": {
|
|
@@ -18,6 +18,11 @@
|
|
|
18
18
|
"types": "./index.d.ts",
|
|
19
19
|
"import": "./src/runtime.js",
|
|
20
20
|
"default": "./src/runtime.js"
|
|
21
|
+
},
|
|
22
|
+
"./html": {
|
|
23
|
+
"types": "./html.d.ts",
|
|
24
|
+
"import": "./src/html.js",
|
|
25
|
+
"default": "./src/html.js"
|
|
21
26
|
}
|
|
22
27
|
},
|
|
23
28
|
"main": "./src/index.js",
|
|
@@ -26,6 +31,7 @@
|
|
|
26
31
|
"files": [
|
|
27
32
|
"src",
|
|
28
33
|
"index.d.ts",
|
|
34
|
+
"html.d.ts",
|
|
29
35
|
"README.md",
|
|
30
36
|
"ARCHITECTURE.md"
|
|
31
37
|
],
|