@arkstack/inertia 0.15.2 → 0.15.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.
@@ -1,4 +1,4 @@
1
- import { n as resolveSsrBundle, o as inertiaConfig, r as superviseProcess } from "../ssr-process-DkRTrGvf.js";
1
+ import { n as resolveSsrBundle, o as inertiaConfig, r as superviseProcess } from "../ssr-process-C6QRQAaQ.js";
2
2
  import { Arkstack } from "@arkstack/contract";
3
3
  import { Command } from "@h3ravel/musket";
4
4
  import { existsSync } from "node:fs";
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Response } from "@arkstack/http";
2
+ import { ViewFactory } from "@arkstack/view";
2
3
 
3
4
  //#region src/types.d.ts
4
5
  /**
@@ -264,6 +265,23 @@ declare const builtInTemplate: (mount: string, head?: string) => string;
264
265
  */
265
266
  declare const renderRootHtml: (page: InertiaPage, config: InertiaConfig) => Promise<string>;
266
267
  //#endregion
268
+ //#region src/tags.d.ts
269
+ /**
270
+ * Register the `@inertia` and `@inertiaHead` Edge tags on a view factory.
271
+ *
272
+ * - `@inertia` renders the root mount element (`<div data-page="…">`), or the
273
+ * server-rendered markup when SSR is enabled.
274
+ * - `@inertiaHead` renders the SSR head tags (empty without SSR).
275
+ *
276
+ * Both read the values the adapter passes to the root template, so they replace
277
+ * the equivalent `{{{ inertia }}}` / `{{{ inertiaHead }}}` interpolations.
278
+ * Idempotent per factory.
279
+ *
280
+ * @param factory
281
+ * @returns
282
+ */
283
+ declare const registerInertiaTags: (factory: ViewFactory) => void;
284
+ //#endregion
267
285
  //#region src/ssr.d.ts
268
286
  /** The default address the Inertia SSR server listens on. */
269
287
  declare const DEFAULT_SSR_URL = "http://127.0.0.1:13714/render";
@@ -374,4 +392,4 @@ declare const SEE_OTHER_METHODS: Set<string>;
374
392
  */
375
393
  declare const shouldUpgradeRedirect: (method: string, status: number) => boolean;
376
394
  //#endregion
377
- export { AlwaysProp, AlwaysPropContract, DEFAULT_SSR_BUNDLE, DEFAULT_SSR_URL, DeferProp, DeferPropContract, Inertia, InertiaConfig, InertiaPage, InertiaPropWrapper, InertiaRequest, type InertiaStore, LazyProp, LazyPropContract, PageProps, SEE_OTHER_METHODS, type SsrProcessController, type SsrResponse, type SuperviseOptions, builtInTemplate, configure, currentStore, defaultConfig, escapeHtmlAttribute, flushShared, inertia, inertiaConfig, isAlwaysProp, isDeferProp, isLazyProp, isPropWrapper, renderDataPage, renderRootHtml, renderViaSsr, resetConfig, resolveProps, resolveSsrBundle, resolveVersion, runInertia, setVersion, shareData, sharedData, shouldUpgradeRedirect, superviseProcess };
395
+ export { AlwaysProp, AlwaysPropContract, DEFAULT_SSR_BUNDLE, DEFAULT_SSR_URL, DeferProp, DeferPropContract, Inertia, InertiaConfig, InertiaPage, InertiaPropWrapper, InertiaRequest, type InertiaStore, LazyProp, LazyPropContract, PageProps, SEE_OTHER_METHODS, type SsrProcessController, type SsrResponse, type SuperviseOptions, builtInTemplate, configure, currentStore, defaultConfig, escapeHtmlAttribute, flushShared, inertia, inertiaConfig, isAlwaysProp, isDeferProp, isLazyProp, isPropWrapper, registerInertiaTags, renderDataPage, renderRootHtml, renderViaSsr, resetConfig, resolveProps, resolveSsrBundle, resolveVersion, runInertia, setVersion, shareData, sharedData, shouldUpgradeRedirect, superviseProcess };
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
- import { a as defaultConfig, c as resolveVersion, i as configure, l as setVersion, n as resolveSsrBundle, o as inertiaConfig, r as superviseProcess, s as resetConfig, t as DEFAULT_SSR_BUNDLE } from "./ssr-process-DkRTrGvf.js";
1
+ import { t as registerInertiaTags } from "./tags-DpBq4bSL.js";
2
+ import { a as defaultConfig, c as resolveVersion, i as configure, l as setVersion, n as resolveSsrBundle, o as inertiaConfig, r as superviseProcess, s as resetConfig, t as DEFAULT_SSR_BUNDLE } from "./ssr-process-C6QRQAaQ.js";
2
3
  import { AsyncLocalStorage } from "node:async_hooks";
3
4
  import { Response } from "@arkstack/http";
4
5
  //#region src/props.ts
@@ -191,7 +192,10 @@ const renderRootHtml = async (page, config) => {
191
192
  }
