@apex-stack/core 0.1.15 → 0.1.17
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-MFLFMGGZ.js → build-KJF4LJWP.js} +1 -1
- package/dist/{chunk-D3VZDJ3R.js → chunk-7GPCNGGO.js} +35 -5
- package/dist/cli.js +3 -3
- package/dist/{dev-FS4VVUX2.js → dev-WS52CGSE.js} +1 -1
- package/dist/{server-OXKBXSET.js → server-5QQGUF3R.js} +15 -3
- package/dist/{start-BZJZSQHW.js → start-XYVCDMPJ.js} +1 -1
- package/package.json +3 -3
|
@@ -154,9 +154,26 @@ function storesInitialState(stores) {
|
|
|
154
154
|
|
|
155
155
|
// src/dev/renderPage.ts
|
|
156
156
|
import { renderComponent, stateIsland } from "@apex-stack/kit";
|
|
157
|
+
function escAttr(s) {
|
|
158
|
+
return String(s).replace(
|
|
159
|
+
/[&<>"]/g,
|
|
160
|
+
(c) => c === "&" ? "&" : c === "<" ? "<" : c === ">" ? ">" : """
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
function renderHead(head) {
|
|
164
|
+
const parts = [`<title>${head?.title ? escAttr(head.title) : "Apex JS"}</title>`];
|
|
165
|
+
for (const m of head?.meta ?? []) {
|
|
166
|
+
parts.push(`<meta ${Object.entries(m).map(([k, v]) => `${k}="${escAttr(v)}"`).join(" ")} />`);
|
|
167
|
+
}
|
|
168
|
+
for (const l of head?.link ?? []) {
|
|
169
|
+
parts.push(`<link ${Object.entries(l).map(([k, v]) => `${k}="${escAttr(v)}"`).join(" ")} />`);
|
|
170
|
+
}
|
|
171
|
+
return parts.join("\n ");
|
|
172
|
+
}
|
|
157
173
|
async function renderPage(opts) {
|
|
158
174
|
const mod = await opts.loadModule(opts.pageId);
|
|
159
175
|
const loaderData = await mod.loader({ params: opts.params ?? {}, url: opts.url }) ?? {};
|
|
176
|
+
const head = mod.head ? await mod.head({ data: loaderData, params: opts.params ?? {}, url: opts.url }) : void 0;
|
|
160
177
|
const stores = opts.stores ?? [];
|
|
161
178
|
const { html } = renderComponent({
|
|
162
179
|
template: mod.template,
|
|
@@ -165,7 +182,8 @@ async function renderPage(opts) {
|
|
|
165
182
|
scopeId: mod.scopeId,
|
|
166
183
|
loaderData,
|
|
167
184
|
registry: opts.registry,
|
|
168
|
-
stores: storesInitialState(stores)
|
|
185
|
+
stores: storesInitialState(stores),
|
|
186
|
+
authoredDefaults: mod.rootData ? mod.rootData() : void 0
|
|
169
187
|
});
|
|
170
188
|
const doc = shell({
|
|
171
189
|
body: html,
|
|
@@ -173,15 +191,27 @@ async function renderPage(opts) {
|
|
|
173
191
|
css: mod.css + (opts.componentCss ?? ""),
|
|
174
192
|
pageId: opts.pageId,
|
|
175
193
|
clientHref: opts.clientHref,
|
|
176
|
-
storeIds: stores.map((s) => s.id)
|
|
194
|
+
storeIds: stores.map((s) => s.id),
|
|
195
|
+
appCss: opts.appCss,
|
|
196
|
+
headTags: renderHead(head)
|
|
177
197
|
});
|
|
178
198
|
return opts.transformHtml ? opts.transformHtml(opts.url, doc) : doc;
|
|
179
199
|
}
|
|
180
|
-
function shell({
|
|
200
|
+
function shell({
|
|
201
|
+
body,
|
|
202
|
+
island,
|
|
203
|
+
css,
|
|
204
|
+
pageId,
|
|
205
|
+
clientHref,
|
|
206
|
+
storeIds = [],
|
|
207
|
+
appCss,
|
|
208
|
+
headTags = "<title>Apex JS</title>"
|
|
209
|
+
}) {
|
|
181
210
|
const storeImports = storeIds.map((id, i) => ` import __s${i} from ${JSON.stringify(id)}`).join("\n");
|
|
182
211
|
const storeRegs = storeIds.map((_, i) => ` Alpine.store(__s${i}.name, __s${i}.factory())`).join("\n");
|
|
183
212
|
const clientScript = clientHref ? `<script type="module" src="${clientHref}"></script>` : `<script type="module">
|
|
184
|
-
import
|
|
213
|
+
${appCss ? ` import ${JSON.stringify(appCss)}
|
|
214
|
+
` : ""} import Alpine from 'alpinejs'
|
|
185
215
|
${storeImports ? `${storeImports}
|
|
186
216
|
` : ""} import ${JSON.stringify(pageId)}
|
|
187
217
|
window.Alpine = Alpine
|
|
@@ -193,7 +223,7 @@ ${storeRegs ? `${storeRegs}
|
|
|
193
223
|
<head>
|
|
194
224
|
<meta charset="utf-8" />
|
|
195
225
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
196
|
-
|
|
226
|
+
${headTags}
|
|
197
227
|
<style>${css}</style>
|
|
198
228
|
</head>
|
|
199
229
|
<body>
|
package/dist/cli.js
CHANGED
|
@@ -109,9 +109,9 @@ var main = defineCommand2({
|
|
|
109
109
|
},
|
|
110
110
|
subCommands: {
|
|
111
111
|
new: newCommand,
|
|
112
|
-
dev: () => import("./dev-
|
|
113
|
-
build: () => import("./build-
|
|
114
|
-
start: () => import("./start-
|
|
112
|
+
dev: () => import("./dev-WS52CGSE.js").then((m) => m.devCommand),
|
|
113
|
+
build: () => import("./build-KJF4LJWP.js").then((m) => m.buildCommand),
|
|
114
|
+
start: () => import("./start-XYVCDMPJ.js").then((m) => m.startCommand),
|
|
115
115
|
make: () => import("./make-62PPHZQY.js").then((m) => m.makeCommand),
|
|
116
116
|
migrate: () => import("./migrate-NOGFOFV2.js").then((m) => m.migrateCommand),
|
|
117
117
|
mcp: () => import("./mcp-DL4J6JFJ.js").then((m) => m.mcpCommand)
|
|
@@ -20,7 +20,7 @@ var devCommand = defineCommand({
|
|
|
20
20
|
process.stdout.write(banner());
|
|
21
21
|
const sp = spinner(`Starting dev server${args.islands ? " (islands mode)" : ""}\u2026`);
|
|
22
22
|
try {
|
|
23
|
-
const { startDevServer } = await import("./server-
|
|
23
|
+
const { startDevServer } = await import("./server-5QQGUF3R.js");
|
|
24
24
|
const { port: actual } = await startDevServer({ root, port, islands: Boolean(args.islands) });
|
|
25
25
|
sp.succeed("Dev server ready");
|
|
26
26
|
ready([
|
|
@@ -13,14 +13,15 @@ import {
|
|
|
13
13
|
renderIslandsPage,
|
|
14
14
|
renderPage,
|
|
15
15
|
scanPages
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-7GPCNGGO.js";
|
|
17
17
|
import "./chunk-MZVLRU3R.js";
|
|
18
18
|
|
|
19
19
|
// src/dev/server.ts
|
|
20
|
+
import { existsSync as existsSync2 } from "fs";
|
|
20
21
|
import { createServer as createHttpServer } from "http";
|
|
21
22
|
import { createRequire } from "module";
|
|
22
23
|
import { join } from "path";
|
|
23
|
-
import { fileURLToPath } from "url";
|
|
24
|
+
import { fileURLToPath, pathToFileURL } from "url";
|
|
24
25
|
import { apex } from "@apex-stack/vite";
|
|
25
26
|
import {
|
|
26
27
|
createApp,
|
|
@@ -165,6 +166,16 @@ async function startDevServer(options) {
|
|
|
165
166
|
};
|
|
166
167
|
if (alpine) alias.alpinejs = alpine;
|
|
167
168
|
if (kit) alias["@apex-stack/kit"] = kit;
|
|
169
|
+
const plugins = [apex({ clientRuntime: "@apex-stack/core/client" })];
|
|
170
|
+
try {
|
|
171
|
+
const reqProj = createRequire(join(options.root, "package.json"));
|
|
172
|
+
const twMod = await import(pathToFileURL(reqProj.resolve("@tailwindcss/vite")).href);
|
|
173
|
+
const tw = twMod.default ?? twMod;
|
|
174
|
+
plugins.unshift(tw());
|
|
175
|
+
} catch {
|
|
176
|
+
}
|
|
177
|
+
const appCssRel = ["app.css", "styles/app.css", "src/app.css"].find((p) => existsSync2(join(options.root, p)));
|
|
178
|
+
const appCss = appCssRel ? `/${appCssRel}` : void 0;
|
|
168
179
|
const vite = await createViteServer({
|
|
169
180
|
root: options.root,
|
|
170
181
|
appType: "custom",
|
|
@@ -174,7 +185,7 @@ async function startDevServer(options) {
|
|
|
174
185
|
resolve: { alias },
|
|
175
186
|
// User apps depend on `@apex-stack/core`, so the client module imports the runtime
|
|
176
187
|
// from `@apex-stack/core/client` (a re-export) rather than the internal kit package.
|
|
177
|
-
plugins
|
|
188
|
+
plugins,
|
|
178
189
|
optimizeDeps: { include: ["alpinejs"] }
|
|
179
190
|
});
|
|
180
191
|
const ssrLoad = (id) => {
|
|
@@ -211,6 +222,7 @@ async function startDevServer(options) {
|
|
|
211
222
|
registry,
|
|
212
223
|
componentCss,
|
|
213
224
|
stores,
|
|
225
|
+
appCss,
|
|
214
226
|
transformHtml: (u, doc) => vite.transformIndexHtml(u, doc)
|
|
215
227
|
});
|
|
216
228
|
setResponseHeader(event, "Content-Type", "text/html");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apex-stack/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
4
4
|
"description": "The full-stack meta-framework for Alpine.js — CLI and runtime",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"h3": "^1.13.0",
|
|
46
46
|
"vite": "^6.0.7",
|
|
47
47
|
"zod": "^4.4.3",
|
|
48
|
-
"@apex-stack/kit": "0.1.
|
|
49
|
-
"@apex-stack/vite": "0.1.
|
|
48
|
+
"@apex-stack/kit": "0.1.4",
|
|
49
|
+
"@apex-stack/vite": "0.1.5"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"alpinejs": "^3.14.0"
|