@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.
- package/build/app.css.stub +39 -0
- package/build/chunk-CXICUKHN.js +165 -0
- package/build/{stubs/config.stub → config.stub} +9 -1
- package/build/index.d.ts +18 -3
- package/build/index.js +231 -11
- package/build/providers/inertia_provider.d.ts +12 -12
- package/build/providers/inertia_provider.js +47 -46
- package/build/react/app.tsx.stub +25 -0
- package/build/react/home.tsx.stub +21 -0
- package/build/react/root.edge.stub +22 -0
- package/build/react/ssr.tsx.stub +17 -0
- package/build/react/tsconfig.json.stub +25 -0
- package/build/solid/app.tsx.stub +24 -0
- package/build/solid/home.tsx.stub +21 -0
- package/build/solid/root.edge.stub +21 -0
- package/build/solid/ssr.tsx.stub +19 -0
- package/build/solid/tsconfig.json.stub +26 -0
- package/build/src/helpers.d.ts +12 -0
- package/build/src/helpers.js +14 -0
- package/build/src/inertia_middleware.d.ts +68 -7
- package/build/src/inertia_middleware.js +6 -47
- package/build/src/plugins/edge/plugin.d.ts +8 -0
- package/build/src/plugins/edge/plugin.js +85 -0
- package/build/src/plugins/{api_client.d.ts → japa/api_client.d.ts} +9 -4
- package/build/src/plugins/japa/api_client.js +70 -0
- package/build/src/plugins/vite.d.ts +26 -0
- package/build/src/plugins/vite.js +33 -0
- package/build/src/types.d.ts +72 -8
- package/build/src/types.js +0 -9
- package/build/vue/app.ts.stub +27 -0
- package/build/vue/home.vue.stub +21 -0
- package/build/vue/root.edge.stub +21 -0
- package/build/vue/ssr.ts.stub +22 -0
- package/build/vue/tsconfig.json.stub +26 -0
- package/package.json +64 -47
- package/build/configure.js +0 -82
- package/build/src/debug.d.ts +0 -3
- package/build/src/debug.js +0 -10
- package/build/src/define_config.d.ts +0 -5
- package/build/src/define_config.js +0 -14
- package/build/src/inertia.d.ts +0 -39
- package/build/src/inertia.js +0 -119
- package/build/src/plugins/api_client.js +0 -62
- package/build/src/plugins/edge.d.ts +0 -5
- package/build/src/plugins/edge.js +0 -43
- package/build/src/version_cache.d.ts +0 -27
- package/build/src/version_cache.js +0 -68
- package/build/stubs/main.d.ts +0 -1
- package/build/stubs/main.js +0 -10
- package/providers/inertia_provider.ts +0 -66
- package/src/debug.ts +0 -12
- package/src/define_config.ts +0 -17
- package/src/inertia.ts +0 -140
- package/src/inertia_middleware.ts +0 -54
- package/src/plugins/api_client.ts +0 -127
- package/src/plugins/edge.ts +0 -50
- package/src/types.ts +0 -48
- 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
|
-
}
|
package/src/version_cache.ts
DELETED
|
@@ -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
|
-
}
|