sh3-core 0.4.2 → 0.4.3
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/dist/build.js +23 -3
- package/dist/registry/client.js +2 -3
- package/dist/registry/schema.js +1 -1
- package/dist/registry/types.d.ts +3 -3
- package/package.json +1 -1
package/dist/build.js
CHANGED
|
@@ -112,7 +112,7 @@ export function sh3Artifact(options = {}) {
|
|
|
112
112
|
}
|
|
113
113
|
},
|
|
114
114
|
async closeBundle() {
|
|
115
|
-
var _a;
|
|
115
|
+
var _a, _b, _c, _d;
|
|
116
116
|
if (!entryFileName)
|
|
117
117
|
return;
|
|
118
118
|
const clientSrc = join(outDir, entryFileName);
|
|
@@ -122,7 +122,7 @@ export function sh3Artifact(options = {}) {
|
|
|
122
122
|
try {
|
|
123
123
|
source = readFileSync(clientSrc, 'utf-8');
|
|
124
124
|
}
|
|
125
|
-
catch (
|
|
125
|
+
catch (_e) {
|
|
126
126
|
console.warn('[sh3-artifact] Could not read entry chunk:', clientSrc);
|
|
127
127
|
return;
|
|
128
128
|
}
|
|
@@ -148,8 +148,28 @@ export function sh3Artifact(options = {}) {
|
|
|
148
148
|
copyFileSync(options.serverEntry, join(outDir, 'server.js'));
|
|
149
149
|
hasServer = true;
|
|
150
150
|
}
|
|
151
|
+
// --- Read fallback metadata from package.json ---
|
|
152
|
+
let pkgDescription;
|
|
153
|
+
let pkgAuthor;
|
|
154
|
+
try {
|
|
155
|
+
const pkg = JSON.parse(readFileSync('package.json', 'utf-8'));
|
|
156
|
+
pkgDescription = typeof pkg.description === 'string' ? pkg.description : undefined;
|
|
157
|
+
pkgAuthor = typeof pkg.author === 'string'
|
|
158
|
+
? pkg.author
|
|
159
|
+
: typeof ((_a = pkg.author) === null || _a === void 0 ? void 0 : _a.name) === 'string' ? pkg.author.name : undefined;
|
|
160
|
+
}
|
|
161
|
+
catch ( /* no package.json or unreadable */_f) { /* no package.json or unreadable */ }
|
|
151
162
|
// --- Write manifest.json ---
|
|
152
|
-
const
|
|
163
|
+
const overrides = (_b = options.manifest) !== null && _b !== void 0 ? _b : {};
|
|
164
|
+
const finalDescription = (_c = overrides.description) !== null && _c !== void 0 ? _c : pkgDescription;
|
|
165
|
+
const finalAuthor = (_d = overrides.author) !== null && _d !== void 0 ? _d : pkgAuthor;
|
|
166
|
+
if (!finalDescription) {
|
|
167
|
+
throw new Error('[sh3-artifact] Missing "description". Add it to package.json or pass it via sh3Artifact({ manifest: { description } }).');
|
|
168
|
+
}
|
|
169
|
+
if (!finalAuthor) {
|
|
170
|
+
throw new Error('[sh3-artifact] Missing "author". Add it to package.json or pass it via sh3Artifact({ manifest: { author } }).');
|
|
171
|
+
}
|
|
172
|
+
const manifest = Object.assign(Object.assign(Object.assign({ id: id || 'unknown', type, label: label || id || 'unknown', version: version || '0.0.0', contractVersion: 1, client: 'client.js' }, (hasServer ? { server: 'server.js' } : {})), { description: finalDescription, author: finalAuthor }), overrides);
|
|
153
173
|
writeFileSync(join(outDir, 'manifest.json'), JSON.stringify(manifest, null, 2) + '\n');
|
|
154
174
|
// --- Log summary ---
|
|
155
175
|
const files = ['manifest.json', 'client.js'];
|
package/dist/registry/client.js
CHANGED
|
@@ -82,9 +82,8 @@ export async function fetchRegistries(urls) {
|
|
|
82
82
|
*/
|
|
83
83
|
export async function fetchBundle(version, sourceRegistry) {
|
|
84
84
|
let url = version.bundleUrl;
|
|
85
|
-
if (sourceRegistry &&
|
|
86
|
-
|
|
87
|
-
url = `${base.origin}${url}`;
|
|
85
|
+
if (sourceRegistry && !/^https?:\/\//i.test(url)) {
|
|
86
|
+
url = new URL(url, sourceRegistry).href;
|
|
88
87
|
}
|
|
89
88
|
const response = await fetch(url);
|
|
90
89
|
if (!response.ok) {
|
package/dist/registry/schema.js
CHANGED
|
@@ -71,7 +71,7 @@ function validatePackageEntry(data, path) {
|
|
|
71
71
|
}
|
|
72
72
|
const obj = data;
|
|
73
73
|
requireString(obj, 'id', path);
|
|
74
|
-
requireOneOf(obj, 'type', ['shard', 'app'], path);
|
|
74
|
+
requireOneOf(obj, 'type', ['shard', 'app', 'combo'], path);
|
|
75
75
|
requireString(obj, 'label', path);
|
|
76
76
|
requireString(obj, 'description', path);
|
|
77
77
|
// author: { name: string }
|
package/dist/registry/types.d.ts
CHANGED
|
@@ -47,7 +47,7 @@ export interface PackageEntry {
|
|
|
47
47
|
* Whether this package is a shard (module that contributes views/commands)
|
|
48
48
|
* or an app (composition document that wires shards into a layout).
|
|
49
49
|
*/
|
|
50
|
-
type: 'shard' | 'app';
|
|
50
|
+
type: 'shard' | 'app' | 'combo';
|
|
51
51
|
/**
|
|
52
52
|
* Human-readable display name shown in the store UI.
|
|
53
53
|
* Should be short (under 40 characters).
|
|
@@ -161,7 +161,7 @@ export interface InstalledPackage {
|
|
|
161
161
|
/**
|
|
162
162
|
* Whether this is a shard or an app.
|
|
163
163
|
*/
|
|
164
|
-
type: 'shard' | 'app';
|
|
164
|
+
type: 'shard' | 'app' | 'combo';
|
|
165
165
|
/**
|
|
166
166
|
* The version that was installed.
|
|
167
167
|
*/
|
|
@@ -226,7 +226,7 @@ export interface PackageMeta {
|
|
|
226
226
|
/**
|
|
227
227
|
* Whether this is a shard or an app.
|
|
228
228
|
*/
|
|
229
|
-
type: 'shard' | 'app';
|
|
229
|
+
type: 'shard' | 'app' | 'combo';
|
|
230
230
|
/**
|
|
231
231
|
* The version being installed. Matches `PackageVersion.version`.
|
|
232
232
|
*/
|