@orieljs/inertia-client 0.1.0-alpha.2

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/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,9 @@
1
+ Oriel
2
+ Copyright 2026 meeeet-dev and Oriel contributors
3
+
4
+ This product includes software developed by the Oriel project
5
+ (https://orieljs.vercel.app, https://github.com/orieljs).
6
+
7
+ Oriel is licensed under the Apache License, Version 2.0 (see LICENSE).
8
+ The Oriel name and logo are not covered by that license; see TRADEMARKS.md
9
+ (https://github.com/orieljs/framework/blob/main/TRADEMARKS.md).
@@ -0,0 +1,165 @@
1
+ import { Progress, Method, VisitOptions } from '@inertiajs/core';
2
+ export { Errors as InertiaErrors, Method, Page, Progress, VisitOptions, router } from '@inertiajs/core';
3
+
4
+ /**
5
+ * The typed surface every Oriel adapter shares. `oriel inertia:types` augments Pages and SharedProps
6
+ * (resources/js/oriel/pages.d.ts); `oriel route:types` augments RouteList (resources/js/oriel/routes.ts).
7
+ */
8
+ /** Page component name → its props. Augmented by the generated page types. */
9
+ interface Pages {
10
+ }
11
+ /** Augmented by the generated page types: `shared` is the resolved HandleInertiaRequests.share() result. */
12
+ interface SharedPropsRegistry {
13
+ }
14
+ /** Props shared with every page (HandleInertiaRequests.share()). */
15
+ type SharedProps = SharedPropsRegistry extends {
16
+ shared: infer S;
17
+ } ? S : Record<never, never>;
18
+ /** A page name: the generated ones, or any string before types are generated. */
19
+ type PageName = [keyof Pages] extends [never] ? string : Extract<keyof Pages, string>;
20
+ /** Validation errors: field → message (or messages, with withAllErrors). */
21
+ type Errors = Record<string, string | string[]>;
22
+ /** Errors under a named bag (useForm({ errorBag })) or several bags. */
23
+ type ErrorBags = Record<string, Errors>;
24
+ type Simplify<T> = {
25
+ [K in keyof T]: T[K];
26
+ } & {};
27
+ /** The props a page receives: shared props, its own props and the validation errors. */
28
+ type PageProps<N extends PageName = PageName> = Simplify<Omit<SharedProps, 'errors'> & (N extends keyof Pages ? Omit<Pages[N], 'errors'> : Record<string, unknown>) & {
29
+ errors: Errors & ErrorBags;
30
+ }>;
31
+ /** The page object with typed props (usePage<'Posts/Index'>()). */
32
+ interface TypedPage<N extends PageName = PageName> {
33
+ component: N;
34
+ props: PageProps<N>;
35
+ url: string;
36
+ version: string | null;
37
+ flash: Record<string, unknown>;
38
+ }
39
+
40
+ /** Route name → its parameters. Augmented by the generated routes module (oriel route:types). */
41
+ interface RouteList {
42
+ }
43
+ /** A route name: the generated ones, or any string before types are generated. */
44
+ type RouteName = [keyof RouteList] extends [never] ? string : Extract<keyof RouteList, string>;
45
+ /** A parameter value: a scalar, or a model-like object (its `id`, or the {post:slug} field, is used). */
46
+ type RouteParameter = string | number | boolean | {
47
+ readonly [key: string]: unknown;
48
+ };
49
+ type ParametersOf<N> = N extends keyof RouteList ? RouteList[N] : Record<string, RouteParameter>;
50
+ type RequiredKeys<T> = {
51
+ [K in keyof T]-?: Record<never, never> extends Pick<T, K> ? never : K;
52
+ }[keyof T];
53
+ /** Named parameters (extras become the query string), one value, or values in URI order. */
54
+ type RouteParameters<N> = (ParametersOf<N> & Record<string, unknown>) | RouteParameter | RouteParameter[];
55
+ /** route(name) is allowed only when the route has no required parameters. */
56
+ type RouteArguments<N> = [RequiredKeys<ParametersOf<N>>] extends [never] ? [parameters?: RouteParameters<N>, absolute?: boolean] : [parameters: RouteParameters<N>, absolute?: boolean];
57
+ /** One named route: its URI (Laravel syntax) and methods. */
58
+ interface RouteDefinition {
59
+ readonly uri: string;
60
+ readonly methods: readonly string[];
61
+ }
62
+ type RouteTable = Readonly<Record<string, RouteDefinition>>;
63
+ /** Registers the route table (the generated routes module calls this) and returns it. */
64
+ declare function defineRoutes<const T extends RouteTable>(table: T): T;
65
+ declare class RouteError extends Error {
66
+ readonly name = "RouteError";
67
+ }
68
+ /**
69
+ * The URL of a named route, like the server's route(): route('posts.show', post), route('posts.show', { post: 1,
70
+ * page: 2 }), route('posts.show', [post, comment]). Relative ('/posts/1') unless `absolute` is true.
71
+ */
72
+ declare function route<N extends RouteName>(name: N, ...[parameters, absolute]: RouteArguments<N>): string;
73
+ /** Is `name` a registered route? */
74
+ declare function hasRoute(name: string): boolean;
75
+ /** The name of the GET route matching the browser's current path, or undefined (also during SSR). */
76
+ declare function currentRoute(): string | undefined;
77
+ /** Does the current route match one of the names or wildcard patterns ('posts.*')? */
78
+ declare function isCurrentRoute(...patterns: string[]): boolean;
79
+
80
+ type Data = Record<string, unknown>;
81
+ type Listener = () => void;
82
+ /** Form options passed through to the visit; the helper wraps the callbacks. */
83
+ type FormSubmitOptions = Omit<VisitOptions, 'data'>;
84
+ /** The state a form helper exposes (what React's useForm returns, minus the framework plumbing). */
85
+ interface FormState<T extends Data> {
86
+ readonly data: T;
87
+ readonly defaults: T;
88
+ readonly errors: Partial<Record<keyof T | string, string>>;
89
+ readonly hasErrors: boolean;
90
+ readonly isDirty: boolean;
91
+ readonly processing: boolean;
92
+ readonly progress: Progress | null;
93
+ readonly wasSuccessful: boolean;
94
+ readonly recentlySuccessful: boolean;
95
+ }
96
+ /**
97
+ * A framework-agnostic form helper on the real Inertia router: the core that Solid and Angular adapters wrap in
98
+ * signals (React, Vue and Svelte use the official useForm). Every change notifies subscribers.
99
+ */
100
+ interface FormHelper<T extends Data> extends FormState<T> {
101
+ subscribe(listener: Listener): () => void;
102
+ setData(key: keyof T & string, value: unknown): void;
103
+ setData(data: Partial<T> | ((data: T) => T)): void;
104
+ setDefaults(): void;
105
+ setDefaults(key: keyof T & string, value: unknown): void;
106
+ setDefaults(fields: Partial<T>): void;
107
+ reset(...fields: Array<keyof T & string>): void;
108
+ clearErrors(...fields: Array<keyof T & string>): void;
109
+ resetAndClearErrors(...fields: Array<keyof T & string>): void;
110
+ setError(field: keyof T & string, message: string): void;
111
+ setError(errors: Record<string, string>): void;
112
+ transform(callback: (data: T) => Data): void;
113
+ submit(method: Method, url: string, options?: FormSubmitOptions): void;
114
+ get(url: string, options?: FormSubmitOptions): void;
115
+ post(url: string, options?: FormSubmitOptions): void;
116
+ put(url: string, options?: FormSubmitOptions): void;
117
+ patch(url: string, options?: FormSubmitOptions): void;
118
+ delete(url: string, options?: FormSubmitOptions): void;
119
+ cancel(): void;
120
+ }
121
+ /** createForm({ title: '' }): a headless form helper (Inertia's useForm without remember or Precognition). */
122
+ declare function createForm<T extends Data>(initial: T | (() => T)): FormHelper<T>;
123
+
124
+ /**
125
+ * The Oriel client contract: what every adapter package (@orieljs/inertia-react, -vue, -svelte, -solid,
126
+ * -angular) exports, in its framework's idiom. The shared conformance suite checks the behaviour.
127
+ *
128
+ * - createInertiaApp(options): mounts the app on the element with id `options.id ?? 'app'` from the page
129
+ * script (`<script data-page="app" type="application/json">`); React/Vue/Svelte re-export the official one.
130
+ * - Link: a component (Angular: the `oLink` directive) taking LinkProps.
131
+ * - useForm(data) (Solid: signals over createForm(); Angular: a signals-based service): the FormHelper API.
132
+ * - usePage<N>(): the current page as TypedPage<N>, reactive in the framework's way.
133
+ * - router, route, hasRoute, currentRoute, isCurrentRoute: re-exported from @orieljs/inertia-client.
134
+ * - Head, Deferred, WhenVisible and InfiniteScroll where the official adapter has them.
135
+ */
136
+ interface LinkProps {
137
+ /** A URL, or the result of route(). */
138
+ href: string;
139
+ method?: Method;
140
+ data?: Record<string, unknown>;
141
+ replace?: boolean;
142
+ preserveScroll?: boolean;
143
+ preserveState?: boolean;
144
+ only?: string[];
145
+ except?: string[];
146
+ headers?: Record<string, string>;
147
+ /** Render as another element (a button for non-GET links). */
148
+ as?: string;
149
+ prefetch?: boolean | 'hover' | 'click' | 'mount';
150
+ }
151
+ /** The functions every adapter re-exports, typed the same everywhere. */
152
+ interface OrielClientApi {
153
+ route<N extends RouteName>(name: N, ...args: RouteArguments<N>): string;
154
+ hasRoute(name: string): boolean;
155
+ currentRoute(): string | undefined;
156
+ isCurrentRoute(...patterns: string[]): boolean;
157
+ }
158
+ /** What an adapter's useForm returns (the official useForm types satisfy it for the fields used here). */
159
+ type AdapterForm<T extends Record<string, unknown>> = Pick<FormHelper<T>, 'data' | 'errors' | 'hasErrors' | 'processing' | 'isDirty' | 'wasSuccessful' | 'recentlySuccessful' | 'setData' | 'reset' | 'clearErrors' | 'setError' | 'submit' | 'get' | 'post' | 'put' | 'patch' | 'delete' | 'cancel' | 'transform'>;
160
+ /** usePage() in every adapter. */
161
+ type UsePage = <N extends PageName = PageName>() => TypedPage<N>;
162
+ /** Visit options a Link forwards to router.visit(). */
163
+ type LinkVisitOptions = Pick<VisitOptions, 'method' | 'data' | 'replace' | 'preserveScroll' | 'preserveState' | 'only' | 'except' | 'headers'>;
164
+
165
+ export { type AdapterForm, type ErrorBags, type Errors, type FormHelper, type FormState, type FormSubmitOptions, type LinkProps, type LinkVisitOptions, type OrielClientApi, type PageName, type PageProps, type Pages, type RouteArguments, type RouteDefinition, RouteError, type RouteList, type RouteName, type RouteParameter, type RouteParameters, type RouteTable, type SharedProps, type SharedPropsRegistry, type TypedPage, type UsePage, createForm, currentRoute, defineRoutes, hasRoute, isCurrentRoute, route };
package/dist/index.js ADDED
@@ -0,0 +1,324 @@
1
+ // index.ts
2
+ import { router as router2 } from "@inertiajs/core";
3
+
4
+ // browser.ts
5
+ function browserLocation() {
6
+ return globalThis.location;
7
+ }
8
+
9
+ // routes.ts
10
+ var PARAMETER = /\{(\w+)(?::(\w+))?(\?)?\}/g;
11
+ var WHOLE_OPTIONAL = /^\{(\w+)(?::\w+)?\?\}$/;
12
+ var TABLE = /* @__PURE__ */ Symbol.for("oriel:inertia.routes");
13
+ var registry = () => {
14
+ const globals = globalThis;
15
+ return globals[TABLE] ??= { table: {} };
16
+ };
17
+ function defineRoutes(table) {
18
+ registry().table = table;
19
+ return table;
20
+ }
21
+ var RouteError = class extends Error {
22
+ name = "RouteError";
23
+ };
24
+ var isPlainObject = (value) => {
25
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
26
+ const prototype = Object.getPrototypeOf(value);
27
+ return prototype === Object.prototype || prototype === null;
28
+ };
29
+ function buildQuery(values) {
30
+ const pairs = [];
31
+ const add = (key, value) => {
32
+ if (value === null || value === void 0) return;
33
+ if (typeof value === "object" && (Array.isArray(value) || isPlainObject(value))) {
34
+ for (const [child, nested] of Object.entries(value)) add(`${key}[${child}]`, nested);
35
+ return;
36
+ }
37
+ const text = value === true ? "1" : value === false ? "0" : String(value);
38
+ pairs.push(`${encodeURIComponent(key)}=${encodeURIComponent(text)}`);
39
+ };
40
+ for (const [key, value] of Object.entries(values)) add(key, value);
41
+ return pairs.join("&");
42
+ }
43
+ function routeKey(value, field) {
44
+ if (typeof value !== "object" || value === null) return value;
45
+ const object = value;
46
+ return field !== void 0 ? object[field] : object.id;
47
+ }
48
+ function parametersOf(uri) {
49
+ return [...uri.matchAll(PARAMETER)].map((match) => ({ name: match[1], field: match[2], optional: match[3] === "?" }));
50
+ }
51
+ function route(name, ...[parameters, absolute = false]) {
52
+ const definition = registry().table[name];
53
+ if (definition === void 0) throw new RouteError(`Route [${name}] not defined.`);
54
+ const declared = parametersOf(definition.uri);
55
+ const only = declared.length === 1 && !declared[0].optional ? declared[0] : void 0;
56
+ const isModel = only !== void 0 && isPlainObject(parameters) && !Object.hasOwn(parameters, only.name) && Object.hasOwn(parameters, only.field ?? "id");
57
+ const named = isModel ? { [only.name]: parameters } : isPlainObject(parameters) ? { ...parameters } : {};
58
+ const positional = Array.isArray(parameters) ? [...parameters] : parameters === void 0 || parameters === null || isPlainObject(parameters) ? [] : [parameters];
59
+ const values = /* @__PURE__ */ new Map();
60
+ const missing = [];
61
+ for (const parameter of declared) {
62
+ let value;
63
+ if (Object.hasOwn(named, parameter.name)) {
64
+ value = named[parameter.name];
65
+ delete named[parameter.name];
66
+ } else if (positional.length > 0) {
67
+ value = positional.shift();
68
+ }
69
+ const key = routeKey(value, parameter.field);
70
+ const text = key === void 0 || key === null ? void 0 : String(key);
71
+ if (text === void 0 && !parameter.optional) missing.push(parameter.name);
72
+ values.set(parameter.name, text);
73
+ }
74
+ if (missing.length > 0) {
75
+ throw new RouteError(`Missing required parameter for [Route: ${name}] [URI: ${definition.uri}] [Missing parameter: ${missing.join(", ")}].`);
76
+ }
77
+ const path = definition.uri === "/" ? "" : definition.uri.split("/").filter((segment) => {
78
+ const whole = WHOLE_OPTIONAL.exec(segment);
79
+ return whole === null || values.get(whole[1]) !== void 0;
80
+ }).map((segment) => segment.replace(PARAMETER, (_match, parameter) => encodeURIComponent(values.get(parameter) ?? ""))).join("/");
81
+ const query = buildQuery(named);
82
+ const relative = `/${path.replace(/^\/+|\/+$/g, "")}${query === "" ? "" : `?${query}`}`;
83
+ if (!absolute) return relative;
84
+ return `${browserLocation()?.origin ?? ""}${relative}`;
85
+ }
86
+ function hasRoute(name) {
87
+ return Object.hasOwn(registry().table, name);
88
+ }
89
+ var escape = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
90
+ function uriPattern(uri) {
91
+ const segments = uri.replace(/^\/+|\/+$/g, "").split("/").filter((segment) => segment !== "");
92
+ const body = segments.map((segment) => {
93
+ if (WHOLE_OPTIONAL.test(segment)) return "(?:/[^/]+)?";
94
+ return `/${segment.split(PARAMETER).map((part, index) => index % 4 === 0 ? escape(part) : index % 4 === 1 ? "[^/]+" : "").join("")}`;
95
+ }).join("");
96
+ return new RegExp(`^${body === "" ? "/" : body}/?$`);
97
+ }
98
+ function currentRoute() {
99
+ const location = browserLocation();
100
+ if (location === void 0) return void 0;
101
+ for (const [name, definition] of Object.entries(registry().table)) {
102
+ if (definition.methods.includes("GET") && uriPattern(definition.uri).test(location.pathname)) return name;
103
+ }
104
+ return void 0;
105
+ }
106
+ function matches(pattern, name) {
107
+ return new RegExp(`^${pattern.split("*").map(escape).join(".*")}$`).test(name);
108
+ }
109
+ function isCurrentRoute(...patterns) {
110
+ const current = currentRoute();
111
+ return current !== void 0 && patterns.some((pattern) => matches(pattern, current));
112
+ }
113
+
114
+ // form.ts
115
+ import { config, router } from "@inertiajs/core";
116
+ var isPlain = (value) => Array.isArray(value) || Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null;
117
+ function clone(value) {
118
+ if (typeof value !== "object" || value === null) return value;
119
+ if (value instanceof Date) return new Date(value.getTime());
120
+ if (!isPlain(value)) return value;
121
+ if (Array.isArray(value)) return value.map(clone);
122
+ return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, clone(entry)]));
123
+ }
124
+ function equal(a, b) {
125
+ if (Object.is(a, b)) return true;
126
+ if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) return false;
127
+ if (a instanceof Date || b instanceof Date) return a instanceof Date && b instanceof Date && a.getTime() === b.getTime();
128
+ if (Array.isArray(a) !== Array.isArray(b)) return false;
129
+ if (!isPlain(a) || !isPlain(b)) return false;
130
+ const keys = Object.keys(a);
131
+ if (keys.length !== Object.keys(b).length) return false;
132
+ return keys.every((key) => Object.hasOwn(b, key) && equal(a[key], b[key]));
133
+ }
134
+ function getPath(target, path) {
135
+ return path.split(".").reduce((current, segment) => typeof current === "object" && current !== null ? current[segment] : void 0, target);
136
+ }
137
+ function hasPath(target, path) {
138
+ const segments = path.split(".");
139
+ const last = segments.pop();
140
+ const parent = segments.length === 0 ? target : getPath(target, segments.join("."));
141
+ return typeof parent === "object" && parent !== null && Object.hasOwn(parent, last);
142
+ }
143
+ function setPath(target, path, value) {
144
+ const segments = path.split(".");
145
+ const last = segments.pop();
146
+ let current = target;
147
+ for (const segment of segments) {
148
+ if (typeof current[segment] !== "object" || current[segment] === null) current[segment] = {};
149
+ current = current[segment];
150
+ }
151
+ current[last] = value;
152
+ return target;
153
+ }
154
+ function createForm(initial) {
155
+ const resolve = () => clone(typeof initial === "function" ? initial() : initial);
156
+ const listeners = /* @__PURE__ */ new Set();
157
+ let data = resolve();
158
+ let defaults = clone(data);
159
+ let errors = {};
160
+ let processing = false;
161
+ let progress = null;
162
+ let wasSuccessful = false;
163
+ let recentlySuccessful = false;
164
+ let recentlyTimer;
165
+ let transformer = (value) => value;
166
+ let cancelToken;
167
+ let defaultsSetInOnSuccess = false;
168
+ const notify = () => {
169
+ for (const listener of [...listeners]) listener();
170
+ };
171
+ const clearErrors = (...fields) => {
172
+ errors = fields.length === 0 ? {} : Object.fromEntries(Object.entries(errors).filter(([field]) => !fields.includes(field)));
173
+ notify();
174
+ };
175
+ const setError = (fieldOrErrors, message) => {
176
+ errors = { ...errors, ...typeof fieldOrErrors === "string" ? { [fieldOrErrors]: message ?? "" } : fieldOrErrors };
177
+ notify();
178
+ };
179
+ const reset = (...fields) => {
180
+ const source = typeof initial === "function" ? resolve() : clone(defaults);
181
+ if (fields.length === 0) {
182
+ if (typeof initial === "function") defaults = clone(source);
183
+ data = source;
184
+ } else {
185
+ const next = { ...data };
186
+ for (const field of fields) if (hasPath(source, field)) setPath(next, field, getPath(source, field));
187
+ data = next;
188
+ }
189
+ notify();
190
+ };
191
+ const submit = (method, url, options = {}) => {
192
+ defaultsSetInOnSuccess = false;
193
+ const payload = transformer(data);
194
+ const visit = {
195
+ ...options,
196
+ onCancelToken: (token) => {
197
+ cancelToken = token;
198
+ return options.onCancelToken?.(token);
199
+ },
200
+ onBefore: (pending) => {
201
+ wasSuccessful = false;
202
+ recentlySuccessful = false;
203
+ clearTimeout(recentlyTimer);
204
+ return options.onBefore?.(pending);
205
+ },
206
+ onStart: (pending) => {
207
+ processing = true;
208
+ notify();
209
+ return options.onStart?.(pending);
210
+ },
211
+ onProgress: (event) => {
212
+ progress = event ?? null;
213
+ notify();
214
+ return options.onProgress?.(event);
215
+ },
216
+ onSuccess: async (page) => {
217
+ errors = {};
218
+ wasSuccessful = true;
219
+ recentlySuccessful = true;
220
+ recentlyTimer = setTimeout(() => {
221
+ recentlySuccessful = false;
222
+ notify();
223
+ }, config.get("form.recentlySuccessfulDuration"));
224
+ notify();
225
+ const result = await options.onSuccess?.(page);
226
+ if (!defaultsSetInOnSuccess) defaults = clone(data);
227
+ notify();
228
+ return result;
229
+ },
230
+ onError: (received) => {
231
+ errors = Object.fromEntries(Object.entries(received).map(([field, value]) => [field, Array.isArray(value) ? String(value[0] ?? "") : String(value)]));
232
+ notify();
233
+ return options.onError?.(received);
234
+ },
235
+ onCancel: () => options.onCancel?.(),
236
+ onFinish: (visitInfo) => {
237
+ processing = false;
238
+ progress = null;
239
+ cancelToken = void 0;
240
+ notify();
241
+ return options.onFinish?.(visitInfo);
242
+ }
243
+ };
244
+ if (method === "delete") router.delete(url, { ...visit, data: payload });
245
+ else router[method](url, payload, visit);
246
+ };
247
+ const helper = {
248
+ get data() {
249
+ return data;
250
+ },
251
+ get defaults() {
252
+ return defaults;
253
+ },
254
+ get errors() {
255
+ return errors;
256
+ },
257
+ get hasErrors() {
258
+ return Object.keys(errors).length > 0;
259
+ },
260
+ get isDirty() {
261
+ return !equal(data, defaults);
262
+ },
263
+ get processing() {
264
+ return processing;
265
+ },
266
+ get progress() {
267
+ return progress;
268
+ },
269
+ get wasSuccessful() {
270
+ return wasSuccessful;
271
+ },
272
+ get recentlySuccessful() {
273
+ return recentlySuccessful;
274
+ },
275
+ subscribe(listener) {
276
+ listeners.add(listener);
277
+ return () => void listeners.delete(listener);
278
+ },
279
+ setData(keyOrData, value) {
280
+ if (typeof keyOrData === "string") data = setPath({ ...data }, keyOrData, value);
281
+ else if (typeof keyOrData === "function") data = keyOrData(data);
282
+ else data = { ...data, ...keyOrData };
283
+ notify();
284
+ },
285
+ setDefaults(keyOrFields, value) {
286
+ defaultsSetInOnSuccess = true;
287
+ if (keyOrFields === void 0) defaults = clone(data);
288
+ else if (typeof keyOrFields === "string") defaults = setPath(clone(defaults), keyOrFields, value);
289
+ else defaults = { ...clone(defaults), ...keyOrFields };
290
+ notify();
291
+ },
292
+ reset,
293
+ clearErrors,
294
+ resetAndClearErrors(...fields) {
295
+ reset(...fields);
296
+ clearErrors(...fields);
297
+ },
298
+ setError,
299
+ transform(callback) {
300
+ transformer = callback;
301
+ },
302
+ submit,
303
+ get: (url, options) => submit("get", url, options),
304
+ post: (url, options) => submit("post", url, options),
305
+ put: (url, options) => submit("put", url, options),
306
+ patch: (url, options) => submit("patch", url, options),
307
+ delete: (url, options) => submit("delete", url, options),
308
+ cancel() {
309
+ cancelToken?.cancel();
310
+ }
311
+ };
312
+ return helper;
313
+ }
314
+ export {
315
+ RouteError,
316
+ createForm,
317
+ currentRoute,
318
+ defineRoutes,
319
+ hasRoute,
320
+ isCurrentRoute,
321
+ route,
322
+ router2 as router
323
+ };
324
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../index.ts","../browser.ts","../routes.ts","../form.ts"],"sourcesContent":["export { router } from '@inertiajs/core'\nexport type { Errors as InertiaErrors, Method, Page, Progress, VisitOptions } from '@inertiajs/core'\nexport type { ErrorBags, Errors, PageName, PageProps, Pages, SharedProps, SharedPropsRegistry, TypedPage } from './types'\nexport {\n currentRoute,\n defineRoutes,\n hasRoute,\n isCurrentRoute,\n route,\n RouteError,\n type RouteArguments,\n type RouteDefinition,\n type RouteList,\n type RouteName,\n type RouteParameter,\n type RouteParameters,\n type RouteTable,\n} from './routes'\nexport { createForm, type FormHelper, type FormState, type FormSubmitOptions } from './form'\nexport type { AdapterForm, LinkProps, LinkVisitOptions, OrielClientApi, UsePage } from './adapter'\n","/**\n * The few browser globals this package reads, typed structurally so the package compiles both against the DOM\n * lib (its own build) and without it (the monorepo's Node program). Nothing here exists during SSR.\n */\ninterface BrowserLocation {\n readonly origin: string\n readonly pathname: string\n readonly search: string\n readonly href: string\n}\n\nexport function browserLocation(): BrowserLocation | undefined {\n return (globalThis as { location?: BrowserLocation }).location\n}\n","import { browserLocation } from './browser'\n\n/** Route name → its parameters. Augmented by the generated routes module (oriel route:types). */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface RouteList {}\n\n/** A route name: the generated ones, or any string before types are generated. */\nexport type RouteName = [keyof RouteList] extends [never] ? string : Extract<keyof RouteList, string>\n\n/** A parameter value: a scalar, or a model-like object (its `id`, or the {post:slug} field, is used). */\nexport type RouteParameter = string | number | boolean | { readonly [key: string]: unknown }\n\ntype ParametersOf<N> = N extends keyof RouteList ? RouteList[N] : Record<string, RouteParameter>\ntype RequiredKeys<T> = { [K in keyof T]-?: Record<never, never> extends Pick<T, K> ? never : K }[keyof T]\n\n/** Named parameters (extras become the query string), one value, or values in URI order. */\nexport type RouteParameters<N> = (ParametersOf<N> & Record<string, unknown>) | RouteParameter | RouteParameter[]\n\n/** route(name) is allowed only when the route has no required parameters. */\nexport type RouteArguments<N> = [RequiredKeys<ParametersOf<N>>] extends [never]\n ? [parameters?: RouteParameters<N>, absolute?: boolean]\n : [parameters: RouteParameters<N>, absolute?: boolean]\n\n/** One named route: its URI (Laravel syntax) and methods. */\nexport interface RouteDefinition {\n readonly uri: string\n readonly methods: readonly string[]\n}\nexport type RouteTable = Readonly<Record<string, RouteDefinition>>\n\nconst PARAMETER = /\\{(\\w+)(?::(\\w+))?(\\?)?\\}/g\nconst WHOLE_OPTIONAL = /^\\{(\\w+)(?::\\w+)?\\?\\}$/\nconst TABLE = Symbol.for('oriel:inertia.routes')\n\nconst registry = (): { table: RouteTable } => {\n const globals = globalThis as unknown as Record<symbol, { table: RouteTable } | undefined>\n return (globals[TABLE] ??= { table: {} })\n}\n\n/** Registers the route table (the generated routes module calls this) and returns it. */\nexport function defineRoutes<const T extends RouteTable>(table: T): T {\n registry().table = table\n return table\n}\n\nexport class RouteError extends Error {\n override readonly name = 'RouteError'\n}\n\nconst isPlainObject = (value: unknown): value is Record<string, unknown> => {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) return false\n const prototype = Object.getPrototypeOf(value) as unknown\n return prototype === Object.prototype || prototype === null\n}\n\n/** PHP's http_build_query, like the server's UrlGenerator: a[b]=1&a[0]=2, booleans as 1/0. */\nfunction buildQuery(values: Record<string, unknown>): string {\n const pairs: string[] = []\n const add = (key: string, value: unknown): void => {\n if (value === null || value === undefined) return\n if (typeof value === 'object' && (Array.isArray(value) || isPlainObject(value))) {\n for (const [child, nested] of Object.entries(value)) add(`${key}[${child}]`, nested)\n return\n }\n const text = value === true ? '1' : value === false ? '0' : String(value)\n pairs.push(`${encodeURIComponent(key)}=${encodeURIComponent(text)}`)\n }\n for (const [key, value] of Object.entries(values)) add(key, value)\n return pairs.join('&')\n}\n\n/** A model-like object's URL value: the {post:slug} field, else `id`; scalars as they are. */\nfunction routeKey(value: unknown, field: string | undefined): unknown {\n if (typeof value !== 'object' || value === null) return value\n const object = value as Record<string, unknown>\n return field !== undefined ? object[field] : object.id\n}\n\nfunction parametersOf(uri: string): Array<{ name: string; field: string | undefined; optional: boolean }> {\n return [...uri.matchAll(PARAMETER)].map((match) => ({ name: match[1]!, field: match[2], optional: match[3] === '?' }))\n}\n\n/**\n * The URL of a named route, like the server's route(): route('posts.show', post), route('posts.show', { post: 1,\n * page: 2 }), route('posts.show', [post, comment]). Relative ('/posts/1') unless `absolute` is true.\n */\nexport function route<N extends RouteName>(name: N, ...[parameters, absolute = false]: RouteArguments<N>): string {\n const definition = registry().table[name]\n if (definition === undefined) throw new RouteError(`Route [${name}] not defined.`)\n const declared = parametersOf(definition.uri)\n // A lone model-like object (route('posts.show', post)) is the value of the route's only parameter, when that\n // parameter is required. For an optional one the server reads the object's keys as the query, and so does this.\n const only = declared.length === 1 && !declared[0]!.optional ? declared[0]! : undefined\n const isModel = only !== undefined && isPlainObject(parameters) && !Object.hasOwn(parameters, only.name) && Object.hasOwn(parameters, only.field ?? 'id')\n const named: Record<string, unknown> = isModel ? { [only.name]: parameters } : isPlainObject(parameters) ? { ...parameters } : {}\n const positional: unknown[] = Array.isArray(parameters) ? [...parameters] : parameters === undefined || parameters === null || isPlainObject(parameters) ? [] : [parameters]\n\n const values = new Map<string, string | undefined>()\n const missing: string[] = []\n for (const parameter of declared) {\n let value: unknown\n if (Object.hasOwn(named, parameter.name)) {\n value = named[parameter.name]\n delete named[parameter.name]\n } else if (positional.length > 0) {\n value = positional.shift()\n }\n const key = routeKey(value, parameter.field)\n const text = key === undefined || key === null ? undefined : String(key)\n if (text === undefined && !parameter.optional) missing.push(parameter.name)\n values.set(parameter.name, text)\n }\n if (missing.length > 0) {\n throw new RouteError(`Missing required parameter for [Route: ${name}] [URI: ${definition.uri}] [Missing parameter: ${missing.join(', ')}].`)\n }\n\n const path =\n definition.uri === '/'\n ? ''\n : definition.uri\n .split('/')\n .filter((segment) => {\n const whole = WHOLE_OPTIONAL.exec(segment)\n return whole === null || values.get(whole[1]!) !== undefined\n })\n .map((segment) => segment.replace(PARAMETER, (_match, parameter: string) => encodeURIComponent(values.get(parameter) ?? '')))\n .join('/')\n const query = buildQuery(named)\n const relative = `/${path.replace(/^\\/+|\\/+$/g, '')}${query === '' ? '' : `?${query}`}`\n if (!absolute) return relative\n return `${browserLocation()?.origin ?? ''}${relative}`\n}\n\n/** Is `name` a registered route? */\nexport function hasRoute(name: string): boolean {\n return Object.hasOwn(registry().table, name)\n}\n\nconst escape = (text: string): string => text.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n\n/** A regex for the paths a URI matches: parameters match one segment, whole optional segments may be absent. */\nfunction uriPattern(uri: string): RegExp {\n const segments = uri.replace(/^\\/+|\\/+$/g, '').split('/').filter((segment) => segment !== '')\n const body = segments\n .map((segment) => {\n if (WHOLE_OPTIONAL.test(segment)) return '(?:/[^/]+)?'\n return `/${segment\n .split(PARAMETER)\n .map((part, index) => (index % 4 === 0 ? escape(part) : index % 4 === 1 ? '[^/]+' : ''))\n .join('')}`\n })\n .join('')\n return new RegExp(`^${body === '' ? '/' : body}/?$`)\n}\n\n/** The name of the GET route matching the browser's current path, or undefined (also during SSR). */\nexport function currentRoute(): string | undefined {\n const location = browserLocation()\n if (location === undefined) return undefined\n for (const [name, definition] of Object.entries(registry().table)) {\n if (definition.methods.includes('GET') && uriPattern(definition.uri).test(location.pathname)) return name\n }\n return undefined\n}\n\n/** 'posts.*' style wildcard match. */\nfunction matches(pattern: string, name: string): boolean {\n return new RegExp(`^${pattern.split('*').map(escape).join('.*')}$`).test(name)\n}\n\n/** Does the current route match one of the names or wildcard patterns ('posts.*')? */\nexport function isCurrentRoute(...patterns: string[]): boolean {\n const current = currentRoute()\n return current !== undefined && patterns.some((pattern) => matches(pattern, current))\n}\n","import { config, router, type Errors, type Method, type Page, type Progress, type RequestPayload, type VisitOptions } from '@inertiajs/core'\n\ntype Data = Record<string, unknown>\ntype Listener = () => void\n\n/** Form options passed through to the visit; the helper wraps the callbacks. */\nexport type FormSubmitOptions = Omit<VisitOptions, 'data'>\n\n/** The state a form helper exposes (what React's useForm returns, minus the framework plumbing). */\nexport interface FormState<T extends Data> {\n readonly data: T\n readonly defaults: T\n readonly errors: Partial<Record<keyof T | string, string>>\n readonly hasErrors: boolean\n readonly isDirty: boolean\n readonly processing: boolean\n readonly progress: Progress | null\n readonly wasSuccessful: boolean\n readonly recentlySuccessful: boolean\n}\n\n/**\n * A framework-agnostic form helper on the real Inertia router: the core that Solid and Angular adapters wrap in\n * signals (React, Vue and Svelte use the official useForm). Every change notifies subscribers.\n */\nexport interface FormHelper<T extends Data> extends FormState<T> {\n subscribe(listener: Listener): () => void\n setData(key: keyof T & string, value: unknown): void\n setData(data: Partial<T> | ((data: T) => T)): void\n setDefaults(): void\n setDefaults(key: keyof T & string, value: unknown): void\n setDefaults(fields: Partial<T>): void\n reset(...fields: Array<keyof T & string>): void\n clearErrors(...fields: Array<keyof T & string>): void\n resetAndClearErrors(...fields: Array<keyof T & string>): void\n setError(field: keyof T & string, message: string): void\n setError(errors: Record<string, string>): void\n transform(callback: (data: T) => Data): void\n submit(method: Method, url: string, options?: FormSubmitOptions): void\n get(url: string, options?: FormSubmitOptions): void\n post(url: string, options?: FormSubmitOptions): void\n put(url: string, options?: FormSubmitOptions): void\n patch(url: string, options?: FormSubmitOptions): void\n delete(url: string, options?: FormSubmitOptions): void\n cancel(): void\n}\n\nconst isPlain = (value: object) => Array.isArray(value) || Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null\n\n/** Deep-copies plain objects, arrays and dates; files, blobs and other instances are kept by reference so identity comparison holds. */\nfunction clone<V>(value: V): V {\n if (typeof value !== 'object' || value === null) return value\n if (value instanceof Date) return new Date(value.getTime()) as V\n if (!isPlain(value)) return value\n if (Array.isArray(value)) return value.map(clone) as V\n return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, clone(entry)])) as V\n}\n\nfunction equal(a: unknown, b: unknown): boolean {\n if (Object.is(a, b)) return true\n if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null) return false\n if (a instanceof Date || b instanceof Date) return a instanceof Date && b instanceof Date && a.getTime() === b.getTime()\n if (Array.isArray(a) !== Array.isArray(b)) return false\n if (!isPlain(a) || !isPlain(b)) return false\n const keys = Object.keys(a)\n if (keys.length !== Object.keys(b).length) return false\n return keys.every((key) => Object.hasOwn(b, key) && equal((a as Data)[key], (b as Data)[key]))\n}\n\nfunction getPath(target: Data, path: string): unknown {\n return path.split('.').reduce<unknown>((current, segment) => (typeof current === 'object' && current !== null ? (current as Data)[segment] : undefined), target)\n}\n\nfunction hasPath(target: Data, path: string): boolean {\n const segments = path.split('.')\n const last = segments.pop()!\n const parent = segments.length === 0 ? target : getPath(target, segments.join('.'))\n return typeof parent === 'object' && parent !== null && Object.hasOwn(parent, last)\n}\n\nfunction setPath<V extends Data>(target: V, path: string, value: unknown): V {\n const segments = path.split('.')\n const last = segments.pop()!\n let current: Data = target\n for (const segment of segments) {\n if (typeof current[segment] !== 'object' || current[segment] === null) current[segment] = {}\n current = current[segment] as Data\n }\n current[last] = value\n return target\n}\n\n/** createForm({ title: '' }): a headless form helper (Inertia's useForm without remember or Precognition). */\nexport function createForm<T extends Data>(initial: T | (() => T)): FormHelper<T> {\n const resolve = (): T => clone(typeof initial === 'function' ? (initial as () => T)() : initial)\n const listeners = new Set<Listener>()\n let data = resolve()\n let defaults = clone(data)\n let errors: Record<string, string> = {}\n let processing = false\n let progress: Progress | null = null\n let wasSuccessful = false\n let recentlySuccessful = false\n let recentlyTimer: ReturnType<typeof setTimeout> | undefined\n let transformer: (data: T) => Data = (value) => value\n let cancelToken: { cancel(): void } | undefined\n let defaultsSetInOnSuccess = false\n\n const notify = () => {\n for (const listener of [...listeners]) listener()\n }\n\n const clearErrors = (...fields: string[]) => {\n errors = fields.length === 0 ? {} : Object.fromEntries(Object.entries(errors).filter(([field]) => !fields.includes(field)))\n notify()\n }\n\n const setError = (fieldOrErrors: string | Record<string, string>, message?: string) => {\n errors = { ...errors, ...(typeof fieldOrErrors === 'string' ? { [fieldOrErrors]: message ?? '' } : fieldOrErrors) }\n notify()\n }\n\n const reset = (...fields: string[]) => {\n const source = typeof initial === 'function' ? resolve() : clone(defaults)\n if (fields.length === 0) {\n if (typeof initial === 'function') defaults = clone(source)\n data = source\n } else {\n const next = { ...data }\n for (const field of fields) if (hasPath(source, field)) setPath(next, field, getPath(source, field))\n data = next\n }\n notify()\n }\n\n const submit = (method: Method, url: string, options: FormSubmitOptions = {}) => {\n defaultsSetInOnSuccess = false\n const payload = transformer(data) as RequestPayload\n const visit: VisitOptions = {\n ...options,\n onCancelToken: (token) => {\n cancelToken = token\n return options.onCancelToken?.(token)\n },\n onBefore: (pending) => {\n wasSuccessful = false\n recentlySuccessful = false\n clearTimeout(recentlyTimer)\n return options.onBefore?.(pending)\n },\n onStart: (pending) => {\n processing = true\n notify()\n return options.onStart?.(pending)\n },\n onProgress: (event) => {\n progress = event ?? null\n notify()\n return options.onProgress?.(event)\n },\n onSuccess: async (page: Page) => {\n errors = {}\n wasSuccessful = true\n recentlySuccessful = true\n recentlyTimer = setTimeout(() => {\n recentlySuccessful = false\n notify()\n }, config.get('form.recentlySuccessfulDuration') as number)\n notify()\n const result = await options.onSuccess?.(page)\n if (!defaultsSetInOnSuccess) defaults = clone(data)\n notify()\n return result\n },\n onError: (received: Errors) => {\n errors = Object.fromEntries(Object.entries(received).map(([field, value]) => [field, Array.isArray(value) ? String(value[0] ?? '') : String(value)]))\n notify()\n return options.onError?.(received)\n },\n onCancel: () => options.onCancel?.(),\n onFinish: (visitInfo) => {\n processing = false\n progress = null\n cancelToken = undefined\n notify()\n return options.onFinish?.(visitInfo)\n },\n }\n if (method === 'delete') router.delete(url, { ...visit, data: payload })\n else router[method](url, payload, visit)\n }\n\n const helper = {\n get data() {\n return data\n },\n get defaults() {\n return defaults\n },\n get errors() {\n return errors\n },\n get hasErrors() {\n return Object.keys(errors).length > 0\n },\n get isDirty() {\n return !equal(data, defaults)\n },\n get processing() {\n return processing\n },\n get progress() {\n return progress\n },\n get wasSuccessful() {\n return wasSuccessful\n },\n get recentlySuccessful() {\n return recentlySuccessful\n },\n subscribe(listener: Listener) {\n listeners.add(listener)\n return () => void listeners.delete(listener)\n },\n setData(keyOrData: string | Partial<T> | ((data: T) => T), value?: unknown) {\n if (typeof keyOrData === 'string') data = setPath({ ...data }, keyOrData, value)\n else if (typeof keyOrData === 'function') data = keyOrData(data)\n else data = { ...data, ...keyOrData }\n notify()\n },\n setDefaults(keyOrFields?: string | Partial<T>, value?: unknown) {\n defaultsSetInOnSuccess = true\n if (keyOrFields === undefined) defaults = clone(data)\n else if (typeof keyOrFields === 'string') defaults = setPath(clone(defaults), keyOrFields, value)\n else defaults = { ...clone(defaults), ...keyOrFields }\n notify()\n },\n reset,\n clearErrors,\n resetAndClearErrors(...fields: string[]) {\n reset(...fields)\n clearErrors(...fields)\n },\n setError,\n transform(callback: (data: T) => Data) {\n transformer = callback\n },\n submit,\n get: (url: string, options?: FormSubmitOptions) => submit('get', url, options),\n post: (url: string, options?: FormSubmitOptions) => submit('post', url, options),\n put: (url: string, options?: FormSubmitOptions) => submit('put', url, options),\n patch: (url: string, options?: FormSubmitOptions) => submit('patch', url, options),\n delete: (url: string, options?: FormSubmitOptions) => submit('delete', url, options),\n cancel() {\n cancelToken?.cancel()\n },\n }\n return helper as unknown as FormHelper<T>\n}\n"],"mappings":";AAAA,SAAS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,QAAO,EAAE,GAAG,MAAM,GAAG,UAAU;AACpC,aAAO;AAAA,IACT;AAAA,IACA,YAAY,aAAmC,OAAiB;AAC9D,+BAAyB;AACzB,UAAI,gBAAgB,OAAW,YAAW,MAAM,IAAI;AAAA,eAC3C,OAAO,gBAAgB,SAAU,YAAW,QAAQ,MAAM,QAAQ,GAAG,aAAa,KAAK;AAAA,UAC3F,YAAW,EAAE,GAAG,MAAM,QAAQ,GAAG,GAAG,YAAY;AACrD,aAAO;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA,uBAAuB,QAAkB;AACvC,YAAM,GAAG,MAAM;AACf,kBAAY,GAAG,MAAM;AAAA,IACvB;AAAA,IACA;AAAA,IACA,UAAU,UAA6B;AACrC,oBAAc;AAAA,IAChB;AAAA,IACA;AAAA,IACA,KAAK,CAAC,KAAa,YAAgC,OAAO,OAAO,KAAK,OAAO;AAAA,IAC7E,MAAM,CAAC,KAAa,YAAgC,OAAO,QAAQ,KAAK,OAAO;AAAA,IAC/E,KAAK,CAAC,KAAa,YAAgC,OAAO,OAAO,KAAK,OAAO;AAAA,IAC7E,OAAO,CAAC,KAAa,YAAgC,OAAO,SAAS,KAAK,OAAO;AAAA,IACjF,QAAQ,CAAC,KAAa,YAAgC,OAAO,UAAU,KAAK,OAAO;AAAA,IACnF,SAAS;AACP,mBAAa,OAAO;AAAA,IACtB;AAAA,EACF;AACA,SAAO;AACT;","names":["router"]}
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@orieljs/inertia-client",
3
+ "version": "0.1.0-alpha.2",
4
+ "description": "The Oriel Inertia client: typed page props, route(), the form helper and the adapter contract.",
5
+ "type": "module",
6
+ "license": "Apache-2.0",
7
+ "sideEffects": false,
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/orieljs/framework.git",
11
+ "directory": "src/Oriel/InertiaClient"
12
+ },
13
+ "engines": {
14
+ "node": ">=22"
15
+ },
16
+ "types": "./dist/index.d.ts",
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "import": "./dist/index.js"
21
+ }
22
+ },
23
+ "publishConfig": {
24
+ "access": "public"
25
+ },
26
+ "files": [
27
+ "dist",
28
+ "LICENSE",
29
+ "NOTICE"
30
+ ],
31
+ "peerDependencies": {
32
+ "@inertiajs/core": "^3.7.1"
33
+ },
34
+ "devDependencies": {
35
+ "@inertiajs/core": "3.7.1"
36
+ },
37
+ "scripts": {
38
+ "build": "tsup && node ../../../scripts/copy-license.mjs"
39
+ }
40
+ }