@arkstack/inertia 0.15.2 → 0.15.4

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-Cz4b8S_f.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, type AlwaysPropContract, DEFAULT_SSR_BUNDLE, DEFAULT_SSR_URL, DeferProp, type DeferPropContract, Inertia, type InertiaConfig, type InertiaPage, type InertiaPropWrapper, type InertiaRequest, type InertiaStore, LazyProp, type LazyPropContract, type 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,6 +1,18 @@
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 { 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-Cz4b8S_f.js";
2
2
  import { AsyncLocalStorage } from "node:async_hooks";
3
3
  import { Response } from "@arkstack/http";
4
+ //#region \0rolldown/runtime.js
5
+ var __defProp = Object.defineProperty;
6
+ var __exportAll = (all, no_symbols) => {
7
+ let target = {};
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
13
+ return target;
14
+ };
15
+ //#endregion
4
16
  //#region src/props.ts
5
17
  /**
6
18
  * A prop that is excluded from the initial page load and only resolved when the
@@ -96,7 +108,7 @@ const flushShared = () => {
96
108
  //#endregion
97
109
  //#region src/protocol.ts
98
110
  /** Methods whose redirects must use `303 See Other` so the Inertia client re-issues a GET. */
99
- const SEE_OTHER_METHODS = new Set([
111
+ const SEE_OTHER_METHODS = /* @__PURE__ */ new Set([
100
112
  "PUT",
101
113
  "PATCH",
102
114
  "DELETE"
@@ -191,7 +203,10 @@ const renderRootHtml = async (page, config) => {
191
203
  }
192
204
  try {
193
205
  const { view } = await import("@arkstack/view");
194
- if (view().exists(config.root_view)) return await view(config.root_view, {
206
+ const { registerInertiaTags } = await Promise.resolve().then(() => tags_exports);
207
+ const factory = view();
208
+ registerInertiaTags(factory);
209
+ if (factory.exists(config.root_view)) return await view(config.root_view, {
195
210
  page,
196
211
  inertia: mount,
197
212
  inertiaHead: head
@@ -391,4 +406,42 @@ function inertia(component, props = {}) {
391
406
  return Inertia.render(component, props);
392
407
  }
393
408
  //#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 };
409
+ //#region src/tags.ts
410
+ var tags_exports = /* @__PURE__ */ __exportAll({ registerInertiaTags: () => registerInertiaTags });
411
+ /** Factories that already have the Inertia tags registered. */
412
+ const registered = /* @__PURE__ */ new WeakSet();
413
+ /**
414
+ * Build an Edge tag compiler that outputs a template data variable raw (falling
415
+ * back to an empty string when it is absent).
416
+ *
417
+ * @param name
418
+ * @returns
419
+ */
420
+ const outputVariable = (name) => {
421
+ return (parser, buffer, token) => {
422
+ const ast = parser.utils.transformAst(parser.utils.generateAST(`${name} || ""`, token.loc, token.filename), token.filename, parser);
423
+ buffer.outputExpression(parser.utils.stringify(ast), token.filename, token.loc.start.line, false);
424
+ };
425
+ };
426
+ /**
427
+ * Register the `@inertia` and `@inertiaHead` Edge tags on a view factory.
428
+ *
429
+ * - `@inertia` renders the root mount element (`<div data-page="…">`), or the
430
+ * server-rendered markup when SSR is enabled.
431
+ * - `@inertiaHead` renders the SSR head tags (empty without SSR).
432
+ *
433
+ * Both read the values the adapter passes to the root template, so they replace
434
+ * the equivalent `{{{ inertia }}}` / `{{{ inertiaHead }}}` interpolations.
435
+ * Idempotent per factory.
436
+ *
437
+ * @param factory
438
+ * @returns
439
+ */
440
+ const registerInertiaTags = (factory) => {
441
+ if (registered.has(factory)) return;
442
+ registered.add(factory);
443
+ factory.tag("inertia", false, false, outputVariable("inertia"));
444
+ factory.tag("inertiaHead", false, false, outputVariable("inertiaHead"));
445
+ };
446
+ //#endregion
447
+ 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkstack/inertia",
3
- "version": "0.15.2",
3
+ "version": "0.15.4",
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.4"
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/http": "^0.15.4",
41
+ "@arkstack/contract": "^0.15.4",
42
+ "@arkstack/view": "^0.15.4"
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>