@sjcx/vorma 0.0.0-pre.2 → 0.0.0-pre.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.
- package/dist/build/assemble-artifacts.d.ts +1 -1
- package/dist/build/bundle-client.d.ts +1 -1
- package/dist/build/cli.js +27 -37
- package/dist/build/compile-application.d.ts +2 -2
- package/dist/build/development-artifacts.d.ts +1 -1
- package/dist/build/development-build.d.ts +3 -6
- package/dist/build/development-work.d.ts +2 -3
- package/dist/build/generate-application.d.ts +2 -2
- package/dist/build/index.d.ts +2 -3
- package/dist/build/index.js +1 -1
- package/dist/build/inspect-projects.d.ts +3 -3
- package/dist/build/load-config.d.ts +0 -2
- package/dist/build/publish-artifacts.d.ts +1 -4
- package/dist/build/render-client-transport.d.ts +1 -1
- package/dist/build/render-server-generated.d.ts +1 -12
- package/dist/build/render-types.d.ts +1 -1
- package/dist/build/resolve-config.d.ts +2 -4
- package/dist/build/source-layout.d.ts +1 -1
- package/dist/{build-DcP5_DUV.js → build-sHSh5zaX.js} +67 -282
- package/package.json +5 -36
- package/dist/build/compile-server.d.ts +0 -42
- package/dist/client/assembly.d.ts +0 -40
- package/dist/client/browser-http-client.d.ts +0 -10
- package/dist/client/client-loaders.d.ts +0 -93
- package/dist/client/commit.d.ts +0 -41
- package/dist/client/contracts.d.ts +0 -192
- package/dist/client/core.d.ts +0 -45
- package/dist/client/development.d.ts +0 -16
- package/dist/client/document-recovery.d.ts +0 -4
- package/dist/client/endpoints.d.ts +0 -54
- package/dist/client/errors.d.ts +0 -87
- package/dist/client/freshness.d.ts +0 -51
- package/dist/client/head.d.ts +0 -14
- package/dist/client/history.d.ts +0 -25
- package/dist/client/index.d.ts +0 -80
- package/dist/client/index.js +0 -150
- package/dist/client/links.d.ts +0 -48
- package/dist/client/materialize.d.ts +0 -21
- package/dist/client/modules.d.ts +0 -2
- package/dist/client/navigation.d.ts +0 -47
- package/dist/client/payload.d.ts +0 -54
- package/dist/client/prefetch.d.ts +0 -28
- package/dist/client/prepare.d.ts +0 -47
- package/dist/client/projections.d.ts +0 -26
- package/dist/client/queries.d.ts +0 -33
- package/dist/client/react/application.d.ts +0 -87
- package/dist/client/react/hooks.d.ts +0 -36
- package/dist/client/react/index.d.ts +0 -5
- package/dist/client/react/index.js +0 -3237
- package/dist/client/react/link.d.ts +0 -27
- package/dist/client/react/view.d.ts +0 -86
- package/dist/client/request.d.ts +0 -16
- package/dist/client/route-context.d.ts +0 -31
- package/dist/client/route-matching.d.ts +0 -22
- package/dist/client/route-synchronization.d.ts +0 -30
- package/dist/client/route-url.d.ts +0 -5
- package/dist/client/runtime.d.ts +0 -82
- package/dist/client/scroll.d.ts +0 -16
- package/dist/client/services.d.ts +0 -34
- package/dist/client/state.d.ts +0 -102
- package/dist/client/static-assets.d.ts +0 -3
- package/dist/client/stylesheets.d.ts +0 -7
- package/dist/client/transport-type-entries.d.ts +0 -2
- package/dist/client/types.d.ts +0 -152
- package/dist/client/view-definition.d.ts +0 -24
- package/dist/client/work-indicator.d.ts +0 -18
- package/dist/compile-Me8EOyMK.js +0 -870
- package/dist/development-B_rxuwY7.js +0 -128
- package/dist/hash-set-BPx3iXec.js +0 -141
- package/dist/href-Cqyax8Y0.js +0 -357
- package/dist/materialize-DZ7VSLFk.js +0 -739
- package/dist/metadata-BoPKo-G2.js +0 -32
- package/dist/primitives/tasks/index.d.ts +0 -1
- package/dist/primitives/tasks/index.js +0 -1
- package/dist/route-context-CtY_9U_W.js +0 -559
- package/dist/route-matching-D_uSG2P9.js +0 -33
- package/dist/search-parse-0f7oqVsG.js +0 -375
- package/dist/server/config/index.d.ts +0 -36
- package/dist/server/config/index.js +0 -30
- package/dist/server/development/metadata.d.ts +0 -11
- package/dist/server/document.d.ts +0 -37
- package/dist/server/form-data.d.ts +0 -21
- package/dist/server/graph/compile.d.ts +0 -118
- package/dist/server/graph/declarations.d.ts +0 -117
- package/dist/server/graph/literal-error-tag.d.ts +0 -14
- package/dist/server/graph/pattern-conflicts.d.ts +0 -36
- package/dist/server/graph/search-schema.d.ts +0 -13
- package/dist/server/graph/transport-schema.d.ts +0 -11
- package/dist/server/index.d.ts +0 -310
- package/dist/server/index.js +0 -2311
- package/dist/server/public-assets.d.ts +0 -18
- package/dist/server/runtime/application.d.ts +0 -15
- package/dist/server/runtime/assets.d.ts +0 -15
- package/dist/server/runtime/context.d.ts +0 -96
- package/dist/server/runtime/domain-errors.d.ts +0 -11
- package/dist/server/runtime/effects.d.ts +0 -83
- package/dist/server/runtime/execute.d.ts +0 -13
- package/dist/server/runtime/finalize.d.ts +0 -44
- package/dist/server/runtime/handler.d.ts +0 -106
- package/dist/server/runtime/head.d.ts +0 -22
- package/dist/server/runtime/payload.d.ts +0 -50
- package/dist/server/runtime/pipeline.d.ts +0 -27
- package/dist/server/runtime/plan.d.ts +0 -98
- package/dist/server/runtime/render-document.d.ts +0 -16
- package/dist/server/runtime/startup-error.d.ts +0 -11
- package/dist/server/runtime/transport-type-entries.d.ts +0 -2
- package/dist/server/runtime/vercel-deployment.d.ts +0 -2
- package/dist/server/url-pathname.d.ts +0 -13
- package/dist/static-assets-BrH3O0M8.js +0 -199
- package/dist/universal/generated-types.d.ts +0 -9
- package/dist/universal/href.d.ts +0 -17
- package/dist/universal/http-method.d.ts +0 -4
- package/dist/universal/json-transport.d.ts +0 -14
- package/dist/universal/null-prototype-record.d.ts +0 -7
- package/dist/universal/path-wire.d.ts +0 -71
- package/dist/universal/pattern-language.d.ts +0 -4
- package/dist/universal/protocol-schemas.d.ts +0 -99
- package/dist/universal/protocol.d.ts +0 -162
- package/dist/universal/search-grammar.d.ts +0 -7
- package/dist/universal/search-parse.d.ts +0 -22
- package/dist/universal/search-serialize.d.ts +0 -16
- package/dist/universal/search-shape.d.ts +0 -32
- package/dist/universal/static-assets.d.ts +0 -2
- package/dist/universal/transport-types/big-decimal.d.ts +0 -13
- package/dist/universal/transport-types/chunk.d.ts +0 -8
- package/dist/universal/transport-types/date-time-utc.d.ts +0 -13
- package/dist/universal/transport-types/date-time-zoned.d.ts +0 -13
- package/dist/universal/transport-types/duration.d.ts +0 -13
- package/dist/universal/transport-types/hash-map.d.ts +0 -8
- package/dist/universal/transport-types/hash-set.d.ts +0 -8
- package/dist/universal/transport-types/option.d.ts +0 -10
- package/dist/universal/transport-types/redacted.d.ts +0 -9
- package/dist/universal/value-transport.d.ts +0 -117
- package/dist/value-transport-Bst4Hk-n.js +0 -864
- /package/dist/{universal → build}/content-digest.d.ts +0 -0
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import { r as commitFrame, t as enableDevelopmentModules } from "./materialize-DZ7VSLFk.js";
|
|
2
|
-
import { Effect, Exit, Fiber, Option, RcMap, Scope } from "effect";
|
|
3
|
-
import { AsyncResult } from "effect/unstable/reactivity";
|
|
4
|
-
//#region src/client/development.ts
|
|
5
|
-
/** Applies accepted view updates through the existing frame publication and service lifetimes. */
|
|
6
|
-
function installDevelopmentUpdates(input) {
|
|
7
|
-
return Effect.gen(function* () {
|
|
8
|
-
const { core, navigation } = input;
|
|
9
|
-
const modules = enableDevelopmentModules();
|
|
10
|
-
let update;
|
|
11
|
-
let revision = 0;
|
|
12
|
-
function reportFailureFn(cause) {
|
|
13
|
-
core.publishEvent({
|
|
14
|
-
_tag: "FailureReported",
|
|
15
|
-
source: "hmr",
|
|
16
|
-
cause
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
const controls = {
|
|
20
|
-
revalidateFn: async () => {
|
|
21
|
-
await Effect.runPromise(navigation.revalidate({ skipWorkIndicator: true }).pipe(Effect.catchCause((cause) => Effect.sync(() => reportFailureFn(cause)))));
|
|
22
|
-
},
|
|
23
|
-
updateModuleFn(url, module) {
|
|
24
|
-
const replacements = modules.replaceFn({
|
|
25
|
-
url,
|
|
26
|
-
module
|
|
27
|
-
});
|
|
28
|
-
core.clientLoaders.replaceViewsFn(replacements);
|
|
29
|
-
navigation.retireReusable();
|
|
30
|
-
const previousUpdate = update;
|
|
31
|
-
const ownRevision = ++revision;
|
|
32
|
-
update = core.forkFiber(Effect.scoped(Effect.gen(function* () {
|
|
33
|
-
if (previousUpdate !== void 0) yield* Fiber.interrupt(previousUpdate);
|
|
34
|
-
const frame = core.getState().frame;
|
|
35
|
-
if (frame === null) return;
|
|
36
|
-
if (frame.entries.filter((entry) => {
|
|
37
|
-
return entry.view !== void 0 && replacements.has(entry.view);
|
|
38
|
-
}).length === 0) return;
|
|
39
|
-
const known = frame.entries.map(toKnownMatch);
|
|
40
|
-
const entries = yield* Effect.forEach(frame.entries, (entry) => {
|
|
41
|
-
return prepareUpdatedEntry({
|
|
42
|
-
core,
|
|
43
|
-
frame,
|
|
44
|
-
entry,
|
|
45
|
-
replacements,
|
|
46
|
-
known,
|
|
47
|
-
reportFailureFn
|
|
48
|
-
});
|
|
49
|
-
}, { concurrency: "unbounded" });
|
|
50
|
-
if (ownRevision !== revision || core.getState().frame !== frame) return;
|
|
51
|
-
commitFrame(core, {
|
|
52
|
-
reason: "hmr",
|
|
53
|
-
entries,
|
|
54
|
-
error: frame.error,
|
|
55
|
-
head: frame.head,
|
|
56
|
-
cssBundles: frame.cssBundles,
|
|
57
|
-
documentUpdate: "adopt",
|
|
58
|
-
position: {
|
|
59
|
-
kind: "adopt",
|
|
60
|
-
position: {
|
|
61
|
-
href: frame.href,
|
|
62
|
-
userState: frame.historyState,
|
|
63
|
-
key: frame.key
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
scrollIntent: void 0,
|
|
67
|
-
committedAt: frame.committedAt,
|
|
68
|
-
scope: frame.scope
|
|
69
|
-
});
|
|
70
|
-
})).pipe(Effect.catchCause((cause) => Effect.sync(() => reportFailureFn(cause)))));
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
window.__vorma_development = controls;
|
|
74
|
-
yield* Scope.addFinalizer(core.scope, Effect.sync(() => {
|
|
75
|
-
if (window.__vorma_development === controls) delete window.__vorma_development;
|
|
76
|
-
modules.closeFn();
|
|
77
|
-
}));
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
function toKnownMatch(entry) {
|
|
81
|
-
return {
|
|
82
|
-
pattern: entry.pattern,
|
|
83
|
-
params: entry.params,
|
|
84
|
-
splatValues: entry.splatValues,
|
|
85
|
-
input: entry.input
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
function prepareUpdatedEntry(input) {
|
|
89
|
-
return Effect.gen(function* () {
|
|
90
|
-
const { core, frame, entry, replacements, known } = input;
|
|
91
|
-
if (entry.view === void 0 || !replacements.has(entry.view)) return entry;
|
|
92
|
-
const view = replacements.get(entry.view);
|
|
93
|
-
if (view === void 0 || view.pattern !== entry.pattern) return entry;
|
|
94
|
-
if (view.clientOnlyServices !== entry.view.clientOnlyServices || view.universalServices !== entry.view.universalServices) {
|
|
95
|
-
window.location.reload();
|
|
96
|
-
return entry;
|
|
97
|
-
}
|
|
98
|
-
let clientLoaderData = entry.clientLoaderData;
|
|
99
|
-
const clientLoaderFn = view.clientLoader;
|
|
100
|
-
if (view.rerunClientLoaderOnHotUpdate && clientLoaderFn !== void 0) {
|
|
101
|
-
const context = {
|
|
102
|
-
trigger: "revalidation",
|
|
103
|
-
href: frame.href,
|
|
104
|
-
historyState: frame.historyState,
|
|
105
|
-
...toKnownMatch(entry),
|
|
106
|
-
knownRouteMatches: known,
|
|
107
|
-
serverConfirmedRouteMatches: Effect.succeed(known),
|
|
108
|
-
loaderData: Effect.succeed(entry.loaderData),
|
|
109
|
-
getLoaderData: (pattern) => {
|
|
110
|
-
const found = frame.entries.find((candidate) => candidate.pattern === pattern);
|
|
111
|
-
return Effect.succeed(Option.map(Option.fromUndefinedOr(found), (candidate) => candidate.loaderData));
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
const loader = Effect.suspend(() => clientLoaderFn(context));
|
|
115
|
-
const activation = entry.activation === void 0 ? void 0 : yield* RcMap.get(core.activations, entry.activation.key);
|
|
116
|
-
const exit = yield* Effect.exit(activation === void 0 ? core.provideClient(loader) : Effect.provideContext(loader, activation.client));
|
|
117
|
-
if (Exit.isSuccess(exit)) clientLoaderData = AsyncResult.success(exit.value);
|
|
118
|
-
else input.reportFailureFn(exit.cause);
|
|
119
|
-
}
|
|
120
|
-
return {
|
|
121
|
-
...entry,
|
|
122
|
-
view,
|
|
123
|
-
clientLoaderData
|
|
124
|
-
};
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
//#endregion
|
|
128
|
-
export { installDevelopmentUpdates };
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import * as Option from "effect/Option";
|
|
2
|
-
import * as Redacted from "effect/Redacted";
|
|
3
|
-
import * as Chunk from "effect/Chunk";
|
|
4
|
-
import * as Duration from "effect/Duration";
|
|
5
|
-
import * as BigDecimal from "effect/BigDecimal";
|
|
6
|
-
import * as DateTime from "effect/DateTime";
|
|
7
|
-
import * as HashMap from "effect/HashMap";
|
|
8
|
-
import * as HashSet from "effect/HashSet";
|
|
9
|
-
//#region src/universal/transport-types/option.ts
|
|
10
|
-
/** Generic Option value operations, independent of application contracts. */
|
|
11
|
-
const optionTransportType = /* @__PURE__ */ (() => {
|
|
12
|
-
return {
|
|
13
|
-
kind: "option",
|
|
14
|
-
matchesValue: Option.isOption,
|
|
15
|
-
matchesNone: (value) => {
|
|
16
|
-
return Option.isNone(value);
|
|
17
|
-
},
|
|
18
|
-
getValue: (value) => {
|
|
19
|
-
return value.value;
|
|
20
|
-
},
|
|
21
|
-
none: Option.none,
|
|
22
|
-
some: Option.some
|
|
23
|
-
};
|
|
24
|
-
})();
|
|
25
|
-
//#endregion
|
|
26
|
-
//#region src/universal/transport-types/redacted.ts
|
|
27
|
-
/** Generic Redacted value operations, independent of application contracts. */
|
|
28
|
-
const redactedTransportType = /* @__PURE__ */ (() => {
|
|
29
|
-
return {
|
|
30
|
-
kind: "redacted",
|
|
31
|
-
matchesValue: Redacted.isRedacted,
|
|
32
|
-
getValue: (value) => {
|
|
33
|
-
return Redacted.value(value);
|
|
34
|
-
},
|
|
35
|
-
getLabel: (value) => {
|
|
36
|
-
return value.label;
|
|
37
|
-
},
|
|
38
|
-
make: (value, label) => {
|
|
39
|
-
return label === void 0 ? Redacted.make(value) : Redacted.make(value, { label });
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
})();
|
|
43
|
-
//#endregion
|
|
44
|
-
//#region src/universal/transport-types/chunk.ts
|
|
45
|
-
/** Generic Chunk value operations, independent of application contracts. */
|
|
46
|
-
const chunkTransportType = /* @__PURE__ */ (() => {
|
|
47
|
-
return {
|
|
48
|
-
kind: "chunk",
|
|
49
|
-
matchesValue: Chunk.isChunk,
|
|
50
|
-
getValues: (value) => {
|
|
51
|
-
return Chunk.toReadonlyArray(value);
|
|
52
|
-
},
|
|
53
|
-
fromValues: Chunk.fromIterable
|
|
54
|
-
};
|
|
55
|
-
})();
|
|
56
|
-
//#endregion
|
|
57
|
-
//#region src/universal/transport-types/duration.ts
|
|
58
|
-
/** Generic Duration value operations, independent of application contracts. */
|
|
59
|
-
const durationTransportType = /* @__PURE__ */ (() => {
|
|
60
|
-
return {
|
|
61
|
-
kind: "duration",
|
|
62
|
-
matchesValue: Duration.isDuration,
|
|
63
|
-
format: (value) => {
|
|
64
|
-
return String(value);
|
|
65
|
-
},
|
|
66
|
-
parse: (value) => {
|
|
67
|
-
return Duration.fromInput(value);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
})();
|
|
71
|
-
//#endregion
|
|
72
|
-
//#region src/universal/transport-types/big-decimal.ts
|
|
73
|
-
/** Generic BigDecimal value operations, independent of application contracts. */
|
|
74
|
-
const bigDecimalTransportType = /* @__PURE__ */ (() => {
|
|
75
|
-
return {
|
|
76
|
-
kind: "big-decimal",
|
|
77
|
-
matchesValue: BigDecimal.isBigDecimal,
|
|
78
|
-
format: (value) => {
|
|
79
|
-
return BigDecimal.format(value);
|
|
80
|
-
},
|
|
81
|
-
parse: BigDecimal.fromString
|
|
82
|
-
};
|
|
83
|
-
})();
|
|
84
|
-
//#endregion
|
|
85
|
-
//#region src/universal/transport-types/date-time-utc.ts
|
|
86
|
-
/** Generic DateTime value operations, independent of application contracts. */
|
|
87
|
-
const dateTimeUtcTransportType = /* @__PURE__ */ (() => {
|
|
88
|
-
return {
|
|
89
|
-
kind: "date-time-utc",
|
|
90
|
-
matchesValue: (value) => {
|
|
91
|
-
return DateTime.isDateTime(value) && DateTime.isUtc(value);
|
|
92
|
-
},
|
|
93
|
-
format: (value) => {
|
|
94
|
-
return DateTime.formatIso(value);
|
|
95
|
-
},
|
|
96
|
-
parse: DateTime.make
|
|
97
|
-
};
|
|
98
|
-
})();
|
|
99
|
-
//#endregion
|
|
100
|
-
//#region src/universal/transport-types/date-time-zoned.ts
|
|
101
|
-
/** Generic DateTime value operations, independent of application contracts. */
|
|
102
|
-
const dateTimeZonedTransportType = /* @__PURE__ */ (() => {
|
|
103
|
-
return {
|
|
104
|
-
kind: "date-time-zoned",
|
|
105
|
-
matchesValue: (value) => {
|
|
106
|
-
return DateTime.isDateTime(value) && DateTime.isZoned(value);
|
|
107
|
-
},
|
|
108
|
-
format: (value) => {
|
|
109
|
-
return DateTime.formatIsoZoned(value);
|
|
110
|
-
},
|
|
111
|
-
parse: DateTime.makeZonedFromString
|
|
112
|
-
};
|
|
113
|
-
})();
|
|
114
|
-
//#endregion
|
|
115
|
-
//#region src/universal/transport-types/hash-map.ts
|
|
116
|
-
/** Generic HashMap value operations, independent of application contracts. */
|
|
117
|
-
const hashMapTransportType = /* @__PURE__ */ (() => {
|
|
118
|
-
return {
|
|
119
|
-
kind: "hash-map",
|
|
120
|
-
matchesValue: HashMap.isHashMap,
|
|
121
|
-
getEntries: (value) => {
|
|
122
|
-
return HashMap.toEntries(value);
|
|
123
|
-
},
|
|
124
|
-
fromEntries: HashMap.fromIterable
|
|
125
|
-
};
|
|
126
|
-
})();
|
|
127
|
-
//#endregion
|
|
128
|
-
//#region src/universal/transport-types/hash-set.ts
|
|
129
|
-
/** Generic HashSet value operations, independent of application contracts. */
|
|
130
|
-
const hashSetTransportType = /* @__PURE__ */ (() => {
|
|
131
|
-
return {
|
|
132
|
-
kind: "hash-set",
|
|
133
|
-
matchesValue: HashSet.isHashSet,
|
|
134
|
-
getValues: (value) => {
|
|
135
|
-
return Array.from(value);
|
|
136
|
-
},
|
|
137
|
-
fromValues: HashSet.fromIterable
|
|
138
|
-
};
|
|
139
|
-
})();
|
|
140
|
-
//#endregion
|
|
141
|
-
export { bigDecimalTransportType as a, redactedTransportType as c, dateTimeUtcTransportType as i, optionTransportType as l, hashMapTransportType as n, durationTransportType as o, dateTimeZonedTransportType as r, chunkTransportType as s, hashSetTransportType as t };
|
package/dist/href-Cqyax8Y0.js
DELETED
|
@@ -1,357 +0,0 @@
|
|
|
1
|
-
import { S as SEARCH_PARAMETER_PROTOCOL, d as encodeRoutePatternForMatcher, f as formatPathWireError, i as encodeTransportedValue, p as makeNullPrototypeRecord, u as encodePathCapture } from "./value-transport-Bst4Hk-n.js";
|
|
2
|
-
import { Result } from "effect";
|
|
3
|
-
//#region src/universal/search-grammar.ts
|
|
4
|
-
const { escapePrefix: ESCAPE_PREFIX, keySeparator: KEY_SEPARATOR, keySegmentEscapes: { empty: EMPTY_KEY_SEGMENT, separator: ESCAPED_KEY_SEPARATOR, tilde: ESCAPED_TILDE }, valueMarkers: { emptyArray: EMPTY_ARRAY_MARKER, emptyObject: EMPTY_OBJECT_MARKER, escapedScalarPrefix: ESCAPED_SCALAR_PREFIX, null: NULL_MARKER } } = SEARCH_PARAMETER_PROTOCOL;
|
|
5
|
-
function encodeKeySegment(value) {
|
|
6
|
-
if (value === "") return EMPTY_KEY_SEGMENT;
|
|
7
|
-
return value.replaceAll(ESCAPE_PREFIX, ESCAPED_TILDE).replaceAll(KEY_SEPARATOR, ESCAPED_KEY_SEPARATOR);
|
|
8
|
-
}
|
|
9
|
-
function encodeScalar(value) {
|
|
10
|
-
return value.startsWith(ESCAPE_PREFIX) ? ESCAPED_SCALAR_PREFIX + value : value;
|
|
11
|
-
}
|
|
12
|
-
function appendKey(input) {
|
|
13
|
-
const encoded = encodeKeySegment(input.child);
|
|
14
|
-
return input.parent === "" ? encoded : `${input.parent}${KEY_SEPARATOR}${encoded}`;
|
|
15
|
-
}
|
|
16
|
-
//#endregion
|
|
17
|
-
//#region src/universal/search-serialize.ts
|
|
18
|
-
/** The own enumerable entries of an object, typed as unknown values. */
|
|
19
|
-
function getOwnEntries(value) {
|
|
20
|
-
return Object.entries(value);
|
|
21
|
-
}
|
|
22
|
-
/** Selects one authored search contract's fields from a composed route value. */
|
|
23
|
-
function projectSearchFields(value, fields) {
|
|
24
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return value;
|
|
25
|
-
const wanted = new Set(fields);
|
|
26
|
-
const projected = makeNullPrototypeRecord();
|
|
27
|
-
for (const [key, child] of getOwnEntries(value)) if (wanted.has(key)) projected[key] = child;
|
|
28
|
-
return projected;
|
|
29
|
-
}
|
|
30
|
-
/** Serializes a decoded search value into the compact search-parameter grammar. */
|
|
31
|
-
function serializeSearchParams(input) {
|
|
32
|
-
const transported = encodeTransportedValue(input);
|
|
33
|
-
if (Result.isFailure(transported)) return Result.fail({
|
|
34
|
-
_tag: "UnsupportedSearchParam",
|
|
35
|
-
path: transported.failure.path.join("."),
|
|
36
|
-
reason: transported.failure.reason
|
|
37
|
-
});
|
|
38
|
-
const marks = /* @__PURE__ */ new Map();
|
|
39
|
-
for (const mark of transported.success.marks) {
|
|
40
|
-
if (mark.kind === "undefined" && typeof mark.path.at(-1) === "number") return failUnsupported({
|
|
41
|
-
path: mark.path.join("."),
|
|
42
|
-
reason: "arrays cannot contain undefined"
|
|
43
|
-
});
|
|
44
|
-
marks.set(toPathKey(mark.path), mark.kind);
|
|
45
|
-
}
|
|
46
|
-
const pairs = [];
|
|
47
|
-
const written = appendValue({
|
|
48
|
-
pairs,
|
|
49
|
-
marks,
|
|
50
|
-
path: [],
|
|
51
|
-
key: "",
|
|
52
|
-
value: transported.success.json
|
|
53
|
-
});
|
|
54
|
-
if (Result.isFailure(written)) return Result.fail(written.failure);
|
|
55
|
-
const parameters = new URLSearchParams();
|
|
56
|
-
for (const [key, item] of pairs) parameters.append(key, item);
|
|
57
|
-
return Result.succeed(parameters.toString());
|
|
58
|
-
}
|
|
59
|
-
function toPathKey(path) {
|
|
60
|
-
return JSON.stringify(path);
|
|
61
|
-
}
|
|
62
|
-
function matchesJsonArray(value) {
|
|
63
|
-
return Array.isArray(value);
|
|
64
|
-
}
|
|
65
|
-
function appendValue(input) {
|
|
66
|
-
const kind = input.marks.get(toPathKey(input.path));
|
|
67
|
-
switch (kind) {
|
|
68
|
-
case "undefined": return Result.succeed(void 0);
|
|
69
|
-
case "number": return input.value === "-0" ? appendScalar({
|
|
70
|
-
...input,
|
|
71
|
-
value: 0
|
|
72
|
-
}) : failUnsupported({
|
|
73
|
-
path: input.path.join("."),
|
|
74
|
-
reason: "numbers must be finite"
|
|
75
|
-
});
|
|
76
|
-
case "date":
|
|
77
|
-
case "bigint":
|
|
78
|
-
case "url":
|
|
79
|
-
case "duration":
|
|
80
|
-
case "big-decimal":
|
|
81
|
-
case "date-time-utc":
|
|
82
|
-
case "date-time-zoned": return typeof input.value === "string" ? appendScalar({
|
|
83
|
-
...input,
|
|
84
|
-
value: input.value
|
|
85
|
-
}) : failUnsupported({
|
|
86
|
-
path: input.path.join("."),
|
|
87
|
-
reason: `a ${kind} mark needs a string`
|
|
88
|
-
});
|
|
89
|
-
case "regexp": return appendRegExp(input, input.value);
|
|
90
|
-
case "url-search-params": return appendUrlSearchParams(input, input.value);
|
|
91
|
-
case "option": return appendOption(input, input.value);
|
|
92
|
-
case "redacted": return appendRedacted(input, input.value);
|
|
93
|
-
case "map":
|
|
94
|
-
case "hash-map": return matchesJsonArray(input.value) ? appendMap(input, input.value) : failUnsupported({
|
|
95
|
-
path: input.path.join("."),
|
|
96
|
-
reason: "a map mark needs an array of pairs"
|
|
97
|
-
});
|
|
98
|
-
case "set":
|
|
99
|
-
case "chunk":
|
|
100
|
-
case "hash-set": return matchesJsonArray(input.value) ? appendArray(input, input.value) : failUnsupported({
|
|
101
|
-
path: input.path.join("."),
|
|
102
|
-
reason: "a set mark needs an array"
|
|
103
|
-
});
|
|
104
|
-
case void 0:
|
|
105
|
-
}
|
|
106
|
-
if (input.value === null) {
|
|
107
|
-
input.pairs.push([input.key, NULL_MARKER]);
|
|
108
|
-
return Result.succeed(void 0);
|
|
109
|
-
}
|
|
110
|
-
if (matchesJsonArray(input.value)) return appendArray(input, input.value);
|
|
111
|
-
if (typeof input.value === "object") return appendObject(input, input.value);
|
|
112
|
-
return appendScalar({
|
|
113
|
-
...input,
|
|
114
|
-
value: input.value
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
function appendRegExp(input, value) {
|
|
118
|
-
if (typeof value !== "object" || value === null || matchesJsonArray(value) || typeof value["source"] !== "string" || typeof value["flags"] !== "string") return failUnsupported({
|
|
119
|
-
path: input.path.join("."),
|
|
120
|
-
reason: "a regexp mark needs a source and flags"
|
|
121
|
-
});
|
|
122
|
-
return appendScalar({
|
|
123
|
-
...input,
|
|
124
|
-
value: `/${value["source"]}/${value["flags"]}`
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
function appendUrlSearchParams(input, value) {
|
|
128
|
-
if (!matchesJsonArray(value)) return failUnsupported({
|
|
129
|
-
path: input.path.join("."),
|
|
130
|
-
reason: "a URLSearchParams mark needs an array of string pairs"
|
|
131
|
-
});
|
|
132
|
-
const entries = [];
|
|
133
|
-
for (const pair of value) {
|
|
134
|
-
if (!matchesJsonArray(pair) || pair.length !== 2 || typeof pair[0] !== "string" || typeof pair[1] !== "string") return failUnsupported({
|
|
135
|
-
path: input.path.join("."),
|
|
136
|
-
reason: "a URLSearchParams mark needs an array of string pairs"
|
|
137
|
-
});
|
|
138
|
-
entries.push([pair[0], pair[1]]);
|
|
139
|
-
}
|
|
140
|
-
return appendScalar({
|
|
141
|
-
...input,
|
|
142
|
-
value: new URLSearchParams(entries).toString()
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
function appendOption(input, value) {
|
|
146
|
-
if (!matchesJsonArray(value) || value.length > 1) return failUnsupported({
|
|
147
|
-
path: input.path.join("."),
|
|
148
|
-
reason: "an option mark needs an empty or one-item array"
|
|
149
|
-
});
|
|
150
|
-
const child = value[0];
|
|
151
|
-
return child === void 0 ? Result.succeed(void 0) : appendValue({
|
|
152
|
-
...input,
|
|
153
|
-
path: [...input.path, 0],
|
|
154
|
-
value: child
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
function appendRedacted(input, value) {
|
|
158
|
-
if (typeof value !== "object" || value === null || matchesJsonArray(value) || !("value" in value)) return failUnsupported({
|
|
159
|
-
path: input.path.join("."),
|
|
160
|
-
reason: "a redacted mark needs a value"
|
|
161
|
-
});
|
|
162
|
-
return appendValue({
|
|
163
|
-
...input,
|
|
164
|
-
path: [...input.path, "value"],
|
|
165
|
-
value: value["value"]
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
function appendArray(input, value) {
|
|
169
|
-
if (value.length === 0) {
|
|
170
|
-
input.pairs.push([input.key, EMPTY_ARRAY_MARKER]);
|
|
171
|
-
return Result.succeed(void 0);
|
|
172
|
-
}
|
|
173
|
-
for (const [index, item] of value.entries()) {
|
|
174
|
-
const written = appendValue({
|
|
175
|
-
...input,
|
|
176
|
-
path: [...input.path, index],
|
|
177
|
-
value: item
|
|
178
|
-
});
|
|
179
|
-
if (Result.isFailure(written)) return written;
|
|
180
|
-
}
|
|
181
|
-
return Result.succeed(void 0);
|
|
182
|
-
}
|
|
183
|
-
/** A Map travels as pairs; its keys must be strings, and its entries are written like an object's fields. */
|
|
184
|
-
function appendMap(input, pairs) {
|
|
185
|
-
const entries = [];
|
|
186
|
-
for (const [index, pair] of pairs.entries()) {
|
|
187
|
-
if (!matchesJsonArray(pair) || pair.length !== 2 || typeof pair[0] !== "string" || input.marks.has(toPathKey([
|
|
188
|
-
...input.path,
|
|
189
|
-
index,
|
|
190
|
-
0
|
|
191
|
-
]))) return failUnsupported({
|
|
192
|
-
path: [...input.path, index].join("."),
|
|
193
|
-
reason: "map keys must be strings"
|
|
194
|
-
});
|
|
195
|
-
const value = pair[1];
|
|
196
|
-
if (value === void 0) return failUnsupported({
|
|
197
|
-
path: [...input.path, index].join("."),
|
|
198
|
-
reason: "a map mark needs an array of pairs"
|
|
199
|
-
});
|
|
200
|
-
if (!input.marks.has(toPathKey([
|
|
201
|
-
...input.path,
|
|
202
|
-
index,
|
|
203
|
-
1
|
|
204
|
-
]))) {
|
|
205
|
-
entries.push({
|
|
206
|
-
field: pair[0],
|
|
207
|
-
index,
|
|
208
|
-
value
|
|
209
|
-
});
|
|
210
|
-
continue;
|
|
211
|
-
}
|
|
212
|
-
if (input.marks.get(toPathKey([
|
|
213
|
-
...input.path,
|
|
214
|
-
index,
|
|
215
|
-
1
|
|
216
|
-
])) !== "undefined") entries.push({
|
|
217
|
-
field: pair[0],
|
|
218
|
-
index,
|
|
219
|
-
value
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
return appendEntries(input, entries);
|
|
223
|
-
}
|
|
224
|
-
function appendObject(input, value) {
|
|
225
|
-
const entries = [];
|
|
226
|
-
for (const [field, child] of getOwnEntries(value)) if (input.marks.get(toPathKey([...input.path, field])) !== "undefined") entries.push({
|
|
227
|
-
field,
|
|
228
|
-
index: field,
|
|
229
|
-
value: child
|
|
230
|
-
});
|
|
231
|
-
return appendEntries(input, entries);
|
|
232
|
-
}
|
|
233
|
-
/** Fields in name order, each at its own transport path, so that a Map and an object are written alike. */
|
|
234
|
-
function appendEntries(input, entries) {
|
|
235
|
-
if (entries.length === 0) {
|
|
236
|
-
input.pairs.push([input.key, EMPTY_OBJECT_MARKER]);
|
|
237
|
-
return Result.succeed(void 0);
|
|
238
|
-
}
|
|
239
|
-
const sorted = [...entries].sort((left, right) => {
|
|
240
|
-
return left.field < right.field ? -1 : left.field > right.field ? 1 : 0;
|
|
241
|
-
});
|
|
242
|
-
for (const entry of sorted) {
|
|
243
|
-
const path = typeof entry.index === "number" ? [
|
|
244
|
-
...input.path,
|
|
245
|
-
entry.index,
|
|
246
|
-
1
|
|
247
|
-
] : [...input.path, entry.index];
|
|
248
|
-
const written = appendValue({
|
|
249
|
-
...input,
|
|
250
|
-
path,
|
|
251
|
-
key: appendKey({
|
|
252
|
-
parent: input.key,
|
|
253
|
-
child: entry.field
|
|
254
|
-
}),
|
|
255
|
-
value: entry.value
|
|
256
|
-
});
|
|
257
|
-
if (Result.isFailure(written)) return written;
|
|
258
|
-
}
|
|
259
|
-
return Result.succeed(void 0);
|
|
260
|
-
}
|
|
261
|
-
function appendScalar(input) {
|
|
262
|
-
input.pairs.push([input.key, encodeScalar(String(input.value))]);
|
|
263
|
-
return Result.succeed(void 0);
|
|
264
|
-
}
|
|
265
|
-
function failUnsupported(input) {
|
|
266
|
-
return Result.fail({
|
|
267
|
-
_tag: "UnsupportedSearchParam",
|
|
268
|
-
path: input.path,
|
|
269
|
-
reason: input.reason
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
//#endregion
|
|
273
|
-
//#region src/universal/href.ts
|
|
274
|
-
function buildHref(input) {
|
|
275
|
-
const encodedPattern = encodeRoutePatternForMatcher(input.pattern);
|
|
276
|
-
if (Result.isFailure(encodedPattern)) return failPathWire(encodedPattern.failure);
|
|
277
|
-
const spelled = encodedPattern.success;
|
|
278
|
-
const hasTrailingSlash = input.kind === "endpoint" && spelled.length > 1 && spelled.endsWith("/");
|
|
279
|
-
const patternSegments = spelled === "/" ? [] : spelled.slice(1, hasTrailingSlash ? -1 : void 0).split("/");
|
|
280
|
-
let trailingSlash = hasTrailingSlash;
|
|
281
|
-
const params = input.params === void 0 ? {} : input.params;
|
|
282
|
-
const splatValues = input.splatValues === void 0 ? [] : input.splatValues;
|
|
283
|
-
const segments = [];
|
|
284
|
-
let hasSplat = false;
|
|
285
|
-
for (const [index, segment] of patternSegments.entries()) {
|
|
286
|
-
const isLast = index === patternSegments.length - 1;
|
|
287
|
-
if (input.kind === "ui" && isLast && segment === "_index") continue;
|
|
288
|
-
if (segment === "*") {
|
|
289
|
-
hasSplat = true;
|
|
290
|
-
if (splatValues.length === 0) {
|
|
291
|
-
if (input.kind === "ui" && patternSegments.length > 1) return failHref(`UI pattern ${JSON.stringify(input.pattern)} cannot select its non-root splat with no values`);
|
|
292
|
-
if (input.kind === "endpoint" && segments.length > 0) trailingSlash = true;
|
|
293
|
-
}
|
|
294
|
-
for (const splatValue of splatValues) {
|
|
295
|
-
const encoded = encodePathCapture(splatValue);
|
|
296
|
-
if (Result.isFailure(encoded)) return failPathWire(encoded.failure);
|
|
297
|
-
segments.push(encoded.success);
|
|
298
|
-
}
|
|
299
|
-
continue;
|
|
300
|
-
}
|
|
301
|
-
if (segment.startsWith(":")) {
|
|
302
|
-
const parameterName = segment.slice(1);
|
|
303
|
-
const value = Object.hasOwn(params, parameterName) ? params[parameterName] : void 0;
|
|
304
|
-
if (value === void 0) return failHref(`missing parameter ${parameterName} for ${input.pattern}`);
|
|
305
|
-
const encoded = encodePathCapture(value);
|
|
306
|
-
if (Result.isFailure(encoded)) return failPathWire(encoded.failure);
|
|
307
|
-
segments.push(encoded.success);
|
|
308
|
-
continue;
|
|
309
|
-
}
|
|
310
|
-
segments.push(segment);
|
|
311
|
-
}
|
|
312
|
-
if (!hasSplat && splatValues.length > 0) return failHref(`pattern ${JSON.stringify(input.pattern)} does not accept splat values`);
|
|
313
|
-
const path = segments.length === 0 ? "/" : `/${segments.join("/")}${trailingSlash ? "/" : ""}`;
|
|
314
|
-
const query = toQueryString({
|
|
315
|
-
search: input.search,
|
|
316
|
-
transportTypeEntries: input.transportTypeEntries
|
|
317
|
-
});
|
|
318
|
-
if (Result.isFailure(query)) return Result.fail(query.failure);
|
|
319
|
-
return Result.succeed(`${path}${query.success}${toFragment(input.hash)}`);
|
|
320
|
-
}
|
|
321
|
-
function toFragment(hash) {
|
|
322
|
-
if (hash === void 0 || hash === "") return "";
|
|
323
|
-
const url = new URL("about:blank");
|
|
324
|
-
url.hash = hash;
|
|
325
|
-
return url.href.slice(11);
|
|
326
|
-
}
|
|
327
|
-
/**
|
|
328
|
-
* Search text is used as given; any other value is a decoded search the
|
|
329
|
-
* compact grammar serializes. A route search is a record of fields, and one
|
|
330
|
-
* with no fields present is the absence of a query, not the grammar's
|
|
331
|
-
* spelling of an empty record.
|
|
332
|
-
*/
|
|
333
|
-
function toQueryString(input) {
|
|
334
|
-
if (input.search === void 0) return Result.succeed("");
|
|
335
|
-
if (typeof input.search === "string") return Result.succeed(input.search === "" ? "" : `?${input.search}`);
|
|
336
|
-
if (typeof input.search === "object" && input.search !== null && !Array.isArray(input.search) && Object.values(input.search).every((field) => field === void 0)) return Result.succeed("");
|
|
337
|
-
const serialized = serializeSearchParams({
|
|
338
|
-
value: input.search,
|
|
339
|
-
typeEntries: input.transportTypeEntries
|
|
340
|
-
});
|
|
341
|
-
if (Result.isFailure(serialized)) return failHref(`search parameters cannot be serialized: ${serialized.failure.reason}`);
|
|
342
|
-
return Result.succeed(serialized.success === "" ? "" : `?${serialized.success}`);
|
|
343
|
-
}
|
|
344
|
-
function failHref(reason) {
|
|
345
|
-
return Result.fail({
|
|
346
|
-
_tag: "HrefError",
|
|
347
|
-
reason
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
function failPathWire(cause) {
|
|
351
|
-
return Result.fail({
|
|
352
|
-
_tag: "HrefError",
|
|
353
|
-
reason: formatPathWireError(cause)
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
//#endregion
|
|
357
|
-
export { EMPTY_ARRAY_MARKER as a, ESCAPED_KEY_SEPARATOR as c, ESCAPE_PREFIX as d, KEY_SEPARATOR as f, encodeScalar as h, serializeSearchParams as i, ESCAPED_SCALAR_PREFIX as l, appendKey as m, getOwnEntries as n, EMPTY_KEY_SEGMENT as o, NULL_MARKER as p, projectSearchFields as r, EMPTY_OBJECT_MARKER as s, buildHref as t, ESCAPED_TILDE as u };
|