houdini-svelte 3.0.2 → 3.0.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.
- package/package.json +8 -8
- package/postInstall.js +1 -1
- package/runtime/stores/fragment.ts +5 -2
- package/runtime/stores/pagination/fragment.ts +13 -8
- package/runtime/stores/pagination/query.ts +5 -2
- package/runtime/stores/query.ts +5 -2
- package/runtime/stores/refetchable.ts +9 -6
- package/vite/transform/init.js +62 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "houdini-svelte",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.4",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/HoudiniGraphql/houdini.git"
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
"svelte": "^5.19.0"
|
|
20
20
|
},
|
|
21
21
|
"optionalDependencies": {
|
|
22
|
-
"houdini-svelte-darwin-x64": "3.0.
|
|
23
|
-
"houdini-svelte-darwin-arm64": "3.0.
|
|
24
|
-
"houdini-svelte-linux-x64": "3.0.
|
|
25
|
-
"houdini-svelte-linux-arm64": "3.0.
|
|
26
|
-
"houdini-svelte-win32-x64": "3.0.
|
|
27
|
-
"houdini-svelte-win32-arm64": "3.0.
|
|
28
|
-
"houdini-svelte-wasm": "3.0.
|
|
22
|
+
"houdini-svelte-darwin-x64": "3.0.4",
|
|
23
|
+
"houdini-svelte-darwin-arm64": "3.0.4",
|
|
24
|
+
"houdini-svelte-linux-x64": "3.0.4",
|
|
25
|
+
"houdini-svelte-linux-arm64": "3.0.4",
|
|
26
|
+
"houdini-svelte-win32-x64": "3.0.4",
|
|
27
|
+
"houdini-svelte-win32-arm64": "3.0.4",
|
|
28
|
+
"houdini-svelte-wasm": "3.0.4"
|
|
29
29
|
},
|
|
30
30
|
"exports": {
|
|
31
31
|
"./package.json": "./package.json",
|
package/postInstall.js
CHANGED
|
@@ -5,7 +5,7 @@ const https = require('https')
|
|
|
5
5
|
const child_process = require('child_process')
|
|
6
6
|
|
|
7
7
|
// Adjust the version you want to install. You can also make this dynamic.
|
|
8
|
-
const BINARY_DISTRIBUTION_VERSION = '3.0.
|
|
8
|
+
const BINARY_DISTRIBUTION_VERSION = '3.0.4'
|
|
9
9
|
|
|
10
10
|
// Windows binaries end with .exe so we need to special case them.
|
|
11
11
|
const binaryName = process.platform === 'win32' ? 'houdini-svelte.exe' : 'houdini-svelte'
|
|
@@ -21,14 +21,17 @@ export class FragmentStore<
|
|
|
21
21
|
_Data extends GraphQLObject,
|
|
22
22
|
_ReferenceType extends {},
|
|
23
23
|
_Input extends GraphQLVariables = GraphQLVariables,
|
|
24
|
+
// generated stores narrow this to their document's artifact type so a store
|
|
25
|
+
// can be matched back to its data/input types (e.g. by record.read/write)
|
|
26
|
+
_Artifact extends FragmentArtifact = FragmentArtifact,
|
|
24
27
|
> {
|
|
25
|
-
artifact:
|
|
28
|
+
artifact: _Artifact
|
|
26
29
|
name: string
|
|
27
30
|
kind = CompiledFragmentKind
|
|
28
31
|
|
|
29
32
|
protected context: HoudiniFetchContext | null = null
|
|
30
33
|
|
|
31
|
-
constructor({ artifact, storeName }: { artifact:
|
|
34
|
+
constructor({ artifact, storeName }: { artifact: _Artifact; storeName: string }) {
|
|
32
35
|
this.artifact = artifact
|
|
33
36
|
this.name = storeName
|
|
34
37
|
}
|
|
@@ -26,16 +26,19 @@ import type { OffsetFragmentStoreInstance } from '../../types.js'
|
|
|
26
26
|
import { FragmentStore } from '../fragment.js'
|
|
27
27
|
import type { StoreConfig } from '../query.js'
|
|
28
28
|
|
|
29
|
-
type FragmentStoreConfig<
|
|
30
|
-
_Data,
|
|
29
|
+
type FragmentStoreConfig<
|
|
30
|
+
_Data extends GraphQLObject,
|
|
31
31
|
_Input,
|
|
32
|
-
FragmentArtifact
|
|
33
|
-
> & { paginationArtifact: QueryArtifact }
|
|
32
|
+
_Artifact extends FragmentArtifact = FragmentArtifact,
|
|
33
|
+
> = StoreConfig<_Data, _Input, _Artifact> & { paginationArtifact: QueryArtifact }
|
|
34
34
|
|
|
35
35
|
export class BasePaginatedFragmentStore<
|
|
36
36
|
_Data extends GraphQLObject,
|
|
37
37
|
_ReferenceType extends {},
|
|
38
38
|
_Input,
|
|
39
|
+
// generated stores narrow this to their document's artifact type so a store
|
|
40
|
+
// can be matched back to its data/input types (e.g. by record.read/write)
|
|
41
|
+
_Artifact extends FragmentArtifact = FragmentArtifact,
|
|
39
42
|
> {
|
|
40
43
|
// all paginated stores need to have a flag to distinguish from other fragment stores
|
|
41
44
|
paginated = true
|
|
@@ -43,9 +46,9 @@ export class BasePaginatedFragmentStore<
|
|
|
43
46
|
protected paginationArtifact: QueryArtifact
|
|
44
47
|
name: string
|
|
45
48
|
kind = CompiledFragmentKind
|
|
46
|
-
artifact:
|
|
49
|
+
artifact: _Artifact
|
|
47
50
|
|
|
48
|
-
constructor(config: FragmentStoreConfig<_Data, _Input>) {
|
|
51
|
+
constructor(config: FragmentStoreConfig<_Data, _Input, _Artifact>) {
|
|
49
52
|
this.paginationArtifact = config.paginationArtifact
|
|
50
53
|
this.name = config.storeName
|
|
51
54
|
this.artifact = config.artifact
|
|
@@ -93,7 +96,8 @@ export class FragmentStoreCursor<
|
|
|
93
96
|
_Data extends GraphQLObject,
|
|
94
97
|
_ReferenceType extends {},
|
|
95
98
|
_Input extends GraphQLVariables,
|
|
96
|
-
|
|
99
|
+
_Artifact extends FragmentArtifact = FragmentArtifact,
|
|
100
|
+
> extends BasePaginatedFragmentStore<_Data, _ReferenceType, _Input, _Artifact> {
|
|
97
101
|
// we want to add the cursor-based fetch to the return value of get
|
|
98
102
|
get(initialValue: _Data | { [fragmentKey]: _ReferenceType } | null) {
|
|
99
103
|
const base = new FragmentStore<_Data, {}, _Input>({
|
|
@@ -286,7 +290,8 @@ export class FragmentStoreOffset<
|
|
|
286
290
|
_Data extends GraphQLObject,
|
|
287
291
|
_ReferenceType extends {},
|
|
288
292
|
_Input extends GraphQLVariables,
|
|
289
|
-
|
|
293
|
+
_Artifact extends FragmentArtifact = FragmentArtifact,
|
|
294
|
+
> extends BasePaginatedFragmentStore<_Data, _ReferenceType, _Input, _Artifact> {
|
|
290
295
|
get(initialValue: _Data | null): OffsetFragmentStoreInstance<_Data, _Input> {
|
|
291
296
|
const base = new FragmentStore<_Data, {}, _Input>({
|
|
292
297
|
artifact: this.artifact,
|
|
@@ -2,6 +2,7 @@ import { extractPageInfo } from 'houdini/runtime'
|
|
|
2
2
|
import { cursorHandlers, offsetHandlers } from 'houdini/runtime'
|
|
3
3
|
import type {
|
|
4
4
|
GraphQLObject,
|
|
5
|
+
QueryArtifact,
|
|
5
6
|
QueryResult,
|
|
6
7
|
CursorHandlers,
|
|
7
8
|
OffsetHandlers,
|
|
@@ -30,7 +31,8 @@ export type CursorStoreResult<
|
|
|
30
31
|
export class QueryStoreCursor<
|
|
31
32
|
_Data extends GraphQLObject,
|
|
32
33
|
_Input extends GraphQLVariables | null | undefined,
|
|
33
|
-
|
|
34
|
+
_Artifact extends QueryArtifact = QueryArtifact,
|
|
35
|
+
> extends QueryStore<_Data, _Input, _Artifact> {
|
|
34
36
|
// all paginated stores need to have a flag to distinguish from other query stores
|
|
35
37
|
paginated = true
|
|
36
38
|
|
|
@@ -130,7 +132,8 @@ export class QueryStoreCursor<
|
|
|
130
132
|
export class QueryStoreOffset<
|
|
131
133
|
_Data extends GraphQLObject,
|
|
132
134
|
_Input extends GraphQLVariables | null | undefined,
|
|
133
|
-
|
|
135
|
+
_Artifact extends QueryArtifact = QueryArtifact,
|
|
136
|
+
> extends QueryStore<_Data, _Input, _Artifact> {
|
|
134
137
|
// all paginated stores need to have a flag to distinguish from other query stores
|
|
135
138
|
paginated = true
|
|
136
139
|
|
package/runtime/stores/query.ts
CHANGED
|
@@ -29,7 +29,10 @@ import { BaseStore } from './base.js'
|
|
|
29
29
|
export class QueryStore<
|
|
30
30
|
_Data extends GraphQLObject,
|
|
31
31
|
_Input extends GraphQLVariables | null | undefined,
|
|
32
|
-
|
|
32
|
+
// generated stores narrow this to their document's artifact type so a store
|
|
33
|
+
// can be matched back to its result/input types (e.g. by cache.read/write)
|
|
34
|
+
_Artifact extends QueryArtifact = QueryArtifact,
|
|
35
|
+
> extends BaseStore<_Data, _Input, _Artifact> {
|
|
33
36
|
// whether the store requires variables for input
|
|
34
37
|
variables: boolean
|
|
35
38
|
|
|
@@ -42,7 +45,7 @@ export class QueryStore<
|
|
|
42
45
|
// the string identifying the store
|
|
43
46
|
protected storeName: string
|
|
44
47
|
|
|
45
|
-
constructor({ artifact, storeName, variables }: StoreConfig<_Data, _Input,
|
|
48
|
+
constructor({ artifact, storeName, variables }: StoreConfig<_Data, _Input, _Artifact>) {
|
|
46
49
|
super({
|
|
47
50
|
artifact,
|
|
48
51
|
})
|
|
@@ -16,11 +16,11 @@ import { getSession } from '../session.js'
|
|
|
16
16
|
import { FragmentStore } from './fragment.js'
|
|
17
17
|
import type { StoreConfig } from './query.js'
|
|
18
18
|
|
|
19
|
-
type RefetchableFragmentStoreConfig<
|
|
20
|
-
_Data,
|
|
19
|
+
type RefetchableFragmentStoreConfig<
|
|
20
|
+
_Data extends GraphQLObject,
|
|
21
21
|
_Input,
|
|
22
|
-
FragmentArtifact
|
|
23
|
-
> & { refetchArtifact: QueryArtifact }
|
|
22
|
+
_Artifact extends FragmentArtifact = FragmentArtifact,
|
|
23
|
+
> = StoreConfig<_Data, _Input, _Artifact> & { refetchArtifact: QueryArtifact }
|
|
24
24
|
|
|
25
25
|
// the value handed back to components subscribing to a refetchable fragment store
|
|
26
26
|
export type RefetchableFragmentResult<_Data extends GraphQLObject, _Input> = {
|
|
@@ -42,15 +42,18 @@ export class FragmentStoreRefetchable<
|
|
|
42
42
|
_Data extends GraphQLObject,
|
|
43
43
|
_ReferenceType extends {},
|
|
44
44
|
_Input extends GraphQLVariables,
|
|
45
|
+
// generated stores narrow this to their document's artifact type so a store
|
|
46
|
+
// can be matched back to its data/input types (e.g. by record.read/write)
|
|
47
|
+
_Artifact extends FragmentArtifact = FragmentArtifact,
|
|
45
48
|
> {
|
|
46
49
|
kind = CompiledFragmentKind
|
|
47
|
-
artifact:
|
|
50
|
+
artifact: _Artifact
|
|
48
51
|
name: string
|
|
49
52
|
// a flag the refetchableFragment() helper looks for to validate the store
|
|
50
53
|
refetchable = true
|
|
51
54
|
protected refetchArtifact: QueryArtifact
|
|
52
55
|
|
|
53
|
-
constructor(config: RefetchableFragmentStoreConfig<_Data, _Input>) {
|
|
56
|
+
constructor(config: RefetchableFragmentStoreConfig<_Data, _Input, _Artifact>) {
|
|
54
57
|
this.artifact = config.artifact
|
|
55
58
|
this.name = config.storeName
|
|
56
59
|
this.refetchArtifact = config.refetchArtifact
|
package/vite/transform/init.js
CHANGED
|
@@ -16,11 +16,34 @@ async function kit_init(config, page) {
|
|
|
16
16
|
sourceModule: "svelte",
|
|
17
17
|
import: ["onMount"]
|
|
18
18
|
}).ids[0];
|
|
19
|
-
const [extract_session, set_session] = ensure_imports({
|
|
19
|
+
const [extract_session, get_client_session, set_session] = ensure_imports({
|
|
20
20
|
script: page.script,
|
|
21
21
|
sourceModule: "$houdini/plugins/houdini-svelte/runtime/session",
|
|
22
|
-
import: ["extractSession", "setClientSession"]
|
|
22
|
+
import: ["extractSession", "getClientSession", "setClientSession"]
|
|
23
23
|
}).ids;
|
|
24
|
+
const page_store = ensure_imports({
|
|
25
|
+
script: page.script,
|
|
26
|
+
sourceModule: "$app/state",
|
|
27
|
+
import: ["page"]
|
|
28
|
+
}).ids[0];
|
|
29
|
+
const get_cache = ensure_imports({
|
|
30
|
+
script: page.script,
|
|
31
|
+
sourceModule: "$houdini",
|
|
32
|
+
import: ["getCache"]
|
|
33
|
+
}).ids[0];
|
|
34
|
+
const deep_equals = ensure_imports({
|
|
35
|
+
script: page.script,
|
|
36
|
+
sourceModule: "houdini/runtime",
|
|
37
|
+
import: ["deepEquals"]
|
|
38
|
+
}).ids[0];
|
|
39
|
+
const session_initialized = AST.identifier("houdini__session__initialized");
|
|
40
|
+
const next_session = AST.identifier("nextSession");
|
|
41
|
+
const session_changed = AST.identifier("sessionChanged");
|
|
42
|
+
page.script.body.push(
|
|
43
|
+
AST.variableDeclaration("let", [
|
|
44
|
+
AST.variableDeclarator(session_initialized, AST.literal(false))
|
|
45
|
+
])
|
|
46
|
+
);
|
|
24
47
|
page.script.body.push(
|
|
25
48
|
AST.expressionStatement(
|
|
26
49
|
AST.callExpression(on_mount, [
|
|
@@ -28,22 +51,52 @@ async function kit_init(config, page) {
|
|
|
28
51
|
])
|
|
29
52
|
)
|
|
30
53
|
);
|
|
31
|
-
const page_store = ensure_imports({
|
|
32
|
-
script: page.script,
|
|
33
|
-
sourceModule: "$app/state",
|
|
34
|
-
import: ["page"]
|
|
35
|
-
}).ids[0];
|
|
36
54
|
page.script.body.push(
|
|
37
55
|
AST.expressionStatement(
|
|
38
56
|
AST.callExpression(AST.identifier("$effect"), [
|
|
39
57
|
AST.arrowFunctionExpression(
|
|
40
58
|
[],
|
|
41
59
|
AST.blockStatement([
|
|
42
|
-
AST.
|
|
43
|
-
AST.
|
|
60
|
+
AST.variableDeclaration("const", [
|
|
61
|
+
AST.variableDeclarator(
|
|
62
|
+
next_session,
|
|
44
63
|
AST.callExpression(extract_session, [
|
|
45
64
|
AST.memberExpression(page_store, AST.identifier("data"))
|
|
46
65
|
])
|
|
66
|
+
)
|
|
67
|
+
]),
|
|
68
|
+
AST.variableDeclaration("const", [
|
|
69
|
+
AST.variableDeclarator(
|
|
70
|
+
session_changed,
|
|
71
|
+
AST.logicalExpression(
|
|
72
|
+
"&&",
|
|
73
|
+
session_initialized,
|
|
74
|
+
AST.unaryExpression(
|
|
75
|
+
"!",
|
|
76
|
+
AST.callExpression(deep_equals, [
|
|
77
|
+
AST.callExpression(get_client_session, []),
|
|
78
|
+
next_session
|
|
79
|
+
])
|
|
80
|
+
)
|
|
81
|
+
)
|
|
82
|
+
)
|
|
83
|
+
]),
|
|
84
|
+
AST.expressionStatement(AST.callExpression(set_session, [next_session])),
|
|
85
|
+
AST.expressionStatement(
|
|
86
|
+
AST.assignmentExpression("=", session_initialized, AST.literal(true))
|
|
87
|
+
),
|
|
88
|
+
AST.ifStatement(
|
|
89
|
+
session_changed,
|
|
90
|
+
AST.blockStatement([
|
|
91
|
+
AST.expressionStatement(
|
|
92
|
+
AST.callExpression(
|
|
93
|
+
AST.memberExpression(
|
|
94
|
+
AST.callExpression(get_cache, []),
|
|
95
|
+
AST.identifier("refreshAll")
|
|
96
|
+
),
|
|
97
|
+
[next_session]
|
|
98
|
+
)
|
|
99
|
+
)
|
|
47
100
|
])
|
|
48
101
|
)
|
|
49
102
|
])
|