@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/index.mjs
CHANGED
|
@@ -17,7 +17,22 @@ import AdmZip from 'adm-zip';
|
|
|
17
17
|
|
|
18
18
|
var __defProp = Object.defineProperty;
|
|
19
19
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
20
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
21
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
22
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
20
23
|
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
|
|
24
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
25
|
+
var __spreadValues = (a, b) => {
|
|
26
|
+
for (var prop in b || (b = {}))
|
|
27
|
+
if (__hasOwnProp.call(b, prop))
|
|
28
|
+
__defNormalProp(a, prop, b[prop]);
|
|
29
|
+
if (__getOwnPropSymbols)
|
|
30
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
31
|
+
if (__propIsEnum.call(b, prop))
|
|
32
|
+
__defNormalProp(a, prop, b[prop]);
|
|
33
|
+
}
|
|
34
|
+
return a;
|
|
35
|
+
};
|
|
21
36
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
22
37
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
23
38
|
}) : x)(function(x) {
|
|
@@ -179,6 +194,75 @@ ${namedExportLines}
|
|
|
179
194
|
}
|
|
180
195
|
};
|
|
181
196
|
}
|
|
197
|
+
async function generateThemeData(themePath, outputDir, themeId) {
|
|
198
|
+
const { createJiti } = await import('jiti');
|
|
199
|
+
const jiti = createJiti(import_meta.url);
|
|
200
|
+
let themeConfig = null;
|
|
201
|
+
let layoutConfig = null;
|
|
202
|
+
const pages = {};
|
|
203
|
+
for (const ext of [".ts", ".js"]) {
|
|
204
|
+
try {
|
|
205
|
+
const mod = await jiti.import(path.join(themePath, `theme.config${ext}`));
|
|
206
|
+
themeConfig = mod.default || mod;
|
|
207
|
+
break;
|
|
208
|
+
} catch (e) {
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
for (const ext of [".ts", ".js"]) {
|
|
212
|
+
try {
|
|
213
|
+
const mod = await jiti.import(path.join(themePath, `theme.layout${ext}`));
|
|
214
|
+
layoutConfig = mod.default || mod;
|
|
215
|
+
break;
|
|
216
|
+
} catch (e) {
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
const pagesDir = path.join(themePath, "pages");
|
|
220
|
+
try {
|
|
221
|
+
const files = await fs6.readdir(pagesDir);
|
|
222
|
+
for (const file of files) {
|
|
223
|
+
if (!file.match(/\.(ts|js)$/)) continue;
|
|
224
|
+
const name = file.replace(/\.(ts|js)$/, "");
|
|
225
|
+
try {
|
|
226
|
+
const mod = await jiti.import(path.join(pagesDir, file));
|
|
227
|
+
const config = mod.default || mod;
|
|
228
|
+
pages[name] = {
|
|
229
|
+
id: name,
|
|
230
|
+
name: config.title || name,
|
|
231
|
+
path: config.path || `/${name}`,
|
|
232
|
+
config: __spreadValues({ id: name }, config),
|
|
233
|
+
sections: config.sections || [],
|
|
234
|
+
seo: config.seo
|
|
235
|
+
};
|
|
236
|
+
} catch (e) {
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
} catch (e) {
|
|
240
|
+
}
|
|
241
|
+
await fs6.writeFile(
|
|
242
|
+
path.join(outputDir, "theme-data.json"),
|
|
243
|
+
JSON.stringify(
|
|
244
|
+
{
|
|
245
|
+
themeId,
|
|
246
|
+
theme: {
|
|
247
|
+
id: themeId,
|
|
248
|
+
name: (themeConfig == null ? void 0 : themeConfig.name) || themeId,
|
|
249
|
+
config: themeConfig,
|
|
250
|
+
layout: {
|
|
251
|
+
header: (layoutConfig == null ? void 0 : layoutConfig.headerSections) || [],
|
|
252
|
+
footer: (layoutConfig == null ? void 0 : layoutConfig.footerSections) || []
|
|
253
|
+
},
|
|
254
|
+
pages: Object.keys(pages)
|
|
255
|
+
},
|
|
256
|
+
pages
|
|
257
|
+
},
|
|
258
|
+
null,
|
|
259
|
+
2
|
|
260
|
+
)
|
|
261
|
+
);
|
|
262
|
+
logger.info(
|
|
263
|
+
`Generated theme-data.json (${Object.keys(pages).length} pages)`
|
|
264
|
+
);
|
|
265
|
+
}
|
|
182
266
|
async function contentHashEntry(outputDir) {
|
|
183
267
|
const entryPath = path.join(outputDir, "bundle-entry.js");
|
|
184
268
|
const mapPath = path.join(outputDir, "bundle-entry.js.map");
|
|
@@ -360,6 +444,7 @@ async function compileStandaloneTheme(themePath, themeName) {
|
|
|
360
444
|
}
|
|
361
445
|
await contentHashEntry(outputDir);
|
|
362
446
|
await generateManifest2(themeName, themePath, outputDir);
|
|
447
|
+
await generateThemeData(themePath, outputDir, themeName);
|
|
363
448
|
if (result.metafile) {
|
|
364
449
|
const outputs = result.metafile.outputs;
|
|
365
450
|
let totalSize = 0;
|
|
@@ -436,6 +521,7 @@ async function compileStandaloneThemeDev(themePath, themeName) {
|
|
|
436
521
|
const context2 = await esbuild.context(buildOptions);
|
|
437
522
|
await context2.rebuild();
|
|
438
523
|
await generateManifest2(themeName, themePath, outputDir);
|
|
524
|
+
await generateThemeData(themePath, outputDir, themeName);
|
|
439
525
|
return { context: context2, outputDir };
|
|
440
526
|
}
|
|
441
527
|
async function compilePreviewRuntime(themePath) {
|
|
@@ -509,6 +595,65 @@ ${locations.join("\n")}`
|
|
|
509
595
|
loader: "js"
|
|
510
596
|
};
|
|
511
597
|
});
|
|
598
|
+
build2.onResolve({ filter: /^lucide-react/ }, async (args) => {
|
|
599
|
+
var _a;
|
|
600
|
+
if ((_a = args.pluginData) == null ? void 0 : _a.skipStub) return void 0;
|
|
601
|
+
try {
|
|
602
|
+
const result = await build2.resolve(args.path, {
|
|
603
|
+
kind: args.kind,
|
|
604
|
+
resolveDir: args.resolveDir,
|
|
605
|
+
importer: args.importer,
|
|
606
|
+
namespace: "file",
|
|
607
|
+
pluginData: { skipStub: true }
|
|
608
|
+
});
|
|
609
|
+
if (!result.errors.length) return result;
|
|
610
|
+
} catch (e) {
|
|
611
|
+
}
|
|
612
|
+
return { path: args.path, namespace: "lucide-stub" };
|
|
613
|
+
});
|
|
614
|
+
build2.onLoad({ filter: /.*/, namespace: "lucide-stub" }, () => ({
|
|
615
|
+
// Provide all icon names used by @onexapis/core as no-op SVG stub components
|
|
616
|
+
contents: `
|
|
617
|
+
const icon = (props) => null;
|
|
618
|
+
export { icon as Check, icon as ChevronDown, icon as XCircle, icon as AlertTriangle };
|
|
619
|
+
export { icon as CheckCircle, icon as Info, icon as X, icon as XIcon };
|
|
620
|
+
export { icon as CircleIcon, icon as Star, icon as ShoppingCart };
|
|
621
|
+
export { icon as ChevronRight, icon as ChevronLeft, icon as ChevronUp };
|
|
622
|
+
export { icon as Search, icon as Menu, icon as Heart, icon as User };
|
|
623
|
+
export { icon as Trash2, icon as Plus, icon as Minus, icon as Eye, icon as EyeOff };
|
|
624
|
+
export { icon as ArrowRight, icon as ArrowLeft, icon as ExternalLink, icon as Mail };
|
|
625
|
+
export { icon as Phone, icon as MapPin, icon as Calendar, icon as Clock };
|
|
626
|
+
export { icon as Facebook, icon as Twitter, icon as Instagram, icon as Linkedin, icon as Github };
|
|
627
|
+
export default new Proxy({}, { get: (_, name) => name === '__esModule' ? true : icon });
|
|
628
|
+
`.trim(),
|
|
629
|
+
loader: "jsx"
|
|
630
|
+
}));
|
|
631
|
+
build2.onResolve({ filter: /^framer-motion/ }, async (args) => {
|
|
632
|
+
var _a;
|
|
633
|
+
if ((_a = args.pluginData) == null ? void 0 : _a.skipStub) return void 0;
|
|
634
|
+
try {
|
|
635
|
+
const result = await build2.resolve(args.path, {
|
|
636
|
+
kind: args.kind,
|
|
637
|
+
resolveDir: args.resolveDir,
|
|
638
|
+
importer: args.importer,
|
|
639
|
+
namespace: "file",
|
|
640
|
+
pluginData: { skipStub: true }
|
|
641
|
+
});
|
|
642
|
+
if (!result.errors.length) return result;
|
|
643
|
+
} catch (e) {
|
|
644
|
+
}
|
|
645
|
+
return { path: args.path, namespace: "motion-stub" };
|
|
646
|
+
});
|
|
647
|
+
build2.onLoad({ filter: /.*/, namespace: "motion-stub" }, () => ({
|
|
648
|
+
contents: `
|
|
649
|
+
const stub = (props) => props.children || null;
|
|
650
|
+
const handler = { get: (_, name) => name === '__esModule' ? true : stub };
|
|
651
|
+
export const motion = new Proxy({}, handler);
|
|
652
|
+
export const AnimatePresence = stub;
|
|
653
|
+
export default { motion, AnimatePresence };
|
|
654
|
+
`.trim(),
|
|
655
|
+
loader: "jsx"
|
|
656
|
+
}));
|
|
512
657
|
}
|
|
513
658
|
};
|
|
514
659
|
await esbuild.build({
|
|
@@ -539,10 +684,11 @@ ${locations.join("\n")}`
|
|
|
539
684
|
});
|
|
540
685
|
return outputPath;
|
|
541
686
|
}
|
|
542
|
-
var PROCESS_SHIM, reactGlobalPlugin;
|
|
687
|
+
var import_meta, PROCESS_SHIM, reactGlobalPlugin;
|
|
543
688
|
var init_compile_theme = __esm({
|
|
544
689
|
"src/utils/compile-theme.ts"() {
|
|
545
690
|
init_logger();
|
|
691
|
+
import_meta = {};
|
|
546
692
|
PROCESS_SHIM = `
|
|
547
693
|
if (typeof process === "undefined") {
|
|
548
694
|
globalThis.process = {
|