houdini 1.0.1 → 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.
@@ -78311,7 +78311,7 @@ async function pullSchema_default(args) {
78311
78311
  }
78312
78312
  if (headerStrings.length > 0) {
78313
78313
  headers = headerStrings.reduce((total, header) => {
78314
- const [key, value] = header.split("=");
78314
+ const [key, value] = header.split(/=(.*)/s);
78315
78315
  return {
78316
78316
  ...total,
78317
78317
  [key]: value
@@ -78366,7 +78366,7 @@ async function init(_path, args) {
78366
78366
  let headers = {};
78367
78367
  if ((args.headers ?? []).length > 0) {
78368
78368
  headers = args.headers.reduce((total, header) => {
78369
- const [key, value] = header.split("=");
78369
+ const [key, value] = header.split(/=(.*)/s);
78370
78370
  return {
78371
78371
  ...total,
78372
78372
  [key]: value
@@ -78724,8 +78724,8 @@ async function updatePackageJSON(targetPath) {
78724
78724
  }
78725
78725
  packageJSON.devDependencies = {
78726
78726
  ...packageJSON.devDependencies,
78727
- houdini: "^1.0.1",
78728
- "houdini-svelte": "^1.0.1"
78727
+ houdini: "^1.0.3",
78728
+ "houdini-svelte": "^1.0.3"
78729
78729
  };
78730
78730
  await fs_exports.writeFile(packagePath, JSON.stringify(packageJSON, null, 4));
78731
78731
  }
@@ -78316,7 +78316,7 @@ async function pullSchema_default(args) {
78316
78316
  }
78317
78317
  if (headerStrings.length > 0) {
78318
78318
  headers = headerStrings.reduce((total, header) => {
78319
- const [key, value] = header.split("=");
78319
+ const [key, value] = header.split(/=(.*)/s);
78320
78320
  return {
78321
78321
  ...total,
78322
78322
  [key]: value
@@ -78371,7 +78371,7 @@ async function init(_path, args) {
78371
78371
  let headers = {};
78372
78372
  if ((args.headers ?? []).length > 0) {
78373
78373
  headers = args.headers.reduce((total, header) => {
78374
- const [key, value] = header.split("=");
78374
+ const [key, value] = header.split(/=(.*)/s);
78375
78375
  return {
78376
78376
  ...total,
78377
78377
  [key]: value
@@ -78729,8 +78729,8 @@ async function updatePackageJSON(targetPath) {
78729
78729
  }
78730
78730
  packageJSON.devDependencies = {
78731
78731
  ...packageJSON.devDependencies,
78732
- houdini: "^1.0.1",
78733
- "houdini-svelte": "^1.0.1"
78732
+ houdini: "^1.0.3",
78733
+ "houdini-svelte": "^1.0.3"
78734
78734
  };
78735
78735
  await fs_exports.writeFile(packagePath, JSON.stringify(packageJSON, null, 4));
78736
78736
  }
@@ -54000,11 +54000,11 @@ var require_esprima2 = __commonJS({
54000
54000
  case "}":
54001
54001
  regex = false;
54002
54002
  if (this.values[this.curly - 3] === "function") {
54003
- var check = this.values[this.curly - 4];
54004
- regex = check ? !this.beforeFunctionExpression(check) : false;
54003
+ var check2 = this.values[this.curly - 4];
54004
+ regex = check2 ? !this.beforeFunctionExpression(check2) : false;
54005
54005
  } else if (this.values[this.curly - 4] === "function") {
54006
- var check = this.values[this.curly - 5];
54007
- regex = check ? !this.beforeFunctionExpression(check) : true;
54006
+ var check2 = this.values[this.curly - 5];
54007
+ regex = check2 ? !this.beforeFunctionExpression(check2) : true;
54008
54008
  }
54009
54009
  break;
54010
54010
  default:
@@ -63489,14 +63489,14 @@ function flatten(source) {
63489
63489
  var fetch2 = (target) => {
63490
63490
  return () => {
63491
63491
  return {
63492
- async network(ctx, { client, resolve: resolve2, marshalVariables: marshalVariables2 }) {
63492
+ async network(ctx, { client: client2, resolve: resolve2, marshalVariables: marshalVariables2 }) {
63493
63493
  const fetch3 = ctx.fetch ?? globalThis.fetch;
63494
63494
  const fetchParams2 = {
63495
63495
  text: ctx.text,
63496
63496
  hash: ctx.hash,
63497
63497
  variables: marshalVariables2(ctx)
63498
63498
  };
63499
- let fetchFn = defaultFetch(client.url, ctx.fetchParams);
63499
+ let fetchFn = defaultFetch(client2.url, ctx.fetchParams);
63500
63500
  if (target) {
63501
63501
  if (typeof target === "string") {
63502
63502
  fetchFn = defaultFetch(target, ctx.fetchParams);
@@ -65675,11 +65675,10 @@ var mutation = documentPlugin(ArtifactKind.Mutation, () => {
65675
65675
  });
65676
65676
 
65677
65677
  // src/runtime/client/plugins/subscription.ts
65678
+ var check = null;
65678
65679
  function subscription(factory) {
65679
65680
  return documentPlugin(ArtifactKind.Subscription, () => {
65680
65681
  let clearSubscription = null;
65681
- let socketClient = null;
65682
- let check = null;
65683
65682
  return {
65684
65683
  start(ctx, { resolve: resolve2, next, initialValue }) {
65685
65684
  if (typeof globalThis.window === "undefined") {
@@ -65688,7 +65687,7 @@ function subscription(factory) {
65688
65687
  }
65689
65688
  next(ctx);
65690
65689
  },
65691
- network(ctx, { resolve: resolve2, initialValue, variablesChanged: variablesChanged2, marshalVariables: marshalVariables2 }) {
65690
+ async network(ctx, { resolve: resolve2, initialValue, variablesChanged: variablesChanged2, marshalVariables: marshalVariables2 }) {
65692
65691
  const checkValue = {
65693
65692
  fetchParams: ctx.fetchParams ?? {},
65694
65693
  session: ctx.session ?? {},
@@ -65701,11 +65700,11 @@ function subscription(factory) {
65701
65700
  return;
65702
65701
  }
65703
65702
  check = checkValue;
65704
- clearSubscription?.();
65705
- if (!socketClient || sessionChange) {
65706
- socketClient = factory(ctx);
65703
+ if (sessionChange) {
65704
+ await loadClient(ctx, factory);
65707
65705
  }
65708
- clearSubscription = socketClient.subscribe(
65706
+ clearSubscription?.();
65707
+ clearSubscription = client.subscribe(
65709
65708
  {
65710
65709
  query: ctx.artifact.raw,
65711
65710
  variables: marshalVariables2(ctx)
@@ -65745,6 +65744,19 @@ function subscription(factory) {
65745
65744
  };
65746
65745
  });
65747
65746
  }
65747
+ var pendingCreate = null;
65748
+ var client;
65749
+ function loadClient(ctx, factory) {
65750
+ if (pendingCreate) {
65751
+ return pendingCreate;
65752
+ }
65753
+ pendingCreate = new Promise((resolve2) => {
65754
+ client = factory(ctx);
65755
+ resolve2();
65756
+ pendingCreate = null;
65757
+ });
65758
+ return pendingCreate;
65759
+ }
65748
65760
 
65749
65761
  // src/runtime/client/plugins/throwOnError.ts
65750
65762
  var throwOnError = ({ operations, error }) => () => {
@@ -65803,7 +65815,7 @@ var DocumentStore = class extends Writable {
65803
65815
  artifact,
65804
65816
  plugins: plugins2,
65805
65817
  pipeline: pipeline2,
65806
- client,
65818
+ client: client2,
65807
65819
  cache = true,
65808
65820
  initialValue,
65809
65821
  fetching
@@ -65827,7 +65839,7 @@ var DocumentStore = class extends Writable {
65827
65839
  };
65828
65840
  });
65829
65841
  this.#artifact = artifact;
65830
- this.#client = client;
65842
+ this.#client = client2;
65831
65843
  this.#lastVariables = null;
65832
65844
  this.#configFile = getCurrentConfig();
65833
65845
  this.#plugins = pipeline2 ?? [
@@ -54005,11 +54005,11 @@ var require_esprima2 = __commonJS({
54005
54005
  case "}":
54006
54006
  regex = false;
54007
54007
  if (this.values[this.curly - 3] === "function") {
54008
- var check = this.values[this.curly - 4];
54009
- regex = check ? !this.beforeFunctionExpression(check) : false;
54008
+ var check2 = this.values[this.curly - 4];
54009
+ regex = check2 ? !this.beforeFunctionExpression(check2) : false;
54010
54010
  } else if (this.values[this.curly - 4] === "function") {
54011
- var check = this.values[this.curly - 5];
54012
- regex = check ? !this.beforeFunctionExpression(check) : true;
54011
+ var check2 = this.values[this.curly - 5];
54012
+ regex = check2 ? !this.beforeFunctionExpression(check2) : true;
54013
54013
  }
54014
54014
  break;
54015
54015
  default:
@@ -63438,14 +63438,14 @@ function flatten(source) {
63438
63438
  var fetch2 = (target) => {
63439
63439
  return () => {
63440
63440
  return {
63441
- async network(ctx, { client, resolve: resolve2, marshalVariables: marshalVariables2 }) {
63441
+ async network(ctx, { client: client2, resolve: resolve2, marshalVariables: marshalVariables2 }) {
63442
63442
  const fetch3 = ctx.fetch ?? globalThis.fetch;
63443
63443
  const fetchParams2 = {
63444
63444
  text: ctx.text,
63445
63445
  hash: ctx.hash,
63446
63446
  variables: marshalVariables2(ctx)
63447
63447
  };
63448
- let fetchFn = defaultFetch(client.url, ctx.fetchParams);
63448
+ let fetchFn = defaultFetch(client2.url, ctx.fetchParams);
63449
63449
  if (target) {
63450
63450
  if (typeof target === "string") {
63451
63451
  fetchFn = defaultFetch(target, ctx.fetchParams);
@@ -65624,11 +65624,10 @@ var mutation = documentPlugin(ArtifactKind.Mutation, () => {
65624
65624
  });
65625
65625
 
65626
65626
  // src/runtime/client/plugins/subscription.ts
65627
+ var check = null;
65627
65628
  function subscription(factory) {
65628
65629
  return documentPlugin(ArtifactKind.Subscription, () => {
65629
65630
  let clearSubscription = null;
65630
- let socketClient = null;
65631
- let check = null;
65632
65631
  return {
65633
65632
  start(ctx, { resolve: resolve2, next, initialValue }) {
65634
65633
  if (typeof globalThis.window === "undefined") {
@@ -65637,7 +65636,7 @@ function subscription(factory) {
65637
65636
  }
65638
65637
  next(ctx);
65639
65638
  },
65640
- network(ctx, { resolve: resolve2, initialValue, variablesChanged: variablesChanged2, marshalVariables: marshalVariables2 }) {
65639
+ async network(ctx, { resolve: resolve2, initialValue, variablesChanged: variablesChanged2, marshalVariables: marshalVariables2 }) {
65641
65640
  const checkValue = {
65642
65641
  fetchParams: ctx.fetchParams ?? {},
65643
65642
  session: ctx.session ?? {},
@@ -65650,11 +65649,11 @@ function subscription(factory) {
65650
65649
  return;
65651
65650
  }
65652
65651
  check = checkValue;
65653
- clearSubscription?.();
65654
- if (!socketClient || sessionChange) {
65655
- socketClient = factory(ctx);
65652
+ if (sessionChange) {
65653
+ await loadClient(ctx, factory);
65656
65654
  }
65657
- clearSubscription = socketClient.subscribe(
65655
+ clearSubscription?.();
65656
+ clearSubscription = client.subscribe(
65658
65657
  {
65659
65658
  query: ctx.artifact.raw,
65660
65659
  variables: marshalVariables2(ctx)
@@ -65694,6 +65693,19 @@ function subscription(factory) {
65694
65693
  };
65695
65694
  });
65696
65695
  }
65696
+ var pendingCreate = null;
65697
+ var client;
65698
+ function loadClient(ctx, factory) {
65699
+ if (pendingCreate) {
65700
+ return pendingCreate;
65701
+ }
65702
+ pendingCreate = new Promise((resolve2) => {
65703
+ client = factory(ctx);
65704
+ resolve2();
65705
+ pendingCreate = null;
65706
+ });
65707
+ return pendingCreate;
65708
+ }
65697
65709
 
65698
65710
  // src/runtime/client/plugins/throwOnError.ts
65699
65711
  var throwOnError = ({ operations, error }) => () => {
@@ -65752,7 +65764,7 @@ var DocumentStore = class extends Writable {
65752
65764
  artifact,
65753
65765
  plugins: plugins2,
65754
65766
  pipeline: pipeline2,
65755
- client,
65767
+ client: client2,
65756
65768
  cache = true,
65757
65769
  initialValue,
65758
65770
  fetching
@@ -65776,7 +65788,7 @@ var DocumentStore = class extends Writable {
65776
65788
  };
65777
65789
  });
65778
65790
  this.#artifact = artifact;
65779
- this.#client = client;
65791
+ this.#client = client2;
65780
65792
  this.#lastVariables = null;
65781
65793
  this.#configFile = getCurrentConfig();
65782
65794
  this.#plugins = pipeline2 ?? [
@@ -1,6 +1,7 @@
1
1
  import type { ClientPluginContext } from '../documentStore';
2
2
  export declare function subscription(factory: SubscriptionHandler): import("../documentStore").ClientPlugin;
3
- export type SubscriptionHandler = (ctx: ClientPluginContext) => {
3
+ export type SubscriptionHandler = (ctx: ClientPluginContext) => SubscriptionClient;
4
+ export type SubscriptionClient = {
4
5
  subscribe: (payload: {
5
6
  query: string;
6
7
  variables?: {};
@@ -1,6 +1,7 @@
1
1
  import type { ClientPluginContext } from '../documentStore';
2
2
  export declare function subscription(factory: SubscriptionHandler): import("../documentStore").ClientPlugin;
3
- export type SubscriptionHandler = (ctx: ClientPluginContext) => {
3
+ export type SubscriptionHandler = (ctx: ClientPluginContext) => SubscriptionClient;
4
+ export type SubscriptionClient = {
4
5
  subscribe: (payload: {
5
6
  query: string;
6
7
  variables?: {};
@@ -24,11 +24,10 @@ module.exports = __toCommonJS(subscription_exports);
24
24
  var import_deepEquals = require("../../lib/deepEquals");
25
25
  var import_types = require("../../lib/types");
26
26
  var import_utils = require("../utils");
27
+ let check = null;
27
28
  function subscription(factory) {
28
29
  return (0, import_utils.documentPlugin)(import_types.ArtifactKind.Subscription, () => {
29
30
  let clearSubscription = null;
30
- let socketClient = null;
31
- let check = null;
32
31
  return {
33
32
  start(ctx, { resolve, next, initialValue }) {
34
33
  if (typeof globalThis.window === "undefined") {
@@ -37,7 +36,7 @@ function subscription(factory) {
37
36
  }
38
37
  next(ctx);
39
38
  },
40
- network(ctx, { resolve, initialValue, variablesChanged, marshalVariables }) {
39
+ async network(ctx, { resolve, initialValue, variablesChanged, marshalVariables }) {
41
40
  const checkValue = {
42
41
  fetchParams: ctx.fetchParams ?? {},
43
42
  session: ctx.session ?? {},
@@ -50,11 +49,11 @@ function subscription(factory) {
50
49
  return;
51
50
  }
52
51
  check = checkValue;
53
- clearSubscription?.();
54
- if (!socketClient || sessionChange) {
55
- socketClient = factory(ctx);
52
+ if (sessionChange) {
53
+ await loadClient(ctx, factory);
56
54
  }
57
- clearSubscription = socketClient.subscribe(
55
+ clearSubscription?.();
56
+ clearSubscription = client.subscribe(
58
57
  {
59
58
  query: ctx.artifact.raw,
60
59
  variables: marshalVariables(ctx)
@@ -94,6 +93,19 @@ function subscription(factory) {
94
93
  };
95
94
  });
96
95
  }
96
+ let pendingCreate = null;
97
+ let client;
98
+ function loadClient(ctx, factory) {
99
+ if (pendingCreate) {
100
+ return pendingCreate;
101
+ }
102
+ pendingCreate = new Promise((resolve) => {
103
+ client = factory(ctx);
104
+ resolve();
105
+ pendingCreate = null;
106
+ });
107
+ return pendingCreate;
108
+ }
97
109
  // Annotate the CommonJS export names for ESM import in node:
98
110
  0 && (module.exports = {
99
111
  subscription
@@ -1,6 +1,7 @@
1
1
  import type { ClientPluginContext } from '../documentStore';
2
2
  export declare function subscription(factory: SubscriptionHandler): import("../documentStore").ClientPlugin;
3
- export type SubscriptionHandler = (ctx: ClientPluginContext) => {
3
+ export type SubscriptionHandler = (ctx: ClientPluginContext) => SubscriptionClient;
4
+ export type SubscriptionClient = {
4
5
  subscribe: (payload: {
5
6
  query: string;
6
7
  variables?: {};
@@ -1,11 +1,10 @@
1
1
  import { deepEquals } from "../../lib/deepEquals";
2
2
  import { ArtifactKind, DataSource } from "../../lib/types";
3
3
  import { documentPlugin } from "../utils";
4
+ let check = null;
4
5
  function subscription(factory) {
5
6
  return documentPlugin(ArtifactKind.Subscription, () => {
6
7
  let clearSubscription = null;
7
- let socketClient = null;
8
- let check = null;
9
8
  return {
10
9
  start(ctx, { resolve, next, initialValue }) {
11
10
  if (typeof globalThis.window === "undefined") {
@@ -14,7 +13,7 @@ function subscription(factory) {
14
13
  }
15
14
  next(ctx);
16
15
  },
17
- network(ctx, { resolve, initialValue, variablesChanged, marshalVariables }) {
16
+ async network(ctx, { resolve, initialValue, variablesChanged, marshalVariables }) {
18
17
  const checkValue = {
19
18
  fetchParams: ctx.fetchParams ?? {},
20
19
  session: ctx.session ?? {},
@@ -27,11 +26,11 @@ function subscription(factory) {
27
26
  return;
28
27
  }
29
28
  check = checkValue;
30
- clearSubscription?.();
31
- if (!socketClient || sessionChange) {
32
- socketClient = factory(ctx);
29
+ if (sessionChange) {
30
+ await loadClient(ctx, factory);
33
31
  }
34
- clearSubscription = socketClient.subscribe(
32
+ clearSubscription?.();
33
+ clearSubscription = client.subscribe(
35
34
  {
36
35
  query: ctx.artifact.raw,
37
36
  variables: marshalVariables(ctx)
@@ -71,6 +70,19 @@ function subscription(factory) {
71
70
  };
72
71
  });
73
72
  }
73
+ let pendingCreate = null;
74
+ let client;
75
+ function loadClient(ctx, factory) {
76
+ if (pendingCreate) {
77
+ return pendingCreate;
78
+ }
79
+ pendingCreate = new Promise((resolve) => {
80
+ client = factory(ctx);
81
+ resolve();
82
+ pendingCreate = null;
83
+ });
84
+ return pendingCreate;
85
+ }
74
86
  export {
75
87
  subscription
76
88
  };
@@ -7,5 +7,5 @@ export type Partial<T> = {
7
7
  [P in keyof T]?: T[P];
8
8
  };
9
9
  export declare function pipelineTest(config: Config, documents: string[], shouldPass: boolean, testBody?: ((result: Error | Error[]) => void) | ((docs: Document[]) => void)): () => Promise<void>;
10
- export declare function mockCollectedDoc(query: string): Document;
10
+ export declare function mockCollectedDoc(query: string, data?: Partial<Document>): Document;
11
11
  export declare function clearMock(): void;
@@ -62495,7 +62495,7 @@ function testConfig(config2 = {}) {
62495
62495
  }
62496
62496
  function pipelineTest(config2, documents, shouldPass, testBody) {
62497
62497
  return async () => {
62498
- const docs = documents.map(mockCollectedDoc);
62498
+ const docs = documents.map((doc) => mockCollectedDoc(doc));
62499
62499
  let error = [];
62500
62500
  try {
62501
62501
  await runPipeline2(config2, docs);
@@ -62514,7 +62514,7 @@ function pipelineTest(config2, documents, shouldPass, testBody) {
62514
62514
  }
62515
62515
  };
62516
62516
  }
62517
- function mockCollectedDoc(query2) {
62517
+ function mockCollectedDoc(query2, data) {
62518
62518
  const parsed = graphql25.parse(query2);
62519
62519
  const name = parsed.definitions[0].name.value;
62520
62520
  const operations = parsed.definitions;
@@ -62537,7 +62537,8 @@ function mockCollectedDoc(query2) {
62537
62537
  generateArtifact: true,
62538
62538
  generateStore: true,
62539
62539
  originalString: query2,
62540
- artifact: null
62540
+ artifact: null,
62541
+ ...data
62541
62542
  };
62542
62543
  }
62543
62544
  function clearMock() {
@@ -62490,7 +62490,7 @@ function testConfig(config2 = {}) {
62490
62490
  }
62491
62491
  function pipelineTest(config2, documents, shouldPass, testBody) {
62492
62492
  return async () => {
62493
- const docs = documents.map(mockCollectedDoc);
62493
+ const docs = documents.map((doc) => mockCollectedDoc(doc));
62494
62494
  let error = [];
62495
62495
  try {
62496
62496
  await runPipeline2(config2, docs);
@@ -62509,7 +62509,7 @@ function pipelineTest(config2, documents, shouldPass, testBody) {
62509
62509
  }
62510
62510
  };
62511
62511
  }
62512
- function mockCollectedDoc(query2) {
62512
+ function mockCollectedDoc(query2, data) {
62513
62513
  const parsed = graphql25.parse(query2);
62514
62514
  const name = parsed.definitions[0].name.value;
62515
62515
  const operations = parsed.definitions;
@@ -62532,7 +62532,8 @@ function mockCollectedDoc(query2) {
62532
62532
  generateArtifact: true,
62533
62533
  generateStore: true,
62534
62534
  originalString: query2,
62535
- artifact: null
62535
+ artifact: null,
62536
+ ...data
62536
62537
  };
62537
62538
  }
62538
62539
  function clearMock() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "The disappearing GraphQL clients",
5
5
  "keywords": [
6
6
  "typescript",