houdini-svelte 1.0.2 → 1.0.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.
@@ -84643,11 +84643,11 @@ var require_esprima2 = __commonJS2({
84643
84643
  case "}":
84644
84644
  regex2 = false;
84645
84645
  if (this.values[this.curly - 3] === "function") {
84646
- var check = this.values[this.curly - 4];
84647
- regex2 = check ? !this.beforeFunctionExpression(check) : false;
84646
+ var check2 = this.values[this.curly - 4];
84647
+ regex2 = check2 ? !this.beforeFunctionExpression(check2) : false;
84648
84648
  } else if (this.values[this.curly - 4] === "function") {
84649
- var check = this.values[this.curly - 5];
84650
- regex2 = check ? !this.beforeFunctionExpression(check) : true;
84649
+ var check2 = this.values[this.curly - 5];
84650
+ regex2 = check2 ? !this.beforeFunctionExpression(check2) : true;
84651
84651
  }
84652
84652
  break;
84653
84653
  default:
@@ -84638,11 +84638,11 @@ var require_esprima2 = __commonJS2({
84638
84638
  case "}":
84639
84639
  regex2 = false;
84640
84640
  if (this.values[this.curly - 3] === "function") {
84641
- var check = this.values[this.curly - 4];
84642
- regex2 = check ? !this.beforeFunctionExpression(check) : false;
84641
+ var check2 = this.values[this.curly - 4];
84642
+ regex2 = check2 ? !this.beforeFunctionExpression(check2) : false;
84643
84643
  } else if (this.values[this.curly - 4] === "function") {
84644
- var check = this.values[this.curly - 5];
84645
- regex2 = check ? !this.beforeFunctionExpression(check) : true;
84644
+ var check2 = this.values[this.curly - 5];
84645
+ regex2 = check2 ? !this.beforeFunctionExpression(check2) : true;
84646
84646
  }
84647
84647
  break;
84648
84648
  default:
@@ -84544,11 +84544,11 @@ var require_esprima2 = __commonJS2({
84544
84544
  case "}":
84545
84545
  regex2 = false;
84546
84546
  if (this.values[this.curly - 3] === "function") {
84547
- var check = this.values[this.curly - 4];
84548
- regex2 = check ? !this.beforeFunctionExpression(check) : false;
84547
+ var check2 = this.values[this.curly - 4];
84548
+ regex2 = check2 ? !this.beforeFunctionExpression(check2) : false;
84549
84549
  } else if (this.values[this.curly - 4] === "function") {
84550
- var check = this.values[this.curly - 5];
84551
- regex2 = check ? !this.beforeFunctionExpression(check) : true;
84550
+ var check2 = this.values[this.curly - 5];
84551
+ regex2 = check2 ? !this.beforeFunctionExpression(check2) : true;
84552
84552
  }
84553
84553
  break;
84554
84554
  default:
@@ -84537,11 +84537,11 @@ var require_esprima2 = __commonJS2({
84537
84537
  case "}":
84538
84538
  regex2 = false;
84539
84539
  if (this.values[this.curly - 3] === "function") {
84540
- var check = this.values[this.curly - 4];
84541
- regex2 = check ? !this.beforeFunctionExpression(check) : false;
84540
+ var check2 = this.values[this.curly - 4];
84541
+ regex2 = check2 ? !this.beforeFunctionExpression(check2) : false;
84542
84542
  } else if (this.values[this.curly - 4] === "function") {
84543
- var check = this.values[this.curly - 5];
84544
- regex2 = check ? !this.beforeFunctionExpression(check) : true;
84543
+ var check2 = this.values[this.curly - 5];
84544
+ regex2 = check2 ? !this.beforeFunctionExpression(check2) : true;
84545
84545
  }
84546
84546
  break;
84547
84547
  default:
@@ -1,8 +1,12 @@
1
- import type { DocumentStore, ObserveParams } from '$houdini/runtime/client';
2
- import type { GraphQLObject, DocumentArtifact } from '$houdini/runtime/lib/types';
1
+ import { DocumentStore, type ObserveParams } from '$houdini/runtime/client';
2
+ import type { GraphQLObject, DocumentArtifact, QueryResult } from '$houdini/runtime/lib/types';
3
+ import type { Readable } from 'svelte/store';
3
4
  export declare class BaseStore<_Data extends GraphQLObject, _Input extends {}, _Artifact extends DocumentArtifact = DocumentArtifact> {
4
5
  #private;
5
- constructor(params: ObserveParams<_Data, _Artifact>);
6
6
  get artifact(): _Artifact;
7
+ get name(): string;
8
+ constructor(params: ObserveParams<_Data, _Artifact>);
7
9
  protected get observer(): DocumentStore<_Data, _Input>;
10
+ subscribe(...args: Parameters<Readable<QueryResult<_Data, _Input>>['subscribe']>): () => void;
11
+ setup(init?: boolean): void;
8
12
  }
@@ -1,4 +1,3 @@
1
- import type { DocumentStore } from '$houdini/runtime/client';
2
1
  import type { MutationArtifact, GraphQLObject, QueryResult } from '$houdini/runtime/lib/types';
3
2
  import type { RequestEvent } from '@sveltejs/kit';
4
3
  import { BaseStore } from './base';
@@ -9,7 +8,6 @@ export declare class MutationStore<_Data extends GraphQLObject, _Input extends {
9
8
  fetch?: typeof globalThis.fetch;
10
9
  event?: RequestEvent;
11
10
  } & MutationConfig<_Data, _Input, _Optimistic>): Promise<QueryResult<_Data, _Input>>;
12
- subscribe(...args: Parameters<DocumentStore<_Data, _Input>['subscribe']>): import("$houdini/runtime/lib").Unsubscriber;
13
11
  }
14
12
  export type MutationConfig<_Result, _Input, _Optimistic> = {
15
13
  optimisticResponse?: _Optimistic;
@@ -1,15 +1,12 @@
1
1
  import type { FetchContext } from '$houdini/runtime/client/plugins/fetch';
2
2
  import type { GraphQLObject, HoudiniFetchContext, MutationArtifact, QueryArtifact, QueryResult, CachePolicies } from '$houdini/runtime/lib/types';
3
3
  import type { LoadEvent, RequestEvent } from '@sveltejs/kit';
4
- import type { Readable } from 'svelte/store';
5
4
  import type { PluginArtifactData } from '../../plugin/artifactData';
6
5
  import { BaseStore } from './base';
7
6
  export declare class QueryStore<_Data extends GraphQLObject, _Input extends {}> extends BaseStore<_Data, _Input, QueryArtifact> {
8
- #private;
9
7
  variables: boolean;
10
8
  kind: "HoudiniQuery";
11
9
  protected loadPending: boolean;
12
- protected subscriberCount: number;
13
10
  protected storeName: string;
14
11
  constructor({ artifact, storeName, variables }: StoreConfig<_Data, _Input, QueryArtifact>);
15
12
  /**
@@ -19,8 +16,6 @@ export declare class QueryStore<_Data extends GraphQLObject, _Input extends {}>
19
16
  fetch(params?: LoadEventFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
20
17
  fetch(params?: ClientFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
21
18
  fetch(params?: QueryStoreFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
22
- get name(): string;
23
- subscribe(...args: Parameters<Readable<QueryResult<_Data, _Input>>['subscribe']>): () => void;
24
19
  }
25
20
  export type StoreConfig<_Data extends GraphQLObject, _Input, _Artifact> = {
26
21
  artifact: _Artifact & {
@@ -1,4 +1,3 @@
1
- import type { DocumentStore } from '$houdini/runtime/client';
2
1
  import type { SubscriptionArtifact } from '$houdini/runtime/lib/types';
3
2
  import type { GraphQLObject } from 'houdini';
4
3
  import { BaseStore } from './base';
@@ -7,7 +6,6 @@ export declare class SubscriptionStore<_Data extends GraphQLObject, _Input exten
7
6
  constructor({ artifact }: {
8
7
  artifact: SubscriptionArtifact;
9
8
  });
10
- subscribe(...args: Parameters<DocumentStore<_Data, _Input>['subscribe']>): import("$houdini/runtime/lib").Unsubscriber;
11
9
  listen(variables?: _Input, args?: {
12
10
  metadata: App.Metadata;
13
11
  }): Promise<void>;
@@ -1,8 +1,12 @@
1
- import type { DocumentStore, ObserveParams } from '$houdini/runtime/client';
2
- import type { GraphQLObject, DocumentArtifact } from '$houdini/runtime/lib/types';
1
+ import { DocumentStore, type ObserveParams } from '$houdini/runtime/client';
2
+ import type { GraphQLObject, DocumentArtifact, QueryResult } from '$houdini/runtime/lib/types';
3
+ import type { Readable } from 'svelte/store';
3
4
  export declare class BaseStore<_Data extends GraphQLObject, _Input extends {}, _Artifact extends DocumentArtifact = DocumentArtifact> {
4
5
  #private;
5
- constructor(params: ObserveParams<_Data, _Artifact>);
6
6
  get artifact(): _Artifact;
7
+ get name(): string;
8
+ constructor(params: ObserveParams<_Data, _Artifact>);
7
9
  protected get observer(): DocumentStore<_Data, _Input>;
10
+ subscribe(...args: Parameters<Readable<QueryResult<_Data, _Input>>['subscribe']>): () => void;
11
+ setup(init?: boolean): void;
8
12
  }
@@ -21,23 +21,74 @@ __export(base_exports, {
21
21
  BaseStore: () => BaseStore
22
22
  });
23
23
  module.exports = __toCommonJS(base_exports);
24
- var import_client = require("../client");
24
+ var import_client = require("$houdini/runtime/client");
25
+ var import_store = require("svelte/store");
26
+ var import_adapter = require("../adapter");
27
+ var import_client2 = require("../client");
25
28
  class BaseStore {
26
29
  #params;
27
- constructor(params) {
28
- this.#params = params;
29
- }
30
30
  get artifact() {
31
31
  return this.#params.artifact;
32
32
  }
33
+ get name() {
34
+ return this.artifact.name;
35
+ }
36
+ #store;
37
+ #unsubscribe = null;
38
+ constructor(params) {
39
+ this.#store = new import_client.DocumentStore({
40
+ artifact: params.artifact,
41
+ client: null,
42
+ fetching: params.fetching
43
+ });
44
+ this.#params = params;
45
+ }
33
46
  #observer = null;
34
47
  get observer() {
35
48
  if (this.#observer) {
36
49
  return this.#observer;
37
50
  }
38
- this.#observer = (0, import_client.getClient)().observe(this.#params);
51
+ this.#observer = (0, import_client2.getClient)().observe(this.#params);
39
52
  return this.#observer;
40
53
  }
54
+ subscribe(...args) {
55
+ const bubbleUp = this.#store.subscribe(...args);
56
+ if (import_adapter.isBrowser && (this.#subscriberCount === 0 || !this.#unsubscribe)) {
57
+ this.setup();
58
+ }
59
+ this.#subscriberCount = (this.#subscriberCount ?? 0) + 1;
60
+ return () => {
61
+ this.#subscriberCount--;
62
+ if (this.#subscriberCount <= 0) {
63
+ this.#unsubscribe?.();
64
+ this.#unsubscribe = null;
65
+ bubbleUp();
66
+ }
67
+ };
68
+ }
69
+ #subscriberCount = 0;
70
+ setup(init = true) {
71
+ let initPromise = Promise.resolve();
72
+ try {
73
+ (0, import_client2.getClient)();
74
+ } catch {
75
+ initPromise = (0, import_client2.initClient)();
76
+ }
77
+ initPromise.then(() => {
78
+ if (this.#unsubscribe) {
79
+ return;
80
+ }
81
+ this.#unsubscribe = this.observer.subscribe((value) => {
82
+ this.#store.set(value);
83
+ });
84
+ if (init) {
85
+ return this.observer.send({
86
+ setup: true,
87
+ variables: (0, import_store.get)(this.observer).variables
88
+ });
89
+ }
90
+ });
91
+ }
41
92
  }
42
93
  // Annotate the CommonJS export names for ESM import in node:
43
94
  0 && (module.exports = {
@@ -1,4 +1,3 @@
1
- import type { DocumentStore } from '$houdini/runtime/client';
2
1
  import type { MutationArtifact, GraphQLObject, QueryResult } from '$houdini/runtime/lib/types';
3
2
  import type { RequestEvent } from '@sveltejs/kit';
4
3
  import { BaseStore } from './base';
@@ -9,7 +8,6 @@ export declare class MutationStore<_Data extends GraphQLObject, _Input extends {
9
8
  fetch?: typeof globalThis.fetch;
10
9
  event?: RequestEvent;
11
10
  } & MutationConfig<_Data, _Input, _Optimistic>): Promise<QueryResult<_Data, _Input>>;
12
- subscribe(...args: Parameters<DocumentStore<_Data, _Input>['subscribe']>): import("$houdini/runtime/lib").Unsubscriber;
13
11
  }
14
12
  export type MutationConfig<_Result, _Input, _Optimistic> = {
15
13
  optimisticResponse?: _Optimistic;
@@ -48,9 +48,6 @@ class MutationStore extends import_base.BaseStore {
48
48
  }
49
49
  });
50
50
  }
51
- subscribe(...args) {
52
- return this.observer.subscribe(...args);
53
- }
54
51
  }
55
52
  // Annotate the CommonJS export names for ESM import in node:
56
53
  0 && (module.exports = {
@@ -1,15 +1,12 @@
1
1
  import type { FetchContext } from '$houdini/runtime/client/plugins/fetch';
2
2
  import type { GraphQLObject, HoudiniFetchContext, MutationArtifact, QueryArtifact, QueryResult, CachePolicies } from '$houdini/runtime/lib/types';
3
3
  import type { LoadEvent, RequestEvent } from '@sveltejs/kit';
4
- import type { Readable } from 'svelte/store';
5
4
  import type { PluginArtifactData } from '../../plugin/artifactData';
6
5
  import { BaseStore } from './base';
7
6
  export declare class QueryStore<_Data extends GraphQLObject, _Input extends {}> extends BaseStore<_Data, _Input, QueryArtifact> {
8
- #private;
9
7
  variables: boolean;
10
8
  kind: "HoudiniQuery";
11
9
  protected loadPending: boolean;
12
- protected subscriberCount: number;
13
10
  protected storeName: string;
14
11
  constructor({ artifact, storeName, variables }: StoreConfig<_Data, _Input, QueryArtifact>);
15
12
  /**
@@ -19,8 +16,6 @@ export declare class QueryStore<_Data extends GraphQLObject, _Input extends {}>
19
16
  fetch(params?: LoadEventFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
20
17
  fetch(params?: ClientFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
21
18
  fetch(params?: QueryStoreFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
22
- get name(): string;
23
- subscribe(...args: Parameters<Readable<QueryResult<_Data, _Input>>['subscribe']>): () => void;
24
19
  }
25
20
  export type StoreConfig<_Data extends GraphQLObject, _Input, _Artifact> = {
26
21
  artifact: _Artifact & {
@@ -28,32 +28,27 @@ __export(query_exports, {
28
28
  fetchParams: () => fetchParams
29
29
  });
30
30
  module.exports = __toCommonJS(query_exports);
31
- var import_client = require("$houdini/runtime/client");
32
31
  var log = __toESM(require("$houdini/runtime/lib/log"), 1);
33
32
  var import_types = require("$houdini/runtime/lib/types");
34
33
  var import_store = require("svelte/store");
35
34
  var import_adapter = require("../adapter");
36
- var import_client2 = require("../client");
35
+ var import_client = require("../client");
37
36
  var import_session = require("../session");
38
37
  var import_base = require("./base");
39
38
  class QueryStore extends import_base.BaseStore {
40
39
  variables;
41
40
  kind = import_types.CompiledQueryKind;
42
41
  loadPending = false;
43
- subscriberCount = 0;
44
42
  storeName;
45
- #store;
46
- #unsubscribe = null;
47
43
  constructor({ artifact, storeName, variables }) {
48
44
  const fetching = artifact.pluginData?.["houdini-svelte"].isManualLoad !== true;
49
45
  super({ artifact, fetching });
50
46
  this.storeName = storeName;
51
47
  this.variables = variables;
52
- this.#store = new import_client.DocumentStore({ artifact, client: null, fetching });
53
48
  }
54
49
  async fetch(args) {
55
- await (0, import_client2.initClient)();
56
- await this.#setup(false);
50
+ await (0, import_client.initClient)();
51
+ this.setup();
57
52
  const { policy, params, context } = await fetchParams(this.artifact, this.storeName, args);
58
53
  if (!import_adapter.isBrowser && !(params && "fetch" in params) && (!params || !("event" in params))) {
59
54
  log.error(contextError(this.storeName));
@@ -101,46 +96,6 @@ This will result in duplicate queries. If you are trying to ensure there is alwa
101
96
  }
102
97
  return (0, import_store.get)(this.observer);
103
98
  }
104
- get name() {
105
- return this.artifact.name;
106
- }
107
- #setup(init = true) {
108
- let initPromise = Promise.resolve();
109
- try {
110
- (0, import_client2.getClient)();
111
- } catch {
112
- initPromise = (0, import_client2.initClient)();
113
- }
114
- initPromise.then(() => {
115
- if (this.#unsubscribe) {
116
- return;
117
- }
118
- this.#unsubscribe = this.observer.subscribe((value) => {
119
- this.#store.set(value);
120
- });
121
- if (init) {
122
- return this.observer.send({
123
- setup: true,
124
- variables: (0, import_store.get)(this.observer).variables
125
- });
126
- }
127
- });
128
- }
129
- subscribe(...args) {
130
- const bubbleUp = this.#store.subscribe(...args);
131
- if (import_adapter.isBrowser && (this.subscriberCount === 0 || !this.#unsubscribe)) {
132
- this.#setup();
133
- }
134
- this.subscriberCount = (this.subscriberCount ?? 0) + 1;
135
- return () => {
136
- this.subscriberCount--;
137
- if (this.subscriberCount <= 0) {
138
- this.#unsubscribe?.();
139
- this.#unsubscribe = null;
140
- bubbleUp();
141
- }
142
- };
143
- }
144
99
  }
145
100
  async function fetchParams(artifact, storeName, params) {
146
101
  let policy = params?.policy;
@@ -1,4 +1,3 @@
1
- import type { DocumentStore } from '$houdini/runtime/client';
2
1
  import type { SubscriptionArtifact } from '$houdini/runtime/lib/types';
3
2
  import type { GraphQLObject } from 'houdini';
4
3
  import { BaseStore } from './base';
@@ -7,7 +6,6 @@ export declare class SubscriptionStore<_Data extends GraphQLObject, _Input exten
7
6
  constructor({ artifact }: {
8
7
  artifact: SubscriptionArtifact;
9
8
  });
10
- subscribe(...args: Parameters<DocumentStore<_Data, _Input>['subscribe']>): import("$houdini/runtime/lib").Unsubscriber;
11
9
  listen(variables?: _Input, args?: {
12
10
  metadata: App.Metadata;
13
11
  }): Promise<void>;
@@ -30,9 +30,6 @@ class SubscriptionStore extends import_base.BaseStore {
30
30
  constructor({ artifact }) {
31
31
  super({ artifact });
32
32
  }
33
- subscribe(...args) {
34
- return this.observer?.subscribe(...args);
35
- }
36
33
  async listen(variables, args) {
37
34
  await (0, import_client.initClient)();
38
35
  this.observer.send({
@@ -1,8 +1,12 @@
1
- import type { DocumentStore, ObserveParams } from '$houdini/runtime/client';
2
- import type { GraphQLObject, DocumentArtifact } from '$houdini/runtime/lib/types';
1
+ import { DocumentStore, type ObserveParams } from '$houdini/runtime/client';
2
+ import type { GraphQLObject, DocumentArtifact, QueryResult } from '$houdini/runtime/lib/types';
3
+ import type { Readable } from 'svelte/store';
3
4
  export declare class BaseStore<_Data extends GraphQLObject, _Input extends {}, _Artifact extends DocumentArtifact = DocumentArtifact> {
4
5
  #private;
5
- constructor(params: ObserveParams<_Data, _Artifact>);
6
6
  get artifact(): _Artifact;
7
+ get name(): string;
8
+ constructor(params: ObserveParams<_Data, _Artifact>);
7
9
  protected get observer(): DocumentStore<_Data, _Input>;
10
+ subscribe(...args: Parameters<Readable<QueryResult<_Data, _Input>>['subscribe']>): () => void;
11
+ setup(init?: boolean): void;
8
12
  }
@@ -1,12 +1,25 @@
1
- import { getClient } from "../client";
1
+ import { DocumentStore } from "$houdini/runtime/client";
2
+ import { get } from "svelte/store";
3
+ import { isBrowser } from "../adapter";
4
+ import { getClient, initClient } from "../client";
2
5
  class BaseStore {
3
6
  #params;
4
- constructor(params) {
5
- this.#params = params;
6
- }
7
7
  get artifact() {
8
8
  return this.#params.artifact;
9
9
  }
10
+ get name() {
11
+ return this.artifact.name;
12
+ }
13
+ #store;
14
+ #unsubscribe = null;
15
+ constructor(params) {
16
+ this.#store = new DocumentStore({
17
+ artifact: params.artifact,
18
+ client: null,
19
+ fetching: params.fetching
20
+ });
21
+ this.#params = params;
22
+ }
10
23
  #observer = null;
11
24
  get observer() {
12
25
  if (this.#observer) {
@@ -15,6 +28,44 @@ class BaseStore {
15
28
  this.#observer = getClient().observe(this.#params);
16
29
  return this.#observer;
17
30
  }
31
+ subscribe(...args) {
32
+ const bubbleUp = this.#store.subscribe(...args);
33
+ if (isBrowser && (this.#subscriberCount === 0 || !this.#unsubscribe)) {
34
+ this.setup();
35
+ }
36
+ this.#subscriberCount = (this.#subscriberCount ?? 0) + 1;
37
+ return () => {
38
+ this.#subscriberCount--;
39
+ if (this.#subscriberCount <= 0) {
40
+ this.#unsubscribe?.();
41
+ this.#unsubscribe = null;
42
+ bubbleUp();
43
+ }
44
+ };
45
+ }
46
+ #subscriberCount = 0;
47
+ setup(init = true) {
48
+ let initPromise = Promise.resolve();
49
+ try {
50
+ getClient();
51
+ } catch {
52
+ initPromise = initClient();
53
+ }
54
+ initPromise.then(() => {
55
+ if (this.#unsubscribe) {
56
+ return;
57
+ }
58
+ this.#unsubscribe = this.observer.subscribe((value) => {
59
+ this.#store.set(value);
60
+ });
61
+ if (init) {
62
+ return this.observer.send({
63
+ setup: true,
64
+ variables: get(this.observer).variables
65
+ });
66
+ }
67
+ });
68
+ }
18
69
  }
19
70
  export {
20
71
  BaseStore
@@ -1,4 +1,3 @@
1
- import type { DocumentStore } from '$houdini/runtime/client';
2
1
  import type { MutationArtifact, GraphQLObject, QueryResult } from '$houdini/runtime/lib/types';
3
2
  import type { RequestEvent } from '@sveltejs/kit';
4
3
  import { BaseStore } from './base';
@@ -9,7 +8,6 @@ export declare class MutationStore<_Data extends GraphQLObject, _Input extends {
9
8
  fetch?: typeof globalThis.fetch;
10
9
  event?: RequestEvent;
11
10
  } & MutationConfig<_Data, _Input, _Optimistic>): Promise<QueryResult<_Data, _Input>>;
12
- subscribe(...args: Parameters<DocumentStore<_Data, _Input>['subscribe']>): import("$houdini/runtime/lib").Unsubscriber;
13
11
  }
14
12
  export type MutationConfig<_Result, _Input, _Optimistic> = {
15
13
  optimisticResponse?: _Optimistic;
@@ -25,9 +25,6 @@ class MutationStore extends BaseStore {
25
25
  }
26
26
  });
27
27
  }
28
- subscribe(...args) {
29
- return this.observer.subscribe(...args);
30
- }
31
28
  }
32
29
  export {
33
30
  MutationStore
@@ -1,15 +1,12 @@
1
1
  import type { FetchContext } from '$houdini/runtime/client/plugins/fetch';
2
2
  import type { GraphQLObject, HoudiniFetchContext, MutationArtifact, QueryArtifact, QueryResult, CachePolicies } from '$houdini/runtime/lib/types';
3
3
  import type { LoadEvent, RequestEvent } from '@sveltejs/kit';
4
- import type { Readable } from 'svelte/store';
5
4
  import type { PluginArtifactData } from '../../plugin/artifactData';
6
5
  import { BaseStore } from './base';
7
6
  export declare class QueryStore<_Data extends GraphQLObject, _Input extends {}> extends BaseStore<_Data, _Input, QueryArtifact> {
8
- #private;
9
7
  variables: boolean;
10
8
  kind: "HoudiniQuery";
11
9
  protected loadPending: boolean;
12
- protected subscriberCount: number;
13
10
  protected storeName: string;
14
11
  constructor({ artifact, storeName, variables }: StoreConfig<_Data, _Input, QueryArtifact>);
15
12
  /**
@@ -19,8 +16,6 @@ export declare class QueryStore<_Data extends GraphQLObject, _Input extends {}>
19
16
  fetch(params?: LoadEventFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
20
17
  fetch(params?: ClientFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
21
18
  fetch(params?: QueryStoreFetchParams<_Data, _Input>): Promise<QueryResult<_Data, _Input>>;
22
- get name(): string;
23
- subscribe(...args: Parameters<Readable<QueryResult<_Data, _Input>>['subscribe']>): () => void;
24
19
  }
25
20
  export type StoreConfig<_Data extends GraphQLObject, _Input, _Artifact> = {
26
21
  artifact: _Artifact & {
@@ -1,29 +1,24 @@
1
- import { DocumentStore } from "$houdini/runtime/client";
2
1
  import * as log from "$houdini/runtime/lib/log";
3
2
  import { ArtifactKind, CachePolicy, CompiledQueryKind } from "$houdini/runtime/lib/types";
4
3
  import { get } from "svelte/store";
5
4
  import { clientStarted, isBrowser } from "../adapter";
6
- import { getClient, initClient } from "../client";
5
+ import { initClient } from "../client";
7
6
  import { getSession } from "../session";
8
7
  import { BaseStore } from "./base";
9
8
  class QueryStore extends BaseStore {
10
9
  variables;
11
10
  kind = CompiledQueryKind;
12
11
  loadPending = false;
13
- subscriberCount = 0;
14
12
  storeName;
15
- #store;
16
- #unsubscribe = null;
17
13
  constructor({ artifact, storeName, variables }) {
18
14
  const fetching = artifact.pluginData?.["houdini-svelte"].isManualLoad !== true;
19
15
  super({ artifact, fetching });
20
16
  this.storeName = storeName;
21
17
  this.variables = variables;
22
- this.#store = new DocumentStore({ artifact, client: null, fetching });
23
18
  }
24
19
  async fetch(args) {
25
20
  await initClient();
26
- await this.#setup(false);
21
+ this.setup();
27
22
  const { policy, params, context } = await fetchParams(this.artifact, this.storeName, args);
28
23
  if (!isBrowser && !(params && "fetch" in params) && (!params || !("event" in params))) {
29
24
  log.error(contextError(this.storeName));
@@ -71,46 +66,6 @@ This will result in duplicate queries. If you are trying to ensure there is alwa
71
66
  }
72
67
  return get(this.observer);
73
68
  }
74
- get name() {
75
- return this.artifact.name;
76
- }
77
- #setup(init = true) {
78
- let initPromise = Promise.resolve();
79
- try {
80
- getClient();
81
- } catch {
82
- initPromise = initClient();
83
- }
84
- initPromise.then(() => {
85
- if (this.#unsubscribe) {
86
- return;
87
- }
88
- this.#unsubscribe = this.observer.subscribe((value) => {
89
- this.#store.set(value);
90
- });
91
- if (init) {
92
- return this.observer.send({
93
- setup: true,
94
- variables: get(this.observer).variables
95
- });
96
- }
97
- });
98
- }
99
- subscribe(...args) {
100
- const bubbleUp = this.#store.subscribe(...args);
101
- if (isBrowser && (this.subscriberCount === 0 || !this.#unsubscribe)) {
102
- this.#setup();
103
- }
104
- this.subscriberCount = (this.subscriberCount ?? 0) + 1;
105
- return () => {
106
- this.subscriberCount--;
107
- if (this.subscriberCount <= 0) {
108
- this.#unsubscribe?.();
109
- this.#unsubscribe = null;
110
- bubbleUp();
111
- }
112
- };
113
- }
114
69
  }
115
70
  async function fetchParams(artifact, storeName, params) {
116
71
  let policy = params?.policy;
@@ -1,4 +1,3 @@
1
- import type { DocumentStore } from '$houdini/runtime/client';
2
1
  import type { SubscriptionArtifact } from '$houdini/runtime/lib/types';
3
2
  import type { GraphQLObject } from 'houdini';
4
3
  import { BaseStore } from './base';
@@ -7,7 +6,6 @@ export declare class SubscriptionStore<_Data extends GraphQLObject, _Input exten
7
6
  constructor({ artifact }: {
8
7
  artifact: SubscriptionArtifact;
9
8
  });
10
- subscribe(...args: Parameters<DocumentStore<_Data, _Input>['subscribe']>): import("$houdini/runtime/lib").Unsubscriber;
11
9
  listen(variables?: _Input, args?: {
12
10
  metadata: App.Metadata;
13
11
  }): Promise<void>;
@@ -7,9 +7,6 @@ class SubscriptionStore extends BaseStore {
7
7
  constructor({ artifact }) {
8
8
  super({ artifact });
9
9
  }
10
- subscribe(...args) {
11
- return this.observer?.subscribe(...args);
12
- }
13
10
  async listen(variables, args) {
14
11
  await initClient();
15
12
  this.observer.send({
@@ -84646,11 +84646,11 @@ var require_esprima2 = __commonJS2({
84646
84646
  case "}":
84647
84647
  regex2 = false;
84648
84648
  if (this.values[this.curly - 3] === "function") {
84649
- var check = this.values[this.curly - 4];
84650
- regex2 = check ? !this.beforeFunctionExpression(check) : false;
84649
+ var check2 = this.values[this.curly - 4];
84650
+ regex2 = check2 ? !this.beforeFunctionExpression(check2) : false;
84651
84651
  } else if (this.values[this.curly - 4] === "function") {
84652
- var check = this.values[this.curly - 5];
84653
- regex2 = check ? !this.beforeFunctionExpression(check) : true;
84652
+ var check2 = this.values[this.curly - 5];
84653
+ regex2 = check2 ? !this.beforeFunctionExpression(check2) : true;
84654
84654
  }
84655
84655
  break;
84656
84656
  default:
@@ -84638,11 +84638,11 @@ var require_esprima2 = __commonJS2({
84638
84638
  case "}":
84639
84639
  regex2 = false;
84640
84640
  if (this.values[this.curly - 3] === "function") {
84641
- var check = this.values[this.curly - 4];
84642
- regex2 = check ? !this.beforeFunctionExpression(check) : false;
84641
+ var check2 = this.values[this.curly - 4];
84642
+ regex2 = check2 ? !this.beforeFunctionExpression(check2) : false;
84643
84643
  } else if (this.values[this.curly - 4] === "function") {
84644
- var check = this.values[this.curly - 5];
84645
- regex2 = check ? !this.beforeFunctionExpression(check) : true;
84644
+ var check2 = this.values[this.curly - 5];
84645
+ regex2 = check2 ? !this.beforeFunctionExpression(check2) : true;
84646
84646
  }
84647
84647
  break;
84648
84648
  default:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini-svelte",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "The svelte plugin for houdini",
5
5
  "keywords": [
6
6
  "typescript",
@@ -32,7 +32,7 @@
32
32
  "rollup": "^3.7.4",
33
33
  "svelte": "^3.55.1",
34
34
  "vite": "^4.1.1",
35
- "houdini": "^1.0.2"
35
+ "houdini": "^1.0.3"
36
36
  },
37
37
  "files": [
38
38
  "build"