192
193
  try {
193
194
  const { view } = await import("@arkstack/view");
194
- if (view().exists(config.root_view)) return await view(config.root_view, {
195
+ const { registerInertiaTags } = await import("./tags-DpBq4bSL.js").then((n) => n.n);
196
+ const factory = view();
197
+ registerInertiaTags(factory);
198
+ if (factory.exists(config.root_view)) return await view(config.root_view, {
195
199
  page,
196
200
  inertia: mount,
197
201
  inertiaHead: head
@@ -391,4 +395,4 @@ function inertia(component, props = {}) {
391
395
  return Inertia.render(component, props);
392
396
  }
393
397
  //#endregion
394
- export { AlwaysProp, DEFAULT_SSR_BUNDLE, DEFAULT_SSR_URL, DeferProp, Inertia, LazyProp, SEE_OTHER_METHODS, builtInTemplate, configure, currentStore, defaultConfig, escapeHtmlAttribute, flushShared, inertia, inertiaConfig, isAlwaysProp, isDeferProp, isLazyProp, isPropWrapper, renderDataPage, renderRootHtml, renderViaSsr, resetConfig, resolveProps, resolveSsrBundle, resolveVersion, runInertia, setVersion, shareData, sharedData, shouldUpgradeRedirect, superviseProcess };
398
+ export { AlwaysProp, DEFAULT_SSR_BUNDLE, DEFAULT_SSR_URL, DeferProp, Inertia, LazyProp, SEE_OTHER_METHODS, builtInTemplate, configure, currentStore, defaultConfig, escapeHtmlAttribute, flushShared, inertia, inertiaConfig, isAlwaysProp, isDeferProp, isLazyProp, isPropWrapper, registerInertiaTags, renderDataPage, renderRootHtml, renderViaSsr, resetConfig, resolveProps, resolveSsrBundle, resolveVersion, runInertia, setVersion, shareData, sharedData, shouldUpgradeRedirect, superviseProcess };
@@ -0,0 +1,51 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __defProp = Object.defineProperty;
3
+ var __exportAll = (all, no_symbols) => {
4
+ let target = {};
5
+ for (var name in all) __defProp(target, name, {
6
+ get: all[name],
7
+ enumerable: true
8
+ });
9
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
10
+ return target;
11
+ };
12
+ //#endregion
13
+ //#region src/tags.ts
14
+ var tags_exports = /* @__PURE__ */ __exportAll({ registerInertiaTags: () => registerInertiaTags });
15
+ /** Factories that already have the Inertia tags registered. */
16
+ const registered = /* @__PURE__ */ new WeakSet();
17
+ /**
18
+ * Build an Edge tag compiler that outputs a template data variable raw (falling
19
+ * back to an empty string when it is absent).
20
+ *
21
+ * @param name
22
+ * @returns
23
+ */
24
+ const outputVariable = (name) => {
25
+ return (parser, buffer, token) => {
26
+ const ast = parser.utils.transformAst(parser.utils.generateAST(`${name} || ""`, token.loc, token.filename), token.filename, parser);
27
+ buffer.outputExpression(parser.utils.stringify(ast), token.filename, token.loc.start.line, false);
28
+ };
29
+ };
30
+ /**
31
+ * Register the `@inertia` and `@inertiaHead` Edge tags on a view factory.
32
+ *
33
+ * - `@inertia` renders the root mount element (`<div data-page="…">`), or the
34
+ * server-rendered markup when SSR is enabled.
35
+ * - `@inertiaHead` renders the SSR head tags (empty without SSR).
36
+ *
37
+ * Both read the values the adapter passes to the root template, so they replace
38
+ * the equivalent `{{{ inertia }}}` / `{{{ inertiaHead }}}` interpolations.
39
+ * Idempotent per factory.
40
+ *
41
+ * @param factory
42
+ * @returns
43
+ */
44
+ const registerInertiaTags = (factory) => {
45
+ if (registered.has(factory)) return;
46
+ registered.add(factory);
47
+ factory.tag("inertia", false, false, outputVariable("inertia"));
48
+ factory.tag("inertiaHead", false, false, outputVariable("inertiaHead"));
49
+ };
50
+ //#endregion
51
+ export { tags_exports as n, registerInertiaTags as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkstack/inertia",
3
- "version": "0.15.2",
3
+ "version": "0.15.3",
4
4
  "type": "module",
5
5
  "description": "InertiaJS server-side adapter for Arkstack, building the modern monolith with server-driven SPAs.",
6
6
  "homepage": "https://arkstack.toneflix.net/guide/inertia",
@@ -33,13 +33,13 @@
33
33
  "./package.json": "./package.json"
34
34
  },
35
35
  "dependencies": {
36
- "@arkstack/common": "^0.15.2"
36
+ "@arkstack/common": "^0.15.3"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "@h3ravel/musket": "^2.2.1",
40
- "@arkstack/contract": "^0.15.2",
41
- "@arkstack/http": "^0.15.2",
42
- "@arkstack/view": "^0.15.2"
40
+ "@arkstack/contract": "^0.15.3",
41
+ "@arkstack/http": "^0.15.3",
42
+ "@arkstack/view": "^0.15.3"
43
43
  },
44
44
  "peerDependenciesMeta": {
45
45
  "@arkstack/view": {
@@ -3,12 +3,10 @@
3
3
  <head>
4
4
  <meta charset="utf-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1">
6
- {{{ inertiaHead }}}
7
- {{-- Replace with your Vite client + entry tags, e.g.: --}}
8
- {{-- <script type="module" src="http://localhost:5173/@@vite/client"></script> --}}
9
- {{-- <script type="module" src="http://localhost:5173/src/main.ts"></script> --}}
6
+ @inertiaHead
7
+ @vite('resources/js/app.ts')
10
8
  </head>
11
9
  <body>
12
- {{{ inertia }}}
10
+ @inertia
13
11
  </body>
14
12
  </html>