@onexapis/cli 1.1.0 → 1.1.2
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/cli.js +153 -2
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +153 -2
- package/dist/cli.mjs.map +1 -1
- package/dist/index.js +147 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +147 -1
- package/dist/index.mjs.map +1 -1
- package/dist/preview/preview-app.tsx +91 -24
- package/package.json +4 -3
package/dist/cli.js
CHANGED
|
@@ -66,7 +66,22 @@ var http__default = /*#__PURE__*/_interopDefault(http);
|
|
|
66
66
|
|
|
67
67
|
var __defProp = Object.defineProperty;
|
|
68
68
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
69
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
70
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
71
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
69
72
|
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
|
|
73
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
74
|
+
var __spreadValues = (a, b) => {
|
|
75
|
+
for (var prop in b || (b = {}))
|
|
76
|
+
if (__hasOwnProp.call(b, prop))
|
|
77
|
+
__defNormalProp(a, prop, b[prop]);
|
|
78
|
+
if (__getOwnPropSymbols)
|
|
79
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
80
|
+
if (__propIsEnum.call(b, prop))
|
|
81
|
+
__defNormalProp(a, prop, b[prop]);
|
|
82
|
+
}
|
|
83
|
+
return a;
|
|
84
|
+
};
|
|
70
85
|
var __esm = (fn, res) => function __init() {
|
|
71
86
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
72
87
|
};
|
|
@@ -222,6 +237,75 @@ ${namedExportLines}
|
|
|
222
237
|
}
|
|
223
238
|
};
|
|
224
239
|
}
|
|
240
|
+
async function generateThemeData(themePath, outputDir, themeId) {
|
|
241
|
+
const { createJiti } = await import('jiti');
|
|
242
|
+
const jiti = createJiti(import_meta.url);
|
|
243
|
+
let themeConfig = null;
|
|
244
|
+
let layoutConfig = null;
|
|
245
|
+
const pages = {};
|
|
246
|
+
for (const ext of [".ts", ".js"]) {
|
|
247
|
+
try {
|
|
248
|
+
const mod = await jiti.import(path__default.default.join(themePath, `theme.config${ext}`));
|
|
249
|
+
themeConfig = mod.default || mod;
|
|
250
|
+
break;
|
|
251
|
+
} catch (e) {
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
for (const ext of [".ts", ".js"]) {
|
|
255
|
+
try {
|
|
256
|
+
const mod = await jiti.import(path__default.default.join(themePath, `theme.layout${ext}`));
|
|
257
|
+
layoutConfig = mod.default || mod;
|
|
258
|
+
break;
|
|
259
|
+
} catch (e) {
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
const pagesDir = path__default.default.join(themePath, "pages");
|
|
263
|
+
try {
|
|
264
|
+
const files = await fs7__default.default.readdir(pagesDir);
|
|
265
|
+
for (const file of files) {
|
|
266
|
+
if (!file.match(/\.(ts|js)$/)) continue;
|
|
267
|
+
const name = file.replace(/\.(ts|js)$/, "");
|
|
268
|
+
try {
|
|
269
|
+
const mod = await jiti.import(path__default.default.join(pagesDir, file));
|
|
270
|
+
const config = mod.default || mod;
|
|
271
|
+
pages[name] = {
|
|
272
|
+
id: name,
|
|
273
|
+
name: config.title || name,
|
|
274
|
+
path: config.path || `/${name}`,
|
|
275
|
+
config: __spreadValues({ id: name }, config),
|
|
276
|
+
sections: config.sections || [],
|
|
277
|
+
seo: config.seo
|
|
278
|
+
};
|
|
279
|
+
} catch (e) {
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
} catch (e) {
|
|
283
|
+
}
|
|
284
|
+
await fs7__default.default.writeFile(
|
|
285
|
+
path__default.default.join(outputDir, "theme-data.json"),
|
|
286
|
+
JSON.stringify(
|
|
287
|
+
{
|
|
288
|
+
themeId,
|
|
289
|
+
theme: {
|
|
290
|
+
id: themeId,
|
|
291
|
+
name: (themeConfig == null ? void 0 : themeConfig.name) || themeId,
|
|
292
|
+
config: themeConfig,
|
|
293
|
+
layout: {
|
|
294
|
+
header: (layoutConfig == null ? void 0 : layoutConfig.headerSections) || [],
|
|
295
|
+
footer: (layoutConfig == null ? void 0 : layoutConfig.footerSections) || []
|
|
296
|
+
},
|
|
297
|
+
pages: Object.keys(pages)
|
|
298
|
+
},
|
|
299
|
+
pages
|
|
300
|
+
},
|
|
301
|
+
null,
|
|
302
|
+
2
|
|
303
|
+
)
|
|
304
|
+
);
|
|
305
|
+
logger.info(
|
|
306
|
+
`Generated theme-data.json (${Object.keys(pages).length} pages)`
|
|
307
|
+
);
|
|
308
|
+
}
|
|
225
309
|
async function contentHashEntry(outputDir) {
|
|
226
310
|
const entryPath = path__default.default.join(outputDir, "bundle-entry.js");
|
|
227
311
|
const mapPath = path__default.default.join(outputDir, "bundle-entry.js.map");
|
|
@@ -403,6 +487,7 @@ async function compileStandaloneTheme(themePath, themeName) {
|
|
|
403
487
|
}
|
|
404
488
|
await contentHashEntry(outputDir);
|
|
405
489
|
await generateManifest2(themeName, themePath, outputDir);
|
|
490
|
+
await generateThemeData(themePath, outputDir, themeName);
|
|
406
491
|
if (result.metafile) {
|
|
407
492
|
const outputs = result.metafile.outputs;
|
|
408
493
|
let totalSize = 0;
|
|
@@ -479,6 +564,7 @@ async function compileStandaloneThemeDev(themePath, themeName) {
|
|
|
479
564
|
const context2 = await esbuild__namespace.context(buildOptions);
|
|
480
565
|
await context2.rebuild();
|
|
481
566
|
await generateManifest2(themeName, themePath, outputDir);
|
|
567
|
+
await generateThemeData(themePath, outputDir, themeName);
|
|
482
568
|
return { context: context2, outputDir };
|
|
483
569
|
}
|
|
484
570
|
async function compilePreviewRuntime(themePath) {
|
|
@@ -552,6 +638,65 @@ ${locations.join("\n")}`
|
|
|
552
638
|
loader: "js"
|
|
553
639
|
};
|
|
554
640
|
});
|
|
641
|
+
build2.onResolve({ filter: /^lucide-react/ }, async (args) => {
|
|
642
|
+
var _a;
|
|
643
|
+
if ((_a = args.pluginData) == null ? void 0 : _a.skipStub) return void 0;
|
|
644
|
+
try {
|
|
645
|
+
const result = await build2.resolve(args.path, {
|
|
646
|
+
kind: args.kind,
|
|
647
|
+
resolveDir: args.resolveDir,
|
|
648
|
+
importer: args.importer,
|
|
649
|
+
namespace: "file",
|
|
650
|
+
pluginData: { skipStub: true }
|
|
651
|
+
});
|
|
652
|
+
if (!result.errors.length) return result;
|
|
653
|
+
} catch (e) {
|
|
654
|
+
}
|
|
655
|
+
return { path: args.path, namespace: "lucide-stub" };
|
|
656
|
+
});
|
|
657
|
+
build2.onLoad({ filter: /.*/, namespace: "lucide-stub" }, () => ({
|
|
658
|
+
// Provide all icon names used by @onexapis/core as no-op SVG stub components
|
|
659
|
+
contents: `
|
|
660
|
+
const icon = (props) => null;
|
|
661
|
+
export { icon as Check, icon as ChevronDown, icon as XCircle, icon as AlertTriangle };
|
|
662
|
+
export { icon as CheckCircle, icon as Info, icon as X, icon as XIcon };
|
|
663
|
+
export { icon as CircleIcon, icon as Star, icon as ShoppingCart };
|
|
664
|
+
export { icon as ChevronRight, icon as ChevronLeft, icon as ChevronUp };
|
|
665
|
+
export { icon as Search, icon as Menu, icon as Heart, icon as User };
|
|
666
|
+
export { icon as Trash2, icon as Plus, icon as Minus, icon as Eye, icon as EyeOff };
|
|
667
|
+
export { icon as ArrowRight, icon as ArrowLeft, icon as ExternalLink, icon as Mail };
|
|
668
|
+
export { icon as Phone, icon as MapPin, icon as Calendar, icon as Clock };
|
|
669
|
+
export { icon as Facebook, icon as Twitter, icon as Instagram, icon as Linkedin, icon as Github };
|
|
670
|
+
export default new Proxy({}, { get: (_, name) => name === '__esModule' ? true : icon });
|
|
671
|
+
`.trim(),
|
|
672
|
+
loader: "jsx"
|
|
673
|
+
}));
|
|
674
|
+
build2.onResolve({ filter: /^framer-motion/ }, async (args) => {
|
|
675
|
+
var _a;
|
|
676
|
+
if ((_a = args.pluginData) == null ? void 0 : _a.skipStub) return void 0;
|
|
677
|
+
try {
|
|
678
|
+
const result = await build2.resolve(args.path, {
|
|
679
|
+
kind: args.kind,
|
|
680
|
+
resolveDir: args.resolveDir,
|
|
681
|
+
importer: args.importer,
|
|
682
|
+
namespace: "file",
|
|
683
|
+
pluginData: { skipStub: true }
|
|
684
|
+
});
|
|
685
|
+
if (!result.errors.length) return result;
|
|
686
|
+
} catch (e) {
|
|
687
|
+
}
|
|
688
|
+
return { path: args.path, namespace: "motion-stub" };
|
|
689
|
+
});
|
|
690
|
+
build2.onLoad({ filter: /.*/, namespace: "motion-stub" }, () => ({
|
|
691
|
+
contents: `
|
|
692
|
+
const stub = (props) => props.children || null;
|
|
693
|
+
const handler = { get: (_, name) => name === '__esModule' ? true : stub };
|
|
694
|
+
export const motion = new Proxy({}, handler);
|
|
695
|
+
export const AnimatePresence = stub;
|
|
696
|
+
export default { motion, AnimatePresence };
|
|
697
|
+
`.trim(),
|
|
698
|
+
loader: "jsx"
|
|
699
|
+
}));
|
|
555
700
|
}
|
|
556
701
|
};
|
|
557
702
|
await esbuild__namespace.build({
|
|
@@ -582,10 +727,11 @@ ${locations.join("\n")}`
|
|
|
582
727
|
});
|
|
583
728
|
return outputPath;
|
|
584
729
|
}
|
|
585
|
-
var PROCESS_SHIM, reactGlobalPlugin;
|
|
730
|
+
var import_meta, PROCESS_SHIM, reactGlobalPlugin;
|
|
586
731
|
var init_compile_theme = __esm({
|
|
587
732
|
"src/utils/compile-theme.ts"() {
|
|
588
733
|
init_logger();
|
|
734
|
+
import_meta = {};
|
|
589
735
|
PROCESS_SHIM = `
|
|
590
736
|
if (typeof process === "undefined") {
|
|
591
737
|
globalThis.process = {
|
|
@@ -3497,7 +3643,12 @@ function createDevServer(options) {
|
|
|
3497
3643
|
res.end("Forbidden");
|
|
3498
3644
|
return;
|
|
3499
3645
|
}
|
|
3500
|
-
|
|
3646
|
+
if (fs2__default.default.existsSync(filePath) && fs2__default.default.statSync(filePath).isFile()) {
|
|
3647
|
+
serveFile(res, filePath);
|
|
3648
|
+
} else {
|
|
3649
|
+
res.writeHead(200, { "Content-Type": "text/html" });
|
|
3650
|
+
res.end(generatePreviewHTML(options.themeName));
|
|
3651
|
+
}
|
|
3501
3652
|
});
|
|
3502
3653
|
const wss = new ws.WebSocketServer({ server });
|
|
3503
3654
|
wss.on("connection", (ws) => {
|