lawspec 0.29.2 → 0.31.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/CHANGELOG.md +407 -1
- package/README.md +9 -3
- package/api.mjs +1 -0
- package/beam-doctor.mjs +2 -2
- package/bin/lawspec.mjs +100 -102
- package/build.json +503 -411
- package/component-packages.mjs +339 -0
- package/component.d.ts +46 -0
- package/component.mjs +208 -0
- package/core.wasm +2 -2
- package/core_jsffi.js +5 -5
- package/examples/native-payments/clojure/lawspec.edn +48 -0
- package/examples/native-payments/clojure/src/domain/payments.clj +1 -1
- package/examples/native-payments/clojure/test/domain/payment_generators.clj +1 -1
- package/examples/native-payments/csharp/lawspec.edn +48 -0
- package/examples/native-payments/elixir/lawspec.edn +123 -0
- package/examples/native-payments/erlang/lawspec.edn +128 -0
- package/examples/native-payments/fsharp/lawspec.edn +123 -0
- package/examples/native-payments/gleam/lawspec.edn +123 -0
- package/examples/native-payments/go/lawspec.edn +123 -0
- package/examples/native-payments/groovy/lawspec.edn +123 -0
- package/examples/native-payments/haskell/lawspec.edn +123 -0
- package/examples/native-payments/java/lawspec.edn +123 -0
- package/examples/native-payments/javascript/lawspec.edn +123 -0
- package/examples/native-payments/kotlin/lawspec.edn +123 -0
- package/examples/native-payments/prolog/lawspec.edn +48 -0
- package/examples/native-payments/python/lawspec.edn +123 -0
- package/examples/native-payments/rust/lawspec.edn +124 -0
- package/examples/native-payments/scala/lawspec.edn +123 -0
- package/examples/native-payments/swift/lawspec.edn +123 -0
- package/examples/native-payments/typescript/lawspec.edn +123 -0
- package/examples/packages/orders/lawspec.edn +25 -0
- package/examples/packages/shop-domain/lawspec.edn +13 -0
- package/examples/packages/shop-tax-1/lawspec.edn +9 -0
- package/examples/packages/shop-tax-2/lawspec.edn +9 -0
- package/examples/specs/handler_bindings.lawspec +2 -2
- package/examples/specs/harness_testing.lawspec +1 -1
- package/files.mjs +2 -1
- package/go.mod +4 -0
- package/index.d.ts +145 -8
- package/input-files.mjs +47 -0
- package/launcher.mjs +33 -13
- package/lsp.mjs +10 -5
- package/native-evidence.mjs +58 -19
- package/native-examples.mjs +8 -7
- package/native-host.mjs +71 -0
- package/package.json +8 -3
- package/proof.d.ts +8 -2
- package/proof.mjs +186 -34
- package/scala-build-state.mjs +59 -0
- package/templates.mjs +242 -2
- package/test-command.mjs +193 -61
- package/builtin-data-names.mjs +0 -73
- package/examples/native-payments/clojure/lawspec.json +0 -62
- package/examples/native-payments/csharp/lawspec.json +0 -62
- package/examples/native-payments/elixir/lawspec.json +0 -160
- package/examples/native-payments/erlang/lawspec.json +0 -159
- package/examples/native-payments/fsharp/lawspec.json +0 -178
- package/examples/native-payments/gleam/lawspec.json +0 -160
- package/examples/native-payments/go/lawspec.json +0 -147
- package/examples/native-payments/groovy/lawspec.json +0 -176
- package/examples/native-payments/haskell/lawspec.json +0 -160
- package/examples/native-payments/java/lawspec.json +0 -176
- package/examples/native-payments/javascript/lawspec.json +0 -160
- package/examples/native-payments/kotlin/lawspec.json +0 -176
- package/examples/native-payments/prolog/lawspec.json +0 -20
- package/examples/native-payments/python/lawspec.json +0 -160
- package/examples/native-payments/rust/lawspec.json +0 -178
- package/examples/native-payments/scala/lawspec.json +0 -176
- package/examples/native-payments/swift/lawspec.json +0 -165
- package/examples/native-payments/typescript/lawspec.json +0 -160
- package/examples/packages/orders/lawspec.json +0 -27
- package/examples/packages/shop-domain/lawspec-package.json +0 -7
- package/examples/packages/shop-tax-1/lawspec-package.json +0 -5
- package/examples/packages/shop-tax-2/lawspec-package.json +0 -5
- package/explain.mjs +0 -114
- package/expression-presentation.mjs +0 -333
- package/positional-fields.mjs +0 -13
- package/typed-presentation.mjs +0 -165
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
// Generated from templates/npm/component-packages.mjs by lawspec-dev generate. Do not edit.
|
|
2
|
+
import {readFile, writeFile, mkdir, readdir, lstat, realpath, rename, rm, mkdtemp} from 'node:fs/promises';
|
|
3
|
+
import {execFile} from 'node:child_process';
|
|
4
|
+
import {promisify} from 'node:util';
|
|
5
|
+
import {Readable} from 'node:stream';
|
|
6
|
+
import {pipeline} from 'node:stream/promises';
|
|
7
|
+
import os from 'node:os';
|
|
8
|
+
import {randomUUID} from 'node:crypto';
|
|
9
|
+
import path from 'node:path';
|
|
10
|
+
import * as tar from 'tar';
|
|
11
|
+
import {readManifest, parseManifest, writeManifest, manifestName, lockName, packageVersions, dependencyRanges, contentDigest, canonical} from './component.mjs';
|
|
12
|
+
import {collectSources, atomicWrite} from './files.mjs';
|
|
13
|
+
|
|
14
|
+
const exec = promisify(execFile);
|
|
15
|
+
const git = async (args, options = {}) => (await exec('git', args, {maxBuffer: 128 * 1024 * 1024, ...options})).stdout;
|
|
16
|
+
const optional = async file => readFile(file, 'utf8').catch(error => {if (error.code === 'ENOENT') return null; throw error;});
|
|
17
|
+
const inside = (root, file) => file === root || file.startsWith(root + path.sep);
|
|
18
|
+
const rangeOf = value => typeof value === 'string' ? value : value.version;
|
|
19
|
+
|
|
20
|
+
function validateLock(lock) {
|
|
21
|
+
const map = value => value && typeof value === 'object' && !Array.isArray(value);
|
|
22
|
+
const invalid = () => {throw new Error('Invalid LawSpec lockfile; regenerate it with lawspec fetch');};
|
|
23
|
+
if (!map(lock) || lock.format !== 'lawspec-lock' || lock.version !== 1 ||
|
|
24
|
+
!map(lock.roots) || !map(lock.selections) || !Array.isArray(lock.packages)) invalid();
|
|
25
|
+
const ids = new Set();
|
|
26
|
+
for (const entry of lock.packages) {
|
|
27
|
+
if (!map(entry) || typeof entry.id !== 'string' || ids.has(entry.id) ||
|
|
28
|
+
typeof entry.name !== 'string' || typeof entry.version !== 'string' ||
|
|
29
|
+
!map(entry.dependencies) || !map(entry.source)) invalid();
|
|
30
|
+
ids.add(entry.id);
|
|
31
|
+
const source = entry.source;
|
|
32
|
+
if (source.kind === 'path') {if (typeof source.path !== 'string') invalid();}
|
|
33
|
+
else if (source.kind === 'embedded') {
|
|
34
|
+
if (typeof source.parent !== 'string' || typeof source.path !== 'string' || !/^[a-f0-9]{64}$/.test(entry.digest)) invalid();
|
|
35
|
+
} else if (['git', 'archive'].includes(source.kind)) {
|
|
36
|
+
if (typeof source.url !== 'string' || !/^[a-f0-9]{64}$/.test(entry.digest)) invalid();
|
|
37
|
+
if (source.kind === 'git' && !/^[a-f0-9]{40,64}$/.test(source.commit)) invalid();
|
|
38
|
+
if (source.kind === 'archive' && !/^[a-f0-9]{64}$/.test(source.sha256)) invalid();
|
|
39
|
+
} else invalid();
|
|
40
|
+
}
|
|
41
|
+
for (const selection of Object.values(lock.selections))
|
|
42
|
+
if (!map(selection) || !Object.hasOwn(selection, 'request') || !ids.has(selection.package)) invalid();
|
|
43
|
+
for (const id of [...Object.values(lock.roots), ...lock.packages.flatMap(entry => Object.values(entry.dependencies))])
|
|
44
|
+
if (!ids.has(id)) invalid();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function filesUnder(root) {
|
|
48
|
+
const files = [];
|
|
49
|
+
async function walk(file, relative) {
|
|
50
|
+
const info = await lstat(file);
|
|
51
|
+
if (info.isSymbolicLink()) throw new Error(`Contract packages cannot contain symbolic links: ${relative}`);
|
|
52
|
+
if (info.isDirectory()) {
|
|
53
|
+
for (const name of (await readdir(file)).sort()) {
|
|
54
|
+
if (['.git', '.lawspec', 'node_modules', 'target', 'bin', 'obj'].includes(name)) continue;
|
|
55
|
+
await walk(path.join(file, name), relative ? `${relative}/${name}` : name);
|
|
56
|
+
}
|
|
57
|
+
} else if (info.isFile()) files.push(relative);
|
|
58
|
+
}
|
|
59
|
+
await walk(root, '');
|
|
60
|
+
return files;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const resolvedPackageDigest = (content, dependencies) => Object.keys(dependencies).length ? contentDigest(canonical({content, dependencies})) : content;
|
|
64
|
+
|
|
65
|
+
export async function packageDigest(root) {
|
|
66
|
+
const manifest = await readManifest(path.join(root, manifestName));
|
|
67
|
+
const files = await packageFiles(root, manifest);
|
|
68
|
+
return contentDigest(canonical(await Promise.all(files.map(async file => [file, contentDigest(await readFile(path.join(root, file)))]))));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function packageFiles(root, manifest, {publish = false, packageRoot = root} = {}, ancestry = []) {
|
|
72
|
+
if (ancestry.includes(root)) throw new Error('Package dependency cycle while collecting published files');
|
|
73
|
+
ancestry = [...ancestry, root];
|
|
74
|
+
const selected = new Set([manifestName]);
|
|
75
|
+
const realRoot = await realpath(root);
|
|
76
|
+
for (const entry of [...manifest.sources, ...(manifest.assets ?? [])]) {
|
|
77
|
+
const location = path.resolve(root, entry);
|
|
78
|
+
if (!inside(root, location) || !inside(realRoot, await realpath(location)))
|
|
79
|
+
throw new Error(`Published package path leaves its root: ${entry}`);
|
|
80
|
+
await filesUnder(location);
|
|
81
|
+
}
|
|
82
|
+
const sources = await collectSources(root, manifest.sources, root);
|
|
83
|
+
for (const source of sources) {
|
|
84
|
+
if (!inside(root, path.resolve(root, source.path))) throw new Error(`Published package source leaves its root: ${source.path}`);
|
|
85
|
+
selected.add(source.path);
|
|
86
|
+
}
|
|
87
|
+
for (const entry of manifest.assets ?? []) {
|
|
88
|
+
const location = path.resolve(root, entry);
|
|
89
|
+
if (!inside(root, location)) throw new Error(`Published package asset leaves its root: ${entry}`);
|
|
90
|
+
const info = await lstat(location);
|
|
91
|
+
if (info.isSymbolicLink()) throw new Error(`Published package asset is a symbolic link: ${entry}`);
|
|
92
|
+
if (info.isDirectory()) for (const nested of await filesUnder(location)) selected.add(path.relative(root, path.join(location, nested)));
|
|
93
|
+
else selected.add(entry);
|
|
94
|
+
}
|
|
95
|
+
for (const dependency of Object.values(manifest.dependencies ?? {})) {
|
|
96
|
+
if (!dependency?.path) continue;
|
|
97
|
+
const location = path.resolve(root, dependency.path);
|
|
98
|
+
if (!inside(packageRoot, location)) {
|
|
99
|
+
if (publish) throw new Error(`Published package dependency leaves its root: ${dependency.path}`);
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
if (!inside(await realpath(packageRoot), await realpath(location))) throw new Error('Published dependency leaves its root through a symbolic link');
|
|
103
|
+
const nested = await readManifest(path.join(location, manifestName));
|
|
104
|
+
for (const file of await packageFiles(location, nested, {publish, packageRoot}, ancestry))
|
|
105
|
+
selected.add(path.relative(root, path.join(location, file)));
|
|
106
|
+
}
|
|
107
|
+
return [...selected].sort();
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async function unpack(bytes, directory) {
|
|
111
|
+
await mkdir(directory, {recursive: true});
|
|
112
|
+
let refused;
|
|
113
|
+
await pipeline(Readable.from([bytes]), tar.x({cwd: directory, strict: true, preservePaths: false, filter(name, entry) {
|
|
114
|
+
const normalized = path.resolve(directory, name);
|
|
115
|
+
if (path.isAbsolute(name) || name.split(/[\\/]/).includes('..') || !inside(directory, normalized) || !['File', 'Directory', 'OldFile', 'ContiguousFile'].includes(entry.type)) {
|
|
116
|
+
refused = `Unsafe package archive entry: ${name}`;
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
return true;
|
|
120
|
+
}}));
|
|
121
|
+
if (refused) throw new Error(refused);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export async function resolveDependencies(file, manifest, options = {}) {
|
|
125
|
+
const root = path.dirname(path.resolve(file));
|
|
126
|
+
const cache = path.resolve(process.env.LAWSPEC_CACHE_DIR ?? path.join(process.env.XDG_CACHE_HOME ?? path.join(os.homedir(), '.cache'), 'lawspec', 'packages'));
|
|
127
|
+
const locked = !!options.locked, offline = !!options.offline || process.env.LAWSPEC_OFFLINE === '1';
|
|
128
|
+
const previousText = await optional(path.join(root, lockName));
|
|
129
|
+
const previous = previousText === null ? null : parseManifest(previousText, path.join(root, lockName));
|
|
130
|
+
if (previous) validateLock(previous);
|
|
131
|
+
const oldSelections = previous?.selections ?? {}, selections = {}, entries = new Map(), packages = new Map(), identities = new Map();
|
|
132
|
+
const local = new Map(), localSeen = new Set(), locations = new Map();
|
|
133
|
+
|
|
134
|
+
async function localCandidates(directory, owner) {
|
|
135
|
+
for (const name of owner.packages ?? []) {
|
|
136
|
+
const location = path.resolve(directory, name);
|
|
137
|
+
if (localSeen.has(location)) continue;
|
|
138
|
+
localSeen.add(location);
|
|
139
|
+
const candidate = await readManifest(path.join(location, manifestName));
|
|
140
|
+
if (!candidate.package) throw new Error(`${location}: expected a package identity`);
|
|
141
|
+
const list = local.get(candidate.package.name) ?? [];
|
|
142
|
+
list.push({directory: location, manifest: candidate});
|
|
143
|
+
local.set(candidate.package.name, list);
|
|
144
|
+
await localCandidates(location, candidate);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
await localCandidates(root, manifest);
|
|
148
|
+
|
|
149
|
+
async function gitRepository(url) {
|
|
150
|
+
const repository = path.join(cache, 'git', contentDigest(url));
|
|
151
|
+
if (await optional(path.join(repository, 'HEAD')) !== null) return repository;
|
|
152
|
+
await mkdir(path.dirname(repository), {recursive: true});
|
|
153
|
+
const temporary = await mkdtemp(path.join(path.dirname(repository), '.initializing-'));
|
|
154
|
+
try {
|
|
155
|
+
await git(['init', '--bare', '--quiet', temporary]);
|
|
156
|
+
try { await rename(temporary, repository); }
|
|
157
|
+
catch (error) { if (!['EEXIST', 'ENOTEMPTY', 'EPERM'].includes(error.code)) throw error; }
|
|
158
|
+
if (await optional(path.join(repository, 'HEAD')) === null)
|
|
159
|
+
throw new Error(`Cached Git repository initialization did not complete: ${repository}`);
|
|
160
|
+
} finally { await rm(temporary, {recursive: true, force: true}); }
|
|
161
|
+
return repository;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
async function gitCheckout(source) {
|
|
165
|
+
const repository = await gitRepository(source.url);
|
|
166
|
+
const present = await git(['--git-dir', repository, 'cat-file', '-e', `${source.commit}^{commit}`]).then(() => true, () => false);
|
|
167
|
+
if (!present) {
|
|
168
|
+
if (offline) throw new Error(`Offline: Git revision ${source.commit} is not cached`);
|
|
169
|
+
await git(['--git-dir', repository, 'fetch', '--quiet', '--no-tags', '--no-write-fetch-head', '--', source.url, source.commit]);
|
|
170
|
+
}
|
|
171
|
+
return git(['--git-dir', repository, 'archive', '--format=tar', source.subdir ? `${source.commit}:${source.subdir}` : source.commit], {encoding: 'buffer'});
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
async function downloaded(source, known) {
|
|
175
|
+
const id = contentDigest(canonical(source)), directory = path.join(cache, id), marker = path.join(cache, id + '.sha256');
|
|
176
|
+
if (await optional(path.join(directory, manifestName)) !== null) {
|
|
177
|
+
const expected = known?.digest ?? (await optional(marker))?.trim();
|
|
178
|
+
if (expected) {
|
|
179
|
+
if (!/^[a-f0-9]{64}$/.test(expected) || await packageDigest(directory) !== expected) throw new Error(`Cached contract content changed: ${known?.name ?? source.url}`);
|
|
180
|
+
await atomicWrite(marker, expected + '\n');
|
|
181
|
+
return {directory, source};
|
|
182
|
+
}
|
|
183
|
+
if (offline) throw new Error(`Offline: cached contract integrity is unavailable for ${source.url}`);
|
|
184
|
+
}
|
|
185
|
+
if (offline && source.kind === 'archive') throw new Error(`Offline: ${source.url} is not cached`);
|
|
186
|
+
let bytes;
|
|
187
|
+
if (source.kind === 'git') bytes = await gitCheckout(source);
|
|
188
|
+
else {
|
|
189
|
+
const url = new URL(source.url);
|
|
190
|
+
if (url.protocol !== 'https:' && !(url.protocol === 'http:' && ['127.0.0.1', 'localhost', '[::1]'].includes(url.hostname)))
|
|
191
|
+
throw new Error('Contract archives must use HTTPS');
|
|
192
|
+
const answer = await fetch(url);
|
|
193
|
+
if (!answer.ok) throw new Error(`Contract download failed: HTTP ${answer.status} for ${url}`);
|
|
194
|
+
bytes = Buffer.from(await answer.arrayBuffer());
|
|
195
|
+
if (contentDigest(bytes) !== source.sha256) throw new Error(`Contract archive SHA-256 mismatch: ${url}`);
|
|
196
|
+
}
|
|
197
|
+
await mkdir(cache, {recursive: true});
|
|
198
|
+
const temporary = await mkdtemp(path.join(cache, '.unpack-'));
|
|
199
|
+
try {
|
|
200
|
+
await unpack(bytes, temporary);
|
|
201
|
+
await readManifest(path.join(temporary, manifestName));
|
|
202
|
+
const digest = await packageDigest(temporary);
|
|
203
|
+
try { await rename(temporary, directory); }
|
|
204
|
+
catch (error) { if (!['EEXIST', 'ENOTEMPTY'].includes(error.code)) throw error; }
|
|
205
|
+
if (await packageDigest(directory) !== digest) throw new Error(`Cached contract content changed: ${source.url}`);
|
|
206
|
+
await atomicWrite(marker, digest + '\n');
|
|
207
|
+
} finally { await rm(temporary, {recursive: true, force: true}); }
|
|
208
|
+
if (known && await packageDigest(directory) !== known.digest) throw new Error(`Downloaded contract content differs from lock: ${known.name}`);
|
|
209
|
+
return {directory, source};
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function immutableOwner(owner) {
|
|
213
|
+
let current = owner;
|
|
214
|
+
while (entries.get(current)?.source.kind === 'embedded') current = entries.get(current).source.parent;
|
|
215
|
+
return entries.has(current) && entries.get(current).source.kind !== 'path' ? current : null;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
async function localSource(location, owner) {
|
|
219
|
+
const parent = immutableOwner(owner);
|
|
220
|
+
if (!parent) return {directory: location, source: {kind: 'path', path: path.relative(root, location) || '.'}};
|
|
221
|
+
const directory = locations.get(parent);
|
|
222
|
+
if (!inside(directory, location) || !inside(await realpath(directory), await realpath(location)))
|
|
223
|
+
throw new Error('Published package dependency leaves its downloaded root');
|
|
224
|
+
return {directory: location, source: {kind: 'embedded', parent, path: path.relative(directory, location) || '.'}};
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
async function materialize(name, specification, directory, old, owner) {
|
|
228
|
+
const refresh = options.update === true || options.update === name;
|
|
229
|
+
if (old && !refresh && canonical(old.request) === canonical(specification)) {
|
|
230
|
+
const entry = previous.packages.find(item => item.id === old.package);
|
|
231
|
+
if (!entry) throw new Error(`Lockfile references missing package ${old.package}`);
|
|
232
|
+
if (entry.source.kind === 'path') {
|
|
233
|
+
if (immutableOwner(owner)) throw new Error('Lockfile contains a non-portable published path; run lawspec update');
|
|
234
|
+
return {directory: path.resolve(root, entry.source.path), source: entry.source};
|
|
235
|
+
}
|
|
236
|
+
if (entry.source.kind === 'embedded') {
|
|
237
|
+
const parent = locations.get(entry.source.parent);
|
|
238
|
+
if (!parent || entry.source.parent !== immutableOwner(owner)) throw new Error('Invalid embedded package parent in lockfile');
|
|
239
|
+
const loaded = await localSource(path.resolve(parent, entry.source.path), owner);
|
|
240
|
+
if (await packageDigest(loaded.directory) !== entry.digest) throw new Error(`Cached embedded contract content changed: ${name}`);
|
|
241
|
+
return loaded;
|
|
242
|
+
}
|
|
243
|
+
return downloaded(entry.source, entry);
|
|
244
|
+
}
|
|
245
|
+
if (locked) throw new Error(`Lockfile must change for ${name}; run lawspec fetch without --locked`);
|
|
246
|
+
if (typeof specification === 'string') {
|
|
247
|
+
const candidates = local.get(name) ?? [];
|
|
248
|
+
const accepted = await packageVersions(specification, candidates.map(item => item.manifest.package.version));
|
|
249
|
+
const chosen = candidates.find(item => item.manifest.package.version === accepted[0]);
|
|
250
|
+
if (!chosen) throw new Error(`requires ${name} ${specification}, but ${candidates.length === 1 ? 'version ' + candidates[0].manifest.package.version + ' is supplied' : 'no supplied version satisfies it'}`);
|
|
251
|
+
return localSource(chosen.directory, owner);
|
|
252
|
+
}
|
|
253
|
+
if (specification.path) {
|
|
254
|
+
const location = path.resolve(directory, specification.path);
|
|
255
|
+
return localSource(location, owner);
|
|
256
|
+
}
|
|
257
|
+
if (specification.archive) return downloaded({kind: 'archive', url: specification.archive, sha256: specification.sha256});
|
|
258
|
+
if (offline) throw new Error(`Offline: resolving ${name} requires a lockfile`);
|
|
259
|
+
let ref = specification.rev, tagVersion;
|
|
260
|
+
if (!ref) {
|
|
261
|
+
const prefix = specification.tagPrefix ?? 'v';
|
|
262
|
+
const tags = (await git(['ls-remote', '--tags', '--refs', '--', specification.git])).trim().split('\n').filter(Boolean).map(line => {
|
|
263
|
+
const [commit, tag] = line.split(/\s+/);
|
|
264
|
+
return {commit, tag: tag.replace('refs/tags/', '')};
|
|
265
|
+
}).filter(item => item.tag.startsWith(prefix) && /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(item.tag.slice(prefix.length)));
|
|
266
|
+
const versions = await packageVersions(specification.version, tags.map(item => item.tag.slice(prefix.length)));
|
|
267
|
+
const chosen = tags.find(item => item.tag.slice(prefix.length) === versions[0]);
|
|
268
|
+
if (!chosen) throw new Error(`No published Git version satisfies ${name} ${specification.version}`);
|
|
269
|
+
ref = chosen.commit;
|
|
270
|
+
tagVersion = chosen.tag.slice(prefix.length);
|
|
271
|
+
}
|
|
272
|
+
const repository = await gitRepository(specification.git);
|
|
273
|
+
const fetched = 'refs/lawspec/' + randomUUID();
|
|
274
|
+
let commit;
|
|
275
|
+
try {
|
|
276
|
+
await git(['--git-dir', repository, 'fetch', '--quiet', '--no-tags', '--no-write-fetch-head', '--', specification.git, ref + ':' + fetched]);
|
|
277
|
+
commit = (await git(['--git-dir', repository, 'rev-parse', fetched + '^{commit}'])).trim();
|
|
278
|
+
} finally { await git(['--git-dir', repository, 'update-ref', '-d', fetched]); }
|
|
279
|
+
return downloaded({kind: 'git', url: specification.git, commit, ...(tagVersion ? {tagVersion} : {}), ...(specification.subdir ? {subdir: specification.subdir} : {})});
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
async function resolve(name, specification, directory, owner, ancestry) {
|
|
283
|
+
const key = owner + '::' + name, old = oldSelections[key];
|
|
284
|
+
const loaded = await materialize(name, specification, directory, old, owner);
|
|
285
|
+
const described = await readManifest(path.join(loaded.directory, manifestName));
|
|
286
|
+
if (!described.package || described.package.name !== name) throw new Error(`Dependency ${name} has a different package identity`);
|
|
287
|
+
const version = described.package.version;
|
|
288
|
+
if (loaded.source.tagVersion && loaded.source.tagVersion !== version)
|
|
289
|
+
throw new Error(`Git tag version ${loaded.source.tagVersion} differs from ${name} manifest version ${version}`);
|
|
290
|
+
if (!(await packageVersions(rangeOf(specification), [version])).length) throw new Error(`requires ${name} ${rangeOf(specification)}, but version ${version} is supplied`);
|
|
291
|
+
const id = contentDigest(canonical({name, version, source: loaded.source}));
|
|
292
|
+
selections[key] = {request: specification, package: id};
|
|
293
|
+
if (ancestry.includes(id)) throw new Error(`Package dependency cycle: ${[...ancestry, id].join(' -> ')}`);
|
|
294
|
+
if (entries.has(id)) return id;
|
|
295
|
+
const digest = await packageDigest(loaded.directory), identity = {name, version, source: loaded.source, digest};
|
|
296
|
+
const sameVersion = [...identities.values()].find(item => item.name === name && item.version === version);
|
|
297
|
+
if (sameVersion && sameVersion.digest !== digest) throw new Error(`Ambiguous content for ${name} ${version}`);
|
|
298
|
+
const entry = {id, name, version, source: loaded.source, ...(loaded.source.kind === 'path' ? {} : {digest}), dependencies: {}};
|
|
299
|
+
entries.set(id, entry);
|
|
300
|
+
identities.set(id, identity);
|
|
301
|
+
locations.set(id, loaded.directory);
|
|
302
|
+
await localCandidates(loaded.directory, described);
|
|
303
|
+
for (const [dependency, child] of Object.entries(described.dependencies ?? {}).sort())
|
|
304
|
+
entry.dependencies[dependency] = await resolve(dependency, child, loaded.directory, id, [...ancestry, id]);
|
|
305
|
+
packages.set(id, {name, version, dependencies: dependencyRanges(described), sources: await collectSources(loaded.directory, described.sources, root)});
|
|
306
|
+
return id;
|
|
307
|
+
}
|
|
308
|
+
const roots = {};
|
|
309
|
+
for (const [name, specification] of Object.entries(manifest.dependencies ?? {}).sort())
|
|
310
|
+
roots[name] = await resolve(name, specification, root, '$', []);
|
|
311
|
+
const lock = {format: 'lawspec-lock', version: 1, roots, selections, packages: [...entries.values()].sort((a,b) => a.id.localeCompare(b.id))};
|
|
312
|
+
if (entries.size || previous) {
|
|
313
|
+
if (locked && canonical(lock) !== canonical(previous)) throw new Error('Lockfile is out of date; run lawspec fetch');
|
|
314
|
+
if (!locked && canonical(lock) !== canonical(previous)) await atomicWrite(path.join(root, lockName), writeManifest(lock));
|
|
315
|
+
}
|
|
316
|
+
const semantic = new Map();
|
|
317
|
+
const closure = id => {
|
|
318
|
+
if (!semantic.has(id)) semantic.set(id, resolvedPackageDigest(identities.get(id).digest,
|
|
319
|
+
Object.fromEntries(Object.entries(entries.get(id).dependencies).map(([name,child]) => [name, closure(child)]))));
|
|
320
|
+
return semantic.get(id);
|
|
321
|
+
};
|
|
322
|
+
const resolvedIdentities = [...identities].map(([id,value]) => ({...value, contentDigest: value.digest, digest: closure(id)}));
|
|
323
|
+
for (const identity of resolvedIdentities) {
|
|
324
|
+
const alternatives = resolvedIdentities.filter(other => other.name === identity.name && other.version === identity.version);
|
|
325
|
+
if (alternatives.some(other => other.digest !== identity.digest)) throw new Error(`Ambiguous resolved contract closure for ${identity.name} ${identity.version}`);
|
|
326
|
+
}
|
|
327
|
+
const ordered = values => [...values].sort((a,b) => a.name.localeCompare(b.name) || a.version.localeCompare(b.version));
|
|
328
|
+
return {packages: ordered(packages.values()), identities: ordered(resolvedIdentities), lock};
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
export async function packComponent(file, output) {
|
|
332
|
+
if (path.basename(file) !== manifestName) throw new Error('Published packages require the canonical lawspec.edn filename');
|
|
333
|
+
const manifest = await readManifest(file), root = path.dirname(path.resolve(file));
|
|
334
|
+
if (!manifest.package) throw new Error('lawspec package --output requires a package identity');
|
|
335
|
+
const selected = await packageFiles(root, manifest, {publish: true});
|
|
336
|
+
await mkdir(path.dirname(path.resolve(output)), {recursive: true});
|
|
337
|
+
await tar.c({cwd: root, file: path.resolve(output), gzip: true, portable: true, mtime: new Date(0), noDirRecurse: true}, selected);
|
|
338
|
+
return {file: path.resolve(output), sha256: contentDigest(await readFile(output)), package: manifest.package};
|
|
339
|
+
}
|
package/component.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Generated from templates/npm/component.d.ts by lawspec-dev generate. Do not edit.
|
|
2
|
+
export interface Identity {name: string; version: string;}
|
|
3
|
+
export interface DependencySource {version: string; path?: string; git?: string; rev?: string; tagPrefix?: string; subdir?: string; archive?: string; sha256?: string;}
|
|
4
|
+
export interface ContractRequirement {contract: string; abilities?: string[]; declarations?: string[]; settings?: string[];}
|
|
5
|
+
export interface ComponentTarget {
|
|
6
|
+
name?: string; language: import('./index.js').Target; root: string;
|
|
7
|
+
sourceDir?: string; testDir?: string;
|
|
8
|
+
python?: string; maven?: string; gradle?: string; rustc?: string; cargo?: string;
|
|
9
|
+
scala?: string; swift?: string; clojure?: string; dotnet?: string;
|
|
10
|
+
nativeBindings?: import('./index.js').NativeBindings;
|
|
11
|
+
}
|
|
12
|
+
export interface ComponentManifest {
|
|
13
|
+
manifestVersion: 1;
|
|
14
|
+
component?: Identity;
|
|
15
|
+
package?: Identity;
|
|
16
|
+
languageProfile: '1.0-rc.2';
|
|
17
|
+
sources: string[];
|
|
18
|
+
targets?: ComponentTarget[];
|
|
19
|
+
dependencies?: Record<string, string | DependencySource>;
|
|
20
|
+
packages?: string[];
|
|
21
|
+
inputs?: string[];
|
|
22
|
+
assets?: string[];
|
|
23
|
+
provides?: ContractRequirement[];
|
|
24
|
+
requires?: Record<string, ContractRequirement>;
|
|
25
|
+
verification?: import('./index.js').Verification;
|
|
26
|
+
generation?: Partial<import('./index.js').Generation>;
|
|
27
|
+
machineBits?: 32 | 64;
|
|
28
|
+
cache?: boolean;
|
|
29
|
+
attestation?: string;
|
|
30
|
+
description?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface ResolutionOptions {locked?: boolean; offline?: boolean; update?: boolean | string;}
|
|
33
|
+
export interface ResolvedContract extends ContractRequirement {version: string; digest: string; versionRequirement?: string;}
|
|
34
|
+
export interface ComponentDescriptor {
|
|
35
|
+
format: 'lawspec-component'; version: 1; manifest: string; root: string;
|
|
36
|
+
component: Identity | null; package: Identity | null;
|
|
37
|
+
fingerprint: string; manifestDigest: string;
|
|
38
|
+
targets: ComponentTarget[]; provides: ResolvedContract[]; requires: Record<string, ResolvedContract>;
|
|
39
|
+
dependencies: unknown[]; laws: unknown[]; declarations: string[];
|
|
40
|
+
}
|
|
41
|
+
/** Parses EDN data; readManifest also validates the component schema. */
|
|
42
|
+
export function parseManifest(text: string, file?: string): Record<string, unknown>;
|
|
43
|
+
export function writeManifest(value: ComponentManifest | Record<string, unknown>, options?: {compact?: boolean}): string;
|
|
44
|
+
export function readManifest(file: string): Promise<ComponentManifest>;
|
|
45
|
+
export function findManifest(start?: string): Promise<string>;
|
|
46
|
+
export function resolveComponent(file: string, options?: ResolutionOptions): Promise<ComponentDescriptor>;
|
package/component.mjs
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
// Generated from templates/npm/component.mjs by lawspec-dev generate. Do not edit.
|
|
2
|
+
import {toEDNString} from 'edn-data';
|
|
3
|
+
import {EDNListParser} from 'edn-data/dist/parse.js';
|
|
4
|
+
import {readFile, stat, mkdir, writeFile, realpath} from 'node:fs/promises';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import {createHash} from 'node:crypto';
|
|
7
|
+
import {loadCore} from './launcher.mjs';
|
|
8
|
+
import {createCompiler} from './api.mjs';
|
|
9
|
+
import {collectSources} from './files.mjs';
|
|
10
|
+
import {fingerprintInputs} from './input-files.mjs';
|
|
11
|
+
|
|
12
|
+
export const manifestName = 'lawspec.edn';
|
|
13
|
+
export const lockName = 'lawspec.lock.edn';
|
|
14
|
+
const camel = key => key.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
15
|
+
const kebab = key => key.replace(/[A-Z]/g, letter => '-' + letter.toLowerCase());
|
|
16
|
+
const own = (value, key) => Object.prototype.hasOwnProperty.call(value, key);
|
|
17
|
+
const fail = (message, file) => {
|
|
18
|
+
const error = new Error(`${file ? file + ': ' : ''}${message}`);
|
|
19
|
+
error.diagnostics = [{code: 'manifest', message, ...(file ? {at: {file, line: 1, column: 1}} : {})}];
|
|
20
|
+
throw error;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export function parseManifest(text, file) {
|
|
24
|
+
let values, parser;
|
|
25
|
+
try {
|
|
26
|
+
parser = new EDNListParser();
|
|
27
|
+
values = parser.next('(' + text + '\n)\n');
|
|
28
|
+
} catch (error) { fail(`Invalid EDN: ${error.message}`, file); }
|
|
29
|
+
if (!parser.isDone() || values.length !== 1 || !Array.isArray(values[0]?.map))
|
|
30
|
+
fail('Expected exactly one complete EDN map', file);
|
|
31
|
+
function convert(value) {
|
|
32
|
+
if (value === null || typeof value === 'string' || typeof value === 'boolean') return value;
|
|
33
|
+
if (typeof value === 'number' && Number.isSafeInteger(value)) return value;
|
|
34
|
+
if (Array.isArray(value)) return value.map(convert);
|
|
35
|
+
if (value && typeof value === 'object' && own(value, 'key')) return value.key;
|
|
36
|
+
if (value && typeof value === 'object' && own(value, 'map')) {
|
|
37
|
+
const entries = [], seen = new Set();
|
|
38
|
+
for (const [key, entry] of value.map) {
|
|
39
|
+
if (typeof key !== 'string' && !(key && typeof key.key === 'string'))
|
|
40
|
+
fail('Manifest map keys must be strings or keywords', file);
|
|
41
|
+
const name = typeof key === 'string' ? key : camel(key.key);
|
|
42
|
+
if (seen.has(name)) fail(`Duplicate manifest key: ${name}`, file);
|
|
43
|
+
seen.add(name);
|
|
44
|
+
entries.push([name, convert(entry)]);
|
|
45
|
+
}
|
|
46
|
+
return Object.fromEntries(entries);
|
|
47
|
+
}
|
|
48
|
+
fail('Unsupported manifest EDN value; use maps, vectors, keywords, strings, integers, booleans or nil', file);
|
|
49
|
+
}
|
|
50
|
+
return convert(values[0]);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function writeManifest(value, options = {}) {
|
|
54
|
+
if (options?.compact !== undefined && typeof options.compact !== 'boolean') throw new TypeError('compact must be a boolean');
|
|
55
|
+
const identifiers = new Set(['language', 'layers']);
|
|
56
|
+
function convert(value, parent) {
|
|
57
|
+
if (Array.isArray(value)) return value.map(entry => convert(entry, parent));
|
|
58
|
+
if (value && typeof value === 'object') return {map: Object.entries(value).filter(([,entry]) => entry !== undefined).map(([key, entry]) => [
|
|
59
|
+
/^[a-z][A-Za-z0-9]*$/.test(key) ? {key: kebab(key)} : key,
|
|
60
|
+
convert(entry, key),
|
|
61
|
+
])};
|
|
62
|
+
return typeof value === 'string' && identifiers.has(parent) ? {key: value} : value;
|
|
63
|
+
}
|
|
64
|
+
function layout(value, depth) {
|
|
65
|
+
const indent = ' '.repeat(depth), child = indent + ' ';
|
|
66
|
+
if (value && !Array.isArray(value) && value.map)
|
|
67
|
+
return '{\n' + value.map.map(([key, entry]) => child + toEDNString(key) + ' ' + layout(entry, depth + 1)).join('\n') + '\n' + indent + '}';
|
|
68
|
+
if (Array.isArray(value) && value.some(entry => entry && typeof entry === 'object'))
|
|
69
|
+
return '[\n' + value.map(entry => child + layout(entry, depth + 1)).join('\n') + '\n' + indent + ']';
|
|
70
|
+
return toEDNString(value);
|
|
71
|
+
}
|
|
72
|
+
const converted = convert(value);
|
|
73
|
+
return (options?.compact === true ? toEDNString(converted) : layout(converted, 0)) + '\n';
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
let core;
|
|
77
|
+
async function coreRequest(request) {
|
|
78
|
+
core ??= loadCore();
|
|
79
|
+
const result = await (await core)({schemaVersion: 5, ...request});
|
|
80
|
+
if (result.diagnostics?.length) {
|
|
81
|
+
const error = new Error(result.diagnostics.map(item => item.message).join('\n'));
|
|
82
|
+
error.diagnostics = result.diagnostics;
|
|
83
|
+
throw error;
|
|
84
|
+
}
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export async function readManifest(file) {
|
|
89
|
+
if (path.extname(file) !== '.edn') fail('LawSpec component and package manifests must use lawspec.edn; JSON configuration is no longer supported', file);
|
|
90
|
+
const manifest = parseManifest(await readFile(file, 'utf8'), file);
|
|
91
|
+
try { return (await coreRequest({method: 'componentManifest', manifest})).manifest; }
|
|
92
|
+
catch (error) {
|
|
93
|
+
error.message = `${file}: ${error.message}`;
|
|
94
|
+
error.diagnostics = error.diagnostics?.map(item => ({...item, at: {file, line: 1, column: 1}}));
|
|
95
|
+
throw error;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export async function findManifest(start = process.cwd()) {
|
|
100
|
+
let directory = path.resolve(start);
|
|
101
|
+
for (;;) {
|
|
102
|
+
const candidate = path.join(directory, manifestName);
|
|
103
|
+
if (await stat(candidate).then(info => info.isFile(), () => false)) return candidate;
|
|
104
|
+
for (const old of ['lawspec.json', 'lawspec-package.json'])
|
|
105
|
+
if (await stat(path.join(directory, old)).then(info => info.isFile(), () => false))
|
|
106
|
+
fail(`${old} is no longer supported; use lawspec.edn`, path.join(directory, old));
|
|
107
|
+
const parent = path.dirname(directory);
|
|
108
|
+
if (parent === directory) fail('No lawspec.edn found in this directory or its parents', start);
|
|
109
|
+
directory = parent;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export async function packageVersions(range, versions) {
|
|
114
|
+
return (await coreRequest({method: 'packageVersions', range, versions})).versions;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export const dependencyRanges = manifest => Object.fromEntries(Object.entries(manifest.dependencies ?? {}).map(([name, value]) => [name, typeof value === 'string' ? value : value.version]));
|
|
118
|
+
export const contentDigest = value => createHash('sha256').update(value).digest('hex');
|
|
119
|
+
export function canonical(value) {
|
|
120
|
+
if (Array.isArray(value)) return '[' + value.map(canonical).join(',') + ']';
|
|
121
|
+
if (value && typeof value === 'object') return '{' + Object.keys(value).sort().map(key => JSON.stringify(key) + ':' + canonical(value[key])).join(',') + '}';
|
|
122
|
+
return JSON.stringify(value);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export async function componentInput(file, options = {}) {
|
|
126
|
+
const manifest = await readManifest(file), root = path.dirname(path.resolve(file));
|
|
127
|
+
const {resolveDependencies} = await import('./component-packages.mjs');
|
|
128
|
+
const dependencies = await resolveDependencies(file, manifest, options);
|
|
129
|
+
const sources = await collectSources(root, manifest.sources, root);
|
|
130
|
+
return {manifest, root, input: {
|
|
131
|
+
sources, languageProfile: manifest.languageProfile,
|
|
132
|
+
verification: manifest.verification ?? {layers: []},
|
|
133
|
+
...(manifest.package ? {package: manifest.package} : {}),
|
|
134
|
+
dependencies: dependencyRanges(manifest), packages: dependencies.packages,
|
|
135
|
+
generation: manifest.generation, machineBits: manifest.machineBits ?? 64,
|
|
136
|
+
projectVersion: manifest.component?.version ?? manifest.package?.version,
|
|
137
|
+
}, dependencies};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export async function resolveComponent(file, options = {}) {
|
|
141
|
+
const {manifest, root, input, dependencies} = await componentInput(file, options);
|
|
142
|
+
const compiler = await createCompiler();
|
|
143
|
+
const relativeCache = path.relative(await realpath(process.cwd()), path.join(await realpath(root), '.lawspec', 'cache'));
|
|
144
|
+
let cacheDirectory;
|
|
145
|
+
if (manifest.cache !== false && relativeCache !== '..' && !relativeCache.startsWith('..' + path.sep) && !path.isAbsolute(relativeCache)) {
|
|
146
|
+
const build = contentDigest(await readFile(new URL('./core.wasm', import.meta.url))).slice(0, 16);
|
|
147
|
+
cacheDirectory = path.join(relativeCache, build).split(path.sep).join('/');
|
|
148
|
+
await mkdir(path.join(process.cwd(), cacheDirectory), {recursive: true});
|
|
149
|
+
await writeFile(path.join(process.cwd(), relativeCache, '.gitignore'), '*\n');
|
|
150
|
+
}
|
|
151
|
+
const request = {...input, verification: {layers: []},
|
|
152
|
+
...(cacheDirectory === undefined ? {} : {cacheDirectory})};
|
|
153
|
+
const checked = await compiler.check(request);
|
|
154
|
+
if (checked.diagnostics?.length) {
|
|
155
|
+
const error = new Error(checked.diagnostics.map(item => item.message).join('\n'));
|
|
156
|
+
error.diagnostics = checked.diagnostics;
|
|
157
|
+
throw error;
|
|
158
|
+
}
|
|
159
|
+
for (const target of manifest.targets ?? []) {
|
|
160
|
+
if (target.nativeBindings === undefined) continue;
|
|
161
|
+
const bound = await compiler.check({...request, nativeBindings: target.nativeBindings});
|
|
162
|
+
if (bound.diagnostics?.length) {
|
|
163
|
+
const error = new Error(bound.diagnostics.map(item => item.message).join('\n'));
|
|
164
|
+
error.diagnostics = bound.diagnostics;
|
|
165
|
+
throw error;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
const declarations = new Set([
|
|
169
|
+
...(checked.units ?? []).flatMap(unit => [...(unit.declarations ?? []), ...(unit.abilities ?? [])]).map(item => item.id),
|
|
170
|
+
...(checked.laws ?? []).map(item => item.id),
|
|
171
|
+
]);
|
|
172
|
+
const contracts = new Map(Object.entries(dependencies.lock.roots).map(([name,id]) => [name, dependencies.lock.packages.find(item => item.id === id)]));
|
|
173
|
+
if (manifest.package) {
|
|
174
|
+
const {packageDigest, resolvedPackageDigest} = await import('./component-packages.mjs');
|
|
175
|
+
contracts.set(manifest.package.name, {...manifest.package, digest: resolvedPackageDigest(await packageDigest(root),
|
|
176
|
+
Object.fromEntries(Object.entries(dependencies.lock.roots).map(([name,id]) => {
|
|
177
|
+
const selected = dependencies.lock.packages.find(entry => entry.id === id);
|
|
178
|
+
return [name, dependencies.identities.find(entry => entry.name === selected.name && entry.version === selected.version).digest];
|
|
179
|
+
})))});
|
|
180
|
+
}
|
|
181
|
+
for (const [name, requirement] of [...Object.entries(manifest.requires ?? {}), ...(manifest.provides ?? []).map((value, index) => [`provides[${index}]`, value])]) {
|
|
182
|
+
if (!contracts.has(requirement.contract)) fail(`${name}: contract ${requirement.contract} is not resolved`, file);
|
|
183
|
+
for (const declaration of [...(requirement.abilities ?? []), ...(requirement.declarations ?? [])])
|
|
184
|
+
if (!declarations.has(declaration)) fail(`${name}: unknown declaration ${declaration}`, file);
|
|
185
|
+
}
|
|
186
|
+
const identity = {
|
|
187
|
+
manifest,
|
|
188
|
+
sources: input.sources,
|
|
189
|
+
dependencies: dependencies.identities,
|
|
190
|
+
inputs: await fingerprintInputs(root, manifest.inputs ?? []),
|
|
191
|
+
};
|
|
192
|
+
const contractView = value => {
|
|
193
|
+
const selected = contracts.get(value.contract);
|
|
194
|
+
const content = dependencies.identities.find(item => item.name === selected.name && item.version === selected.version);
|
|
195
|
+
return {...value, version: selected.version, digest: content?.digest ?? selected.digest,
|
|
196
|
+
...(manifest.dependencies?.[value.contract] ? {versionRequirement: typeof manifest.dependencies[value.contract] === 'string' ? manifest.dependencies[value.contract] : manifest.dependencies[value.contract].version} : {})};
|
|
197
|
+
};
|
|
198
|
+
return {
|
|
199
|
+
format: 'lawspec-component', version: 1, manifest: path.resolve(file), root,
|
|
200
|
+
component: manifest.component ?? null, package: manifest.package ?? null,
|
|
201
|
+
fingerprint: contentDigest(canonical(identity)),
|
|
202
|
+
manifestDigest: contentDigest(await readFile(file)),
|
|
203
|
+
targets: manifest.targets ?? [], provides: (manifest.provides ?? []).map(contractView),
|
|
204
|
+
requires: Object.fromEntries(Object.entries(manifest.requires ?? {}).map(([name,value]) => [name, contractView(value)])),
|
|
205
|
+
dependencies: dependencies.identities,
|
|
206
|
+
laws: checked.laws ?? [], declarations: [...declarations].sort(),
|
|
207
|
+
};
|
|
208
|
+
}
|
package/core.wasm
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: package/core.wasm
|
|
3
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 91825038 bytes
|
|
4
|
+
sha256: 3a869088e465263362697b046d9bc7c17908c568af1a2d0a723d319ae607f801
|
package/core_jsffi.js
CHANGED
|
@@ -92,11 +92,11 @@ newJSVal: (v) => __ghc_wasm_jsffi_jsval_manager.newJSVal(v),
|
|
|
92
92
|
getJSVal: (k) => __ghc_wasm_jsffi_jsval_manager.getJSVal(k),
|
|
93
93
|
freeJSVal: (k) => __ghc_wasm_jsffi_jsval_manager.freeJSVal(k),
|
|
94
94
|
scheduleWork: () => setImmediate(__exports.rts_schedulerLoop),
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
95
|
+
ZC1ZClawspeczmwasmzm0zi31zi0zminplacezmlawspeczmwasmZCMainZC: ($1) => (($1.parts.push($1.decoder.decode()), $1.parts.join(''))),
|
|
96
|
+
ZC2ZClawspeczmwasmzm0zi31zi0zminplacezmlawspeczmwasmZCMainZC: ($1,$2,$3) => ($1.parts.push($1.decoder.decode(new Uint8Array(__exports.memory.buffer, $2 >>> 0, $3), {stream: true}))),
|
|
97
|
+
ZC3ZClawspeczmwasmzm0zi31zi0zminplacezmlawspeczmwasmZCMainZC: () => (({decoder: new TextDecoder('utf-8', {fatal: true}), parts: []})),
|
|
98
|
+
ZC4ZClawspeczmwasmzm0zi31zi0zminplacezmlawspeczmwasmZCMainZC: ($1,$2,$3) => ((new TextEncoder()).encodeInto($1, new Uint8Array(__exports.memory.buffer, $2 >>> 0, $3)).written),
|
|
99
|
+
ZC5ZClawspeczmwasmzm0zi31zi0zminplacezmlawspeczmwasmZCMainZC: ($1) => ($1.length),
|
|
100
100
|
ZC0ZCghczminternalZCGHCziInternalziWasmziPrimziExportsZC: ($1,$2) => ($1.reject(new WebAssembly.RuntimeError($2))),
|
|
101
101
|
ZC18ZCghczminternalZCGHCziInternalziWasmziPrimziExportsZC: ($1,$2) => ($1.resolve($2)),
|
|
102
102
|
ZC20ZCghczminternalZCGHCziInternalziWasmziPrimziExportsZC: ($1) => {$1.throwTo = () => {};},
|