@componentonce/compiler-esbuild 0.1.0-beta.0 → 0.1.0-beta.1
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 +103 -15
- package/dist/cli.d.ts +4 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +171 -0
- package/dist/cli.js.map +1 -0
- package/dist/compiler.d.ts +141 -0
- package/dist/compiler.d.ts.map +1 -0
- package/dist/compiler.js +296 -0
- package/dist/compiler.js.map +1 -0
- package/dist/index.d.ts +2 -136
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -289
- package/dist/index.js.map +1 -1
- package/dist/package.d.ts +88 -0
- package/dist/package.d.ts.map +1 -0
- package/dist/package.js +229 -0
- package/dist/package.js.map +1 -0
- package/examples/react-card.tsx +31 -0
- package/package.json +22 -2
package/dist/compiler.js
ADDED
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { isAbsolute } from "node:path";
|
|
3
|
+
import { build, } from "esbuild";
|
|
4
|
+
/** Stable identifier for the trusted CommonJS bundle contract emitted by this package. */
|
|
5
|
+
export const COMPONENTONCE_TRUSTED_BUNDLE_FORMAT = "componentonce.trusted-cjs.v1";
|
|
6
|
+
const DEFAULT_SOURCE_FILE_NAME = "componentonce-module.ts";
|
|
7
|
+
const DEFAULT_REACT_SOURCE_FILE_NAME = "componentonce-module.tsx";
|
|
8
|
+
const DEFAULT_EVALUATED_SOURCE_NAME = "componentonce-trusted-bundle.js";
|
|
9
|
+
const REACT_EXTERNALS = ["react", "react/jsx-runtime", "react/jsx-dev-runtime"];
|
|
10
|
+
/** Compilation failure with stable, normalized esbuild diagnostics. */
|
|
11
|
+
export class ComponentOnceCompileError extends Error {
|
|
12
|
+
/** Compiler errors that caused the build to fail. */
|
|
13
|
+
diagnostics;
|
|
14
|
+
constructor(diagnostics) {
|
|
15
|
+
super(formatCompileErrorMessage(diagnostics));
|
|
16
|
+
this.name = "ComponentOnceCompileError";
|
|
17
|
+
this.diagnostics = Object.freeze([...diagnostics]);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/** Deterministic error raised when a bundle requests an external the host did not inject. */
|
|
21
|
+
export class ComponentOnceMissingExternalError extends Error {
|
|
22
|
+
/** Exact module specifier requested by the bundle. */
|
|
23
|
+
specifier;
|
|
24
|
+
/** Sorted external specifiers supplied by the host. */
|
|
25
|
+
availableExternals;
|
|
26
|
+
constructor(specifier, availableExternals) {
|
|
27
|
+
const sortedExternals = Object.freeze([...availableExternals].sort());
|
|
28
|
+
const available = sortedExternals.length === 0 ? "(none)" : sortedExternals.join(", ");
|
|
29
|
+
super(`Missing trusted bundle external "${specifier}". Available externals: ${available}.`);
|
|
30
|
+
this.name = "ComponentOnceMissingExternalError";
|
|
31
|
+
this.specifier = specifier;
|
|
32
|
+
this.availableExternals = sortedExternals;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/** Error raised when loaded bundle content does not match its expected SHA-256 integrity. */
|
|
36
|
+
export class ComponentOnceIntegrityError extends Error {
|
|
37
|
+
/** Expected subresource-integrity-style SHA-256 value. */
|
|
38
|
+
expectedIntegrity;
|
|
39
|
+
/** Actual subresource-integrity-style SHA-256 value. */
|
|
40
|
+
actualIntegrity;
|
|
41
|
+
constructor(expectedIntegrity, actualIntegrity) {
|
|
42
|
+
super(`Trusted bundle integrity mismatch. Expected "${expectedIntegrity}" but received "${actualIntegrity}".`);
|
|
43
|
+
this.name = "ComponentOnceIntegrityError";
|
|
44
|
+
this.expectedIntegrity = expectedIntegrity;
|
|
45
|
+
this.actualIntegrity = actualIntegrity;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Compile one trusted module into a deterministic CommonJS artifact.
|
|
50
|
+
*
|
|
51
|
+
* Only caller-declared imports remain external. This generic path does not add React or any other
|
|
52
|
+
* runtime implicitly; every external must be injected explicitly by the host at instantiation.
|
|
53
|
+
*/
|
|
54
|
+
export async function compileTrustedModule(input) {
|
|
55
|
+
const sourceFileName = input.sourceFileName ?? DEFAULT_SOURCE_FILE_NAME;
|
|
56
|
+
const loader = input.loader ?? inferLoader(sourceFileName);
|
|
57
|
+
const allowedExternals = normalizeAllowedExternals(input.externalModules ?? []);
|
|
58
|
+
try {
|
|
59
|
+
const result = await build({
|
|
60
|
+
bundle: true,
|
|
61
|
+
charset: "utf8",
|
|
62
|
+
format: "cjs",
|
|
63
|
+
jsx: input.jsx ?? "transform",
|
|
64
|
+
legalComments: "none",
|
|
65
|
+
logLevel: "silent",
|
|
66
|
+
metafile: true,
|
|
67
|
+
minify: false,
|
|
68
|
+
platform: "neutral",
|
|
69
|
+
plugins: [createHostExternalPlugin(allowedExternals)],
|
|
70
|
+
sourcemap: "inline",
|
|
71
|
+
sourcesContent: true,
|
|
72
|
+
stdin: {
|
|
73
|
+
contents: input.source,
|
|
74
|
+
loader: loader,
|
|
75
|
+
sourcefile: sourceFileName,
|
|
76
|
+
...(input.resolveDir === undefined ? {} : { resolveDir: input.resolveDir }),
|
|
77
|
+
},
|
|
78
|
+
target: "es2022",
|
|
79
|
+
treeShaking: true,
|
|
80
|
+
write: false,
|
|
81
|
+
});
|
|
82
|
+
const output = result.outputFiles?.[0];
|
|
83
|
+
if (output === undefined || result.metafile === undefined) {
|
|
84
|
+
throw new ComponentOnceCompileError([
|
|
85
|
+
createInternalDiagnostic("esbuild did not return an in-memory bundle and metafile."),
|
|
86
|
+
]);
|
|
87
|
+
}
|
|
88
|
+
const code = output.text;
|
|
89
|
+
const hashes = hashBundleSource(code);
|
|
90
|
+
const metafile = deepFreeze(result.metafile);
|
|
91
|
+
const diagnostics = Object.freeze(result.warnings.map((warning) => normalizeMessage("warning", warning)));
|
|
92
|
+
const externalModules = Object.freeze(collectExternalModules(metafile));
|
|
93
|
+
return Object.freeze({
|
|
94
|
+
format: COMPONENTONCE_TRUSTED_BUNDLE_FORMAT,
|
|
95
|
+
code,
|
|
96
|
+
byteLength: hashes.byteLength,
|
|
97
|
+
sha256: hashes.sha256,
|
|
98
|
+
integrity: hashes.integrity,
|
|
99
|
+
externalModules,
|
|
100
|
+
diagnostics,
|
|
101
|
+
metafile,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
if (error instanceof ComponentOnceCompileError)
|
|
106
|
+
throw error;
|
|
107
|
+
if (isBuildFailure(error)) {
|
|
108
|
+
throw new ComponentOnceCompileError(error.errors.map((message) => normalizeMessage("error", message)));
|
|
109
|
+
}
|
|
110
|
+
throw error;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/** Compile a trusted React module while keeping the host React singleton external. */
|
|
114
|
+
export function compileTrustedReactModule(input) {
|
|
115
|
+
return compileTrustedModule({
|
|
116
|
+
source: input.source,
|
|
117
|
+
sourceFileName: input.sourceFileName ?? DEFAULT_REACT_SOURCE_FILE_NAME,
|
|
118
|
+
...(input.loader === undefined ? {} : { loader: input.loader }),
|
|
119
|
+
...(input.resolveDir === undefined ? {} : { resolveDir: input.resolveDir }),
|
|
120
|
+
externalModules: [
|
|
121
|
+
...REACT_EXTERNALS,
|
|
122
|
+
...(input.additionalExternalModules ?? []),
|
|
123
|
+
],
|
|
124
|
+
jsx: "automatic",
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
/** Calculate a subresource-integrity-style SHA-256 value for bundle text or UTF-8 bytes. */
|
|
128
|
+
export function calculateTrustedBundleIntegrity(source) {
|
|
129
|
+
return hashBundleSource(source).integrity;
|
|
130
|
+
}
|
|
131
|
+
/** Throw when bundle text or bytes do not match an expected SHA-256 integrity value. */
|
|
132
|
+
export function assertTrustedBundleIntegrity(source, expectedIntegrity) {
|
|
133
|
+
const actualIntegrity = calculateTrustedBundleIntegrity(source);
|
|
134
|
+
if (actualIntegrity !== expectedIntegrity) {
|
|
135
|
+
throw new ComponentOnceIntegrityError(expectedIntegrity, actualIntegrity);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Execute a trusted bundle with a deliberately narrow CommonJS environment.
|
|
140
|
+
*
|
|
141
|
+
* This API uses `new Function` and is only for trusted internal code. It is not a sandbox: evaluated
|
|
142
|
+
* code retains access to JavaScript globals. The only available `require` values are provided by
|
|
143
|
+
* `options.externals`, so React is always the exact instance selected by the host.
|
|
144
|
+
*/
|
|
145
|
+
export function instantiateTrustedBundle(source, options) {
|
|
146
|
+
const artifact = isBundleArtifact(source) ? source : undefined;
|
|
147
|
+
if (artifact !== undefined && artifact.format !== COMPONENTONCE_TRUSTED_BUNDLE_FORMAT) {
|
|
148
|
+
throw new TypeError(`Unsupported trusted bundle format: "${String(artifact.format)}".`);
|
|
149
|
+
}
|
|
150
|
+
const bundleSource = artifact === undefined ? source : artifact.code;
|
|
151
|
+
const expectedIntegrity = options.expectedIntegrity ?? artifact?.integrity;
|
|
152
|
+
if (expectedIntegrity !== undefined) {
|
|
153
|
+
assertTrustedBundleIntegrity(bundleSource, expectedIntegrity);
|
|
154
|
+
}
|
|
155
|
+
const code = typeof bundleSource === "string" ? bundleSource : decodeUtf8(bundleSource);
|
|
156
|
+
const availableExternals = Object.keys(options.externals).sort();
|
|
157
|
+
const trustedRequire = (specifier) => {
|
|
158
|
+
if (!Object.prototype.hasOwnProperty.call(options.externals, specifier)) {
|
|
159
|
+
throw new ComponentOnceMissingExternalError(specifier, availableExternals);
|
|
160
|
+
}
|
|
161
|
+
return options.externals[specifier];
|
|
162
|
+
};
|
|
163
|
+
const commonJsModule = { exports: {} };
|
|
164
|
+
const sourceName = sanitizeSourceName(options.sourceName ?? DEFAULT_EVALUATED_SOURCE_NAME);
|
|
165
|
+
const evaluate = new Function("module", "exports", "require", `"use strict";\n${code}\n//# sourceURL=${sourceName}`);
|
|
166
|
+
evaluate(commonJsModule, commonJsModule.exports, trustedRequire);
|
|
167
|
+
return commonJsModule.exports;
|
|
168
|
+
}
|
|
169
|
+
function createHostExternalPlugin(allowedExternals) {
|
|
170
|
+
return {
|
|
171
|
+
name: "componentonce-host-externals",
|
|
172
|
+
setup(buildApi) {
|
|
173
|
+
buildApi.onResolve({ filter: /.*/ }, (args) => {
|
|
174
|
+
if (allowedExternals.has(args.path)) {
|
|
175
|
+
return { external: true, path: args.path };
|
|
176
|
+
}
|
|
177
|
+
if (args.path.startsWith(".") || isAbsolute(args.path)) {
|
|
178
|
+
return undefined;
|
|
179
|
+
}
|
|
180
|
+
return {
|
|
181
|
+
errors: [
|
|
182
|
+
{
|
|
183
|
+
text: `Import "${args.path}" is not an allowed host external. ` +
|
|
184
|
+
"Add its exact specifier to externalModules (or additionalExternalModules for the React helper).",
|
|
185
|
+
},
|
|
186
|
+
],
|
|
187
|
+
};
|
|
188
|
+
});
|
|
189
|
+
},
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
function normalizeAllowedExternals(additionalExternals) {
|
|
193
|
+
const externals = new Set();
|
|
194
|
+
for (const specifier of additionalExternals) {
|
|
195
|
+
if (specifier.length === 0 ||
|
|
196
|
+
specifier !== specifier.trim() ||
|
|
197
|
+
specifier.includes("\0") ||
|
|
198
|
+
specifier.includes("\n") ||
|
|
199
|
+
specifier.includes("\r")) {
|
|
200
|
+
throw new ComponentOnceCompileError([
|
|
201
|
+
createInternalDiagnostic(`Invalid additional external module specifier: ${JSON.stringify(specifier)}.`),
|
|
202
|
+
]);
|
|
203
|
+
}
|
|
204
|
+
externals.add(specifier);
|
|
205
|
+
}
|
|
206
|
+
return externals;
|
|
207
|
+
}
|
|
208
|
+
function inferLoader(sourceFileName) {
|
|
209
|
+
const lowerName = sourceFileName.toLowerCase();
|
|
210
|
+
if (lowerName.endsWith(".jsx"))
|
|
211
|
+
return "jsx";
|
|
212
|
+
if (lowerName.endsWith(".js") || lowerName.endsWith(".mjs") || lowerName.endsWith(".cjs")) {
|
|
213
|
+
return "js";
|
|
214
|
+
}
|
|
215
|
+
if (lowerName.endsWith(".ts") || lowerName.endsWith(".mts") || lowerName.endsWith(".cts")) {
|
|
216
|
+
return "ts";
|
|
217
|
+
}
|
|
218
|
+
return "tsx";
|
|
219
|
+
}
|
|
220
|
+
function normalizeMessage(kind, message) {
|
|
221
|
+
return Object.freeze({
|
|
222
|
+
kind,
|
|
223
|
+
text: message.text,
|
|
224
|
+
...(message.location === null ? {} : { location: normalizeLocation(message.location) }),
|
|
225
|
+
notes: Object.freeze(message.notes.map((note) => Object.freeze({
|
|
226
|
+
text: note.text,
|
|
227
|
+
...(note.location === null ? {} : { location: normalizeLocation(note.location) }),
|
|
228
|
+
}))),
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
function normalizeLocation(location) {
|
|
232
|
+
return Object.freeze({
|
|
233
|
+
file: location.file,
|
|
234
|
+
line: location.line,
|
|
235
|
+
column: location.column,
|
|
236
|
+
length: location.length,
|
|
237
|
+
lineText: location.lineText,
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
function createInternalDiagnostic(text) {
|
|
241
|
+
return Object.freeze({ kind: "error", text, notes: Object.freeze([]) });
|
|
242
|
+
}
|
|
243
|
+
function formatCompileErrorMessage(diagnostics) {
|
|
244
|
+
const details = diagnostics.map((diagnostic) => {
|
|
245
|
+
const location = diagnostic.location;
|
|
246
|
+
const prefix = location === undefined
|
|
247
|
+
? diagnostic.kind
|
|
248
|
+
: `${location.file}:${location.line}:${location.column + 1}`;
|
|
249
|
+
return `${prefix}: ${diagnostic.text}`;
|
|
250
|
+
});
|
|
251
|
+
return `ComponentOnce compilation failed${details.length === 0 ? "." : `:\n${details.join("\n")}`}`;
|
|
252
|
+
}
|
|
253
|
+
function isBuildFailure(error) {
|
|
254
|
+
return (typeof error === "object" &&
|
|
255
|
+
error !== null &&
|
|
256
|
+
"errors" in error &&
|
|
257
|
+
Array.isArray(error.errors));
|
|
258
|
+
}
|
|
259
|
+
function collectExternalModules(metafile) {
|
|
260
|
+
const modules = new Set();
|
|
261
|
+
for (const output of Object.values(metafile.outputs)) {
|
|
262
|
+
for (const imported of output.imports) {
|
|
263
|
+
if (imported.external)
|
|
264
|
+
modules.add(imported.path);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return [...modules].sort();
|
|
268
|
+
}
|
|
269
|
+
function hashBundleSource(source) {
|
|
270
|
+
const bytes = typeof source === "string" ? Buffer.from(source, "utf8") : source;
|
|
271
|
+
const digest = createHash("sha256").update(bytes).digest();
|
|
272
|
+
return {
|
|
273
|
+
byteLength: bytes.byteLength,
|
|
274
|
+
sha256: digest.toString("hex"),
|
|
275
|
+
integrity: `sha256-${digest.toString("base64")}`,
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
function isBundleArtifact(source) {
|
|
279
|
+
return typeof source === "object" && !(source instanceof Uint8Array);
|
|
280
|
+
}
|
|
281
|
+
function decodeUtf8(source) {
|
|
282
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(source);
|
|
283
|
+
}
|
|
284
|
+
function sanitizeSourceName(sourceName) {
|
|
285
|
+
return sourceName.replace(/[\r\n\u2028\u2029]/g, "_");
|
|
286
|
+
}
|
|
287
|
+
function deepFreeze(value) {
|
|
288
|
+
if (value !== null && typeof value === "object" && !Object.isFrozen(value)) {
|
|
289
|
+
for (const child of Object.values(value)) {
|
|
290
|
+
deepFreeze(child);
|
|
291
|
+
}
|
|
292
|
+
Object.freeze(value);
|
|
293
|
+
}
|
|
294
|
+
return value;
|
|
295
|
+
}
|
|
296
|
+
//# sourceMappingURL=compiler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiler.js","sourceRoot":"","sources":["../src/compiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EACL,KAAK,GAMN,MAAM,SAAS,CAAC;AAEjB,0FAA0F;AAC1F,MAAM,CAAC,MAAM,mCAAmC,GAAG,8BAAuC,CAAC;AAE3F,MAAM,wBAAw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,CAAC,EAAE;KACjD,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CACvB,MAAwC;IAExC,OAAO,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,YAAY,UAAU,CAAC,CAAC;AACvE,CAAC;AAED,SAAS,UAAU,CAAC,MAAkB;IACpC,OAAO,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAClE,CAAC;AAED,SAAS,kBAAkB,CAAC,UAAkB;IAC5C,OAAO,UAAU,CAAC,OAAO,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAC;AACxD,CAAC;AAED,SAAS,UAAU,CAAI,KAAQ;IAC7B,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3E,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,KAAgC,CAAC,EAAE,CAAC;YACpE,UAAU,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC;QACD,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,137 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export declare const COMPONENTONCE_TRUSTED_BUNDLE_FORMAT: "componentonce.trusted-cjs.v1";
|
|
4
|
-
/** Source syntaxes accepted by the trusted compiler. */
|
|
5
|
-
export type ComponentOnceSourceLoader = "js" | "jsx" | "ts" | "tsx";
|
|
6
|
-
/** JSX transform mode forwarded to esbuild by the generic compiler. */
|
|
7
|
-
export type ComponentOnceJsxMode = "transform" | "preserve" | "automatic";
|
|
8
|
-
/** Input for compiling one trusted JavaScript or TypeScript module. */
|
|
9
|
-
export interface ComponentOnceCompileInput {
|
|
10
|
-
/** TypeScript, TSX, JavaScript, or JSX module source. */
|
|
11
|
-
readonly source: string;
|
|
12
|
-
/** Stable diagnostic/source-map name. */
|
|
13
|
-
readonly sourceFileName?: string;
|
|
14
|
-
/** Explicit source syntax, otherwise inferred from sourceFileName. */
|
|
15
|
-
readonly loader?: ComponentOnceSourceLoader;
|
|
16
|
-
/** Exact import specifiers the host will inject during instantiation. */
|
|
17
|
-
readonly externalModules?: readonly string[];
|
|
18
|
-
/** JSX transform mode; generic compilation defaults to transform. */
|
|
19
|
-
readonly jsx?: ComponentOnceJsxMode;
|
|
20
|
-
}
|
|
21
|
-
/** React convenience compiler input; React externals are supplied by the wrapper. */
|
|
22
|
-
export interface ComponentOnceReactCompileInput {
|
|
23
|
-
readonly source: string;
|
|
24
|
-
readonly sourceFileName?: string;
|
|
25
|
-
readonly loader?: ComponentOnceSourceLoader;
|
|
26
|
-
/** Additional non-React host externals. */
|
|
27
|
-
readonly additionalExternalModules?: readonly string[];
|
|
28
|
-
}
|
|
29
|
-
/** Source location attached to a normalized compiler diagnostic. */
|
|
30
|
-
export interface ComponentOnceDiagnosticLocation {
|
|
31
|
-
/** Source file name supplied to the compiler. */
|
|
32
|
-
readonly file: string;
|
|
33
|
-
/** One-based source line. */
|
|
34
|
-
readonly line: number;
|
|
35
|
-
/** Zero-based source column. */
|
|
36
|
-
readonly column: number;
|
|
37
|
-
/** Length of the highlighted source range. */
|
|
38
|
-
readonly length: number;
|
|
39
|
-
/** Full source line associated with the diagnostic. */
|
|
40
|
-
readonly lineText: string;
|
|
41
|
-
}
|
|
42
|
-
/** Secondary explanatory note attached to a compiler diagnostic. */
|
|
43
|
-
export interface ComponentOnceDiagnosticNote {
|
|
44
|
-
/** Human-readable note. */
|
|
45
|
-
readonly text: string;
|
|
46
|
-
/** Source location when esbuild can identify one. */
|
|
47
|
-
readonly location?: ComponentOnceDiagnosticLocation;
|
|
48
|
-
}
|
|
49
|
-
/** Storage-neutral compiler warning or error. */
|
|
50
|
-
export interface ComponentOnceDiagnostic {
|
|
51
|
-
/** Diagnostic severity. */
|
|
52
|
-
readonly kind: "error" | "warning";
|
|
53
|
-
/** Human-readable diagnostic text. */
|
|
54
|
-
readonly text: string;
|
|
55
|
-
/** Primary source location when available. */
|
|
56
|
-
readonly location?: ComponentOnceDiagnosticLocation;
|
|
57
|
-
/** Supporting notes supplied by esbuild. */
|
|
58
|
-
readonly notes: readonly ComponentOnceDiagnosticNote[];
|
|
59
|
-
}
|
|
60
|
-
/** Read-only esbuild metadata describing the emitted bundle and its external imports. */
|
|
61
|
-
export type ComponentOnceBundleMetafile = Readonly<Metafile>;
|
|
62
|
-
/** Immutable, storage-neutral output of the trusted module compiler. */
|
|
63
|
-
export interface ComponentOnceTrustedBundleArtifact {
|
|
64
|
-
/** Bundle contract understood by `instantiateTrustedBundle`. */
|
|
65
|
-
readonly format: typeof COMPONENTONCE_TRUSTED_BUNDLE_FORMAT;
|
|
66
|
-
/** Executable CommonJS bundle text. */
|
|
67
|
-
readonly code: string;
|
|
68
|
-
/** UTF-8 byte length of `code`. */
|
|
69
|
-
readonly byteLength: number;
|
|
70
|
-
/** Lowercase hexadecimal SHA-256 digest of `code`. */
|
|
71
|
-
readonly sha256: string;
|
|
72
|
-
/** Subresource-integrity-style SHA-256 value for `code`. */
|
|
73
|
-
readonly integrity: string;
|
|
74
|
-
/** Exact external module specifiers referenced by the emitted bundle. */
|
|
75
|
-
readonly externalModules: readonly string[];
|
|
76
|
-
/** Normalized non-fatal compiler diagnostics. */
|
|
77
|
-
readonly diagnostics: readonly ComponentOnceDiagnostic[];
|
|
78
|
-
/** esbuild metadata for dependency and output inspection. */
|
|
79
|
-
readonly metafile: ComponentOnceBundleMetafile;
|
|
80
|
-
}
|
|
81
|
-
/** Compilation failure with stable, normalized esbuild diagnostics. */
|
|
82
|
-
export declare class ComponentOnceCompileError extends Error {
|
|
83
|
-
/** Compiler errors that caused the build to fail. */
|
|
84
|
-
readonly diagnostics: readonly ComponentOnceDiagnostic[];
|
|
85
|
-
constructor(diagnostics: readonly ComponentOnceDiagnostic[]);
|
|
86
|
-
}
|
|
87
|
-
/** Exact host-owned module values exposed to a trusted bundle's local `require`. */
|
|
88
|
-
export type ComponentOnceHostExternals = Readonly<Record<string, unknown>>;
|
|
89
|
-
/** JavaScript text, UTF-8 bytes, or an in-memory artifact accepted by the trusted evaluator. */
|
|
90
|
-
export type ComponentOnceTrustedBundleSource = string | Uint8Array | ComponentOnceTrustedBundleArtifact;
|
|
91
|
-
/** Options controlling explicit external injection and optional integrity verification. */
|
|
92
|
-
export interface InstantiateTrustedBundleOptions {
|
|
93
|
-
/** Exact external values, including the host's React and JSX runtime instances. */
|
|
94
|
-
readonly externals: ComponentOnceHostExternals;
|
|
95
|
-
/** Expected integrity for separately loaded text/bytes; artifacts verify their own value by default. */
|
|
96
|
-
readonly expectedIntegrity?: string;
|
|
97
|
-
/** Debugger-only source name appended to the evaluated bundle. */
|
|
98
|
-
readonly sourceName?: string;
|
|
99
|
-
}
|
|
100
|
-
/** Deterministic error raised when a bundle requests an external the host did not inject. */
|
|
101
|
-
export declare class ComponentOnceMissingExternalError extends Error {
|
|
102
|
-
/** Exact module specifier requested by the bundle. */
|
|
103
|
-
readonly specifier: string;
|
|
104
|
-
/** Sorted external specifiers supplied by the host. */
|
|
105
|
-
readonly availableExternals: readonly string[];
|
|
106
|
-
constructor(specifier: string, availableExternals: readonly string[]);
|
|
107
|
-
}
|
|
108
|
-
/** Error raised when loaded bundle content does not match its expected SHA-256 integrity. */
|
|
109
|
-
export declare class ComponentOnceIntegrityError extends Error {
|
|
110
|
-
/** Expected subresource-integrity-style SHA-256 value. */
|
|
111
|
-
readonly expectedIntegrity: string;
|
|
112
|
-
/** Actual subresource-integrity-style SHA-256 value. */
|
|
113
|
-
readonly actualIntegrity: string;
|
|
114
|
-
constructor(expectedIntegrity: string, actualIntegrity: string);
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Compile one trusted module into a deterministic CommonJS artifact.
|
|
118
|
-
*
|
|
119
|
-
* Only caller-declared imports remain external. This generic path does not add React or any other
|
|
120
|
-
* runtime implicitly; every external must be injected explicitly by the host at instantiation.
|
|
121
|
-
*/
|
|
122
|
-
export declare function compileTrustedModule(input: ComponentOnceCompileInput): Promise<ComponentOnceTrustedBundleArtifact>;
|
|
123
|
-
/** Compile a trusted React module while keeping the host React singleton external. */
|
|
124
|
-
export declare function compileTrustedReactModule(input: ComponentOnceReactCompileInput): Promise<ComponentOnceTrustedBundleArtifact>;
|
|
125
|
-
/** Calculate a subresource-integrity-style SHA-256 value for bundle text or UTF-8 bytes. */
|
|
126
|
-
export declare function calculateTrustedBundleIntegrity(source: string | Uint8Array): string;
|
|
127
|
-
/** Throw when bundle text or bytes do not match an expected SHA-256 integrity value. */
|
|
128
|
-
export declare function assertTrustedBundleIntegrity(source: string | Uint8Array, expectedIntegrity: string): void;
|
|
129
|
-
/**
|
|
130
|
-
* Execute a trusted bundle with a deliberately narrow CommonJS environment.
|
|
131
|
-
*
|
|
132
|
-
* This API uses `new Function` and is only for trusted internal code. It is not a sandbox: evaluated
|
|
133
|
-
* code retains access to JavaScript globals. The only available `require` values are provided by
|
|
134
|
-
* `options.externals`, so React is always the exact instance selected by the host.
|
|
135
|
-
*/
|
|
136
|
-
export declare function instantiateTrustedBundle<TExports = Record<string, unknown>>(source: ComponentOnceTrustedBundleSource, options: InstantiateTrustedBundleOptions): TExports;
|
|
1
|
+
export * from "./compiler.js";
|
|
2
|
+
export * from "./package.js";
|
|
137
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC"}
|