houdini 1.2.45 → 1.2.47
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/cmd-cjs/index.js +42 -12
- package/build/cmd-esm/index.js +42 -12
- package/build/codegen-cjs/index.js +40 -10
- package/build/codegen-esm/index.js +40 -10
- package/build/lib-cjs/index.js +91 -12
- package/build/lib-esm/index.js +91 -12
- package/build/runtime/cache/cache.d.ts +1 -1
- package/build/runtime/cache/subscription.d.ts +1 -0
- package/build/runtime/router/match.d.ts +3 -2
- package/build/runtime-cjs/cache/cache.d.ts +1 -1
- package/build/runtime-cjs/cache/cache.js +7 -4
- package/build/runtime-cjs/cache/subscription.d.ts +1 -0
- package/build/runtime-cjs/cache/subscription.js +20 -2
- package/build/runtime-cjs/client/plugins/cache.js +1 -1
- package/build/runtime-cjs/client/plugins/fetchParams.js +1 -1
- package/build/runtime-cjs/router/match.d.ts +3 -2
- package/build/runtime-cjs/router/match.js +13 -2
- package/build/runtime-cjs/router/server.js +1 -1
- package/build/runtime-esm/cache/cache.d.ts +1 -1
- package/build/runtime-esm/cache/cache.js +7 -4
- package/build/runtime-esm/cache/subscription.d.ts +1 -0
- package/build/runtime-esm/cache/subscription.js +20 -2
- package/build/runtime-esm/client/plugins/cache.js +1 -1
- package/build/runtime-esm/client/plugins/fetchParams.js +1 -1
- package/build/runtime-esm/router/match.d.ts +3 -2
- package/build/runtime-esm/router/match.js +13 -2
- package/build/runtime-esm/router/server.js +1 -1
- package/build/test-cjs/index.js +40 -10
- package/build/test-esm/index.js +40 -10
- package/build/vite-cjs/index.js +52 -11
- package/build/vite-esm/index.js +52 -11
- package/package.json +1 -1
package/build/lib-cjs/index.js
CHANGED
|
@@ -61644,6 +61644,38 @@ function marshalInputs({
|
|
|
61644
61644
|
function isScalar(config, type) {
|
|
61645
61645
|
return ["String", "Boolean", "Float", "ID", "Int"].concat(Object.keys(config.scalars || {})).includes(type);
|
|
61646
61646
|
}
|
|
61647
|
+
function parseScalar(config, type, value) {
|
|
61648
|
+
if (typeof value === "undefined") {
|
|
61649
|
+
return void 0;
|
|
61650
|
+
}
|
|
61651
|
+
if (type === "Boolean") {
|
|
61652
|
+
return value === "true";
|
|
61653
|
+
}
|
|
61654
|
+
if (type === "ID") {
|
|
61655
|
+
return value;
|
|
61656
|
+
}
|
|
61657
|
+
if (type === "String") {
|
|
61658
|
+
return value;
|
|
61659
|
+
}
|
|
61660
|
+
if (type === "Int") {
|
|
61661
|
+
const result = parseInt(value, 10);
|
|
61662
|
+
if (Number.isNaN(result)) {
|
|
61663
|
+
return void 0;
|
|
61664
|
+
}
|
|
61665
|
+
return result;
|
|
61666
|
+
}
|
|
61667
|
+
if (type === "Float") {
|
|
61668
|
+
const result = parseFloat(value);
|
|
61669
|
+
if (Number.isNaN(result)) {
|
|
61670
|
+
return void 0;
|
|
61671
|
+
}
|
|
61672
|
+
return result;
|
|
61673
|
+
}
|
|
61674
|
+
if (config.scalars?.[type]?.marshal) {
|
|
61675
|
+
return config.scalars[type]?.marshal(value);
|
|
61676
|
+
}
|
|
61677
|
+
return value;
|
|
61678
|
+
}
|
|
61647
61679
|
|
|
61648
61680
|
// src/runtime/lib/store.ts
|
|
61649
61681
|
var subscriber_queue = [];
|
|
@@ -64622,9 +64654,12 @@ var InMemorySubscriptions = class {
|
|
|
64622
64654
|
removeSubscribers(id, fieldName, specs) {
|
|
64623
64655
|
let targets = [];
|
|
64624
64656
|
const subscriber = this.subscribers.get(id);
|
|
64625
|
-
|
|
64657
|
+
if (!subscriber) {
|
|
64658
|
+
return;
|
|
64659
|
+
}
|
|
64660
|
+
const subscriberField = subscriber.get(fieldName);
|
|
64626
64661
|
for (const spec of specs) {
|
|
64627
|
-
const counts = subscriber
|
|
64662
|
+
const counts = subscriber.get(fieldName)?.referenceCounts;
|
|
64628
64663
|
if (!counts?.has(spec.set)) {
|
|
64629
64664
|
continue;
|
|
64630
64665
|
}
|
|
@@ -64634,12 +64669,18 @@ var InMemorySubscriptions = class {
|
|
|
64634
64669
|
targets.push(spec.set);
|
|
64635
64670
|
counts.delete(spec.set);
|
|
64636
64671
|
}
|
|
64672
|
+
if (counts.size === 0) {
|
|
64673
|
+
subscriber.delete(fieldName);
|
|
64674
|
+
}
|
|
64637
64675
|
}
|
|
64638
64676
|
if (subscriberField) {
|
|
64639
64677
|
subscriberField.selections = this.get(id, fieldName).filter(
|
|
64640
64678
|
([{ set }]) => !targets.includes(set)
|
|
64641
64679
|
);
|
|
64642
64680
|
}
|
|
64681
|
+
if (subscriber.size === 0) {
|
|
64682
|
+
this.subscribers.delete(id);
|
|
64683
|
+
}
|
|
64643
64684
|
}
|
|
64644
64685
|
removeAllSubscribers(id, targets, visited = []) {
|
|
64645
64686
|
visited.push(id);
|
|
@@ -64660,6 +64701,15 @@ var InMemorySubscriptions = class {
|
|
|
64660
64701
|
}
|
|
64661
64702
|
}
|
|
64662
64703
|
}
|
|
64704
|
+
get size() {
|
|
64705
|
+
let size = 0;
|
|
64706
|
+
for (const [, nodeCounts] of this.subscribers) {
|
|
64707
|
+
for (const [, { referenceCounts }] of nodeCounts) {
|
|
64708
|
+
size += [...referenceCounts.values()].reduce((size2, count) => size2 + count, 0);
|
|
64709
|
+
}
|
|
64710
|
+
}
|
|
64711
|
+
return size;
|
|
64712
|
+
}
|
|
64663
64713
|
};
|
|
64664
64714
|
|
|
64665
64715
|
// src/runtime/cache/cache.ts
|
|
@@ -64708,6 +64758,9 @@ var Cache = class {
|
|
|
64708
64758
|
};
|
|
64709
64759
|
}
|
|
64710
64760
|
subscribe(spec, variables = {}) {
|
|
64761
|
+
if (this._internal_unstable.disabled) {
|
|
64762
|
+
return;
|
|
64763
|
+
}
|
|
64711
64764
|
return this._internal_unstable.subscriptions.add({
|
|
64712
64765
|
parent: spec.parentID || rootID,
|
|
64713
64766
|
spec,
|
|
@@ -64847,7 +64900,7 @@ var Cache = class {
|
|
|
64847
64900
|
}
|
|
64848
64901
|
};
|
|
64849
64902
|
var CacheInternal = class {
|
|
64850
|
-
|
|
64903
|
+
disabled = false;
|
|
64851
64904
|
_config;
|
|
64852
64905
|
storage;
|
|
64853
64906
|
subscriptions;
|
|
@@ -64878,10 +64931,10 @@ var CacheInternal = class {
|
|
|
64878
64931
|
this._config = config;
|
|
64879
64932
|
this.componentCache = componentCache ?? {};
|
|
64880
64933
|
this.createComponent = createComponent ?? (() => ({}));
|
|
64881
|
-
this.
|
|
64934
|
+
this.disabled = disabled;
|
|
64882
64935
|
try {
|
|
64883
64936
|
if (process.env.HOUDINI_TEST === "true") {
|
|
64884
|
-
this.
|
|
64937
|
+
this.disabled = false;
|
|
64885
64938
|
}
|
|
64886
64939
|
} catch {
|
|
64887
64940
|
}
|
|
@@ -64903,7 +64956,7 @@ var CacheInternal = class {
|
|
|
64903
64956
|
forceNotify,
|
|
64904
64957
|
forceStale
|
|
64905
64958
|
}) {
|
|
64906
|
-
if (this.
|
|
64959
|
+
if (this.disabled) {
|
|
64907
64960
|
return [];
|
|
64908
64961
|
}
|
|
64909
64962
|
let targetSelection = getFieldsForType(
|
|
@@ -65766,7 +65819,7 @@ var cachePolicy = ({
|
|
|
65766
65819
|
serverSideFallback = true
|
|
65767
65820
|
}) => () => {
|
|
65768
65821
|
return {
|
|
65769
|
-
|
|
65822
|
+
beforeNetwork(ctx, { initialValue, next, resolve: resolve2, marshalVariables: marshalVariables2 }) {
|
|
65770
65823
|
const { policy, artifact } = ctx;
|
|
65771
65824
|
let useCache = false;
|
|
65772
65825
|
if (enabled && (artifact.kind === ArtifactKind.Query || artifact.kind === ArtifactKind.Fragment) && !ctx.cacheParams?.disableRead) {
|
|
@@ -66160,7 +66213,7 @@ var defaultErrorFn = async (errors) => new Error(errors.map((error) => error.mes
|
|
|
66160
66213
|
|
|
66161
66214
|
// src/runtime/client/plugins/fetchParams.ts
|
|
66162
66215
|
var fetchParams = (fn = () => ({})) => () => ({
|
|
66163
|
-
|
|
66216
|
+
start(ctx, { next, marshalVariables: marshalVariables2 }) {
|
|
66164
66217
|
next({
|
|
66165
66218
|
...ctx,
|
|
66166
66219
|
fetchParams: fn({
|
|
@@ -67802,7 +67855,12 @@ function deepMerge2(filepath, ...targets) {
|
|
|
67802
67855
|
// src/lib/parse.ts
|
|
67803
67856
|
function parseJS(str, config) {
|
|
67804
67857
|
const defaultConfig = {
|
|
67805
|
-
plugins: [
|
|
67858
|
+
plugins: [
|
|
67859
|
+
"typescript",
|
|
67860
|
+
"importAssertions",
|
|
67861
|
+
"decorators-legacy",
|
|
67862
|
+
"explicitResourceManagement"
|
|
67863
|
+
],
|
|
67806
67864
|
sourceType: "module"
|
|
67807
67865
|
};
|
|
67808
67866
|
return (0, import_parser.parse)(str || "", config ? deepMerge2("", defaultConfig, config) : defaultConfig).program;
|
|
@@ -67945,7 +68003,7 @@ async function detectTools(cwd = process.cwd()) {
|
|
|
67945
68003
|
|
|
67946
68004
|
// src/runtime/router/match.ts
|
|
67947
68005
|
var param_pattern = /^(\[)?(\.\.\.)?(\w+)(?:=(\w+))?(\])?$/;
|
|
67948
|
-
function find_match(manifest, current, allowNull = true) {
|
|
68006
|
+
function find_match(config, manifest, current, allowNull = true) {
|
|
67949
68007
|
let match = null;
|
|
67950
68008
|
let matchVariables = null;
|
|
67951
68009
|
for (const page of Object.values(manifest.pages)) {
|
|
@@ -67960,7 +68018,17 @@ function find_match(manifest, current, allowNull = true) {
|
|
|
67960
68018
|
if (!match && !allowNull) {
|
|
67961
68019
|
throw new Error("404");
|
|
67962
68020
|
}
|
|
67963
|
-
|
|
68021
|
+
let variables = {
|
|
68022
|
+
...matchVariables
|
|
68023
|
+
};
|
|
68024
|
+
for (const document of Object.values(match?.documents ?? {})) {
|
|
68025
|
+
for (const [variable, { type }] of Object.entries(document.variables)) {
|
|
68026
|
+
if (matchVariables?.[variable]) {
|
|
68027
|
+
variables[variable] = parseScalar(config, type, matchVariables[variable]);
|
|
68028
|
+
}
|
|
68029
|
+
}
|
|
68030
|
+
}
|
|
68031
|
+
return [match, variables];
|
|
67964
68032
|
}
|
|
67965
68033
|
function parse_page_pattern(id) {
|
|
67966
68034
|
const params = [];
|
|
@@ -68893,7 +68961,18 @@ async function extractQueries(source) {
|
|
|
68893
68961
|
} else {
|
|
68894
68962
|
return [];
|
|
68895
68963
|
}
|
|
68896
|
-
return props.
|
|
68964
|
+
return props.reduce((queries, query2) => {
|
|
68965
|
+
if (query2 === "children") {
|
|
68966
|
+
return queries;
|
|
68967
|
+
}
|
|
68968
|
+
if (query2.endsWith("$handle")) {
|
|
68969
|
+
query2 = query2.substring(0, query2.length - "$handle".length);
|
|
68970
|
+
}
|
|
68971
|
+
if (queries.includes(query2)) {
|
|
68972
|
+
return queries;
|
|
68973
|
+
}
|
|
68974
|
+
return queries.concat([query2]);
|
|
68975
|
+
}, []);
|
|
68897
68976
|
}
|
|
68898
68977
|
|
|
68899
68978
|
// src/lib/router/server.ts
|
package/build/lib-esm/index.js
CHANGED
|
@@ -61560,6 +61560,38 @@ function marshalInputs({
|
|
|
61560
61560
|
function isScalar(config, type) {
|
|
61561
61561
|
return ["String", "Boolean", "Float", "ID", "Int"].concat(Object.keys(config.scalars || {})).includes(type);
|
|
61562
61562
|
}
|
|
61563
|
+
function parseScalar(config, type, value) {
|
|
61564
|
+
if (typeof value === "undefined") {
|
|
61565
|
+
return void 0;
|
|
61566
|
+
}
|
|
61567
|
+
if (type === "Boolean") {
|
|
61568
|
+
return value === "true";
|
|
61569
|
+
}
|
|
61570
|
+
if (type === "ID") {
|
|
61571
|
+
return value;
|
|
61572
|
+
}
|
|
61573
|
+
if (type === "String") {
|
|
61574
|
+
return value;
|
|
61575
|
+
}
|
|
61576
|
+
if (type === "Int") {
|
|
61577
|
+
const result = parseInt(value, 10);
|
|
61578
|
+
if (Number.isNaN(result)) {
|
|
61579
|
+
return void 0;
|
|
61580
|
+
}
|
|
61581
|
+
return result;
|
|
61582
|
+
}
|
|
61583
|
+
if (type === "Float") {
|
|
61584
|
+
const result = parseFloat(value);
|
|
61585
|
+
if (Number.isNaN(result)) {
|
|
61586
|
+
return void 0;
|
|
61587
|
+
}
|
|
61588
|
+
return result;
|
|
61589
|
+
}
|
|
61590
|
+
if (config.scalars?.[type]?.marshal) {
|
|
61591
|
+
return config.scalars[type]?.marshal(value);
|
|
61592
|
+
}
|
|
61593
|
+
return value;
|
|
61594
|
+
}
|
|
61563
61595
|
|
|
61564
61596
|
// src/runtime/lib/store.ts
|
|
61565
61597
|
var subscriber_queue = [];
|
|
@@ -64538,9 +64570,12 @@ var InMemorySubscriptions = class {
|
|
|
64538
64570
|
removeSubscribers(id, fieldName, specs) {
|
|
64539
64571
|
let targets = [];
|
|
64540
64572
|
const subscriber = this.subscribers.get(id);
|
|
64541
|
-
|
|
64573
|
+
if (!subscriber) {
|
|
64574
|
+
return;
|
|
64575
|
+
}
|
|
64576
|
+
const subscriberField = subscriber.get(fieldName);
|
|
64542
64577
|
for (const spec of specs) {
|
|
64543
|
-
const counts = subscriber
|
|
64578
|
+
const counts = subscriber.get(fieldName)?.referenceCounts;
|
|
64544
64579
|
if (!counts?.has(spec.set)) {
|
|
64545
64580
|
continue;
|
|
64546
64581
|
}
|
|
@@ -64550,12 +64585,18 @@ var InMemorySubscriptions = class {
|
|
|
64550
64585
|
targets.push(spec.set);
|
|
64551
64586
|
counts.delete(spec.set);
|
|
64552
64587
|
}
|
|
64588
|
+
if (counts.size === 0) {
|
|
64589
|
+
subscriber.delete(fieldName);
|
|
64590
|
+
}
|
|
64553
64591
|
}
|
|
64554
64592
|
if (subscriberField) {
|
|
64555
64593
|
subscriberField.selections = this.get(id, fieldName).filter(
|
|
64556
64594
|
([{ set }]) => !targets.includes(set)
|
|
64557
64595
|
);
|
|
64558
64596
|
}
|
|
64597
|
+
if (subscriber.size === 0) {
|
|
64598
|
+
this.subscribers.delete(id);
|
|
64599
|
+
}
|
|
64559
64600
|
}
|
|
64560
64601
|
removeAllSubscribers(id, targets, visited = []) {
|
|
64561
64602
|
visited.push(id);
|
|
@@ -64576,6 +64617,15 @@ var InMemorySubscriptions = class {
|
|
|
64576
64617
|
}
|
|
64577
64618
|
}
|
|
64578
64619
|
}
|
|
64620
|
+
get size() {
|
|
64621
|
+
let size = 0;
|
|
64622
|
+
for (const [, nodeCounts] of this.subscribers) {
|
|
64623
|
+
for (const [, { referenceCounts }] of nodeCounts) {
|
|
64624
|
+
size += [...referenceCounts.values()].reduce((size2, count) => size2 + count, 0);
|
|
64625
|
+
}
|
|
64626
|
+
}
|
|
64627
|
+
return size;
|
|
64628
|
+
}
|
|
64579
64629
|
};
|
|
64580
64630
|
|
|
64581
64631
|
// src/runtime/cache/cache.ts
|
|
@@ -64624,6 +64674,9 @@ var Cache = class {
|
|
|
64624
64674
|
};
|
|
64625
64675
|
}
|
|
64626
64676
|
subscribe(spec, variables = {}) {
|
|
64677
|
+
if (this._internal_unstable.disabled) {
|
|
64678
|
+
return;
|
|
64679
|
+
}
|
|
64627
64680
|
return this._internal_unstable.subscriptions.add({
|
|
64628
64681
|
parent: spec.parentID || rootID,
|
|
64629
64682
|
spec,
|
|
@@ -64763,7 +64816,7 @@ var Cache = class {
|
|
|
64763
64816
|
}
|
|
64764
64817
|
};
|
|
64765
64818
|
var CacheInternal = class {
|
|
64766
|
-
|
|
64819
|
+
disabled = false;
|
|
64767
64820
|
_config;
|
|
64768
64821
|
storage;
|
|
64769
64822
|
subscriptions;
|
|
@@ -64794,10 +64847,10 @@ var CacheInternal = class {
|
|
|
64794
64847
|
this._config = config;
|
|
64795
64848
|
this.componentCache = componentCache ?? {};
|
|
64796
64849
|
this.createComponent = createComponent ?? (() => ({}));
|
|
64797
|
-
this.
|
|
64850
|
+
this.disabled = disabled;
|
|
64798
64851
|
try {
|
|
64799
64852
|
if (process.env.HOUDINI_TEST === "true") {
|
|
64800
|
-
this.
|
|
64853
|
+
this.disabled = false;
|
|
64801
64854
|
}
|
|
64802
64855
|
} catch {
|
|
64803
64856
|
}
|
|
@@ -64819,7 +64872,7 @@ var CacheInternal = class {
|
|
|
64819
64872
|
forceNotify,
|
|
64820
64873
|
forceStale
|
|
64821
64874
|
}) {
|
|
64822
|
-
if (this.
|
|
64875
|
+
if (this.disabled) {
|
|
64823
64876
|
return [];
|
|
64824
64877
|
}
|
|
64825
64878
|
let targetSelection = getFieldsForType(
|
|
@@ -65682,7 +65735,7 @@ var cachePolicy = ({
|
|
|
65682
65735
|
serverSideFallback = true
|
|
65683
65736
|
}) => () => {
|
|
65684
65737
|
return {
|
|
65685
|
-
|
|
65738
|
+
beforeNetwork(ctx, { initialValue, next, resolve: resolve2, marshalVariables: marshalVariables2 }) {
|
|
65686
65739
|
const { policy, artifact } = ctx;
|
|
65687
65740
|
let useCache = false;
|
|
65688
65741
|
if (enabled && (artifact.kind === ArtifactKind.Query || artifact.kind === ArtifactKind.Fragment) && !ctx.cacheParams?.disableRead) {
|
|
@@ -66076,7 +66129,7 @@ var defaultErrorFn = async (errors) => new Error(errors.map((error) => error.mes
|
|
|
66076
66129
|
|
|
66077
66130
|
// src/runtime/client/plugins/fetchParams.ts
|
|
66078
66131
|
var fetchParams = (fn = () => ({})) => () => ({
|
|
66079
|
-
|
|
66132
|
+
start(ctx, { next, marshalVariables: marshalVariables2 }) {
|
|
66080
66133
|
next({
|
|
66081
66134
|
...ctx,
|
|
66082
66135
|
fetchParams: fn({
|
|
@@ -67717,7 +67770,12 @@ function deepMerge2(filepath, ...targets) {
|
|
|
67717
67770
|
// src/lib/parse.ts
|
|
67718
67771
|
function parseJS(str, config) {
|
|
67719
67772
|
const defaultConfig = {
|
|
67720
|
-
plugins: [
|
|
67773
|
+
plugins: [
|
|
67774
|
+
"typescript",
|
|
67775
|
+
"importAssertions",
|
|
67776
|
+
"decorators-legacy",
|
|
67777
|
+
"explicitResourceManagement"
|
|
67778
|
+
],
|
|
67721
67779
|
sourceType: "module"
|
|
67722
67780
|
};
|
|
67723
67781
|
return (0, import_parser.parse)(str || "", config ? deepMerge2("", defaultConfig, config) : defaultConfig).program;
|
|
@@ -67860,7 +67918,7 @@ async function detectTools(cwd = process.cwd()) {
|
|
|
67860
67918
|
|
|
67861
67919
|
// src/runtime/router/match.ts
|
|
67862
67920
|
var param_pattern = /^(\[)?(\.\.\.)?(\w+)(?:=(\w+))?(\])?$/;
|
|
67863
|
-
function find_match(manifest, current, allowNull = true) {
|
|
67921
|
+
function find_match(config, manifest, current, allowNull = true) {
|
|
67864
67922
|
let match = null;
|
|
67865
67923
|
let matchVariables = null;
|
|
67866
67924
|
for (const page of Object.values(manifest.pages)) {
|
|
@@ -67875,7 +67933,17 @@ function find_match(manifest, current, allowNull = true) {
|
|
|
67875
67933
|
if (!match && !allowNull) {
|
|
67876
67934
|
throw new Error("404");
|
|
67877
67935
|
}
|
|
67878
|
-
|
|
67936
|
+
let variables = {
|
|
67937
|
+
...matchVariables
|
|
67938
|
+
};
|
|
67939
|
+
for (const document of Object.values(match?.documents ?? {})) {
|
|
67940
|
+
for (const [variable, { type }] of Object.entries(document.variables)) {
|
|
67941
|
+
if (matchVariables?.[variable]) {
|
|
67942
|
+
variables[variable] = parseScalar(config, type, matchVariables[variable]);
|
|
67943
|
+
}
|
|
67944
|
+
}
|
|
67945
|
+
}
|
|
67946
|
+
return [match, variables];
|
|
67879
67947
|
}
|
|
67880
67948
|
function parse_page_pattern(id) {
|
|
67881
67949
|
const params = [];
|
|
@@ -68808,7 +68876,18 @@ async function extractQueries(source) {
|
|
|
68808
68876
|
} else {
|
|
68809
68877
|
return [];
|
|
68810
68878
|
}
|
|
68811
|
-
return props.
|
|
68879
|
+
return props.reduce((queries, query2) => {
|
|
68880
|
+
if (query2 === "children") {
|
|
68881
|
+
return queries;
|
|
68882
|
+
}
|
|
68883
|
+
if (query2.endsWith("$handle")) {
|
|
68884
|
+
query2 = query2.substring(0, query2.length - "$handle".length);
|
|
68885
|
+
}
|
|
68886
|
+
if (queries.includes(query2)) {
|
|
68887
|
+
return queries;
|
|
68888
|
+
}
|
|
68889
|
+
return queries.concat([query2]);
|
|
68890
|
+
}, []);
|
|
68812
68891
|
}
|
|
68813
68892
|
|
|
68814
68893
|
// src/lib/router/server.ts
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { GraphQLVariables } from '$houdini/runtime/lib/types';
|
|
2
|
+
import { type ConfigFile } from '../lib';
|
|
2
3
|
import type { RouterManifest, RouterPageManifest } from './types';
|
|
3
4
|
export type RouteParam = {
|
|
4
5
|
name: string;
|
|
@@ -10,8 +11,8 @@ export type RouteParam = {
|
|
|
10
11
|
export interface ParamMatcher {
|
|
11
12
|
(param: string): boolean;
|
|
12
13
|
}
|
|
13
|
-
export declare function find_match<_ComponentType>(manifest: RouterManifest<_ComponentType>, current: string, allowNull: true): [RouterPageManifest<_ComponentType> | null, GraphQLVariables];
|
|
14
|
-
export declare function find_match<_ComponentType>(manifest: RouterManifest<_ComponentType>, current: string, allowNull?: false): [RouterPageManifest<_ComponentType>, GraphQLVariables];
|
|
14
|
+
export declare function find_match<_ComponentType>(config: ConfigFile, manifest: RouterManifest<_ComponentType>, current: string, allowNull: true): [RouterPageManifest<_ComponentType> | null, GraphQLVariables];
|
|
15
|
+
export declare function find_match<_ComponentType>(config: ConfigFile, manifest: RouterManifest<_ComponentType>, current: string, allowNull?: false): [RouterPageManifest<_ComponentType>, GraphQLVariables];
|
|
15
16
|
/**
|
|
16
17
|
* Creates the regex pattern, extracts parameter names, and generates types for a route
|
|
17
18
|
*/
|
|
@@ -83,6 +83,9 @@ class Cache {
|
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
85
|
subscribe(spec, variables = {}) {
|
|
86
|
+
if (this._internal_unstable.disabled) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
86
89
|
return this._internal_unstable.subscriptions.add({
|
|
87
90
|
parent: spec.parentID || rootID,
|
|
88
91
|
spec,
|
|
@@ -222,7 +225,7 @@ class Cache {
|
|
|
222
225
|
}
|
|
223
226
|
}
|
|
224
227
|
class CacheInternal {
|
|
225
|
-
|
|
228
|
+
disabled = false;
|
|
226
229
|
_config;
|
|
227
230
|
storage;
|
|
228
231
|
subscriptions;
|
|
@@ -253,10 +256,10 @@ class CacheInternal {
|
|
|
253
256
|
this._config = config;
|
|
254
257
|
this.componentCache = componentCache ?? {};
|
|
255
258
|
this.createComponent = createComponent ?? (() => ({}));
|
|
256
|
-
this.
|
|
259
|
+
this.disabled = disabled;
|
|
257
260
|
try {
|
|
258
261
|
if (process.env.HOUDINI_TEST === "true") {
|
|
259
|
-
this.
|
|
262
|
+
this.disabled = false;
|
|
260
263
|
}
|
|
261
264
|
} catch {
|
|
262
265
|
}
|
|
@@ -278,7 +281,7 @@ class CacheInternal {
|
|
|
278
281
|
forceNotify,
|
|
279
282
|
forceStale
|
|
280
283
|
}) {
|
|
281
|
-
if (this.
|
|
284
|
+
if (this.disabled) {
|
|
282
285
|
return [];
|
|
283
286
|
}
|
|
284
287
|
let targetSelection = (0, import_selection.getFieldsForType)(
|
|
@@ -253,9 +253,12 @@ class InMemorySubscriptions {
|
|
|
253
253
|
removeSubscribers(id, fieldName, specs) {
|
|
254
254
|
let targets = [];
|
|
255
255
|
const subscriber = this.subscribers.get(id);
|
|
256
|
-
|
|
256
|
+
if (!subscriber) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
const subscriberField = subscriber.get(fieldName);
|
|
257
260
|
for (const spec of specs) {
|
|
258
|
-
const counts = subscriber
|
|
261
|
+
const counts = subscriber.get(fieldName)?.referenceCounts;
|
|
259
262
|
if (!counts?.has(spec.set)) {
|
|
260
263
|
continue;
|
|
261
264
|
}
|
|
@@ -265,12 +268,18 @@ class InMemorySubscriptions {
|
|
|
265
268
|
targets.push(spec.set);
|
|
266
269
|
counts.delete(spec.set);
|
|
267
270
|
}
|
|
271
|
+
if (counts.size === 0) {
|
|
272
|
+
subscriber.delete(fieldName);
|
|
273
|
+
}
|
|
268
274
|
}
|
|
269
275
|
if (subscriberField) {
|
|
270
276
|
subscriberField.selections = this.get(id, fieldName).filter(
|
|
271
277
|
([{ set }]) => !targets.includes(set)
|
|
272
278
|
);
|
|
273
279
|
}
|
|
280
|
+
if (subscriber.size === 0) {
|
|
281
|
+
this.subscribers.delete(id);
|
|
282
|
+
}
|
|
274
283
|
}
|
|
275
284
|
removeAllSubscribers(id, targets, visited = []) {
|
|
276
285
|
visited.push(id);
|
|
@@ -291,6 +300,15 @@ class InMemorySubscriptions {
|
|
|
291
300
|
}
|
|
292
301
|
}
|
|
293
302
|
}
|
|
303
|
+
get size() {
|
|
304
|
+
let size = 0;
|
|
305
|
+
for (const [, nodeCounts] of this.subscribers) {
|
|
306
|
+
for (const [, { referenceCounts }] of nodeCounts) {
|
|
307
|
+
size += [...referenceCounts.values()].reduce((size2, count) => size2 + count, 0);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return size;
|
|
311
|
+
}
|
|
294
312
|
}
|
|
295
313
|
// Annotate the CommonJS export names for ESM import in node:
|
|
296
314
|
0 && (module.exports = {
|
|
@@ -38,7 +38,7 @@ const cachePolicy = ({
|
|
|
38
38
|
serverSideFallback = true
|
|
39
39
|
}) => () => {
|
|
40
40
|
return {
|
|
41
|
-
|
|
41
|
+
beforeNetwork(ctx, { initialValue, next, resolve, marshalVariables }) {
|
|
42
42
|
const { policy, artifact } = ctx;
|
|
43
43
|
let useCache = false;
|
|
44
44
|
if (enabled && (artifact.kind === import_types.ArtifactKind.Query || artifact.kind === import_types.ArtifactKind.Fragment) && !ctx.cacheParams?.disableRead) {
|
|
@@ -22,7 +22,7 @@ __export(fetchParams_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(fetchParams_exports);
|
|
24
24
|
const fetchParams = (fn = () => ({})) => () => ({
|
|
25
|
-
|
|
25
|
+
start(ctx, { next, marshalVariables }) {
|
|
26
26
|
next({
|
|
27
27
|
...ctx,
|
|
28
28
|
fetchParams: fn({
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { GraphQLVariables } from '$houdini/runtime/lib/types';
|
|
2
|
+
import { type ConfigFile } from '../lib';
|
|
2
3
|
import type { RouterManifest, RouterPageManifest } from './types';
|
|
3
4
|
export type RouteParam = {
|
|
4
5
|
name: string;
|
|
@@ -10,8 +11,8 @@ export type RouteParam = {
|
|
|
10
11
|
export interface ParamMatcher {
|
|
11
12
|
(param: string): boolean;
|
|
12
13
|
}
|
|
13
|
-
export declare function find_match<_ComponentType>(manifest: RouterManifest<_ComponentType>, current: string, allowNull: true): [RouterPageManifest<_ComponentType> | null, GraphQLVariables];
|
|
14
|
-
export declare function find_match<_ComponentType>(manifest: RouterManifest<_ComponentType>, current: string, allowNull?: false): [RouterPageManifest<_ComponentType>, GraphQLVariables];
|
|
14
|
+
export declare function find_match<_ComponentType>(config: ConfigFile, manifest: RouterManifest<_ComponentType>, current: string, allowNull: true): [RouterPageManifest<_ComponentType> | null, GraphQLVariables];
|
|
15
|
+
export declare function find_match<_ComponentType>(config: ConfigFile, manifest: RouterManifest<_ComponentType>, current: string, allowNull?: false): [RouterPageManifest<_ComponentType>, GraphQLVariables];
|
|
15
16
|
/**
|
|
16
17
|
* Creates the regex pattern, extracts parameter names, and generates types for a route
|
|
17
18
|
*/
|
|
@@ -24,8 +24,9 @@ __export(match_exports, {
|
|
|
24
24
|
parse_page_pattern: () => parse_page_pattern
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(match_exports);
|
|
27
|
+
var import_lib = require("../lib");
|
|
27
28
|
const param_pattern = /^(\[)?(\.\.\.)?(\w+)(?:=(\w+))?(\])?$/;
|
|
28
|
-
function find_match(manifest, current, allowNull = true) {
|
|
29
|
+
function find_match(config, manifest, current, allowNull = true) {
|
|
29
30
|
let match = null;
|
|
30
31
|
let matchVariables = null;
|
|
31
32
|
for (const page of Object.values(manifest.pages)) {
|
|
@@ -40,7 +41,17 @@ function find_match(manifest, current, allowNull = true) {
|
|
|
40
41
|
if (!match && !allowNull) {
|
|
41
42
|
throw new Error("404");
|
|
42
43
|
}
|
|
43
|
-
|
|
44
|
+
let variables = {
|
|
45
|
+
...matchVariables
|
|
46
|
+
};
|
|
47
|
+
for (const document of Object.values(match?.documents ?? {})) {
|
|
48
|
+
for (const [variable, { type }] of Object.entries(document.variables)) {
|
|
49
|
+
if (matchVariables?.[variable]) {
|
|
50
|
+
variables[variable] = (0, import_lib.parseScalar)(config, type, matchVariables[variable]);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return [match, variables];
|
|
44
55
|
}
|
|
45
56
|
function parse_page_pattern(id) {
|
|
46
57
|
const params = [];
|
|
@@ -73,7 +73,7 @@ function _serverHandler({
|
|
|
73
73
|
if (authResponse) {
|
|
74
74
|
return authResponse;
|
|
75
75
|
}
|
|
76
|
-
const [match] = (0, import_match.find_match)(manifest, url);
|
|
76
|
+
const [match] = (0, import_match.find_match)(config_file, manifest, url);
|
|
77
77
|
const rendered = await on_render({
|
|
78
78
|
url,
|
|
79
79
|
match,
|
|
@@ -55,6 +55,9 @@ class Cache {
|
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
subscribe(spec, variables = {}) {
|
|
58
|
+
if (this._internal_unstable.disabled) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
58
61
|
return this._internal_unstable.subscriptions.add({
|
|
59
62
|
parent: spec.parentID || rootID,
|
|
60
63
|
spec,
|
|
@@ -194,7 +197,7 @@ class Cache {
|
|
|
194
197
|
}
|
|
195
198
|
}
|
|
196
199
|
class CacheInternal {
|
|
197
|
-
|
|
200
|
+
disabled = false;
|
|
198
201
|
_config;
|
|
199
202
|
storage;
|
|
200
203
|
subscriptions;
|
|
@@ -225,10 +228,10 @@ class CacheInternal {
|
|
|
225
228
|
this._config = config;
|
|
226
229
|
this.componentCache = componentCache ?? {};
|
|
227
230
|
this.createComponent = createComponent ?? (() => ({}));
|
|
228
|
-
this.
|
|
231
|
+
this.disabled = disabled;
|
|
229
232
|
try {
|
|
230
233
|
if (process.env.HOUDINI_TEST === "true") {
|
|
231
|
-
this.
|
|
234
|
+
this.disabled = false;
|
|
232
235
|
}
|
|
233
236
|
} catch {
|
|
234
237
|
}
|
|
@@ -250,7 +253,7 @@ class CacheInternal {
|
|
|
250
253
|
forceNotify,
|
|
251
254
|
forceStale
|
|
252
255
|
}) {
|
|
253
|
-
if (this.
|
|
256
|
+
if (this.disabled) {
|
|
254
257
|
return [];
|
|
255
258
|
}
|
|
256
259
|
let targetSelection = getFieldsForType(
|