solid-tag-runtime 0.0.13 → 0.0.15
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 +114 -2
- package/README.md +85 -19
- package/docs/README.md +5 -2
- package/docs/api/html.md +8 -0
- package/docs/api/solid.md +71 -0
- package/docs/getting-started.md +29 -22
- package/docs/html-runtime.md +12 -0
- package/docs/lifecycle-events.md +2 -0
- package/docs/rendering.md +6 -0
- package/docs/solid-runtime-setup.md +181 -0
- package/docs/wrapperless-delegation.md +81 -0
- package/examples/solid-runtime.js +24 -0
- package/package.json +7 -1
- package/solid.d.ts +77 -0
- package/src/html/delegated-events.js +69 -0
- package/src/html/delegation-host.js +29 -0
- package/src/html.js +76 -1
- package/src/render.js +4 -0
- package/src/solid/import-map.js +29 -0
- package/src/solid/index.js +67 -0
- package/src/solid/integration.js +30 -0
- package/src/solid/packages.js +24 -0
- package/src/solid/providers/esm-sh.js +81 -0
- package/src/solid/providers/index.js +22 -0
- package/src/solid/providers/jsdelivr.js +45 -0
- package/src/solid/resolve.js +287 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ensureDocumentDelegationHost } from "../html/delegation-host.js";
|
|
2
|
+
import { ensureDelegatedEvents } from "../html/delegated-events.js";
|
|
3
|
+
|
|
4
|
+
const integrations = new WeakMap();
|
|
5
|
+
|
|
6
|
+
export function installSolidRuntimeIntegration(runtime, modules, options = {}) {
|
|
7
|
+
if (!runtime || (typeof runtime !== "object" && typeof runtime !== "function")) {
|
|
8
|
+
throw new TypeError("installSolidRuntimeIntegration() requires a runtime object.");
|
|
9
|
+
}
|
|
10
|
+
const web = modules?.["@solidjs/web"];
|
|
11
|
+
if (!web) {
|
|
12
|
+
throw new TypeError("Solid runtime integration requires the @solidjs/web host module.");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const integration = {
|
|
16
|
+
modules,
|
|
17
|
+
web,
|
|
18
|
+
ensureDelegation(document) {
|
|
19
|
+
const host = ensureDocumentDelegationHost(web, document);
|
|
20
|
+
ensureDelegatedEvents(web, document, options.delegatedEvents);
|
|
21
|
+
return host;
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
integrations.set(runtime, integration);
|
|
25
|
+
return integration;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function getSolidRuntimeIntegration(runtime) {
|
|
29
|
+
return integrations.get(runtime);
|
|
30
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const SOLID_RUNTIME_PACKAGES = Object.freeze([
|
|
2
|
+
"solid-js",
|
|
3
|
+
"@solidjs/web",
|
|
4
|
+
"@solidjs/html",
|
|
5
|
+
"@solidjs/signals",
|
|
6
|
+
]);
|
|
7
|
+
|
|
8
|
+
// Keep CDN fallback deterministic. This runtime release is tested against the
|
|
9
|
+
// coordinated Solid 2 RC family below rather than provider "latest" tags.
|
|
10
|
+
export const TESTED_SOLID_VERSION = "2.0.0-rc.13";
|
|
11
|
+
|
|
12
|
+
export function isSolidRuntimePackage(value) {
|
|
13
|
+
return SOLID_RUNTIME_PACKAGES.includes(String(value));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function pickSolidRuntimeModules(modules = {}) {
|
|
17
|
+
const picked = {};
|
|
18
|
+
for (const packageName of SOLID_RUNTIME_PACKAGES) {
|
|
19
|
+
if (Object.prototype.hasOwnProperty.call(modules, packageName)) {
|
|
20
|
+
picked[packageName] = modules[packageName];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return picked;
|
|
24
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
const HOSTS = new Set(["esm.sh", "www.esm.sh"]);
|
|
2
|
+
|
|
3
|
+
export const esmShProvider = {
|
|
4
|
+
id: "esm.sh",
|
|
5
|
+
|
|
6
|
+
matches(value) {
|
|
7
|
+
const url = toURL(value);
|
|
8
|
+
return Boolean(url && HOSTS.has(url.hostname));
|
|
9
|
+
},
|
|
10
|
+
|
|
11
|
+
inspect(value) {
|
|
12
|
+
const url = toURL(value);
|
|
13
|
+
if (!url || !HOSTS.has(url.hostname)) return {};
|
|
14
|
+
const parsed = parsePackagePath(url.pathname);
|
|
15
|
+
return {
|
|
16
|
+
provider: "esm.sh",
|
|
17
|
+
packageName: parsed.packageName,
|
|
18
|
+
version: parsed.version,
|
|
19
|
+
url: url.href,
|
|
20
|
+
};
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
createPackageUrl(packageName, context = {}) {
|
|
24
|
+
const version = context.version;
|
|
25
|
+
const base = new URL(`https://esm.sh/${packageName}${version ? `@${version}` : ""}`);
|
|
26
|
+
const authoritative = context.authoritativeMappings ?? new Map();
|
|
27
|
+
const external = [];
|
|
28
|
+
const deps = [];
|
|
29
|
+
|
|
30
|
+
for (const dependency of solidFamilyDependencyClosure(packageName)) {
|
|
31
|
+
if (authoritative.has(dependency)) {
|
|
32
|
+
// Preserve the page's exact identity anchor. esm.sh leaves this bare so
|
|
33
|
+
// the browser/import map resolves the already-authoritative package.
|
|
34
|
+
external.push(dependency);
|
|
35
|
+
} else if (version) {
|
|
36
|
+
// With no page-owned anchor, pin coordinated sibling dependencies so
|
|
37
|
+
// separately generated package URLs converge on one provider version.
|
|
38
|
+
deps.push(`${dependency}@${version}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Explicit mappings for other family members are also authoritative when a
|
|
43
|
+
// generated package happens to import them.
|
|
44
|
+
for (const [name] of authoritative) {
|
|
45
|
+
if (name === packageName || external.includes(name)) continue;
|
|
46
|
+
if (!context.familyPackages?.includes?.(name)) continue;
|
|
47
|
+
external.push(name);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (external.length) base.searchParams.set("external", external.join(","));
|
|
51
|
+
if (deps.length) base.searchParams.set("deps", deps.join(","));
|
|
52
|
+
return base.href;
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
function parsePackagePath(pathname) {
|
|
57
|
+
const value = decodeURIComponent(String(pathname ?? "")).replace(/^\/+/, "");
|
|
58
|
+
const match = value.match(/^(@[^/]+\/[^@/?]+|[^@/?]+)(?:@([^/?]+))?/);
|
|
59
|
+
if (!match) return {};
|
|
60
|
+
return { packageName: match[1], version: match[2] };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function toURL(value) {
|
|
64
|
+
try {
|
|
65
|
+
return new URL(String(value));
|
|
66
|
+
} catch {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function solidFamilyDependencyClosure(packageName) {
|
|
72
|
+
// Solid 2's reactive core is @solidjs/signals. solid-js consumes it,
|
|
73
|
+
// @solidjs/web consumes solid-js, and @solidjs/html consumes @solidjs/web.
|
|
74
|
+
// Include the family closure rather than only direct package dependencies so
|
|
75
|
+
// provider-generated URLs cannot silently pick a second reactive-core copy.
|
|
76
|
+
if (packageName === "solid-js") return ["@solidjs/signals"];
|
|
77
|
+
if (packageName === "@solidjs/web") return ["solid-js", "@solidjs/signals"];
|
|
78
|
+
if (packageName === "@solidjs/html") return ["@solidjs/web", "solid-js", "@solidjs/signals"];
|
|
79
|
+
if (packageName === "@solidjs/signals") return [];
|
|
80
|
+
return [];
|
|
81
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { esmShProvider } from "./esm-sh.js";
|
|
2
|
+
import { jsDelivrProvider } from "./jsdelivr.js";
|
|
3
|
+
|
|
4
|
+
export const SOLID_MODULE_PROVIDERS = Object.freeze([
|
|
5
|
+
esmShProvider,
|
|
6
|
+
jsDelivrProvider,
|
|
7
|
+
]);
|
|
8
|
+
|
|
9
|
+
export function getSolidModuleProvider(id) {
|
|
10
|
+
const normalized = normalizeProviderId(id);
|
|
11
|
+
return SOLID_MODULE_PROVIDERS.find(provider => provider.id === normalized);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function matchSolidModuleProvider(url) {
|
|
15
|
+
return SOLID_MODULE_PROVIDERS.find(provider => provider.matches(url));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function normalizeProviderId(value) {
|
|
19
|
+
if (value === "esm.sh" || value === "esm") return "esm.sh";
|
|
20
|
+
if (value === "jsdelivr" || value === "jsDelivr") return "jsdelivr";
|
|
21
|
+
return value == null ? undefined : String(value);
|
|
22
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const HOSTS = new Set(["cdn.jsdelivr.net", "fastly.jsdelivr.net"]);
|
|
2
|
+
|
|
3
|
+
export const jsDelivrProvider = {
|
|
4
|
+
id: "jsdelivr",
|
|
5
|
+
|
|
6
|
+
matches(value) {
|
|
7
|
+
const url = toURL(value);
|
|
8
|
+
return Boolean(url && HOSTS.has(url.hostname) && url.pathname.includes("/npm/"));
|
|
9
|
+
},
|
|
10
|
+
|
|
11
|
+
inspect(value) {
|
|
12
|
+
const url = toURL(value);
|
|
13
|
+
if (!url || !HOSTS.has(url.hostname)) return {};
|
|
14
|
+
const marker = "/npm/";
|
|
15
|
+
const index = url.pathname.indexOf(marker);
|
|
16
|
+
if (index < 0) return {};
|
|
17
|
+
const parsed = parsePackagePath(url.pathname.slice(index + marker.length));
|
|
18
|
+
return {
|
|
19
|
+
provider: "jsdelivr",
|
|
20
|
+
packageName: parsed.packageName,
|
|
21
|
+
version: parsed.version,
|
|
22
|
+
url: url.href,
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
createPackageUrl(packageName, context = {}) {
|
|
27
|
+
const version = context.version;
|
|
28
|
+
return `https://cdn.jsdelivr.net/npm/${packageName}${version ? `@${version}` : ""}/+esm`;
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
function parsePackagePath(pathname) {
|
|
33
|
+
const value = decodeURIComponent(String(pathname ?? "")).replace(/^\/+/, "");
|
|
34
|
+
const match = value.match(/^(@[^/]+\/[^@/?]+|[^@/?]+)(?:@([^/?]+))?/);
|
|
35
|
+
if (!match) return {};
|
|
36
|
+
return { packageName: match[1], version: match[2] };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function toURL(value) {
|
|
40
|
+
try {
|
|
41
|
+
return new URL(String(value));
|
|
42
|
+
} catch {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import { readImportMapImports } from "./import-map.js";
|
|
2
|
+
import {
|
|
3
|
+
SOLID_RUNTIME_PACKAGES,
|
|
4
|
+
TESTED_SOLID_VERSION,
|
|
5
|
+
isSolidRuntimePackage,
|
|
6
|
+
} from "./packages.js";
|
|
7
|
+
import {
|
|
8
|
+
getSolidModuleProvider,
|
|
9
|
+
matchSolidModuleProvider,
|
|
10
|
+
normalizeProviderId,
|
|
11
|
+
} from "./providers/index.js";
|
|
12
|
+
|
|
13
|
+
export class SolidModuleResolutionError extends Error {
|
|
14
|
+
constructor(message, details = {}) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.name = "SolidModuleResolutionError";
|
|
17
|
+
Object.assign(this, details);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export async function loadSolidModulesWithEnvironment(options = {}, environment = createDefaultSolidEnvironment()) {
|
|
22
|
+
const source = normalizeSource(options.source);
|
|
23
|
+
const modules = Object.create(null);
|
|
24
|
+
const resolvedSpecifiers = new Map();
|
|
25
|
+
const authoritativeMappings = new Map();
|
|
26
|
+
const failures = new Map();
|
|
27
|
+
const unknownHostNamespaces = new Set();
|
|
28
|
+
const pageMappings = readImportMapImports(options.document ?? environment.document);
|
|
29
|
+
|
|
30
|
+
for (const packageName of SOLID_RUNTIME_PACKAGES) {
|
|
31
|
+
if (Object.prototype.hasOwnProperty.call(options.modules ?? {}, packageName)) {
|
|
32
|
+
modules[packageName] = options.modules[packageName];
|
|
33
|
+
}
|
|
34
|
+
const explicit = options.specifiers?.[packageName];
|
|
35
|
+
if (typeof explicit === "string" && explicit) {
|
|
36
|
+
resolvedSpecifiers.set(packageName, explicit);
|
|
37
|
+
authoritativeMappings.set(packageName, explicit);
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
const mapped = pageMappings.get(packageName);
|
|
41
|
+
if (mapped) {
|
|
42
|
+
// Keep the browser/import map authoritative. Importing the bare package
|
|
43
|
+
// also handles relative map targets correctly against the document base.
|
|
44
|
+
resolvedSpecifiers.set(packageName, packageName);
|
|
45
|
+
authoritativeMappings.set(packageName, mapped);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Discover the browser/bundler's effective resolution without overriding
|
|
50
|
+
// explicit mappings. This is advisory; dynamic import remains authoritative.
|
|
51
|
+
if (source === "auto" || source === "host") {
|
|
52
|
+
for (const packageName of SOLID_RUNTIME_PACKAGES) {
|
|
53
|
+
if (modules[packageName] || resolvedSpecifiers.has(packageName)) continue;
|
|
54
|
+
try {
|
|
55
|
+
const resolved = await environment.resolve?.(packageName);
|
|
56
|
+
if (typeof resolved === "string" && resolved && resolved !== packageName) {
|
|
57
|
+
resolvedSpecifiers.set(packageName, resolved);
|
|
58
|
+
authoritativeMappings.set(packageName, resolved);
|
|
59
|
+
}
|
|
60
|
+
} catch {
|
|
61
|
+
// Import may still work in a bundler even when import.meta.resolve does not.
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Import everything the host already knows how to resolve. Existing exact
|
|
67
|
+
// URLs are used verbatim, preserving page-owned import-map identity.
|
|
68
|
+
for (const packageName of SOLID_RUNTIME_PACKAGES) {
|
|
69
|
+
if (modules[packageName]) continue;
|
|
70
|
+
const specifier = resolvedSpecifiers.get(packageName);
|
|
71
|
+
if (!specifier) continue;
|
|
72
|
+
try {
|
|
73
|
+
modules[packageName] = await environment.importModule(specifier);
|
|
74
|
+
} catch (error) {
|
|
75
|
+
failures.set(packageName, error);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// A bundler may resolve bare dynamic imports even when import.meta.resolve is
|
|
80
|
+
// unavailable. Try that path in host/auto modes before considering a CDN.
|
|
81
|
+
if (source === "auto" || source === "host") {
|
|
82
|
+
for (const packageName of SOLID_RUNTIME_PACKAGES) {
|
|
83
|
+
if (modules[packageName]) continue;
|
|
84
|
+
try {
|
|
85
|
+
modules[packageName] = await environment.importModule(packageName);
|
|
86
|
+
let anchored = authoritativeMappings.has(packageName);
|
|
87
|
+
try {
|
|
88
|
+
const resolved = await environment.resolve?.(packageName);
|
|
89
|
+
if (typeof resolved === "string" && resolved && resolved !== packageName) {
|
|
90
|
+
resolvedSpecifiers.set(packageName, resolved);
|
|
91
|
+
authoritativeMappings.set(packageName, resolved);
|
|
92
|
+
anchored = true;
|
|
93
|
+
}
|
|
94
|
+
} catch {
|
|
95
|
+
// A complete host-resolved family needs no provider fallback.
|
|
96
|
+
}
|
|
97
|
+
if (!anchored) unknownHostNamespaces.add(packageName);
|
|
98
|
+
} catch (error) {
|
|
99
|
+
failures.set(packageName, error);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
let missing = SOLID_RUNTIME_PACKAGES.filter(packageName => !modules[packageName]);
|
|
105
|
+
if (!missing.length) return freezeModuleFamily(modules);
|
|
106
|
+
|
|
107
|
+
if (source === "host") {
|
|
108
|
+
throw createResolutionFailure({ source, missing, failures, authoritativeMappings });
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (source === "auto" && unknownHostNamespaces.size) {
|
|
112
|
+
throw createResolutionFailure({
|
|
113
|
+
source,
|
|
114
|
+
missing,
|
|
115
|
+
failures,
|
|
116
|
+
authoritativeMappings,
|
|
117
|
+
hint: `Refusing to mix CDN fallback with host-resolved Solid modules whose identity is opaque (${[...unknownHostNamespaces].join(", ")}). Provide the remaining Solid namespaces/specifiers explicitly or make the host mapping resolvable.`,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const strongAnchor = findStrongAnchor(authoritativeMappings);
|
|
122
|
+
let providerId = source === "esm.sh" || source === "jsdelivr"
|
|
123
|
+
? normalizeProviderId(source)
|
|
124
|
+
: strongAnchor?.provider?.id;
|
|
125
|
+
if (!providerId) providerId = inferWeakProvider(pageMappings)?.id;
|
|
126
|
+
if (!providerId) providerId = normalizeProviderId(options.fallbackProvider);
|
|
127
|
+
if (!providerId) {
|
|
128
|
+
throw createResolutionFailure({
|
|
129
|
+
source,
|
|
130
|
+
missing,
|
|
131
|
+
failures,
|
|
132
|
+
authoritativeMappings,
|
|
133
|
+
hint: "Configure `fallbackProvider`/`version`, provide explicit module namespaces, or add resolvable Solid import-map entries.",
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const provider = getSolidModuleProvider(providerId);
|
|
138
|
+
if (!provider) {
|
|
139
|
+
throw new SolidModuleResolutionError(`Unknown Solid module provider ${JSON.stringify(providerId)}.`, {
|
|
140
|
+
provider: providerId,
|
|
141
|
+
missing,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const version = selectVersion(options, strongAnchor);
|
|
146
|
+
validateProviderMix(provider, strongAnchor, authoritativeMappings, missing);
|
|
147
|
+
|
|
148
|
+
for (const packageName of missing) {
|
|
149
|
+
const existing = authoritativeMappings.get(packageName);
|
|
150
|
+
const specifier = existing ?? provider.createPackageUrl(packageName, {
|
|
151
|
+
version,
|
|
152
|
+
authoritativeMappings,
|
|
153
|
+
familyPackages: SOLID_RUNTIME_PACKAGES,
|
|
154
|
+
});
|
|
155
|
+
resolvedSpecifiers.set(packageName, specifier);
|
|
156
|
+
try {
|
|
157
|
+
modules[packageName] = await environment.importModule(specifier);
|
|
158
|
+
} catch (error) {
|
|
159
|
+
failures.set(packageName, error);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
missing = SOLID_RUNTIME_PACKAGES.filter(packageName => !modules[packageName]);
|
|
164
|
+
if (missing.length) {
|
|
165
|
+
throw createResolutionFailure({
|
|
166
|
+
source,
|
|
167
|
+
provider: provider.id,
|
|
168
|
+
version,
|
|
169
|
+
missing,
|
|
170
|
+
failures,
|
|
171
|
+
authoritativeMappings,
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return freezeModuleFamily(modules);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export function createDefaultSolidEnvironment() {
|
|
179
|
+
return {
|
|
180
|
+
document: globalThis.document,
|
|
181
|
+
async resolve(specifier) {
|
|
182
|
+
if (typeof import.meta.resolve !== "function") return undefined;
|
|
183
|
+
return import.meta.resolve(specifier);
|
|
184
|
+
},
|
|
185
|
+
importModule(specifier) {
|
|
186
|
+
return import(specifier);
|
|
187
|
+
},
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export function inspectSolidResolution(options = {}) {
|
|
192
|
+
const pageMappings = readImportMapImports(options.document ?? globalThis.document);
|
|
193
|
+
const authoritativeMappings = new Map();
|
|
194
|
+
for (const packageName of SOLID_RUNTIME_PACKAGES) {
|
|
195
|
+
const explicit = options.specifiers?.[packageName];
|
|
196
|
+
const mapped = explicit ?? pageMappings.get(packageName);
|
|
197
|
+
if (mapped) authoritativeMappings.set(packageName, mapped);
|
|
198
|
+
}
|
|
199
|
+
const strongAnchor = findStrongAnchor(authoritativeMappings);
|
|
200
|
+
return {
|
|
201
|
+
pageMappings,
|
|
202
|
+
authoritativeMappings,
|
|
203
|
+
provider: strongAnchor?.provider?.id ?? inferWeakProvider(pageMappings)?.id,
|
|
204
|
+
version: strongAnchor?.version,
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function normalizeSource(value) {
|
|
209
|
+
const source = value ?? "auto";
|
|
210
|
+
if (source === "auto" || source === "host" || source === "esm.sh" || source === "jsdelivr") return source;
|
|
211
|
+
throw new TypeError(`Unknown Solid module source ${JSON.stringify(source)}.`);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function findStrongAnchor(authoritativeMappings) {
|
|
215
|
+
const ordered = ["solid-js", ...SOLID_RUNTIME_PACKAGES.filter(name => name !== "solid-js")];
|
|
216
|
+
for (const packageName of ordered) {
|
|
217
|
+
const url = authoritativeMappings.get(packageName);
|
|
218
|
+
if (!url) continue;
|
|
219
|
+
const provider = matchSolidModuleProvider(url);
|
|
220
|
+
if (!provider) continue;
|
|
221
|
+
const inspected = provider.inspect(url);
|
|
222
|
+
return {
|
|
223
|
+
packageName,
|
|
224
|
+
url,
|
|
225
|
+
provider,
|
|
226
|
+
version: inspected.version,
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
return undefined;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function inferWeakProvider(pageMappings) {
|
|
233
|
+
for (const [, target] of pageMappings) {
|
|
234
|
+
const provider = matchSolidModuleProvider(target);
|
|
235
|
+
if (provider) return provider;
|
|
236
|
+
}
|
|
237
|
+
return undefined;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function selectVersion(options, strongAnchor) {
|
|
241
|
+
if (strongAnchor?.version) return strongAnchor.version;
|
|
242
|
+
if (options.version) return String(options.version);
|
|
243
|
+
if (strongAnchor) return undefined; // Preserve an explicitly unversioned family anchor.
|
|
244
|
+
return TESTED_SOLID_VERSION;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function validateProviderMix(provider, strongAnchor, authoritativeMappings, missing) {
|
|
248
|
+
if (!missing.length || provider.id !== "jsdelivr") return;
|
|
249
|
+
const incompatible = Array.from(authoritativeMappings.entries())
|
|
250
|
+
.filter(([packageName, target]) => isSolidRuntimePackage(packageName) && !provider.matches(target));
|
|
251
|
+
if (!incompatible.length) return;
|
|
252
|
+
throw new SolidModuleResolutionError(
|
|
253
|
+
"Cannot safely generate jsDelivr Solid sibling packages while one or more Solid-family packages are mapped through another/custom provider. Provide the full Solid family explicitly or use a provider that can externalize the authoritative mappings.",
|
|
254
|
+
{
|
|
255
|
+
provider: provider.id,
|
|
256
|
+
anchor: strongAnchor,
|
|
257
|
+
missing,
|
|
258
|
+
incompatibleMappings: incompatible,
|
|
259
|
+
},
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function createResolutionFailure({ source, provider, version, missing, failures, authoritativeMappings, hint }) {
|
|
264
|
+
const details = missing.map(packageName => {
|
|
265
|
+
const error = failures.get(packageName);
|
|
266
|
+
return `${packageName}${error ? ` (${error?.message ?? String(error)})` : ""}`;
|
|
267
|
+
}).join(", ");
|
|
268
|
+
const mappingText = authoritativeMappings.size
|
|
269
|
+
? ` Existing Solid mappings: ${Array.from(authoritativeMappings, ([key, value]) => `${key}=${value}`).join(", ")}.`
|
|
270
|
+
: "";
|
|
271
|
+
const providerText = provider ? ` Provider: ${provider}${version ? `@${version}` : ""}.` : "";
|
|
272
|
+
return new SolidModuleResolutionError(
|
|
273
|
+
`Could not resolve a coherent Solid runtime module family. Missing: ${details}.${providerText}${mappingText}${hint ? ` ${hint}` : ""}`,
|
|
274
|
+
{ source, provider, version, missing, failures, authoritativeMappings },
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function freezeModuleFamily(modules) {
|
|
279
|
+
const result = {};
|
|
280
|
+
for (const packageName of SOLID_RUNTIME_PACKAGES) {
|
|
281
|
+
if (!modules[packageName]) {
|
|
282
|
+
throw new SolidModuleResolutionError(`Solid module family is incomplete; missing ${JSON.stringify(packageName)}.`);
|
|
283
|
+
}
|
|
284
|
+
result[packageName] = modules[packageName];
|
|
285
|
+
}
|
|
286
|
+
return Object.freeze(result);
|
|
287
|
+
}
|