@opys/core 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -75
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
# @opys/core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@opys/core)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The frozen-manifest contract for opys: data model, opys shorthand,
|
|
6
|
+
`Val`/`Valset`, glob, interpolation. Behaviors are backed by the
|
|
7
|
+
[`opys-core`](https://crates.io/crates/opys-core) Rust crate via
|
|
8
|
+
napi-rs; domain types and small sugar helpers are hand-written TS.
|
|
6
9
|
|
|
7
10
|
```sh
|
|
8
|
-
npm install @opys/core
|
|
11
|
+
npm install @opys/core
|
|
9
12
|
```
|
|
10
13
|
|
|
11
|
-
##
|
|
14
|
+
## Domain types
|
|
12
15
|
|
|
13
16
|
### `Source` — artifact origin
|
|
14
17
|
|
|
@@ -17,105 +20,81 @@ type Source =
|
|
|
17
20
|
| { kind: 'url'; url: string }
|
|
18
21
|
| { kind: 'file'; file: string }
|
|
19
22
|
| { kind: 'string'; string: string }
|
|
20
|
-
| { kind: '
|
|
23
|
+
| { kind: 'bytes'; bytes: string } // base64
|
|
24
|
+
| { kind: 'pointer'; pointer: string };
|
|
21
25
|
|
|
22
|
-
// Factory functions
|
|
23
26
|
sourceUrl('https://example.com/file.jar');
|
|
24
27
|
sourceFile('./local/file.jar');
|
|
25
28
|
sourceString('inline content');
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
// Parse / encode
|
|
29
|
-
SourceSchema.parse(raw);
|
|
30
|
-
encodeSource(source);
|
|
29
|
+
Source.bytes(new Uint8Array([1, 2, 3])); // auto-base64
|
|
30
|
+
sourcePointer('forge:libraries.json');
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
### `ExtractRule` — zip extraction instructions
|
|
34
34
|
|
|
35
35
|
```ts
|
|
36
36
|
type ExtractRule =
|
|
37
|
-
| { kind: 'pick'; file: string; into: string }
|
|
38
|
-
| { kind: 'scan'; matches: string; into: string; ... }
|
|
39
|
-
| { kind: 'dump'; into: string; clean?: boolean; ... }
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
extractDump('${natives_directory}', { clean: true, excludes: ['META-INF/'] })
|
|
45
|
-
|
|
46
|
-
// Parse / encode
|
|
47
|
-
ExtractSchema.parse(raw) // always returns ExtractRule[]
|
|
48
|
-
encodeExtract(rules)
|
|
37
|
+
| { kind: 'pick'; file: string; into: string } // single file
|
|
38
|
+
| { kind: 'scan'; matches: string; into: string; ... } // glob match
|
|
39
|
+
| { kind: 'dump'; into: string; clean?: boolean; ... }; // full extract
|
|
40
|
+
|
|
41
|
+
extractPick('lwjgl.dll', '${natives_directory}');
|
|
42
|
+
extractScan('*.so', '${natives_directory}', { excludes: ['META-INF/'] });
|
|
43
|
+
extractDump('${natives_directory}', { clean: true, excludes: ['META-INF/'] });
|
|
49
44
|
```
|
|
50
45
|
|
|
51
46
|
### `Artifact` — a single installable artifact
|
|
52
47
|
|
|
53
|
-
An artifact has a source, optional integrity/size checks, optional
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
import { ArtifactSchema, encodeArtifact } from '@opys/core';
|
|
57
|
-
|
|
58
|
-
const artifact = ArtifactSchema.parse(raw);
|
|
59
|
-
encodeArtifact(artifact);
|
|
60
|
-
```
|
|
48
|
+
An artifact has a source, optional integrity/size checks, optional
|
|
49
|
+
extract rules, and optional rulesets that gate it per platform or
|
|
50
|
+
feature.
|
|
61
51
|
|
|
62
|
-
### `Manifest` — the
|
|
52
|
+
### `Manifest` — the frozen wire shape
|
|
63
53
|
|
|
64
54
|
```ts
|
|
65
|
-
|
|
66
|
-
vars: ValDefs;
|
|
67
|
-
launch?: Launch;
|
|
68
|
-
artifacts: ReadonlyArray<Artifact>;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Parse JSON string
|
|
72
|
-
const manifest = await parseManifest(jsonString);
|
|
73
|
-
|
|
74
|
-
// Filter to current platform
|
|
75
|
-
const filtered = filterManifest(manifest, { name: 'linux', arch: 'x64' });
|
|
55
|
+
import { parseManifest, filterManifest, encodeManifest } from '@opys/core';
|
|
76
56
|
|
|
77
|
-
|
|
78
|
-
|
|
57
|
+
const manifest = parseManifest(jsonString);
|
|
58
|
+
const filtered = filterManifest(manifest, {
|
|
59
|
+
name: 'linux',
|
|
60
|
+
version: '',
|
|
61
|
+
arch: 'x86_64',
|
|
62
|
+
});
|
|
63
|
+
const wire = encodeManifest(filtered);
|
|
79
64
|
```
|
|
80
65
|
|
|
81
|
-
### `ValDefs` — interpolation variables
|
|
82
|
-
|
|
83
|
-
Variables support OS-conditional values and `${ref}` interpolation.
|
|
66
|
+
### `ValDefs` — interpolation variables with OS-conditional arms
|
|
84
67
|
|
|
85
68
|
```ts
|
|
86
|
-
import {
|
|
87
|
-
|
|
88
|
-
encodeValDefs,
|
|
89
|
-
resolveValDefs,
|
|
90
|
-
resolveVars,
|
|
91
|
-
} from '@opys/core';
|
|
92
|
-
|
|
93
|
-
const defs = parseValDefs(raw);
|
|
69
|
+
import { resolveValDefs, resolveVars, interpolate } from '@opys/core';
|
|
70
|
+
|
|
94
71
|
const flat = resolveValDefs(defs, platform); // pick OS-appropriate values
|
|
95
72
|
const vars = resolveVars(flat); // resolve ${ref} chains
|
|
96
73
|
const result = interpolate('${root}/assets', vars);
|
|
97
74
|
```
|
|
98
75
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
Used as the default export in `opys.config.mjs`:
|
|
76
|
+
## Build-time HTTP helper
|
|
102
77
|
|
|
103
78
|
```ts
|
|
104
|
-
import {
|
|
105
|
-
|
|
106
|
-
export default defineConfig({
|
|
107
|
-
output: 'opys.json',
|
|
108
|
-
manifest: {
|
|
109
|
-
artifacts: [...],
|
|
110
|
-
vars: [...],
|
|
111
|
-
launch: { ... },
|
|
112
|
-
},
|
|
113
|
-
});
|
|
79
|
+
import { fetchWithRetry } from '@opys/core';
|
|
114
80
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
},
|
|
120
|
-
}));
|
|
81
|
+
const res = await fetchWithRetry('https://api.example.com/data', {
|
|
82
|
+
attempts: 4,
|
|
83
|
+
baseDelayMs: 250,
|
|
84
|
+
});
|
|
121
85
|
```
|
|
86
|
+
|
|
87
|
+
Used by every plugin that resolves data from upstream APIs. Bounded
|
|
88
|
+
exponential backoff on transient errors (network failures + 5xx);
|
|
89
|
+
4xx and JSON-parse failures surface unchanged.
|
|
90
|
+
|
|
91
|
+
## Frozen wire format
|
|
92
|
+
|
|
93
|
+
`opys.json` is the contract. Other opys packages layer on top:
|
|
94
|
+
|
|
95
|
+
- [`@opys/dev`](https://www.npmjs.com/package/@opys/dev) — config +
|
|
96
|
+
plugin SDK that produces manifests.
|
|
97
|
+
- [`@opys/runtime`](https://www.npmjs.com/package/@opys/runtime) —
|
|
98
|
+
install + launch executor that consumes manifests.
|
|
99
|
+
|
|
100
|
+
Part of the [opys](https://github.com/harmoniya-net/opys) toolkit.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opys/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.js",
|
|
6
6
|
"peerDependencies": {
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
},
|
|
23
23
|
"type": "module",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@opys/core-binding": "^0.1.
|
|
26
|
-
"@opys/mojang-rules": "^0.1.
|
|
25
|
+
"@opys/core-binding": "^0.1.7",
|
|
26
|
+
"@opys/mojang-rules": "^0.1.7"
|
|
27
27
|
},
|
|
28
28
|
"engines": {
|
|
29
29
|
"node": ">=20"
|