@adonisjs/inertia 1.0.0-0 → 1.0.0-10

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.
Files changed (58) hide show
  1. package/build/app.css.stub +39 -0
  2. package/build/chunk-CXICUKHN.js +165 -0
  3. package/build/{stubs/config.stub → config.stub} +9 -1
  4. package/build/index.d.ts +18 -3
  5. package/build/index.js +231 -11
  6. package/build/providers/inertia_provider.d.ts +12 -12
  7. package/build/providers/inertia_provider.js +47 -46
  8. package/build/react/app.tsx.stub +25 -0
  9. package/build/react/home.tsx.stub +21 -0
  10. package/build/react/root.edge.stub +22 -0
  11. package/build/react/ssr.tsx.stub +17 -0
  12. package/build/react/tsconfig.json.stub +25 -0
  13. package/build/solid/app.tsx.stub +24 -0
  14. package/build/solid/home.tsx.stub +21 -0
  15. package/build/solid/root.edge.stub +21 -0
  16. package/build/solid/ssr.tsx.stub +19 -0
  17. package/build/solid/tsconfig.json.stub +26 -0
  18. package/build/src/helpers.d.ts +12 -0
  19. package/build/src/helpers.js +14 -0
  20. package/build/src/inertia_middleware.d.ts +68 -7
  21. package/build/src/inertia_middleware.js +6 -47
  22. package/build/src/plugins/edge/plugin.d.ts +8 -0
  23. package/build/src/plugins/edge/plugin.js +85 -0
  24. package/build/src/plugins/{api_client.d.ts → japa/api_client.d.ts} +9 -4
  25. package/build/src/plugins/japa/api_client.js +70 -0
  26. package/build/src/plugins/vite.d.ts +26 -0
  27. package/build/src/plugins/vite.js +33 -0
  28. package/build/src/types.d.ts +72 -8
  29. package/build/src/types.js +0 -9
  30. package/build/vue/app.ts.stub +27 -0
  31. package/build/vue/home.vue.stub +21 -0
  32. package/build/vue/root.edge.stub +21 -0
  33. package/build/vue/ssr.ts.stub +22 -0
  34. package/build/vue/tsconfig.json.stub +26 -0
  35. package/package.json +64 -47
  36. package/build/configure.js +0 -82
  37. package/build/src/debug.d.ts +0 -3
  38. package/build/src/debug.js +0 -10
  39. package/build/src/define_config.d.ts +0 -5
  40. package/build/src/define_config.js +0 -14
  41. package/build/src/inertia.d.ts +0 -39
  42. package/build/src/inertia.js +0 -119
  43. package/build/src/plugins/api_client.js +0 -62
  44. package/build/src/plugins/edge.d.ts +0 -5
  45. package/build/src/plugins/edge.js +0 -43
  46. package/build/src/version_cache.d.ts +0 -27
  47. package/build/src/version_cache.js +0 -68
  48. package/build/stubs/main.d.ts +0 -1
  49. package/build/stubs/main.js +0 -10
  50. package/providers/inertia_provider.ts +0 -66
  51. package/src/debug.ts +0 -12
  52. package/src/define_config.ts +0 -17
  53. package/src/inertia.ts +0 -140
  54. package/src/inertia_middleware.ts +0 -54
  55. package/src/plugins/api_client.ts +0 -127
  56. package/src/plugins/edge.ts +0 -50
  57. package/src/types.ts +0 -48
  58. package/src/version_cache.ts +0 -74
package/src/types.ts DELETED
@@ -1,48 +0,0 @@
1
- /*
2
- * @adonisjs/inertia
3
- *
4
- * (c) AdonisJS
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
-
10
- import type { HttpContext } from '@adonisjs/core/http'
11
-
12
- export type MaybePromise<T> = T | Promise<T>
13
-
14
- /**
15
- * Props that will be passed to inertia render method
16
- */
17
- export type PageProps = Record<string, unknown>
18
-
19
- /**
20
- * Shared data types
21
- */
22
- export type Data = string | number | object | boolean
23
- export type SharedDatumFactory = (ctx: HttpContext) => MaybePromise<Data>
24
- export type SharedData = Record<string, Data | SharedDatumFactory>
25
-
26
- /**
27
- * Allowed values for the assets version
28
- */
29
- export type AssetsVersion = string | number | undefined
30
-
31
- export interface InertiaConfig {
32
- /**
33
- * Path to the Edge view that will be used as the root view for Inertia responses.
34
- * @default root (resources/views/root.edge)
35
- */
36
- rootView?: string
37
-
38
- /**
39
- * The version of your assets. Every client request will be checked against this version.
40
- * If the version is not the same, the client will do a full reload.
41
- */
42
- assetsVersion?: AssetsVersion
43
-
44
- /**
45
- * Data that should be shared with all rendered pages
46
- */
47
- sharedData?: SharedData
48
- }
@@ -1,74 +0,0 @@
1
- /*
2
- * @adonisjs/inertia
3
- *
4
- * (c) AdonisJS
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
-
10
- import crc32 from 'crc-32'
11
- import { readFile } from 'node:fs/promises'
12
-
13
- import type { AssetsVersion } from './types.js'
14
-
15
- /**
16
- * VersionCache is used to cache the version of the assets.
17
- *
18
- * If the user has provided a version, it will be used.
19
- * Otherwise, we will compute a hash from the manifest file
20
- * and cache it.
21
- */
22
- export class VersionCache {
23
- #cachedVersion?: AssetsVersion
24
-
25
- constructor(
26
- protected appRoot: URL,
27
- protected assetsVersion?: AssetsVersion
28
- ) {
29
- this.#cachedVersion = assetsVersion
30
- }
31
-
32
- /**
33
- * Compute the hash of the manifest file and cache it
34
- */
35
- async #getManifestHash(): Promise<AssetsVersion> {
36
- try {
37
- const manifestPath = new URL('public/assets/manifest.json', this.appRoot)
38
- const manifestFile = await readFile(manifestPath, 'utf-8')
39
- this.#cachedVersion = crc32.str(manifestFile)
40
-
41
- return this.#cachedVersion
42
- } catch {
43
- /**
44
- * If the manifest file does not exist, it probably means that we are in
45
- * development mode
46
- */
47
- this.#cachedVersion = '1'
48
- return this.#cachedVersion
49
- }
50
- }
51
-
52
- /**
53
- * Pre-compute the version
54
- */
55
- async computeVersion() {
56
- if (!this.assetsVersion) await this.#getManifestHash()
57
- return this
58
- }
59
-
60
- /**
61
- * Returns the current assets version
62
- */
63
- getVersion() {
64
- if (!this.#cachedVersion) throw new Error('Version has not been computed yet')
65
- return this.#cachedVersion
66
- }
67
-
68
- /**
69
- * Set the assets version
70
- */
71
- async setVersion(version: AssetsVersion) {
72
- this.#cachedVersion = version
73
- }
74
- }