@ampless/runtime 1.0.0-alpha.29 → 1.0.0-alpha.31
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/index.js +22 -4
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -236,9 +236,25 @@ import {
|
|
|
236
236
|
} from "ampless";
|
|
237
237
|
|
|
238
238
|
// src/plugin-package-manifest.ts
|
|
239
|
-
import { readFileSync } from "fs";
|
|
240
|
-
import { fileURLToPath } from "url";
|
|
241
239
|
var TRUST_LEVELS = ["untrusted", "trusted", "privileged"];
|
|
240
|
+
function getNodeApi() {
|
|
241
|
+
if (typeof window !== "undefined") return null;
|
|
242
|
+
const proc = typeof process !== "undefined" ? process : void 0;
|
|
243
|
+
if (typeof proc?.getBuiltinModule !== "function") return null;
|
|
244
|
+
if (typeof import.meta.resolve !== "function") return null;
|
|
245
|
+
try {
|
|
246
|
+
const fs = proc.getBuiltinModule("node:fs");
|
|
247
|
+
const url = proc.getBuiltinModule("node:url");
|
|
248
|
+
if (!fs || !url) return null;
|
|
249
|
+
const resolve = import.meta.resolve.bind(import.meta);
|
|
250
|
+
return {
|
|
251
|
+
readFile: (u) => fs.readFileSync(url.fileURLToPath(u), "utf8"),
|
|
252
|
+
resolve
|
|
253
|
+
};
|
|
254
|
+
} catch {
|
|
255
|
+
return null;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
242
258
|
function isValidManifest(value) {
|
|
243
259
|
if (typeof value !== "object" || value === null) return false;
|
|
244
260
|
const v = value;
|
|
@@ -253,15 +269,17 @@ function isValidManifest(value) {
|
|
|
253
269
|
return true;
|
|
254
270
|
}
|
|
255
271
|
function loadPackageManifest(packageName) {
|
|
272
|
+
const node = getNodeApi();
|
|
273
|
+
if (!node) return null;
|
|
256
274
|
let resolvedUrl;
|
|
257
275
|
try {
|
|
258
|
-
resolvedUrl =
|
|
276
|
+
resolvedUrl = node.resolve(`${packageName}/package.json`);
|
|
259
277
|
} catch {
|
|
260
278
|
return null;
|
|
261
279
|
}
|
|
262
280
|
let raw;
|
|
263
281
|
try {
|
|
264
|
-
raw =
|
|
282
|
+
raw = node.readFile(resolvedUrl);
|
|
265
283
|
} catch {
|
|
266
284
|
return null;
|
|
267
285
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ampless/runtime",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.31",
|
|
4
4
|
"description": "Public-side runtime for ampless: post fetching, theme dispatch, middleware, public route handlers",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"lucide-react": "^1.16.0",
|
|
50
50
|
"marked": "^18.0.4",
|
|
51
51
|
"tailwind-merge": "^3.6.0",
|
|
52
|
-
"
|
|
53
|
-
"ampless": "
|
|
52
|
+
"ampless": "1.0.0-alpha.23",
|
|
53
|
+
"@ampless/plugin-og-image": "0.2.0-alpha.23"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"next": "^15 || ^16",
|