houdini-svelte 2.1.10 → 2.1.11

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.
@@ -152853,6 +152853,7 @@ async function queryStore({ config, pluginRoot }, doc) {
152853
152853
  const { store_class, statement } = store_import2(config, which);
152854
152854
  const storeData = `${statement}
152855
152855
  import artifact from '$houdini/artifacts/${artifactName}'
152856
+ import { initClient } from '$houdini/plugins/houdini-svelte/runtime/client'
152856
152857
 
152857
152858
  export class ${storeName} extends ${store_class} {
152858
152859
  constructor() {
@@ -152865,6 +152866,7 @@ export class ${storeName} extends ${store_class} {
152865
152866
  }
152866
152867
 
152867
152868
  export async function load_${artifactName}(params) {
152869
+ await initClient()
152868
152870
 
152869
152871
  const store = new ${storeName}()
152870
152872
 
@@ -154238,7 +154240,7 @@ export const redirect = svelteKitRedirect
154238
154240
  path_exports.dirname(networkFilePath),
154239
154241
  path_exports.join(config.projectRoot, plugin_config(config).client)
154240
154242
  );
154241
- return content.replace("HOUDINI_CLIENT_PATH", relativePath);
154243
+ return content.replaceAll("HOUDINI_CLIENT_PATH", relativePath);
154242
154244
  }
154243
154245
  },
154244
154246
  artifactData,
@@ -152848,6 +152848,7 @@ async function queryStore({ config, pluginRoot }, doc) {
152848
152848
  const { store_class, statement } = store_import2(config, which);
152849
152849
  const storeData = `${statement}
152850
152850
  import artifact from '$houdini/artifacts/${artifactName}'
152851
+ import { initClient } from '$houdini/plugins/houdini-svelte/runtime/client'
152851
152852
 
152852
152853
  export class ${storeName} extends ${store_class} {
152853
152854
  constructor() {
@@ -152860,6 +152861,7 @@ export class ${storeName} extends ${store_class} {
152860
152861
  }
152861
152862
 
152862
152863
  export async function load_${artifactName}(params) {
152864
+ await initClient()
152863
152865
 
152864
152866
  const store = new ${storeName}()
152865
152867
 
@@ -154233,7 +154235,7 @@ export const redirect = svelteKitRedirect
154233
154235
  path_exports.dirname(networkFilePath),
154234
154236
  path_exports.join(config.projectRoot, plugin_config(config).client)
154235
154237
  );
154236
- return content.replace("HOUDINI_CLIENT_PATH", relativePath);
154238
+ return content.replaceAll("HOUDINI_CLIENT_PATH", relativePath);
154237
154239
  }
154238
154240
  },
154239
154241
  artifactData,
@@ -1,2 +1,3 @@
1
1
  import type { HoudiniClient } from '$houdini/runtime/client';
2
+ export declare function initClient(): Promise<HoudiniClient>;
2
3
  export declare function getClient(): HoudiniClient;
@@ -1,4 +1,4 @@
1
+ export { QueryStore, QueryStoreCursor, QueryStoreOffset } from './query';
1
2
  export { FragmentStore, FragmentStoreCursor, FragmentStoreOffset } from './fragment';
2
3
  export { SubscriptionStore } from './subscription';
3
4
  export { MutationStore, type MutationConfig } from './mutation';
4
- export { QueryStore, QueryStoreCursor, QueryStoreOffset } from './query';
@@ -1,2 +1,3 @@
1
1
  import type { HoudiniClient } from '$houdini/runtime/client';
2
+ export declare function initClient(): Promise<HoudiniClient>;
2
3
  export declare function getClient(): HoudiniClient;
@@ -24,17 +24,34 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
24
24
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
25
  var client_exports = {};
26
26
  __export(client_exports, {
27
- getClient: () => getClient
27
+ getClient: () => getClient,
28
+ initClient: () => initClient
28
29
  });
29
30
  module.exports = __toCommonJS(client_exports);
30
- var import_HOUDINI_CLIENT_PATH = __toESM(require("HOUDINI_CLIENT_PATH"), 1);
31
+ let client = null;
32
+ async function initClient() {
33
+ if (client) {
34
+ return client;
35
+ }
36
+ client = (await import("HOUDINI_CLIENT_PATH")).default;
37
+ const delay = (ms) => new Promise((res) => setTimeout(res, ms));
38
+ for (let retry = 0; retry < 10; retry++) {
39
+ if (client) {
40
+ break;
41
+ }
42
+ await delay(100);
43
+ client = (await import("HOUDINI_CLIENT_PATH")).default;
44
+ }
45
+ return client;
46
+ }
31
47
  function getClient() {
32
- if (!import_HOUDINI_CLIENT_PATH.default) {
48
+ if (!client) {
33
49
  throw new Error("client hasn't been initialized");
34
50
  }
35
- return import_HOUDINI_CLIENT_PATH.default;
51
+ return client;
36
52
  }
37
53
  // Annotate the CommonJS export names for ESM import in node:
38
54
  0 && (module.exports = {
39
- getClient
55
+ getClient,
56
+ initClient
40
57
  });
@@ -73,6 +73,11 @@ class BaseStore {
73
73
  #subscriberCount = 0;
74
74
  setup(init = true) {
75
75
  let initPromise = Promise.resolve();
76
+ try {
77
+ (0, import_client2.getClient)();
78
+ } catch {
79
+ initPromise = (0, import_client2.initClient)();
80
+ }
76
81
  initPromise.then(() => {
77
82
  if (this.#unsubscribe) {
78
83
  return;
@@ -162,6 +162,7 @@ class FragmentStoreCursor extends BasePaginatedFragmentStore {
162
162
  getVariables,
163
163
  artifact: this.paginationArtifact,
164
164
  fetchUpdate: async (args, updates) => {
165
+ await (0, import_client.initClient)();
165
166
  return observer.send({
166
167
  session: await (0, import_session.getSession)(),
167
168
  ...args,
@@ -176,6 +177,7 @@ class FragmentStoreCursor extends BasePaginatedFragmentStore {
176
177
  });
177
178
  },
178
179
  fetch: async (args) => {
180
+ await (0, import_client.initClient)();
179
181
  return await observer.send({
180
182
  session: await (0, import_session.getSession)(),
181
183
  ...args,
@@ -209,6 +211,7 @@ class FragmentStoreOffset extends BasePaginatedFragmentStore {
209
211
  getVariables: () => store.variables,
210
212
  artifact: this.paginationArtifact,
211
213
  fetch: async (args) => {
214
+ await (0, import_client.initClient)();
212
215
  return paginationStore.send({
213
216
  ...args,
214
217
  session: await (0, import_session.getSession)(),
@@ -222,6 +225,7 @@ class FragmentStoreOffset extends BasePaginatedFragmentStore {
222
225
  });
223
226
  },
224
227
  fetchUpdate: async (args) => {
228
+ await (0, import_client.initClient)();
225
229
  return paginationStore.send({
226
230
  session: await (0, import_session.getSession)(),
227
231
  ...args,
@@ -1,4 +1,4 @@
1
+ export { QueryStore, QueryStoreCursor, QueryStoreOffset } from './query';
1
2
  export { FragmentStore, FragmentStoreCursor, FragmentStoreOffset } from './fragment';
2
3
  export { SubscriptionStore } from './subscription';
3
4
  export { MutationStore, type MutationConfig } from './mutation';
4
- export { QueryStore, QueryStoreCursor, QueryStoreOffset } from './query';
@@ -28,10 +28,10 @@ __export(stores_exports, {
28
28
  SubscriptionStore: () => import_subscription.SubscriptionStore
29
29
  });
30
30
  module.exports = __toCommonJS(stores_exports);
31
+ var import_query = require("./query");
31
32
  var import_fragment = require("./fragment");
32
33
  var import_subscription = require("./subscription");
33
34
  var import_mutation = require("./mutation");
34
- var import_query = require("./query");
35
35
  // Annotate the CommonJS export names for ESM import in node:
36
36
  0 && (module.exports = {
37
37
  FragmentStore,
@@ -21,6 +21,7 @@ __export(mutation_exports, {
21
21
  MutationStore: () => MutationStore
22
22
  });
23
23
  module.exports = __toCommonJS(mutation_exports);
24
+ var import_client = require("../client");
24
25
  var import_base = require("./base");
25
26
  var import_query = require("./query");
26
27
  class MutationStore extends import_base.BaseStore {
@@ -32,6 +33,7 @@ class MutationStore extends import_base.BaseStore {
32
33
  abortController,
33
34
  ...mutationConfig
34
35
  } = {}) {
36
+ await (0, import_client.initClient)();
35
37
  const { context } = await (0, import_query.fetchParams)(this.artifact, this.artifact.name, {
36
38
  fetch,
37
39
  metadata,
@@ -56,7 +56,7 @@ class QueryStore extends import_base.BaseStore {
56
56
  this.variables = variables;
57
57
  }
58
58
  async fetch(args) {
59
- const client = (0, import_client.getClient)();
59
+ const client = await (0, import_client.initClient)();
60
60
  this.setup(false);
61
61
  const { policy, params, context } = await fetchParams(this.artifact, this.storeName, args);
62
62
  if (!import_adapter.isBrowser && !(params && "fetch" in params) && (!params || !("event" in params))) {
@@ -204,6 +204,7 @@ class QueryStoreCursor extends QueryStore {
204
204
  if (this.#_handlers) {
205
205
  return this.#_handlers;
206
206
  }
207
+ await (0, import_client.initClient)();
207
208
  const paginationObserver = (0, import_client.getClient)().observe({
208
209
  artifact: this.artifact
209
210
  });
@@ -214,6 +215,7 @@ class QueryStoreCursor extends QueryStore {
214
215
  fetch: super.fetch.bind(this),
215
216
  getSession: import_session.getSession,
216
217
  fetchUpdate: async (args, updates) => {
218
+ await (0, import_client.initClient)();
217
219
  return paginationObserver.send({
218
220
  ...args,
219
221
  cacheParams: {
@@ -281,6 +283,7 @@ class QueryStoreOffset extends QueryStore {
281
283
  if (this.#_handlers) {
282
284
  return this.#_handlers;
283
285
  }
286
+ await (0, import_client.initClient)();
284
287
  const paginationObserver = (0, import_client.getClient)().observe({
285
288
  artifact: this.artifact
286
289
  });
@@ -292,6 +295,7 @@ class QueryStoreOffset extends QueryStore {
292
295
  getVariables: () => (0, import_store.get)(this.observer).variables,
293
296
  getSession: import_session.getSession,
294
297
  fetchUpdate: async (args) => {
298
+ await (0, import_client.initClient)();
295
299
  return paginationObserver.send({
296
300
  ...args,
297
301
  variables: {
@@ -23,6 +23,7 @@ __export(subscription_exports, {
23
23
  module.exports = __toCommonJS(subscription_exports);
24
24
  var import_types = require("$houdini/runtime/lib/types");
25
25
  var import_store = require("svelte/store");
26
+ var import_client = require("../client");
26
27
  var import_session = require("../session");
27
28
  var import_base = require("./base");
28
29
  class SubscriptionStore extends import_base.BaseStore {
@@ -33,6 +34,7 @@ class SubscriptionStore extends import_base.BaseStore {
33
34
  this.fetchingStore = (0, import_store.writable)(false);
34
35
  }
35
36
  async listen(variables, args) {
37
+ await (0, import_client.initClient)();
36
38
  this.fetchingStore.set(true);
37
39
  this.observer.send({
38
40
  variables,
@@ -41,6 +43,7 @@ class SubscriptionStore extends import_base.BaseStore {
41
43
  });
42
44
  }
43
45
  async unlisten() {
46
+ await (0, import_client.initClient)();
44
47
  this.fetchingStore.set(false);
45
48
  await this.observer.cleanup();
46
49
  }
@@ -1,2 +1,3 @@
1
1
  import type { HoudiniClient } from '$houdini/runtime/client';
2
+ export declare function initClient(): Promise<HoudiniClient>;
2
3
  export declare function getClient(): HoudiniClient;
@@ -1,4 +1,19 @@
1
- import client from "HOUDINI_CLIENT_PATH";
1
+ let client = null;
2
+ async function initClient() {
3
+ if (client) {
4
+ return client;
5
+ }
6
+ client = (await import("HOUDINI_CLIENT_PATH")).default;
7
+ const delay = (ms) => new Promise((res) => setTimeout(res, ms));
8
+ for (let retry = 0; retry < 10; retry++) {
9
+ if (client) {
10
+ break;
11
+ }
12
+ await delay(100);
13
+ client = (await import("HOUDINI_CLIENT_PATH")).default;
14
+ }
15
+ return client;
16
+ }
2
17
  function getClient() {
3
18
  if (!client) {
4
19
  throw new Error("client hasn't been initialized");
@@ -6,5 +21,6 @@ function getClient() {
6
21
  return client;
7
22
  }
8
23
  export {
9
- getClient
24
+ getClient,
25
+ initClient
10
26
  };
@@ -1,7 +1,7 @@
1
1
  import { DocumentStore } from "$houdini/runtime/client";
2
2
  import { get } from "svelte/store";
3
3
  import { isBrowser } from "../adapter";
4
- import { getClient } from "../client";
4
+ import { getClient, initClient } from "../client";
5
5
  class BaseStore {
6
6
  #params;
7
7
  get artifact() {
@@ -50,6 +50,11 @@ class BaseStore {
50
50
  #subscriberCount = 0;
51
51
  setup(init = true) {
52
52
  let initPromise = Promise.resolve();
53
+ try {
54
+ getClient();
55
+ } catch {
56
+ initPromise = initClient();
57
+ }
53
58
  initPromise.then(() => {
54
59
  if (this.#unsubscribe) {
55
60
  return;
@@ -7,7 +7,7 @@ import { marshalInputs } from "$houdini/runtime/lib/scalars";
7
7
  import { CompiledFragmentKind, fragmentKey } from "$houdini/runtime/lib/types";
8
8
  import { get, derived } from "svelte/store";
9
9
  import { isBrowser } from "../adapter";
10
- import { getClient } from "../client";
10
+ import { getClient, initClient } from "../client";
11
11
  import { getSession } from "../session";
12
12
  import { BaseStore } from "./base";
13
13
  class FragmentStore {
@@ -131,6 +131,7 @@ class FragmentStoreCursor extends BasePaginatedFragmentStore {
131
131
  getVariables,
132
132
  artifact: this.paginationArtifact,
133
133
  fetchUpdate: async (args, updates) => {
134
+ await initClient();
134
135
  return observer.send({
135
136
  session: await getSession(),
136
137
  ...args,
@@ -145,6 +146,7 @@ class FragmentStoreCursor extends BasePaginatedFragmentStore {
145
146
  });
146
147
  },
147
148
  fetch: async (args) => {
149
+ await initClient();
148
150
  return await observer.send({
149
151
  session: await getSession(),
150
152
  ...args,
@@ -178,6 +180,7 @@ class FragmentStoreOffset extends BasePaginatedFragmentStore {
178
180
  getVariables: () => store.variables,
179
181
  artifact: this.paginationArtifact,
180
182
  fetch: async (args) => {
183
+ await initClient();
181
184
  return paginationStore.send({
182
185
  ...args,
183
186
  session: await getSession(),
@@ -191,6 +194,7 @@ class FragmentStoreOffset extends BasePaginatedFragmentStore {
191
194
  });
192
195
  },
193
196
  fetchUpdate: async (args) => {
197
+ await initClient();
194
198
  return paginationStore.send({
195
199
  session: await getSession(),
196
200
  ...args,
@@ -1,4 +1,4 @@
1
+ export { QueryStore, QueryStoreCursor, QueryStoreOffset } from './query';
1
2
  export { FragmentStore, FragmentStoreCursor, FragmentStoreOffset } from './fragment';
2
3
  export { SubscriptionStore } from './subscription';
3
4
  export { MutationStore, type MutationConfig } from './mutation';
4
- export { QueryStore, QueryStoreCursor, QueryStoreOffset } from './query';
@@ -1,7 +1,7 @@
1
+ import { QueryStore, QueryStoreCursor, QueryStoreOffset } from "./query";
1
2
  import { FragmentStore, FragmentStoreCursor, FragmentStoreOffset } from "./fragment";
2
3
  import { SubscriptionStore } from "./subscription";
3
4
  import { MutationStore } from "./mutation";
4
- import { QueryStore, QueryStoreCursor, QueryStoreOffset } from "./query";
5
5
  export {
6
6
  FragmentStore,
7
7
  FragmentStoreCursor,
@@ -1,3 +1,4 @@
1
+ import { initClient } from "../client";
1
2
  import { BaseStore } from "./base";
2
3
  import { fetchParams } from "./query";
3
4
  class MutationStore extends BaseStore {
@@ -9,6 +10,7 @@ class MutationStore extends BaseStore {
9
10
  abortController,
10
11
  ...mutationConfig
11
12
  } = {}) {
13
+ await initClient();
12
14
  const { context } = await fetchParams(this.artifact, this.artifact.name, {
13
15
  fetch,
14
16
  metadata,
@@ -5,7 +5,7 @@ import { cursorHandlers, offsetHandlers } from "$houdini/runtime/lib/pagination"
5
5
  import { CompiledQueryKind, CachePolicy, ArtifactKind } from "$houdini/runtime/lib/types";
6
6
  import { get, derived } from "svelte/store";
7
7
  import { clientStarted, isBrowser } from "../adapter";
8
- import { getClient } from "../client";
8
+ import { getClient, initClient } from "../client";
9
9
  import { getSession } from "../session";
10
10
  import { BaseStore } from "./base";
11
11
  class QueryStore extends BaseStore {
@@ -24,7 +24,7 @@ class QueryStore extends BaseStore {
24
24
  this.variables = variables;
25
25
  }
26
26
  async fetch(args) {
27
- const client = getClient();
27
+ const client = await initClient();
28
28
  this.setup(false);
29
29
  const { policy, params, context } = await fetchParams(this.artifact, this.storeName, args);
30
30
  if (!isBrowser && !(params && "fetch" in params) && (!params || !("event" in params))) {
@@ -172,6 +172,7 @@ class QueryStoreCursor extends QueryStore {
172
172
  if (this.#_handlers) {
173
173
  return this.#_handlers;
174
174
  }
175
+ await initClient();
175
176
  const paginationObserver = getClient().observe({
176
177
  artifact: this.artifact
177
178
  });
@@ -182,6 +183,7 @@ class QueryStoreCursor extends QueryStore {
182
183
  fetch: super.fetch.bind(this),
183
184
  getSession,
184
185
  fetchUpdate: async (args, updates) => {
186
+ await initClient();
185
187
  return paginationObserver.send({
186
188
  ...args,
187
189
  cacheParams: {
@@ -249,6 +251,7 @@ class QueryStoreOffset extends QueryStore {
249
251
  if (this.#_handlers) {
250
252
  return this.#_handlers;
251
253
  }
254
+ await initClient();
252
255
  const paginationObserver = getClient().observe({
253
256
  artifact: this.artifact
254
257
  });
@@ -260,6 +263,7 @@ class QueryStoreOffset extends QueryStore {
260
263
  getVariables: () => get(this.observer).variables,
261
264
  getSession,
262
265
  fetchUpdate: async (args) => {
266
+ await initClient();
263
267
  return paginationObserver.send({
264
268
  ...args,
265
269
  variables: {
@@ -1,5 +1,6 @@
1
1
  import { CompiledSubscriptionKind } from "$houdini/runtime/lib/types";
2
2
  import { derived, writable } from "svelte/store";
3
+ import { initClient } from "../client";
3
4
  import { getSession } from "../session";
4
5
  import { BaseStore } from "./base";
5
6
  class SubscriptionStore extends BaseStore {
@@ -10,6 +11,7 @@ class SubscriptionStore extends BaseStore {
10
11
  this.fetchingStore = writable(false);
11
12
  }
12
13
  async listen(variables, args) {
14
+ await initClient();
13
15
  this.fetchingStore.set(true);
14
16
  this.observer.send({
15
17
  variables,
@@ -18,6 +20,7 @@ class SubscriptionStore extends BaseStore {
18
20
  });
19
21
  }
20
22
  async unlisten() {
23
+ await initClient();
21
24
  this.fetchingStore.set(false);
22
25
  await this.observer.cleanup();
23
26
  }
@@ -282710,6 +282710,7 @@ async function queryStore({ config, pluginRoot }, doc) {
282710
282710
  const { store_class, statement } = store_import2(config, which);
282711
282711
  const storeData = `${statement}
282712
282712
  import artifact from '$houdini/artifacts/${artifactName}'
282713
+ import { initClient } from '$houdini/plugins/houdini-svelte/runtime/client'
282713
282714
 
282714
282715
  export class ${storeName} extends ${store_class} {
282715
282716
  constructor() {
@@ -282722,6 +282723,7 @@ export class ${storeName} extends ${store_class} {
282722
282723
  }
282723
282724
 
282724
282725
  export async function load_${artifactName}(params) {
282726
+ await initClient()
282725
282727
 
282726
282728
  const store = new ${storeName}()
282727
282729
 
@@ -284095,7 +284097,7 @@ export const redirect = svelteKitRedirect
284095
284097
  path_exports.dirname(networkFilePath),
284096
284098
  path_exports.join(config.projectRoot, plugin_config(config).client)
284097
284099
  );
284098
- return content.replace("HOUDINI_CLIENT_PATH", relativePath);
284100
+ return content.replaceAll("HOUDINI_CLIENT_PATH", relativePath);
284099
284101
  }
284100
284102
  },
284101
284103
  artifactData,
@@ -282699,6 +282699,7 @@ async function queryStore({ config, pluginRoot }, doc) {
282699
282699
  const { store_class, statement } = store_import2(config, which);
282700
282700
  const storeData = `${statement}
282701
282701
  import artifact from '$houdini/artifacts/${artifactName}'
282702
+ import { initClient } from '$houdini/plugins/houdini-svelte/runtime/client'
282702
282703
 
282703
282704
  export class ${storeName} extends ${store_class} {
282704
282705
  constructor() {
@@ -282711,6 +282712,7 @@ export class ${storeName} extends ${store_class} {
282711
282712
  }
282712
282713
 
282713
282714
  export async function load_${artifactName}(params) {
282715
+ await initClient()
282714
282716
 
282715
282717
  const store = new ${storeName}()
282716
282718
 
@@ -284084,7 +284086,7 @@ export const redirect = svelteKitRedirect
284084
284086
  path_exports.dirname(networkFilePath),
284085
284087
  path_exports.join(config.projectRoot, plugin_config(config).client)
284086
284088
  );
284087
- return content.replace("HOUDINI_CLIENT_PATH", relativePath);
284089
+ return content.replaceAll("HOUDINI_CLIENT_PATH", relativePath);
284088
284090
  }
284089
284091
  },
284090
284092
  artifactData,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini-svelte",
3
- "version": "2.1.10",
3
+ "version": "2.1.11",
4
4
  "description": "The svelte plugin for houdini",
5
5
  "keywords": [
6
6
  "typescript",