@renderify/ir 0.1.0
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/LICENSE +21 -0
- package/README.md +55 -0
- package/dist/ir.cjs.js +576 -0
- package/dist/ir.cjs.js.map +1 -0
- package/dist/ir.d.mts +175 -0
- package/dist/ir.d.ts +175 -0
- package/dist/ir.esm.js +556 -0
- package/dist/ir.esm.js.map +1 -0
- package/package.json +57 -0
package/dist/ir.esm.js
ADDED
|
@@ -0,0 +1,556 @@
|
|
|
1
|
+
// src/hash.ts
|
|
2
|
+
var FNV1A_64_OFFSET_BASIS = 0xcbf29ce484222325n;
|
|
3
|
+
var FNV1A_64_PRIME = 0x100000001b3n;
|
|
4
|
+
var UINT64_MASK = 0xffffffffffffffffn;
|
|
5
|
+
function createFnv1a64Hasher() {
|
|
6
|
+
let hash = FNV1A_64_OFFSET_BASIS;
|
|
7
|
+
return {
|
|
8
|
+
update: (chunk) => {
|
|
9
|
+
for (let index = 0; index < chunk.length; index += 1) {
|
|
10
|
+
hash ^= BigInt(chunk.charCodeAt(index));
|
|
11
|
+
hash = hash * FNV1A_64_PRIME & UINT64_MASK;
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
digestHex: () => hash.toString(16)
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function hashStringFNV1a64Hex(value) {
|
|
18
|
+
const hasher = createFnv1a64Hasher();
|
|
19
|
+
hasher.update(value);
|
|
20
|
+
return hasher.digestHex();
|
|
21
|
+
}
|
|
22
|
+
function hashStringFNV1a32(value) {
|
|
23
|
+
let hash = 2166136261;
|
|
24
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
25
|
+
hash ^= value.charCodeAt(index);
|
|
26
|
+
hash += (hash << 1) + (hash << 4) + (hash << 7) + (hash << 8) + (hash << 24);
|
|
27
|
+
}
|
|
28
|
+
return hash >>> 0;
|
|
29
|
+
}
|
|
30
|
+
function hashStringFNV1a32Base36(value) {
|
|
31
|
+
return hashStringFNV1a32(value).toString(36);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// src/source-imports.ts
|
|
35
|
+
import {
|
|
36
|
+
init as initModuleLexer,
|
|
37
|
+
parse as parseModuleImports
|
|
38
|
+
} from "es-module-lexer";
|
|
39
|
+
var SOURCE_IMPORT_REWRITE_PATTERNS = [
|
|
40
|
+
/\bfrom\s+["']([^"']+)["']/g,
|
|
41
|
+
/\bimport\s+["']([^"']+)["']/g,
|
|
42
|
+
/\bimport\s*\(\s*["']([^"']+)["']\s*\)/g
|
|
43
|
+
];
|
|
44
|
+
async function parseRuntimeSourceImportRanges(source) {
|
|
45
|
+
if (source.trim().length === 0) {
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
await initModuleLexer;
|
|
50
|
+
const [imports] = parseModuleImports(source);
|
|
51
|
+
const parsed = [];
|
|
52
|
+
for (const entry of imports) {
|
|
53
|
+
const specifier = entry.n?.trim();
|
|
54
|
+
if (!specifier) {
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
if (entry.s < 0 || entry.e <= entry.s) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
parsed.push({
|
|
61
|
+
start: entry.s,
|
|
62
|
+
end: entry.e,
|
|
63
|
+
specifier
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
return parsed.sort((left, right) => left.start - right.start);
|
|
67
|
+
} catch {
|
|
68
|
+
return parseRuntimeSourceImportRangesFromRegex(source);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async function collectRuntimeSourceImports(source) {
|
|
72
|
+
const ranges = await parseRuntimeSourceImportRanges(source);
|
|
73
|
+
const imports = /* @__PURE__ */ new Set();
|
|
74
|
+
for (const entry of ranges) {
|
|
75
|
+
imports.add(entry.specifier);
|
|
76
|
+
}
|
|
77
|
+
return [...imports];
|
|
78
|
+
}
|
|
79
|
+
function parseRuntimeSourceImportRangesFromRegex(source) {
|
|
80
|
+
const parsed = /* @__PURE__ */ new Map();
|
|
81
|
+
for (const pattern of SOURCE_IMPORT_REWRITE_PATTERNS) {
|
|
82
|
+
const regex = new RegExp(
|
|
83
|
+
pattern.source,
|
|
84
|
+
pattern.flags.includes("g") ? pattern.flags : `${pattern.flags}g`
|
|
85
|
+
);
|
|
86
|
+
let match = regex.exec(source);
|
|
87
|
+
while (match) {
|
|
88
|
+
const fullMatch = String(match[0] ?? "");
|
|
89
|
+
const capturedSpecifier = String(match[1] ?? "").trim();
|
|
90
|
+
if (capturedSpecifier.length === 0) {
|
|
91
|
+
match = regex.exec(source);
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
const relativeIndex = fullMatch.indexOf(capturedSpecifier);
|
|
95
|
+
if (relativeIndex < 0) {
|
|
96
|
+
match = regex.exec(source);
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
const start = match.index + relativeIndex;
|
|
100
|
+
const end = start + capturedSpecifier.length;
|
|
101
|
+
parsed.set(`${start}:${end}`, {
|
|
102
|
+
start,
|
|
103
|
+
end,
|
|
104
|
+
specifier: capturedSpecifier
|
|
105
|
+
});
|
|
106
|
+
match = regex.exec(source);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return [...parsed.values()].sort((left, right) => left.start - right.start);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// src/index.ts
|
|
113
|
+
var DEFAULT_JSPM_SPECIFIER_OVERRIDES = Object.freeze({
|
|
114
|
+
preact: "https://ga.jspm.io/npm:preact@10.28.3/dist/preact.module.js",
|
|
115
|
+
"preact/hooks": "https://ga.jspm.io/npm:preact@10.28.3/hooks/dist/hooks.module.js",
|
|
116
|
+
"preact/compat": "https://ga.jspm.io/npm:preact@10.28.3/compat/dist/compat.module.js",
|
|
117
|
+
"preact/jsx-runtime": "https://ga.jspm.io/npm:preact@10.28.3/jsx-runtime/dist/jsxRuntime.module.js",
|
|
118
|
+
react: "https://ga.jspm.io/npm:preact@10.28.3/compat/dist/compat.module.js",
|
|
119
|
+
"react-dom": "https://ga.jspm.io/npm:preact@10.28.3/compat/dist/compat.module.js",
|
|
120
|
+
"react-dom/client": "https://ga.jspm.io/npm:preact@10.28.3/compat/dist/compat.module.js",
|
|
121
|
+
"react/jsx-runtime": "https://ga.jspm.io/npm:preact@10.28.3/jsx-runtime/dist/jsxRuntime.module.js",
|
|
122
|
+
"react/jsx-dev-runtime": "https://ga.jspm.io/npm:preact@10.28.3/jsx-runtime/dist/jsxRuntime.module.js",
|
|
123
|
+
recharts: "https://ga.jspm.io/npm:recharts@3.3.0/es6/index.js"
|
|
124
|
+
});
|
|
125
|
+
var RUNTIME_PLAN_SPEC_VERSION_V1 = "runtime-plan/v1";
|
|
126
|
+
var DEFAULT_RUNTIME_PLAN_SPEC_VERSION = RUNTIME_PLAN_SPEC_VERSION_V1;
|
|
127
|
+
function createTextNode(value) {
|
|
128
|
+
return { type: "text", value };
|
|
129
|
+
}
|
|
130
|
+
function createElementNode(tag, props, children) {
|
|
131
|
+
return { type: "element", tag, props, children };
|
|
132
|
+
}
|
|
133
|
+
function createComponentNode(module, exportName = "default", props, children) {
|
|
134
|
+
return { type: "component", module, exportName, props, children };
|
|
135
|
+
}
|
|
136
|
+
function isRuntimeNode(value) {
|
|
137
|
+
if (typeof value !== "object" || value === null) {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
const candidate = value;
|
|
141
|
+
if (candidate.type === "text") {
|
|
142
|
+
return typeof candidate.value === "string";
|
|
143
|
+
}
|
|
144
|
+
if (candidate.type === "element") {
|
|
145
|
+
return typeof candidate.tag === "string";
|
|
146
|
+
}
|
|
147
|
+
if (candidate.type === "component") {
|
|
148
|
+
return typeof candidate.module === "string";
|
|
149
|
+
}
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
function isJsonValue(value) {
|
|
153
|
+
return isJsonValueInternal(value, /* @__PURE__ */ new Set());
|
|
154
|
+
}
|
|
155
|
+
function isRuntimeValueFromPath(value) {
|
|
156
|
+
if (typeof value !== "object" || value === null) {
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
const candidate = value;
|
|
160
|
+
return typeof candidate.$from === "string";
|
|
161
|
+
}
|
|
162
|
+
function isRuntimeAction(value) {
|
|
163
|
+
if (!isRecord(value)) {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
if (typeof value.path !== "string" || value.path.trim().length === 0) {
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
if (value.type === "set" || value.type === "push") {
|
|
170
|
+
return "value" in value && (isJsonValue(value.value) || isRuntimeValueFromPath(value.value));
|
|
171
|
+
}
|
|
172
|
+
if (value.type === "increment") {
|
|
173
|
+
return value.by === void 0 || typeof value.by === "number" && Number.isFinite(value.by);
|
|
174
|
+
}
|
|
175
|
+
if (value.type === "toggle") {
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
function isRuntimeStateSnapshot(value) {
|
|
181
|
+
if (!isRecord(value)) {
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
for (const entry of Object.values(value)) {
|
|
185
|
+
if (!isJsonValue(entry)) {
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
function isRuntimeStateModel(value) {
|
|
192
|
+
if (!isRecord(value)) {
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
if (!isRuntimeStateSnapshot(value.initial)) {
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
if (value.transitions === void 0) {
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
201
|
+
if (!isRecord(value.transitions)) {
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
for (const [eventType, actions] of Object.entries(value.transitions)) {
|
|
205
|
+
if (eventType.trim().length === 0) {
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
if (!Array.isArray(actions)) {
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
for (const action of actions) {
|
|
212
|
+
if (!isRuntimeAction(action)) {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
219
|
+
function isRuntimeCapabilities(value) {
|
|
220
|
+
if (!isRecord(value)) {
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
223
|
+
if (value.domWrite !== void 0 && typeof value.domWrite !== "boolean") {
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
if (value.networkHosts !== void 0 && (!Array.isArray(value.networkHosts) || value.networkHosts.some((entry) => typeof entry !== "string"))) {
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
if (value.allowedModules !== void 0 && (!Array.isArray(value.allowedModules) || value.allowedModules.some((entry) => typeof entry !== "string"))) {
|
|
230
|
+
return false;
|
|
231
|
+
}
|
|
232
|
+
if (value.timers !== void 0 && typeof value.timers !== "boolean") {
|
|
233
|
+
return false;
|
|
234
|
+
}
|
|
235
|
+
if (value.executionProfile !== void 0 && value.executionProfile !== "standard" && value.executionProfile !== "isolated-vm" && value.executionProfile !== "sandbox-worker" && value.executionProfile !== "sandbox-iframe") {
|
|
236
|
+
return false;
|
|
237
|
+
}
|
|
238
|
+
if (value.storage !== void 0 && (!Array.isArray(value.storage) || value.storage.some(
|
|
239
|
+
(entry) => entry !== "localStorage" && entry !== "sessionStorage"
|
|
240
|
+
))) {
|
|
241
|
+
return false;
|
|
242
|
+
}
|
|
243
|
+
if (!isFiniteNonNegativeNumber(value.maxImports)) {
|
|
244
|
+
return false;
|
|
245
|
+
}
|
|
246
|
+
if (!isFiniteNonNegativeNumber(value.maxComponentInvocations)) {
|
|
247
|
+
return false;
|
|
248
|
+
}
|
|
249
|
+
if (value.maxExecutionMs !== void 0 && (typeof value.maxExecutionMs !== "number" || !Number.isFinite(value.maxExecutionMs) || value.maxExecutionMs < 1)) {
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
return true;
|
|
253
|
+
}
|
|
254
|
+
function isRuntimeSourceLanguage(value) {
|
|
255
|
+
return value === "js" || value === "jsx" || value === "ts" || value === "tsx";
|
|
256
|
+
}
|
|
257
|
+
function isRuntimeSourceRuntime(value) {
|
|
258
|
+
return value === "renderify" || value === "preact";
|
|
259
|
+
}
|
|
260
|
+
function isRuntimeSourceModule(value) {
|
|
261
|
+
if (!isRecord(value)) {
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
if (typeof value.code !== "string" || value.code.trim().length === 0) {
|
|
265
|
+
return false;
|
|
266
|
+
}
|
|
267
|
+
if (!isRuntimeSourceLanguage(value.language)) {
|
|
268
|
+
return false;
|
|
269
|
+
}
|
|
270
|
+
if (value.exportName !== void 0 && (typeof value.exportName !== "string" || value.exportName.trim().length === 0)) {
|
|
271
|
+
return false;
|
|
272
|
+
}
|
|
273
|
+
if (value.runtime !== void 0 && !isRuntimeSourceRuntime(value.runtime)) {
|
|
274
|
+
return false;
|
|
275
|
+
}
|
|
276
|
+
return true;
|
|
277
|
+
}
|
|
278
|
+
function isRuntimePlanMetadata(value) {
|
|
279
|
+
if (!isRecord(value)) {
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
if (value.sourcePrompt !== void 0 && typeof value.sourcePrompt !== "string") {
|
|
283
|
+
return false;
|
|
284
|
+
}
|
|
285
|
+
if (value.sourceModel !== void 0 && typeof value.sourceModel !== "string") {
|
|
286
|
+
return false;
|
|
287
|
+
}
|
|
288
|
+
if (value.tags !== void 0 && (!Array.isArray(value.tags) || value.tags.some((entry) => typeof entry !== "string"))) {
|
|
289
|
+
return false;
|
|
290
|
+
}
|
|
291
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
292
|
+
if (key === "sourcePrompt" || key === "sourceModel" || key === "tags") {
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
if (entry !== void 0 && !isJsonValue(entry)) {
|
|
296
|
+
return false;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return true;
|
|
300
|
+
}
|
|
301
|
+
function isRuntimeEvent(value) {
|
|
302
|
+
if (!isRecord(value)) {
|
|
303
|
+
return false;
|
|
304
|
+
}
|
|
305
|
+
if (typeof value.type !== "string" || value.type.trim().length === 0) {
|
|
306
|
+
return false;
|
|
307
|
+
}
|
|
308
|
+
if (value.payload !== void 0 && !isRuntimeStateSnapshot(value.payload)) {
|
|
309
|
+
return false;
|
|
310
|
+
}
|
|
311
|
+
return true;
|
|
312
|
+
}
|
|
313
|
+
function isRuntimePlan(value) {
|
|
314
|
+
if (!isRecord(value)) {
|
|
315
|
+
return false;
|
|
316
|
+
}
|
|
317
|
+
if (typeof value.id !== "string" || value.id.trim().length === 0) {
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
320
|
+
if (typeof value.version !== "number" || !Number.isInteger(value.version) || value.version <= 0) {
|
|
321
|
+
return false;
|
|
322
|
+
}
|
|
323
|
+
if (!isRuntimeNode(value.root)) {
|
|
324
|
+
return false;
|
|
325
|
+
}
|
|
326
|
+
if (!isRuntimeCapabilities(value.capabilities)) {
|
|
327
|
+
return false;
|
|
328
|
+
}
|
|
329
|
+
if (value.specVersion !== void 0 && (typeof value.specVersion !== "string" || value.specVersion.trim().length === 0)) {
|
|
330
|
+
return false;
|
|
331
|
+
}
|
|
332
|
+
if (value.imports !== void 0 && (!Array.isArray(value.imports) || value.imports.some((entry) => typeof entry !== "string"))) {
|
|
333
|
+
return false;
|
|
334
|
+
}
|
|
335
|
+
if (value.moduleManifest !== void 0 && !isRuntimeModuleManifest(value.moduleManifest)) {
|
|
336
|
+
return false;
|
|
337
|
+
}
|
|
338
|
+
if (value.state !== void 0 && !isRuntimeStateModel(value.state)) {
|
|
339
|
+
return false;
|
|
340
|
+
}
|
|
341
|
+
if (value.source !== void 0 && !isRuntimeSourceModule(value.source)) {
|
|
342
|
+
return false;
|
|
343
|
+
}
|
|
344
|
+
if (value.metadata !== void 0 && !isRuntimePlanMetadata(value.metadata)) {
|
|
345
|
+
return false;
|
|
346
|
+
}
|
|
347
|
+
return true;
|
|
348
|
+
}
|
|
349
|
+
function isRuntimeModuleDescriptor(value) {
|
|
350
|
+
if (!isRecord(value)) {
|
|
351
|
+
return false;
|
|
352
|
+
}
|
|
353
|
+
if (typeof value.resolvedUrl !== "string" || value.resolvedUrl.trim().length === 0) {
|
|
354
|
+
return false;
|
|
355
|
+
}
|
|
356
|
+
if (value.integrity !== void 0 && (typeof value.integrity !== "string" || value.integrity.trim().length === 0)) {
|
|
357
|
+
return false;
|
|
358
|
+
}
|
|
359
|
+
if (value.version !== void 0 && (typeof value.version !== "string" || value.version.trim().length === 0)) {
|
|
360
|
+
return false;
|
|
361
|
+
}
|
|
362
|
+
if (value.signer !== void 0 && (typeof value.signer !== "string" || value.signer.trim().length === 0)) {
|
|
363
|
+
return false;
|
|
364
|
+
}
|
|
365
|
+
return true;
|
|
366
|
+
}
|
|
367
|
+
function isRuntimeModuleManifest(value) {
|
|
368
|
+
if (!isRecord(value)) {
|
|
369
|
+
return false;
|
|
370
|
+
}
|
|
371
|
+
for (const [specifier, descriptor] of Object.entries(value)) {
|
|
372
|
+
if (specifier.trim().length === 0) {
|
|
373
|
+
return false;
|
|
374
|
+
}
|
|
375
|
+
if (!isRuntimeModuleDescriptor(descriptor)) {
|
|
376
|
+
return false;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
return true;
|
|
380
|
+
}
|
|
381
|
+
function resolveRuntimePlanSpecVersion(specVersion) {
|
|
382
|
+
if (typeof specVersion === "string" && specVersion.trim().length > 0) {
|
|
383
|
+
return specVersion.trim();
|
|
384
|
+
}
|
|
385
|
+
return DEFAULT_RUNTIME_PLAN_SPEC_VERSION;
|
|
386
|
+
}
|
|
387
|
+
function walkRuntimeNode(node, visitor, depth = 0) {
|
|
388
|
+
visitor(node, depth);
|
|
389
|
+
const children = node.type === "text" ? void 0 : node.children;
|
|
390
|
+
if (!children || children.length === 0) {
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
for (const child of children) {
|
|
394
|
+
walkRuntimeNode(child, visitor, depth + 1);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
function collectComponentModules(root) {
|
|
398
|
+
const modules = /* @__PURE__ */ new Set();
|
|
399
|
+
walkRuntimeNode(root, (node) => {
|
|
400
|
+
if (node.type === "component") {
|
|
401
|
+
modules.add(node.module);
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
return [...modules];
|
|
405
|
+
}
|
|
406
|
+
function splitPath(path) {
|
|
407
|
+
return path.split(".").map((segment) => segment.trim()).filter((segment) => segment.length > 0);
|
|
408
|
+
}
|
|
409
|
+
function isSafePath(path) {
|
|
410
|
+
const segments = splitPath(path);
|
|
411
|
+
if (segments.length === 0) {
|
|
412
|
+
return false;
|
|
413
|
+
}
|
|
414
|
+
for (const segment of segments) {
|
|
415
|
+
if (segment === "__proto__" || segment === "prototype" || segment === "constructor") {
|
|
416
|
+
return false;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
return true;
|
|
420
|
+
}
|
|
421
|
+
function getValueByPath(source, path) {
|
|
422
|
+
const segments = splitPath(path);
|
|
423
|
+
if (segments.length === 0) {
|
|
424
|
+
return void 0;
|
|
425
|
+
}
|
|
426
|
+
let cursor = source;
|
|
427
|
+
for (const segment of segments) {
|
|
428
|
+
if (typeof cursor !== "object" || cursor === null) {
|
|
429
|
+
return void 0;
|
|
430
|
+
}
|
|
431
|
+
cursor = cursor[segment];
|
|
432
|
+
}
|
|
433
|
+
return cursor;
|
|
434
|
+
}
|
|
435
|
+
function setValueByPath(target, path, value) {
|
|
436
|
+
const segments = splitPath(path);
|
|
437
|
+
if (segments.length === 0) {
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
let cursor = target;
|
|
441
|
+
for (let i = 0; i < segments.length; i += 1) {
|
|
442
|
+
const segment = segments[i];
|
|
443
|
+
const isLast = i === segments.length - 1;
|
|
444
|
+
if (isLast) {
|
|
445
|
+
cursor[segment] = value;
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
const next = cursor[segment];
|
|
449
|
+
if (typeof next !== "object" || next === null || Array.isArray(next)) {
|
|
450
|
+
cursor[segment] = {};
|
|
451
|
+
}
|
|
452
|
+
cursor = cursor[segment];
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
function cloneJsonValue(value) {
|
|
456
|
+
if (typeof globalThis.structuredClone === "function") {
|
|
457
|
+
return globalThis.structuredClone(value);
|
|
458
|
+
}
|
|
459
|
+
return JSON.parse(JSON.stringify(value));
|
|
460
|
+
}
|
|
461
|
+
function asJsonValue(value) {
|
|
462
|
+
if (value === void 0) {
|
|
463
|
+
return null;
|
|
464
|
+
}
|
|
465
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") {
|
|
466
|
+
return value;
|
|
467
|
+
}
|
|
468
|
+
if (typeof value === "number") {
|
|
469
|
+
return Number.isFinite(value) ? value : null;
|
|
470
|
+
}
|
|
471
|
+
if (Array.isArray(value)) {
|
|
472
|
+
return value.map((item) => asJsonValue(item));
|
|
473
|
+
}
|
|
474
|
+
if (typeof value === "object" && value !== null) {
|
|
475
|
+
const result = {};
|
|
476
|
+
for (const [key, item] of Object.entries(value)) {
|
|
477
|
+
result[key] = asJsonValue(item);
|
|
478
|
+
}
|
|
479
|
+
return result;
|
|
480
|
+
}
|
|
481
|
+
return String(value);
|
|
482
|
+
}
|
|
483
|
+
function isRecord(value) {
|
|
484
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
485
|
+
}
|
|
486
|
+
function isFiniteNonNegativeNumber(value) {
|
|
487
|
+
return value === void 0 || typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
488
|
+
}
|
|
489
|
+
function isJsonValueInternal(value, seen) {
|
|
490
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") {
|
|
491
|
+
return true;
|
|
492
|
+
}
|
|
493
|
+
if (typeof value === "number") {
|
|
494
|
+
return Number.isFinite(value);
|
|
495
|
+
}
|
|
496
|
+
if (Array.isArray(value)) {
|
|
497
|
+
if (seen.has(value)) {
|
|
498
|
+
return false;
|
|
499
|
+
}
|
|
500
|
+
seen.add(value);
|
|
501
|
+
const valid = value.every((entry) => isJsonValueInternal(entry, seen));
|
|
502
|
+
seen.delete(value);
|
|
503
|
+
return valid;
|
|
504
|
+
}
|
|
505
|
+
if (isRecord(value)) {
|
|
506
|
+
if (seen.has(value)) {
|
|
507
|
+
return false;
|
|
508
|
+
}
|
|
509
|
+
seen.add(value);
|
|
510
|
+
const valid = Object.values(value).every(
|
|
511
|
+
(entry) => isJsonValueInternal(entry, seen)
|
|
512
|
+
);
|
|
513
|
+
seen.delete(value);
|
|
514
|
+
return valid;
|
|
515
|
+
}
|
|
516
|
+
return false;
|
|
517
|
+
}
|
|
518
|
+
export {
|
|
519
|
+
DEFAULT_JSPM_SPECIFIER_OVERRIDES,
|
|
520
|
+
DEFAULT_RUNTIME_PLAN_SPEC_VERSION,
|
|
521
|
+
RUNTIME_PLAN_SPEC_VERSION_V1,
|
|
522
|
+
asJsonValue,
|
|
523
|
+
cloneJsonValue,
|
|
524
|
+
collectComponentModules,
|
|
525
|
+
collectRuntimeSourceImports,
|
|
526
|
+
createComponentNode,
|
|
527
|
+
createElementNode,
|
|
528
|
+
createFnv1a64Hasher,
|
|
529
|
+
createTextNode,
|
|
530
|
+
getValueByPath,
|
|
531
|
+
hashStringFNV1a32,
|
|
532
|
+
hashStringFNV1a32Base36,
|
|
533
|
+
hashStringFNV1a64Hex,
|
|
534
|
+
isJsonValue,
|
|
535
|
+
isRuntimeAction,
|
|
536
|
+
isRuntimeCapabilities,
|
|
537
|
+
isRuntimeEvent,
|
|
538
|
+
isRuntimeModuleDescriptor,
|
|
539
|
+
isRuntimeModuleManifest,
|
|
540
|
+
isRuntimeNode,
|
|
541
|
+
isRuntimePlan,
|
|
542
|
+
isRuntimePlanMetadata,
|
|
543
|
+
isRuntimeSourceLanguage,
|
|
544
|
+
isRuntimeSourceModule,
|
|
545
|
+
isRuntimeSourceRuntime,
|
|
546
|
+
isRuntimeStateModel,
|
|
547
|
+
isRuntimeStateSnapshot,
|
|
548
|
+
isRuntimeValueFromPath,
|
|
549
|
+
isSafePath,
|
|
550
|
+
parseRuntimeSourceImportRanges,
|
|
551
|
+
resolveRuntimePlanSpecVersion,
|
|
552
|
+
setValueByPath,
|
|
553
|
+
splitPath,
|
|
554
|
+
walkRuntimeNode
|
|
555
|
+
};
|
|
556
|
+
//# sourceMappingURL=ir.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hash.ts","../src/source-imports.ts","../src/index.ts"],"sourcesContent":["const FNV1A_64_OFFSET_BASIS = 0xcbf29ce484222325n;\nconst FNV1A_64_PRIME = 0x100000001b3n;\nconst UINT64_MASK = 0xffffffffffffffffn;\n\nexport interface Fnv1a64Hasher {\n update(chunk: string): void;\n digestHex(): string;\n}\n\nexport function createFnv1a64Hasher(): Fnv1a64Hasher {\n let hash = FNV1A_64_OFFSET_BASIS;\n\n return {\n update: (chunk: string) => {\n for (let index = 0; index < chunk.length; index += 1) {\n hash ^= BigInt(chunk.charCodeAt(index));\n hash = (hash * FNV1A_64_PRIME) & UINT64_MASK;\n }\n },\n digestHex: () => hash.toString(16),\n };\n}\n\nexport function hashStringFNV1a64Hex(value: string): string {\n const hasher = createFnv1a64Hasher();\n hasher.update(value);\n return hasher.digestHex();\n}\n\nexport function hashStringFNV1a32(value: string): number {\n let hash = 2166136261;\n for (let index = 0; index < value.length; index += 1) {\n hash ^= value.charCodeAt(index);\n // Equivalent to `hash *= 0x01000193` (FNV-1a 32-bit prime) via bit shifts.\n hash +=\n (hash << 1) + (hash << 4) + (hash << 7) + (hash << 8) + (hash << 24);\n }\n return hash >>> 0;\n}\n\nexport function hashStringFNV1a32Base36(value: string): string {\n return hashStringFNV1a32(value).toString(36);\n}\n","import {\n init as initModuleLexer,\n parse as parseModuleImports,\n} from \"es-module-lexer\";\n\nconst SOURCE_IMPORT_REWRITE_PATTERNS = [\n /\\bfrom\\s+[\"']([^\"']+)[\"']/g,\n /\\bimport\\s+[\"']([^\"']+)[\"']/g,\n /\\bimport\\s*\\(\\s*[\"']([^\"']+)[\"']\\s*\\)/g,\n] as const;\n\nexport interface RuntimeSourceImportRange {\n start: number;\n end: number;\n specifier: string;\n}\n\nexport async function parseRuntimeSourceImportRanges(\n source: string,\n): Promise<RuntimeSourceImportRange[]> {\n if (source.trim().length === 0) {\n return [];\n }\n\n try {\n await initModuleLexer;\n const [imports] = parseModuleImports(source);\n const parsed: RuntimeSourceImportRange[] = [];\n\n for (const entry of imports) {\n const specifier = entry.n?.trim();\n if (!specifier) {\n continue;\n }\n\n if (entry.s < 0 || entry.e <= entry.s) {\n continue;\n }\n\n parsed.push({\n start: entry.s,\n end: entry.e,\n specifier,\n });\n }\n\n return parsed.sort((left, right) => left.start - right.start);\n } catch {\n return parseRuntimeSourceImportRangesFromRegex(source);\n }\n}\n\nexport async function collectRuntimeSourceImports(\n source: string,\n): Promise<string[]> {\n const ranges = await parseRuntimeSourceImportRanges(source);\n const imports = new Set<string>();\n\n for (const entry of ranges) {\n imports.add(entry.specifier);\n }\n\n return [...imports];\n}\n\nfunction parseRuntimeSourceImportRangesFromRegex(\n source: string,\n): RuntimeSourceImportRange[] {\n const parsed = new Map<string, RuntimeSourceImportRange>();\n\n for (const pattern of SOURCE_IMPORT_REWRITE_PATTERNS) {\n const regex = new RegExp(\n pattern.source,\n pattern.flags.includes(\"g\") ? pattern.flags : `${pattern.flags}g`,\n );\n\n let match = regex.exec(source);\n while (match) {\n const fullMatch = String(match[0] ?? \"\");\n const capturedSpecifier = String(match[1] ?? \"\").trim();\n if (capturedSpecifier.length === 0) {\n match = regex.exec(source);\n continue;\n }\n\n const relativeIndex = fullMatch.indexOf(capturedSpecifier);\n if (relativeIndex < 0) {\n match = regex.exec(source);\n continue;\n }\n\n const start = match.index + relativeIndex;\n const end = start + capturedSpecifier.length;\n parsed.set(`${start}:${end}`, {\n start,\n end,\n specifier: capturedSpecifier,\n });\n\n match = regex.exec(source);\n }\n }\n\n return [...parsed.values()].sort((left, right) => left.start - right.start);\n}\n","export type JsonPrimitive = string | number | boolean | null;\n\nexport {\n createFnv1a64Hasher,\n type Fnv1a64Hasher,\n hashStringFNV1a32,\n hashStringFNV1a32Base36,\n hashStringFNV1a64Hex,\n} from \"./hash\";\nexport {\n collectRuntimeSourceImports,\n parseRuntimeSourceImportRanges,\n type RuntimeSourceImportRange,\n} from \"./source-imports\";\n\nexport type JsonValue = JsonPrimitive | JsonObject | JsonValue[];\n\nexport interface JsonObject {\n [key: string]: JsonValue;\n}\n\nexport interface RuntimeTextNode {\n type: \"text\";\n value: string;\n}\n\nexport interface RuntimeElementNode {\n type: \"element\";\n tag: string;\n props?: Record<string, JsonValue>;\n children?: RuntimeNode[];\n}\n\nexport interface RuntimeComponentNode {\n type: \"component\";\n module: string;\n exportName?: string;\n props?: Record<string, JsonValue>;\n children?: RuntimeNode[];\n}\n\nexport type RuntimeNode =\n | RuntimeTextNode\n | RuntimeElementNode\n | RuntimeComponentNode;\n\nexport type RuntimeExecutionProfile =\n | \"standard\"\n | \"isolated-vm\"\n | \"sandbox-worker\"\n | \"sandbox-iframe\";\n\nexport const DEFAULT_JSPM_SPECIFIER_OVERRIDES: Readonly<\n Record<string, string>\n> = Object.freeze({\n preact: \"https://ga.jspm.io/npm:preact@10.28.3/dist/preact.module.js\",\n \"preact/hooks\":\n \"https://ga.jspm.io/npm:preact@10.28.3/hooks/dist/hooks.module.js\",\n \"preact/compat\":\n \"https://ga.jspm.io/npm:preact@10.28.3/compat/dist/compat.module.js\",\n \"preact/jsx-runtime\":\n \"https://ga.jspm.io/npm:preact@10.28.3/jsx-runtime/dist/jsxRuntime.module.js\",\n react: \"https://ga.jspm.io/npm:preact@10.28.3/compat/dist/compat.module.js\",\n \"react-dom\":\n \"https://ga.jspm.io/npm:preact@10.28.3/compat/dist/compat.module.js\",\n \"react-dom/client\":\n \"https://ga.jspm.io/npm:preact@10.28.3/compat/dist/compat.module.js\",\n \"react/jsx-runtime\":\n \"https://ga.jspm.io/npm:preact@10.28.3/jsx-runtime/dist/jsxRuntime.module.js\",\n \"react/jsx-dev-runtime\":\n \"https://ga.jspm.io/npm:preact@10.28.3/jsx-runtime/dist/jsxRuntime.module.js\",\n recharts: \"https://ga.jspm.io/npm:recharts@3.3.0/es6/index.js\",\n});\n\nexport type RuntimeSourceLanguage = \"js\" | \"jsx\" | \"ts\" | \"tsx\";\nexport type RuntimeSourceRuntime = \"renderify\" | \"preact\";\n\nexport interface RuntimeSourceModule {\n code: string;\n language: RuntimeSourceLanguage;\n exportName?: string;\n runtime?: RuntimeSourceRuntime;\n}\n\nexport const RUNTIME_PLAN_SPEC_VERSION_V1 = \"runtime-plan/v1\";\nexport const DEFAULT_RUNTIME_PLAN_SPEC_VERSION = RUNTIME_PLAN_SPEC_VERSION_V1;\n\nexport type RuntimePlanSpecVersion = typeof RUNTIME_PLAN_SPEC_VERSION_V1;\n\nexport interface RuntimeModuleDescriptor {\n resolvedUrl: string;\n integrity?: string;\n version?: string;\n signer?: string;\n}\n\nexport type RuntimeModuleManifest = Record<string, RuntimeModuleDescriptor>;\n\nexport interface RuntimeCapabilities {\n domWrite?: boolean;\n networkHosts?: string[];\n allowedModules?: string[];\n timers?: boolean;\n storage?: Array<\"localStorage\" | \"sessionStorage\">;\n executionProfile?: RuntimeExecutionProfile;\n maxImports?: number;\n maxComponentInvocations?: number;\n maxExecutionMs?: number;\n}\n\nexport interface RuntimeValueFromPath {\n $from: string;\n}\n\nexport type RuntimeActionValue = JsonValue | RuntimeValueFromPath;\n\nexport interface RuntimeSetAction {\n type: \"set\";\n path: string;\n value: RuntimeActionValue;\n}\n\nexport interface RuntimeIncrementAction {\n type: \"increment\";\n path: string;\n by?: number;\n}\n\nexport interface RuntimeToggleAction {\n type: \"toggle\";\n path: string;\n}\n\nexport interface RuntimePushAction {\n type: \"push\";\n path: string;\n value: RuntimeActionValue;\n}\n\nexport type RuntimeAction =\n | RuntimeSetAction\n | RuntimeIncrementAction\n | RuntimeToggleAction\n | RuntimePushAction;\n\nexport interface RuntimeEvent {\n type: string;\n payload?: Record<string, JsonValue>;\n}\n\nexport type RuntimeStateSnapshot = Record<string, JsonValue>;\n\nexport interface RuntimeStateModel {\n initial: RuntimeStateSnapshot;\n transitions?: Record<string, RuntimeAction[]>;\n}\n\nexport interface RuntimePlanMetadata {\n sourcePrompt?: string;\n sourceModel?: string;\n tags?: string[];\n [key: string]: JsonValue | undefined;\n}\n\nexport interface RuntimePlan {\n specVersion?: string;\n id: string;\n version: number;\n root: RuntimeNode;\n capabilities: RuntimeCapabilities;\n state?: RuntimeStateModel;\n imports?: string[];\n moduleManifest?: RuntimeModuleManifest;\n source?: RuntimeSourceModule;\n metadata?: RuntimePlanMetadata;\n}\n\nexport interface RuntimeExecutionContext {\n userId?: string;\n variables?: Record<string, JsonValue>;\n}\n\nexport interface RuntimeDiagnostic {\n level: \"info\" | \"warning\" | \"error\";\n code: string;\n message: string;\n}\n\nexport type RuntimeRenderArtifactMode = \"preact-vnode\";\n\nexport interface RuntimeRenderArtifact {\n mode: RuntimeRenderArtifactMode;\n payload: unknown;\n}\n\nexport interface RuntimeExecutionResult {\n planId: string;\n root: RuntimeNode;\n diagnostics: RuntimeDiagnostic[];\n state?: RuntimeStateSnapshot;\n handledEvent?: RuntimeEvent;\n appliedActions?: RuntimeAction[];\n renderArtifact?: RuntimeRenderArtifact;\n}\n\nexport function createTextNode(value: string): RuntimeTextNode {\n return { type: \"text\", value };\n}\n\nexport function createElementNode(\n tag: string,\n props?: Record<string, JsonValue>,\n children?: RuntimeNode[],\n): RuntimeElementNode {\n return { type: \"element\", tag, props, children };\n}\n\nexport function createComponentNode(\n module: string,\n exportName = \"default\",\n props?: Record<string, JsonValue>,\n children?: RuntimeNode[],\n): RuntimeComponentNode {\n return { type: \"component\", module, exportName, props, children };\n}\n\nexport function isRuntimeNode(value: unknown): value is RuntimeNode {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n\n const candidate = value as Partial<RuntimeNode>;\n\n if (candidate.type === \"text\") {\n return typeof (candidate as RuntimeTextNode).value === \"string\";\n }\n\n if (candidate.type === \"element\") {\n return typeof (candidate as RuntimeElementNode).tag === \"string\";\n }\n\n if (candidate.type === \"component\") {\n return typeof (candidate as RuntimeComponentNode).module === \"string\";\n }\n\n return false;\n}\n\nexport function isJsonValue(value: unknown): value is JsonValue {\n return isJsonValueInternal(value, new Set<object>());\n}\n\nexport function isRuntimeValueFromPath(\n value: unknown,\n): value is RuntimeValueFromPath {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n\n const candidate = value as Partial<RuntimeValueFromPath>;\n return typeof candidate.$from === \"string\";\n}\n\nexport function isRuntimeAction(value: unknown): value is RuntimeAction {\n if (!isRecord(value)) {\n return false;\n }\n\n if (typeof value.path !== \"string\" || value.path.trim().length === 0) {\n return false;\n }\n\n if (value.type === \"set\" || value.type === \"push\") {\n return (\n \"value\" in value &&\n (isJsonValue(value.value) || isRuntimeValueFromPath(value.value))\n );\n }\n\n if (value.type === \"increment\") {\n return (\n value.by === undefined ||\n (typeof value.by === \"number\" && Number.isFinite(value.by))\n );\n }\n\n if (value.type === \"toggle\") {\n return true;\n }\n\n return false;\n}\n\nexport function isRuntimeStateSnapshot(\n value: unknown,\n): value is RuntimeStateSnapshot {\n if (!isRecord(value)) {\n return false;\n }\n\n for (const entry of Object.values(value)) {\n if (!isJsonValue(entry)) {\n return false;\n }\n }\n\n return true;\n}\n\nexport function isRuntimeStateModel(\n value: unknown,\n): value is RuntimeStateModel {\n if (!isRecord(value)) {\n return false;\n }\n\n if (!isRuntimeStateSnapshot(value.initial)) {\n return false;\n }\n\n if (value.transitions === undefined) {\n return true;\n }\n\n if (!isRecord(value.transitions)) {\n return false;\n }\n\n for (const [eventType, actions] of Object.entries(value.transitions)) {\n if (eventType.trim().length === 0) {\n return false;\n }\n\n if (!Array.isArray(actions)) {\n return false;\n }\n\n for (const action of actions) {\n if (!isRuntimeAction(action)) {\n return false;\n }\n }\n }\n\n return true;\n}\n\nexport function isRuntimeCapabilities(\n value: unknown,\n): value is RuntimeCapabilities {\n if (!isRecord(value)) {\n return false;\n }\n\n if (value.domWrite !== undefined && typeof value.domWrite !== \"boolean\") {\n return false;\n }\n\n if (\n value.networkHosts !== undefined &&\n (!Array.isArray(value.networkHosts) ||\n value.networkHosts.some((entry) => typeof entry !== \"string\"))\n ) {\n return false;\n }\n\n if (\n value.allowedModules !== undefined &&\n (!Array.isArray(value.allowedModules) ||\n value.allowedModules.some((entry) => typeof entry !== \"string\"))\n ) {\n return false;\n }\n\n if (value.timers !== undefined && typeof value.timers !== \"boolean\") {\n return false;\n }\n\n if (\n value.executionProfile !== undefined &&\n value.executionProfile !== \"standard\" &&\n value.executionProfile !== \"isolated-vm\" &&\n value.executionProfile !== \"sandbox-worker\" &&\n value.executionProfile !== \"sandbox-iframe\"\n ) {\n return false;\n }\n\n if (\n value.storage !== undefined &&\n (!Array.isArray(value.storage) ||\n value.storage.some(\n (entry) => entry !== \"localStorage\" && entry !== \"sessionStorage\",\n ))\n ) {\n return false;\n }\n\n if (!isFiniteNonNegativeNumber(value.maxImports)) {\n return false;\n }\n\n if (!isFiniteNonNegativeNumber(value.maxComponentInvocations)) {\n return false;\n }\n\n if (\n value.maxExecutionMs !== undefined &&\n (typeof value.maxExecutionMs !== \"number\" ||\n !Number.isFinite(value.maxExecutionMs) ||\n value.maxExecutionMs < 1)\n ) {\n return false;\n }\n\n return true;\n}\n\nexport function isRuntimeSourceLanguage(\n value: unknown,\n): value is RuntimeSourceLanguage {\n return value === \"js\" || value === \"jsx\" || value === \"ts\" || value === \"tsx\";\n}\n\nexport function isRuntimeSourceRuntime(\n value: unknown,\n): value is RuntimeSourceRuntime {\n return value === \"renderify\" || value === \"preact\";\n}\n\nexport function isRuntimeSourceModule(\n value: unknown,\n): value is RuntimeSourceModule {\n if (!isRecord(value)) {\n return false;\n }\n\n if (typeof value.code !== \"string\" || value.code.trim().length === 0) {\n return false;\n }\n\n if (!isRuntimeSourceLanguage(value.language)) {\n return false;\n }\n\n if (\n value.exportName !== undefined &&\n (typeof value.exportName !== \"string\" ||\n value.exportName.trim().length === 0)\n ) {\n return false;\n }\n\n if (value.runtime !== undefined && !isRuntimeSourceRuntime(value.runtime)) {\n return false;\n }\n\n return true;\n}\n\nexport function isRuntimePlanMetadata(\n value: unknown,\n): value is RuntimePlanMetadata {\n if (!isRecord(value)) {\n return false;\n }\n\n if (\n value.sourcePrompt !== undefined &&\n typeof value.sourcePrompt !== \"string\"\n ) {\n return false;\n }\n\n if (\n value.sourceModel !== undefined &&\n typeof value.sourceModel !== \"string\"\n ) {\n return false;\n }\n\n if (\n value.tags !== undefined &&\n (!Array.isArray(value.tags) ||\n value.tags.some((entry) => typeof entry !== \"string\"))\n ) {\n return false;\n }\n\n for (const [key, entry] of Object.entries(value)) {\n if (key === \"sourcePrompt\" || key === \"sourceModel\" || key === \"tags\") {\n continue;\n }\n\n if (entry !== undefined && !isJsonValue(entry)) {\n return false;\n }\n }\n\n return true;\n}\n\nexport function isRuntimeEvent(value: unknown): value is RuntimeEvent {\n if (!isRecord(value)) {\n return false;\n }\n\n if (typeof value.type !== \"string\" || value.type.trim().length === 0) {\n return false;\n }\n\n if (value.payload !== undefined && !isRuntimeStateSnapshot(value.payload)) {\n return false;\n }\n\n return true;\n}\n\nexport function isRuntimePlan(value: unknown): value is RuntimePlan {\n if (!isRecord(value)) {\n return false;\n }\n\n if (typeof value.id !== \"string\" || value.id.trim().length === 0) {\n return false;\n }\n\n if (\n typeof value.version !== \"number\" ||\n !Number.isInteger(value.version) ||\n value.version <= 0\n ) {\n return false;\n }\n\n if (!isRuntimeNode(value.root)) {\n return false;\n }\n\n if (!isRuntimeCapabilities(value.capabilities)) {\n return false;\n }\n\n if (\n value.specVersion !== undefined &&\n (typeof value.specVersion !== \"string\" ||\n value.specVersion.trim().length === 0)\n ) {\n return false;\n }\n\n if (\n value.imports !== undefined &&\n (!Array.isArray(value.imports) ||\n value.imports.some((entry) => typeof entry !== \"string\"))\n ) {\n return false;\n }\n\n if (\n value.moduleManifest !== undefined &&\n !isRuntimeModuleManifest(value.moduleManifest)\n ) {\n return false;\n }\n\n if (value.state !== undefined && !isRuntimeStateModel(value.state)) {\n return false;\n }\n\n if (value.source !== undefined && !isRuntimeSourceModule(value.source)) {\n return false;\n }\n\n if (value.metadata !== undefined && !isRuntimePlanMetadata(value.metadata)) {\n return false;\n }\n\n return true;\n}\n\nexport function isRuntimeModuleDescriptor(\n value: unknown,\n): value is RuntimeModuleDescriptor {\n if (!isRecord(value)) {\n return false;\n }\n\n if (\n typeof value.resolvedUrl !== \"string\" ||\n value.resolvedUrl.trim().length === 0\n ) {\n return false;\n }\n\n if (\n value.integrity !== undefined &&\n (typeof value.integrity !== \"string\" || value.integrity.trim().length === 0)\n ) {\n return false;\n }\n\n if (\n value.version !== undefined &&\n (typeof value.version !== \"string\" || value.version.trim().length === 0)\n ) {\n return false;\n }\n\n if (\n value.signer !== undefined &&\n (typeof value.signer !== \"string\" || value.signer.trim().length === 0)\n ) {\n return false;\n }\n\n return true;\n}\n\nexport function isRuntimeModuleManifest(\n value: unknown,\n): value is RuntimeModuleManifest {\n if (!isRecord(value)) {\n return false;\n }\n\n for (const [specifier, descriptor] of Object.entries(value)) {\n if (specifier.trim().length === 0) {\n return false;\n }\n\n if (!isRuntimeModuleDescriptor(descriptor)) {\n return false;\n }\n }\n\n return true;\n}\n\nexport function resolveRuntimePlanSpecVersion(specVersion?: string): string {\n if (typeof specVersion === \"string\" && specVersion.trim().length > 0) {\n return specVersion.trim();\n }\n\n return DEFAULT_RUNTIME_PLAN_SPEC_VERSION;\n}\n\nexport function walkRuntimeNode(\n node: RuntimeNode,\n visitor: (node: RuntimeNode, depth: number) => void,\n depth = 0,\n): void {\n visitor(node, depth);\n\n const children = node.type === \"text\" ? undefined : node.children;\n if (!children || children.length === 0) {\n return;\n }\n\n for (const child of children) {\n walkRuntimeNode(child, visitor, depth + 1);\n }\n}\n\nexport function collectComponentModules(root: RuntimeNode): string[] {\n const modules = new Set<string>();\n\n walkRuntimeNode(root, (node) => {\n if (node.type === \"component\") {\n modules.add(node.module);\n }\n });\n\n return [...modules];\n}\n\nexport function splitPath(path: string): string[] {\n return path\n .split(\".\")\n .map((segment) => segment.trim())\n .filter((segment) => segment.length > 0);\n}\n\nexport function isSafePath(path: string): boolean {\n const segments = splitPath(path);\n\n if (segments.length === 0) {\n return false;\n }\n\n for (const segment of segments) {\n if (\n segment === \"__proto__\" ||\n segment === \"prototype\" ||\n segment === \"constructor\"\n ) {\n return false;\n }\n }\n\n return true;\n}\n\nexport function getValueByPath(source: unknown, path: string): unknown {\n const segments = splitPath(path);\n if (segments.length === 0) {\n return undefined;\n }\n\n let cursor: unknown = source;\n\n for (const segment of segments) {\n if (typeof cursor !== \"object\" || cursor === null) {\n return undefined;\n }\n\n cursor = (cursor as Record<string, unknown>)[segment];\n }\n\n return cursor;\n}\n\nexport function setValueByPath(\n target: RuntimeStateSnapshot,\n path: string,\n value: JsonValue,\n): void {\n const segments = splitPath(path);\n if (segments.length === 0) {\n return;\n }\n\n let cursor: Record<string, JsonValue> = target;\n\n for (let i = 0; i < segments.length; i += 1) {\n const segment = segments[i];\n const isLast = i === segments.length - 1;\n\n if (isLast) {\n cursor[segment] = value;\n return;\n }\n\n const next = cursor[segment];\n if (typeof next !== \"object\" || next === null || Array.isArray(next)) {\n cursor[segment] = {};\n }\n\n cursor = cursor[segment] as Record<string, JsonValue>;\n }\n}\n\nexport function cloneJsonValue<T extends JsonValue>(value: T): T {\n if (typeof globalThis.structuredClone === \"function\") {\n return globalThis.structuredClone(value) as T;\n }\n\n return JSON.parse(JSON.stringify(value)) as T;\n}\n\nexport function asJsonValue(value: unknown): JsonValue {\n if (value === undefined) {\n return null;\n }\n\n if (\n value === null ||\n typeof value === \"string\" ||\n typeof value === \"boolean\"\n ) {\n return value;\n }\n\n if (typeof value === \"number\") {\n return Number.isFinite(value) ? value : null;\n }\n\n if (Array.isArray(value)) {\n return value.map((item) => asJsonValue(item));\n }\n\n if (typeof value === \"object\" && value !== null) {\n const result: JsonObject = {};\n for (const [key, item] of Object.entries(value)) {\n result[key] = asJsonValue(item);\n }\n return result;\n }\n\n return String(value);\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction isFiniteNonNegativeNumber(value: unknown): boolean {\n return (\n value === undefined ||\n (typeof value === \"number\" && Number.isFinite(value) && value >= 0)\n );\n}\n\nfunction isJsonValueInternal(value: unknown, seen: Set<object>): boolean {\n if (\n value === null ||\n typeof value === \"string\" ||\n typeof value === \"boolean\"\n ) {\n return true;\n }\n\n if (typeof value === \"number\") {\n return Number.isFinite(value);\n }\n\n if (Array.isArray(value)) {\n if (seen.has(value)) {\n return false;\n }\n\n seen.add(value);\n const valid = value.every((entry) => isJsonValueInternal(entry, seen));\n seen.delete(value);\n return valid;\n }\n\n if (isRecord(value)) {\n if (seen.has(value)) {\n return false;\n }\n\n seen.add(value);\n const valid = Object.values(value).every((entry) =>\n isJsonValueInternal(entry, seen),\n );\n seen.delete(value);\n return valid;\n }\n\n return false;\n}\n"],"mappings":";AAAA,IAAM,wBAAwB;AAC9B,IAAM,iBAAiB;AACvB,IAAM,cAAc;AAOb,SAAS,sBAAqC;AACnD,MAAI,OAAO;AAEX,SAAO;AAAA,IACL,QAAQ,CAAC,UAAkB;AACzB,eAAS,QAAQ,GAAG,QAAQ,MAAM,QAAQ,SAAS,GAAG;AACpD,gBAAQ,OAAO,MAAM,WAAW,KAAK,CAAC;AACtC,eAAQ,OAAO,iBAAkB;AAAA,MACnC;AAAA,IACF;AAAA,IACA,WAAW,MAAM,KAAK,SAAS,EAAE;AAAA,EACnC;AACF;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CAAC;AACrE,SAAK,OAAO,KAAK;AACjB,WAAO;AAAA,EACT;AAEA,MAAI,SAAS,KAAK,GAAG;AACnB,QAAI,KAAK,IAAI,KAAK,GAAG;AACnB,aAAO;AAAA,IACT;AAEA,SAAK,IAAI,KAAK;AACd,UAAM,QAAQ,OAAO,OAAO,KAAK,EAAE;AAAA,MAAM,CAAC,UACxC,oBAAoB,OAAO,IAAI;AAAA,IACjC;AACA,SAAK,OAAO,KAAK;AACjB,WAAO;AAAA,EACT;AAEA,SAAO;AACT;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@renderify/ir",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"main": "dist/ir.cjs.js",
|
|
5
|
+
"types": "dist/ir.d.ts",
|
|
6
|
+
"module": "dist/ir.esm.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/ir.d.ts",
|
|
10
|
+
"import": "./dist/ir.esm.js",
|
|
11
|
+
"require": "./dist/ir.cjs.js",
|
|
12
|
+
"default": "./dist/ir.esm.js"
|
|
13
|
+
},
|
|
14
|
+
"./package.json": "./package.json"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"author": "unadlib",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"description": "Runtime IR contracts for Renderify",
|
|
22
|
+
"keywords": [
|
|
23
|
+
"renderify",
|
|
24
|
+
"runtime-plan",
|
|
25
|
+
"runtime",
|
|
26
|
+
"ui-runtime",
|
|
27
|
+
"ir"
|
|
28
|
+
],
|
|
29
|
+
"homepage": "https://github.com/webllm/renderify#readme",
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/webllm/renderify/issues"
|
|
32
|
+
},
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "https://github.com/webllm/renderify.git",
|
|
36
|
+
"directory": "packages/ir"
|
|
37
|
+
},
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=22.0.0"
|
|
40
|
+
},
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public",
|
|
43
|
+
"provenance": true
|
|
44
|
+
},
|
|
45
|
+
"sideEffects": false,
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"es-module-lexer": "^1.7.0"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
51
|
+
"typecheck": "tsc -p tsconfig.json --pretty false --noEmit",
|
|
52
|
+
"lint": "biome lint src",
|
|
53
|
+
"clean": "rm -rf dist dist-types",
|
|
54
|
+
"build:repo": "tsup --config tsup.config.ts",
|
|
55
|
+
"watch:repo": "tsup --config tsup.config.ts --watch"
|
|
56
|
+
}
|
|
57
|
+
}
|