@demokit-ai/remix 0.2.0 → 0.3.0

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,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2025 Kasava, Inc.
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
@@ -0,0 +1,161 @@
1
+ // src/fixtures.ts
2
+ import { matchUrl } from "@demokit-ai/core";
3
+ var FixtureStore = class {
4
+ constructor(config) {
5
+ this.loaders = {};
6
+ this.actions = {};
7
+ if (config?.loaders) {
8
+ this.loaders = { ...config.loaders };
9
+ }
10
+ if (config?.actions) {
11
+ this.actions = { ...config.actions };
12
+ }
13
+ }
14
+ /**
15
+ * Register a loader fixture
16
+ */
17
+ setLoader(path, handler) {
18
+ this.loaders[path] = handler;
19
+ return this;
20
+ }
21
+ /**
22
+ * Register an action fixture
23
+ */
24
+ setAction(path, handler) {
25
+ this.actions[path] = handler;
26
+ return this;
27
+ }
28
+ /**
29
+ * Get a loader fixture for a path
30
+ */
31
+ getLoader(path) {
32
+ if (path in this.loaders) {
33
+ return this.loaders[path];
34
+ }
35
+ for (const [pattern, handler] of Object.entries(this.loaders)) {
36
+ const fullPattern = pattern.startsWith("GET ") ? pattern : `GET ${pattern}`;
37
+ const result = matchUrl(fullPattern, "GET", path);
38
+ if (result) {
39
+ return handler;
40
+ }
41
+ }
42
+ return void 0;
43
+ }
44
+ /**
45
+ * Get an action fixture for a path and method
46
+ */
47
+ getAction(path, method) {
48
+ if (path in this.actions) {
49
+ return resolveActionHandler(this.actions[path], method);
50
+ }
51
+ for (const [pattern, fixture] of Object.entries(this.actions)) {
52
+ const fullPattern = /^(GET|POST|PUT|PATCH|DELETE)\s/.test(pattern) ? pattern : `${method} ${pattern}`;
53
+ const result = matchUrl(fullPattern, method, path);
54
+ if (result) {
55
+ return resolveActionHandler(fixture, method);
56
+ }
57
+ }
58
+ return void 0;
59
+ }
60
+ /**
61
+ * Find loader fixture with match info
62
+ */
63
+ findLoader(path) {
64
+ if (path in this.loaders) {
65
+ return {
66
+ handler: this.loaders[path],
67
+ match: { matched: true, params: {} }
68
+ };
69
+ }
70
+ for (const [pattern, handler] of Object.entries(this.loaders)) {
71
+ const fullPattern = pattern.startsWith("GET ") ? pattern : `GET ${pattern}`;
72
+ const result = matchUrl(fullPattern, "GET", path);
73
+ if (result) {
74
+ return { handler, match: result };
75
+ }
76
+ }
77
+ return null;
78
+ }
79
+ /**
80
+ * Find action fixture with match info
81
+ */
82
+ findAction(path, method) {
83
+ if (path in this.actions) {
84
+ const handler = resolveActionHandler(this.actions[path], method);
85
+ if (handler) {
86
+ return {
87
+ handler,
88
+ match: { matched: true, params: {} }
89
+ };
90
+ }
91
+ }
92
+ for (const [pattern, fixture] of Object.entries(this.actions)) {
93
+ const fullPattern = /^(GET|POST|PUT|PATCH|DELETE)\s/.test(pattern) ? pattern : `${method} ${pattern}`;
94
+ const result = matchUrl(fullPattern, method, path);
95
+ if (result) {
96
+ const handler = resolveActionHandler(fixture, method);
97
+ if (handler) {
98
+ return { handler, match: result };
99
+ }
100
+ }
101
+ }
102
+ return null;
103
+ }
104
+ /**
105
+ * Get all loader fixtures
106
+ */
107
+ getLoaders() {
108
+ return { ...this.loaders };
109
+ }
110
+ /**
111
+ * Get all action fixtures
112
+ */
113
+ getActions() {
114
+ return { ...this.actions };
115
+ }
116
+ /**
117
+ * Clear all fixtures
118
+ */
119
+ clear() {
120
+ this.loaders = {};
121
+ this.actions = {};
122
+ }
123
+ };
124
+ function resolveActionHandler(fixture, method) {
125
+ if (isMethodActionHandlers(fixture)) {
126
+ const upperMethod = method.toUpperCase();
127
+ return fixture[upperMethod];
128
+ }
129
+ return fixture;
130
+ }
131
+ function isMethodActionHandlers(fixture) {
132
+ if (typeof fixture !== "object" || fixture === null) {
133
+ return false;
134
+ }
135
+ const methods = ["POST", "PUT", "PATCH", "DELETE"];
136
+ return methods.some((method) => method in fixture);
137
+ }
138
+ function createFixtureStore(config) {
139
+ return new FixtureStore(config);
140
+ }
141
+ function defineRemixLoaderFixtures(fixtures) {
142
+ return fixtures;
143
+ }
144
+ function defineRemixActionFixtures(fixtures) {
145
+ return fixtures;
146
+ }
147
+ function defineRemixFixtures(config) {
148
+ return {
149
+ loaders: config.loaders ?? {},
150
+ actions: config.actions ?? {}
151
+ };
152
+ }
153
+
154
+ export {
155
+ FixtureStore,
156
+ createFixtureStore,
157
+ defineRemixLoaderFixtures,
158
+ defineRemixActionFixtures,
159
+ defineRemixFixtures
160
+ };
161
+ //# sourceMappingURL=chunk-GUQM5HE6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/fixtures.ts"],"sourcesContent":["import { matchUrl, type MatchResult } from '@demokit-ai/core'\nimport type {\n LoaderFixtureMapObject,\n ActionFixtureMapObject,\n LoaderFixtureHandler,\n ActionFixtureHandler,\n MethodActionHandlers,\n FixtureStoreConfig,\n} from './types'\n\n/**\n * Server-side fixture store for managing demo data\n *\n * Use this to centralize fixture definitions for your Remix app.\n * Works with the demo mode detection utilities.\n */\nexport class FixtureStore {\n private loaders: LoaderFixtureMapObject = {}\n private actions: ActionFixtureMapObject = {}\n\n constructor(config?: FixtureStoreConfig) {\n if (config?.loaders) {\n this.loaders = { ...config.loaders }\n }\n if (config?.actions) {\n this.actions = { ...config.actions }\n }\n }\n\n /**\n * Register a loader fixture\n */\n setLoader(path: string, handler: LoaderFixtureHandler): this {\n this.loaders[path] = handler\n return this\n }\n\n /**\n * Register an action fixture\n */\n setAction(path: string, handler: ActionFixtureHandler | MethodActionHandlers): this {\n this.actions[path] = handler\n return this\n }\n\n /**\n * Get a loader fixture for a path\n */\n getLoader(path: string): LoaderFixtureHandler | undefined {\n // Try exact match first\n if (path in this.loaders) {\n return this.loaders[path]\n }\n\n // Try pattern matching\n for (const [pattern, handler] of Object.entries(this.loaders)) {\n const fullPattern = pattern.startsWith('GET ') ? pattern : `GET ${pattern}`\n const result = matchUrl(fullPattern, 'GET', path)\n if (result) {\n return handler\n }\n }\n\n return undefined\n }\n\n /**\n * Get an action fixture for a path and method\n */\n getAction(path: string, method: string): ActionFixtureHandler | undefined {\n // Try exact match first\n if (path in this.actions) {\n return resolveActionHandler(this.actions[path], method)\n }\n\n // Try pattern matching\n for (const [pattern, fixture] of Object.entries(this.actions)) {\n const fullPattern = /^(GET|POST|PUT|PATCH|DELETE)\\s/.test(pattern)\n ? pattern\n : `${method} ${pattern}`\n const result = matchUrl(fullPattern, method, path)\n if (result) {\n return resolveActionHandler(fixture, method)\n }\n }\n\n return undefined\n }\n\n /**\n * Find loader fixture with match info\n */\n findLoader(path: string): { handler: LoaderFixtureHandler; match: MatchResult } | null {\n // Try exact match first\n if (path in this.loaders) {\n return {\n handler: this.loaders[path],\n match: { matched: true, params: {} },\n }\n }\n\n // Try pattern matching\n for (const [pattern, handler] of Object.entries(this.loaders)) {\n const fullPattern = pattern.startsWith('GET ') ? pattern : `GET ${pattern}`\n const result = matchUrl(fullPattern, 'GET', path)\n if (result) {\n return { handler, match: result }\n }\n }\n\n return null\n }\n\n /**\n * Find action fixture with match info\n */\n findAction(\n path: string,\n method: string\n ): { handler: ActionFixtureHandler; match: MatchResult } | null {\n // Try exact match first\n if (path in this.actions) {\n const handler = resolveActionHandler(this.actions[path], method)\n if (handler) {\n return {\n handler,\n match: { matched: true, params: {} },\n }\n }\n }\n\n // Try pattern matching\n for (const [pattern, fixture] of Object.entries(this.actions)) {\n const fullPattern = /^(GET|POST|PUT|PATCH|DELETE)\\s/.test(pattern)\n ? pattern\n : `${method} ${pattern}`\n const result = matchUrl(fullPattern, method, path)\n if (result) {\n const handler = resolveActionHandler(fixture, method)\n if (handler) {\n return { handler, match: result }\n }\n }\n }\n\n return null\n }\n\n /**\n * Get all loader fixtures\n */\n getLoaders(): LoaderFixtureMapObject {\n return { ...this.loaders }\n }\n\n /**\n * Get all action fixtures\n */\n getActions(): ActionFixtureMapObject {\n return { ...this.actions }\n }\n\n /**\n * Clear all fixtures\n */\n clear(): void {\n this.loaders = {}\n this.actions = {}\n }\n}\n\n/**\n * Resolve action handler based on method\n */\nfunction resolveActionHandler(\n fixture: ActionFixtureHandler | MethodActionHandlers,\n method: string\n): ActionFixtureHandler | undefined {\n if (isMethodActionHandlers(fixture)) {\n const upperMethod = method.toUpperCase() as keyof MethodActionHandlers\n return fixture[upperMethod]\n }\n return fixture\n}\n\n/**\n * Type guard for method action handlers\n */\nfunction isMethodActionHandlers(fixture: unknown): fixture is MethodActionHandlers {\n if (typeof fixture !== 'object' || fixture === null) {\n return false\n }\n const methods = ['POST', 'PUT', 'PATCH', 'DELETE']\n return methods.some((method) => method in fixture)\n}\n\n/**\n * Create a fixture store with initial fixtures\n *\n * @example\n * import { createFixtureStore } from '@demokit-ai/remix/server'\n *\n * export const fixtures = createFixtureStore({\n * loaders: {\n * '/users': [{ id: '1', name: 'Demo User' }],\n * '/users/:id': ({ params }) => ({ id: params.id, name: 'Demo User' }),\n * },\n * actions: {\n * '/users': {\n * POST: ({ formData }) => ({ id: crypto.randomUUID(), name: formData?.get('name') }),\n * },\n * '/users/:id': {\n * PUT: ({ formData }) => ({ updated: true }),\n * DELETE: ({ params }) => ({ deleted: true, id: params.id }),\n * },\n * },\n * })\n */\nexport function createFixtureStore(config?: FixtureStoreConfig): FixtureStore {\n return new FixtureStore(config)\n}\n\n/**\n * Define loader fixtures with type inference\n *\n * @example\n * const loaders = defineRemixLoaderFixtures({\n * '/users': [{ id: '1', name: 'Demo User' }],\n * '/users/:id': ({ params }) => ({ id: params.id, name: 'Demo User' }),\n * '/projects': async () => fetchDemoProjects(),\n * })\n */\nexport function defineRemixLoaderFixtures<T extends LoaderFixtureMapObject>(fixtures: T): T {\n return fixtures\n}\n\n/**\n * Define action fixtures with type inference\n *\n * @example\n * const actions = defineRemixActionFixtures({\n * '/users': {\n * POST: ({ formData }) => ({ id: crypto.randomUUID(), name: formData?.get('name') }),\n * },\n * '/users/:id': {\n * PUT: ({ formData }) => ({ updated: true }),\n * DELETE: ({ params }) => ({ deleted: true, id: params.id }),\n * },\n * })\n */\nexport function defineRemixActionFixtures<T extends ActionFixtureMapObject>(fixtures: T): T {\n return fixtures\n}\n\n/**\n * Define complete Remix fixtures (loaders + actions)\n *\n * @example\n * const { loaders, actions } = defineRemixFixtures({\n * loaders: {\n * '/users': [{ id: '1', name: 'Demo User' }],\n * },\n * actions: {\n * '/users': ({ formData }) => ({ created: true }),\n * },\n * })\n */\nexport function defineRemixFixtures<\n L extends LoaderFixtureMapObject,\n A extends ActionFixtureMapObject,\n>(config: { loaders?: L; actions?: A }): { loaders: L; actions: A } {\n return {\n loaders: (config.loaders ?? {}) as L,\n actions: (config.actions ?? {}) as A,\n }\n}\n"],"mappings":";AAAA,SAAS,gBAAkC;AAgBpC,IAAM,eAAN,MAAmB;AAAA,EAIxB,YAAY,QAA6B;AAHzC,SAAQ,UAAkC,CAAC;AAC3C,SAAQ,UAAkC,CAAC;AAGzC,QAAI,QAAQ,SAAS;AACnB,WAAK,UAAU,EAAE,GAAG,OAAO,QAAQ;AAAA,IACrC;AACA,QAAI,QAAQ,SAAS;AACnB,WAAK,UAAU,EAAE,GAAG,OAAO,QAAQ;AAAA,IACrC;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,UAAU,MAAc,SAAqC;AAC3D,SAAK,QAAQ,IAAI,IAAI;AACrB,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,UAAU,MAAc,SAA4D;AAClF,SAAK,QAAQ,IAAI,IAAI;AACrB,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,UAAU,MAAgD;AAExD,QAAI,QAAQ,KAAK,SAAS;AACxB,aAAO,KAAK,QAAQ,IAAI;AAAA,IAC1B;AAGA,eAAW,CAAC,SAAS,OAAO,KAAK,OAAO,QAAQ,KAAK,OAAO,GAAG;AAC7D,YAAM,cAAc,QAAQ,WAAW,MAAM,IAAI,UAAU,OAAO,OAAO;AACzE,YAAM,SAAS,SAAS,aAAa,OAAO,IAAI;AAChD,UAAI,QAAQ;AACV,eAAO;AAAA,MACT;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,UAAU,MAAc,QAAkD;AAExE,QAAI,QAAQ,KAAK,SAAS;AACxB,aAAO,qBAAqB,KAAK,QAAQ,IAAI,GAAG,MAAM;AAAA,IACxD;AAGA,eAAW,CAAC,SA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B,SAAS,MAAM;AACpD,YAAI,SAAS;AACX,iBAAO,EAAE,SAAS,OAAO,OAAO;AAAA,QAClC;AAAA,MACF;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,aAAqC;AACnC,WAAO,EAAE,GAAG,KAAK,QAAQ;AAAA,EAC3B;AAAA;AAAA;AAAA;AAAA,EAKA,aAAqC;AACnC,WAAO,EAAE,GAAG,KAAK,QAAQ;AAAA,EAC3B;AAAA;AAAA;AAAA;AAAA,EAKA,QAAc;AACZ,SAAK,UAAU,CAAC;AAChB,SAAK,UAAU,CAAC;AAAA,EAClB;AACF;AAKA,SAAS,qBACP,SACA,QACkC;AAClC,MAAI,uBAAuB,OAAO,GAAG;AACnC,UAAM,cAAc,OAAO,YAAY;AACvC,WAAO,QAAQ,WAAW;AAAA,EAC5B;AACA,SAAO;AACT;AAKA,SAAS,uBAAuB,SAAmD;AACjF,MAAI,OAAO,YAAY,YAAY,YAAY,MAAM;AACnD,WAAO;AAAA,EACT;AACA,QAAM,UAAU,CAAC,QAAQ,OAAO,SAAS,QAAQ;AACjD,SAAO,QAAQ,KAAK,CAAC,WAAW,UAAU,OAAO;AACnD;AAwBO,SAAS,mBAAmB,QAA2C;AAC5E,SAAO,IAAI,aAAa,MAAM;AAChC;AAYO,SAAS,0BAA4D,UAAgB;AAC1F,SAAO;AACT;AAgBO,SAAS,0BAA4D,UAAgB;AAC1F,SAAO;AACT;AAeO,SAAS,oBAGd,QAAkE;AAClE,SAAO;AAAA,IACL,SAAU,OAAO,WAAW,CAAC;AAAA,IAC7B,SAAU,OAAO,WAAW,CAAC;AAAA,EAC/B;AACF;","names":[]}
package/dist/index.cjs CHANGED
@@ -118,9 +118,9 @@ function withDemoAction(action, options) {
118
118
  // src/fixtures.ts
119
119
  var import_core = require("@demokit-ai/core");
120
120
  var FixtureStore = class {
121
- loaders = {};
122
- actions = {};
123
121
  constructor(config) {
122
+ this.loaders = {};
123
+ this.actions = {};
124
124
  if (config?.loaders) {
125
125
  this.loaders = { ...config.loaders };
126
126
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/wrappers.ts","../src/fixtures.ts","../src/provider.tsx"],"sourcesContent":["/**\n * @demokit-ai/remix\n *\n * Remix adapter for DemoKit.\n * Demo-aware loader and action mocking for Remix applications.\n *\n * Since Remix loaders run on the server, demo mode detection happens server-side\n * via cookies, headers, or environment variables. This package provides both\n * server-side utilities and client-side state management.\n *\n * ## Server-Side Usage\n *\n * For loaders and actions, use the server utilities:\n *\n * @example\n * // In your loader file\n * import { createDemoLoader } from '@demokit-ai/remix'\n * import { isDemoMode } from '@demokit-ai/remix/server'\n *\n * export const loader = createDemoLoader({\n * loader: async ({ params }) => {\n * const user = await db.users.findUnique({ where: { id: params.id } })\n * return json({ user })\n * },\n * isEnabled: isDemoMode,\n * fixture: ({ params }) => ({\n * user: { id: params.id, name: 'Demo User', email: 'demo@example.com' }\n * }),\n * })\n *\n * @example\n * // Action with method-specific fixtures\n * import { createDemoAction } from '@demokit-ai/remix'\n * import { isDemoMode } from '@demokit-ai/remix/server'\n *\n * export const action = createDemoAction({\n * action: async ({ request }) => {\n * const formData = await request.formData()\n * return json(await db.users.update({ ... }))\n * },\n * isEnabled: isDemoMode,\n * fixture: {\n * PUT: ({ formData }) => json({ updated: true, name: formData?.get('name') }),\n * DELETE: ({ params }) => json({ deleted: true, id: params.id }),\n * },\n * })\n *\n * ## Direct Demo Mode Check\n *\n * For more control, use isDemoMode directly:\n *\n * @example\n * import { isDemoMode, getDemoData } from '@demokit-ai/remix/server'\n *\n * export async function loader({ request, params }: LoaderFunctionArgs) {\n * if (isDemoMode(request)) {\n * return json({\n * user: { id: params.id, name: 'Demo User' }\n * })\n * }\n * return json({\n * user: await db.users.findFirst({ where: { id: params.id } })\n * })\n * }\n *\n * ## Fixture Store (Centralized)\n *\n * For larger apps, use a centralized fixture store:\n *\n * @example\n * // In entry.server.tsx or root.tsx loader\n * import { setupDemoFixtures } from '@demokit-ai/remix/server'\n *\n * setupDemoFixtures({\n * loaders: {\n * '/users': [{ id: '1', name: 'Demo User' }],\n * '/users/:id': ({ params }) => ({ id: params.id, name: 'Demo User' }),\n * '/projects': async () => fetchDemoProjects(),\n * },\n * actions: {\n * '/users': {\n * POST: ({ formData }) => ({ id: crypto.randomUUID(), name: formData?.get('name') }),\n * },\n * },\n * })\n *\n * ## Client-Side State (Optional)\n *\n * For client-side demo mode toggle UI:\n *\n * @example\n * import { DemoRemixProvider, useDemoRemix } from '@demokit-ai/remix'\n *\n * export default function App() {\n * return (\n * <DemoRemixProvider enabled={isDemoFromCookie}>\n * <Outlet />\n * <DemoControls />\n * </DemoRemixProvider>\n * )\n * }\n *\n * function DemoControls() {\n * const { enabled, toggle } = useDemoRemix()\n * return (\n * <button onClick={toggle}>\n * Demo: {enabled ? 'ON' : 'OFF'}\n * </button>\n * )\n * }\n *\n * ## Cookie-Based Demo Mode\n *\n * Enable demo mode via URL parameter or cookie:\n *\n * @example\n * // Enable with URL: /any-page?demo=true\n * // Enable with cookie: Set 'demokit-demo-mode=true' cookie\n * // Enable with header: Set 'x-demokit-demo-mode: true' header\n * // Enable globally: Set DEMOKIT_DEMO_MODE=true env var\n *\n * @packageDocumentation\n */\n\n// Wrapper utilities (client + server compatible)\nexport { createDemoLoader, createDemoAction, withDemoLoader, withDemoAction } from './wrappers'\n\n// Fixture utilities\nexport {\n FixtureStore,\n createFixtureStore,\n defineRemixLoaderFixtures,\n defineRemixActionFixtures,\n defineRemixFixtures,\n} from './fixtures'\n\n// Provider and hooks (client-side)\nexport {\n DemoRemixProvider,\n useDemoRemix,\n useIsDemoRemixMode,\n useDemoRemixOptional,\n} from './provider'\n\n// Types\nexport type {\n LoaderFixtureContext,\n ActionFixtureContext,\n LoaderFixtureHandler,\n ActionFixtureHandler,\n LoaderFixtureMap,\n LoaderFixtureMapObject,\n ActionFixtureMap,\n ActionFixtureMapObject,\n MethodActionHandlers,\n CreateDemoLoaderOptions,\n CreateDemoActionOptions,\n DemoRouteOptions,\n DemoRemixState,\n DemoRemixProviderConfig,\n DemoRemixProviderProps,\n DemoModeOptions,\n FixtureStoreConfig,\n RemixResponse,\n} from './types'\n","import type { LoaderFunctionArgs, ActionFunctionArgs } from '@remix-run/node'\nimport type {\n CreateDemoLoaderOptions,\n CreateDemoActionOptions,\n LoaderFixtureContext,\n ActionFixtureContext,\n LoaderFixtureHandler,\n ActionFixtureHandler,\n MethodActionHandlers,\n} from './types'\n\n/**\n * Create a demo-aware loader function for Remix\n *\n * Returns a loader that intercepts requests when demo mode is enabled\n * and returns fixture data instead of calling the real loader.\n * Demo mode is checked server-side via cookies, headers, or request context.\n *\n * @example\n * // Basic usage with inline fixture\n * export const loader = createDemoLoader({\n * loader: async ({ params }) => {\n * const user = await db.users.findUnique({ where: { id: params.id } })\n * return json({ user })\n * },\n * isEnabled: (request) => request.headers.get('cookie')?.includes('demo=true') ?? false,\n * fixture: ({ params }) => ({\n * user: { id: params.id, name: 'Demo User', email: 'demo@example.com' }\n * }),\n * })\n *\n * @example\n * // With cookie-based detection\n * import { isDemoMode } from '@demokit-ai/remix/server'\n *\n * export const loader = createDemoLoader({\n * loader: realLoader,\n * isEnabled: (request) => isDemoMode(request),\n * fixture: demoData,\n * delay: 200, // Simulate 200ms network latency\n * })\n */\nexport function createDemoLoader<T = unknown>(\n options: CreateDemoLoaderOptions<T>\n): (args: LoaderFunctionArgs) => Promise<T> {\n const { loader, isEnabled = () => false, fixture, delay = 0, onDemo } = options\n\n return async (args: LoaderFunctionArgs): Promise<T> => {\n // Check if demo mode is enabled (async to support cookie parsing)\n const enabled = await isEnabled(args.request)\n if (!enabled) {\n return loader(args)\n }\n\n // If no fixture provided, fall back to real loader\n if (fixture === undefined) {\n return loader(args)\n }\n\n // Build context for fixture handler\n const context: LoaderFixtureContext = {\n params: args.params,\n request: args.request,\n path: new URL(args.request.url).pathname,\n }\n\n // Notify callback\n onDemo?.(context)\n\n // Apply delay if configured\n if (delay > 0) {\n await new Promise((resolve) => setTimeout(resolve, delay))\n }\n\n // Execute fixture\n return executeFixture(fixture, context)\n }\n}\n\n/**\n * Create a demo-aware action function for Remix\n *\n * Returns an action that intercepts requests when demo mode is enabled\n * and returns fixture data instead of calling the real action.\n *\n * @example\n * // Basic usage with inline fixture\n * export const action = createDemoAction({\n * action: async ({ request }) => {\n * const formData = await request.formData()\n * const user = await db.users.create({ data: Object.fromEntries(formData) })\n * return json({ user })\n * },\n * isEnabled: (request) => request.headers.get('cookie')?.includes('demo=true') ?? false,\n * fixture: async ({ formData }) => ({\n * user: { id: crypto.randomUUID(), ...Object.fromEntries(formData!) }\n * }),\n * })\n *\n * @example\n * // With method-specific fixtures\n * export const action = createDemoAction({\n * action: realAction,\n * isEnabled: isDemoMode,\n * fixture: {\n * POST: ({ formData }) => json({ created: true, id: crypto.randomUUID() }),\n * DELETE: ({ params }) => json({ deleted: true, id: params.id }),\n * },\n * })\n */\nexport function createDemoAction<T = unknown>(\n options: CreateDemoActionOptions<T>\n): (args: ActionFunctionArgs) => Promise<T> {\n const { action, isEnabled = () => false, fixture, delay = 0, onDemo } = options\n\n return async (args: ActionFunctionArgs): Promise<T> => {\n // Check if demo mode is enabled (async to support cookie parsing)\n const enabled = await isEnabled(args.request)\n if (!enabled) {\n return action(args)\n }\n\n // If no fixture provided, fall back to real action\n if (fixture === undefined) {\n return action(args)\n }\n\n // Parse form data for convenience\n let formData: FormData | undefined\n try {\n formData = await args.request.clone().formData()\n } catch {\n // Not form data, that's fine\n }\n\n // Build context for fixture handler\n const context: ActionFixtureContext = {\n params: args.params,\n request: args.request,\n path: new URL(args.request.url).pathname,\n formData,\n }\n\n // Notify callback\n onDemo?.(context)\n\n // Apply delay if configured\n if (delay > 0) {\n await new Promise((resolve) => setTimeout(resolve, delay))\n }\n\n // Check if fixture is method-specific\n if (isMethodActionHandlers(fixture)) {\n const method = args.request.method.toUpperCase() as keyof MethodActionHandlers\n const handler = fixture[method]\n if (handler) {\n return executeFixture(handler, context) as Promise<T>\n }\n // No handler for this method, fall back to real action\n return action(args)\n }\n\n // Execute fixture\n return executeFixture(fixture as ActionFixtureHandler<T>, context)\n }\n}\n\n/**\n * Execute a fixture handler (static value or function)\n */\nasync function executeFixture<T, C extends LoaderFixtureContext | ActionFixtureContext>(\n fixture: T | ((context: C) => T | Promise<T>),\n context: C\n): Promise<T> {\n if (typeof fixture === 'function') {\n return (fixture as (context: C) => T | Promise<T>)(context)\n }\n return fixture\n}\n\n/**\n * Type guard for method action handlers\n */\nfunction isMethodActionHandlers(fixture: unknown): fixture is MethodActionHandlers {\n if (typeof fixture !== 'object' || fixture === null) {\n return false\n }\n const methods = ['POST', 'PUT', 'PATCH', 'DELETE']\n return methods.some((method) => method in fixture)\n}\n\n/**\n * Helper to create a demo loader with context from request\n *\n * Simplified version that uses request-based demo mode detection.\n *\n * @example\n * import { withDemoLoader, isDemoMode } from '@demokit-ai/remix'\n *\n * export const loader = withDemoLoader(\n * async ({ params }) => {\n * return json(await db.users.findUnique({ where: { id: params.id } }))\n * },\n * {\n * isEnabled: isDemoMode,\n * fixture: ({ params }) => ({ id: params.id, name: 'Demo User' }),\n * }\n * )\n */\nexport function withDemoLoader<T = unknown>(\n loader: (args: LoaderFunctionArgs) => T | Promise<T>,\n options: Omit<CreateDemoLoaderOptions<T>, 'loader'>\n): (args: LoaderFunctionArgs) => Promise<T> {\n return createDemoLoader({ ...options, loader })\n}\n\n/**\n * Helper to create a demo action with context from request\n *\n * Simplified version that uses request-based demo mode detection.\n *\n * @example\n * import { withDemoAction, isDemoMode } from '@demokit-ai/remix'\n *\n * export const action = withDemoAction(\n * async ({ request }) => {\n * const formData = await request.formData()\n * return json(await db.users.create({ data: Object.fromEntries(formData) }))\n * },\n * {\n * isEnabled: isDemoMode,\n * fixture: ({ formData }) => ({ id: crypto.randomUUID(), name: formData?.get('name') }),\n * }\n * )\n */\nexport function withDemoAction<T = unknown>(\n action: (args: ActionFunctionArgs) => T | Promise<T>,\n options: Omit<CreateDemoActionOptions<T>, 'action'>\n): (args: ActionFunctionArgs) => Promise<T> {\n return createDemoAction({ ...options, action })\n}\n","import { matchUrl, type MatchResult } from '@demokit-ai/core'\nimport type {\n LoaderFixtureMapObject,\n ActionFixtureMapObject,\n LoaderFixtureHandler,\n ActionFixtureHandler,\n MethodActionHandlers,\n FixtureStoreConfig,\n} from './types'\n\n/**\n * Server-side fixture store for managing demo data\n *\n * Use this to centralize fixture definitions for your Remix app.\n * Works with the demo mode detection utilities.\n */\nexport class FixtureStore {\n private loaders: LoaderFixtureMapObject = {}\n private actions: ActionFixtureMapObject = {}\n\n constructor(config?: FixtureStoreConfig) {\n if (config?.loaders) {\n this.loaders = { ...config.loaders }\n }\n if (config?.actions) {\n this.actions = { ...config.actions }\n }\n }\n\n /**\n * Register a loader fixture\n */\n setLoader(path: string, handler: LoaderFixtureHandler): this {\n this.loaders[path] = handler\n return this\n }\n\n /**\n * Register an action fixture\n */\n setAction(path: string, handler: ActionFixtureHandler | MethodActionHandlers): this {\n this.actions[path] = handler\n return this\n }\n\n /**\n * Get a loader fixture for a path\n */\n getLoader(path: string): LoaderFixtureHandler | undefined {\n // Try exact match first\n if (path in this.loaders) {\n return this.loaders[path]\n }\n\n // Try pattern matching\n for (const [pattern, handler] of Object.entries(this.loaders)) {\n const fullPattern = pattern.startsWith('GET ') ? pattern : `GET ${pattern}`\n const result = matchUrl(fullPattern, 'GET', path)\n if (result) {\n return handler\n }\n }\n\n return undefined\n }\n\n /**\n * Get an action fixture for a path and method\n */\n getAction(path: string, method: string): ActionFixtureHandler | undefined {\n // Try exact match first\n if (path in this.actions) {\n return resolveActionHandler(this.actions[path], method)\n }\n\n // Try pattern matching\n for (const [pattern, fixture] of Object.entries(this.actions)) {\n const fullPattern = /^(GET|POST|PUT|PATCH|DELETE)\\s/.test(pattern)\n ? pattern\n : `${method} ${pattern}`\n const result = matchUrl(fullPattern, method, path)\n if (result) {\n return resolveActionHandler(fixture, method)\n }\n }\n\n return undefined\n }\n\n /**\n * Find loader fixture with match info\n */\n findLoader(path: string): { handler: LoaderFixtureHandler; match: MatchResult } | null {\n // Try exact match first\n if (path in this.loaders) {\n return {\n handler: this.loaders[path],\n match: { matched: true, params: {} },\n }\n }\n\n // Try pattern matching\n for (const [pattern, handler] of Object.entries(this.loaders)) {\n const fullPattern = pattern.startsWith('GET ') ? pattern : `GET ${pattern}`\n const result = matchUrl(fullPattern, 'GET', path)\n if (result) {\n return { handler, match: result }\n }\n }\n\n return null\n }\n\n /**\n * Find action fixture with match info\n */\n findAction(\n path: string,\n method: string\n ): { handler: ActionFixtureHandler; match: MatchResult } | null {\n // Try exact match first\n if (path in this.actions) {\n const handler = resolveActionHandler(this.actions[path], method)\n if (handler) {\n return {\n handler,\n match: { matched: true, params: {} },\n }\n }\n }\n\n // Try pattern matching\n for (const [pattern, fixture] of Object.entries(this.actions)) {\n const fullPattern = /^(GET|POST|PUT|PATCH|DELETE)\\s/.test(pattern)\n ? pattern\n : `${method} ${pattern}`\n const result = matchUrl(fullPattern, method, path)\n if (result) {\n const handler = resolveActionHandler(fixture, method)\n if (handler) {\n return { handler, match: result }\n }\n }\n }\n\n return null\n }\n\n /**\n * Get all loader fixtures\n */\n getLoaders(): LoaderFixtureMapObject {\n return { ...this.loaders }\n }\n\n /**\n * Get all action fixtures\n */\n getActions(): ActionFixtureMapObject {\n return { ...this.actions }\n }\n\n /**\n * Clear all fixtures\n */\n clear(): void {\n this.loaders = {}\n this.actions = {}\n }\n}\n\n/**\n * Resolve action handler based on method\n */\nfunction resolveActionHandler(\n fixture: ActionFixtureHandler | MethodActionHandlers,\n method: string\n): ActionFixtureHandler | undefined {\n if (isMethodActionHandlers(fixture)) {\n const upperMethod = method.toUpperCase() as keyof MethodActionHandlers\n return fixture[upperMethod]\n }\n return fixture\n}\n\n/**\n * Type guard for method action handlers\n */\nfunction isMethodActionHandlers(fixture: unknown): fixture is MethodActionHandlers {\n if (typeof fixture !== 'object' || fixture === null) {\n return false\n }\n const methods = ['POST', 'PUT', 'PATCH', 'DELETE']\n return methods.some((method) => method in fixture)\n}\n\n/**\n * Create a fixture store with initial fixtures\n *\n * @example\n * import { createFixtureStore } from '@demokit-ai/remix/server'\n *\n * export const fixtures = createFixtureStore({\n * loaders: {\n * '/users': [{ id: '1', name: 'Demo User' }],\n * '/users/:id': ({ params }) => ({ id: params.id, name: 'Demo User' }),\n * },\n * actions: {\n * '/users': {\n * POST: ({ formData }) => ({ id: crypto.randomUUID(), name: formData?.get('name') }),\n * },\n * '/users/:id': {\n * PUT: ({ formData }) => ({ updated: true }),\n * DELETE: ({ params }) => ({ deleted: true, id: params.id }),\n * },\n * },\n * })\n */\nexport function createFixtureStore(config?: FixtureStoreConfig): FixtureStore {\n return new FixtureStore(config)\n}\n\n/**\n * Define loader fixtures with type inference\n *\n * @example\n * const loaders = defineRemixLoaderFixtures({\n * '/users': [{ id: '1', name: 'Demo User' }],\n * '/users/:id': ({ params }) => ({ id: params.id, name: 'Demo User' }),\n * '/projects': async () => fetchDemoProjects(),\n * })\n */\nexport function defineRemixLoaderFixtures<T extends LoaderFixtureMapObject>(fixtures: T): T {\n return fixtures\n}\n\n/**\n * Define action fixtures with type inference\n *\n * @example\n * const actions = defineRemixActionFixtures({\n * '/users': {\n * POST: ({ formData }) => ({ id: crypto.randomUUID(), name: formData?.get('name') }),\n * },\n * '/users/:id': {\n * PUT: ({ formData }) => ({ updated: true }),\n * DELETE: ({ params }) => ({ deleted: true, id: params.id }),\n * },\n * })\n */\nexport function defineRemixActionFixtures<T extends ActionFixtureMapObject>(fixtures: T): T {\n return fixtures\n}\n\n/**\n * Define complete Remix fixtures (loaders + actions)\n *\n * @example\n * const { loaders, actions } = defineRemixFixtures({\n * loaders: {\n * '/users': [{ id: '1', name: 'Demo User' }],\n * },\n * actions: {\n * '/users': ({ formData }) => ({ created: true }),\n * },\n * })\n */\nexport function defineRemixFixtures<\n L extends LoaderFixtureMapObject,\n A extends ActionFixtureMapObject,\n>(config: { loaders?: L; actions?: A }): { loaders: L; actions: A } {\n return {\n loaders: (config.loaders ?? {}) as L,\n actions: (config.actions ?? {}) as A,\n }\n}\n","import { createContext, useContext, useMemo, useState, useCallback } from 'react'\nimport type {\n DemoRemixProviderProps,\n DemoRemixState,\n LoaderFixtureMap,\n ActionFixtureMap,\n LoaderFixtureMapObject,\n ActionFixtureMapObject,\n LoaderFixtureHandler,\n ActionFixtureHandler,\n} from './types'\n\n/**\n * Context value for demo remix state\n */\ninterface DemoRemixContextValue extends DemoRemixState {\n /** Enable demo mode */\n enable: () => void\n /** Disable demo mode */\n disable: () => void\n /** Toggle demo mode */\n toggle: () => boolean\n /** Set a loader fixture */\n setLoader: (path: string, handler: LoaderFixtureHandler) => void\n /** Remove a loader fixture */\n removeLoader: (path: string) => void\n /** Set an action fixture */\n setAction: (path: string, handler: ActionFixtureHandler) => void\n /** Remove an action fixture */\n removeAction: (path: string) => void\n /** Clear all fixtures */\n clearFixtures: () => void\n /** Get delay setting */\n delay: number\n}\n\nconst DemoRemixContext = createContext<DemoRemixContextValue | null>(null)\n\n/**\n * Convert object fixture map to Map\n */\nfunction toLoaderMap(obj?: LoaderFixtureMapObject): LoaderFixtureMap {\n if (!obj) return new Map()\n return new Map(Object.entries(obj))\n}\n\n/**\n * Convert object fixture map to Map\n */\nfunction toActionMap(obj?: ActionFixtureMapObject): ActionFixtureMap {\n if (!obj) return new Map()\n return new Map(Object.entries(obj))\n}\n\n/**\n * Provider for demo remix state (client-side)\n *\n * Wrap your Remix app with this provider to enable client-side fixture management\n * and demo mode toggle. For server-side demo mode detection, use the server utilities.\n *\n * @example\n * import { DemoRemixProvider } from '@demokit-ai/remix'\n *\n * const loaders = {\n * '/users': [{ id: '1', name: 'Demo User' }],\n * '/users/:id': ({ params }) => ({ id: params.id, name: 'Demo User' }),\n * }\n *\n * const actions = {\n * '/users': ({ formData }) => ({\n * id: crypto.randomUUID(),\n * name: formData?.get('name'),\n * }),\n * }\n *\n * export default function App() {\n * return (\n * <DemoRemixProvider loaders={loaders} actions={actions} enabled>\n * <Outlet />\n * </DemoRemixProvider>\n * )\n * }\n */\nexport function DemoRemixProvider({\n children,\n enabled: initialEnabled = false,\n loaders: initialLoaders,\n actions: initialActions,\n delay = 0,\n}: DemoRemixProviderProps) {\n const [enabled, setEnabled] = useState(initialEnabled)\n const [loaders, setLoaders] = useState<LoaderFixtureMap>(() => toLoaderMap(initialLoaders))\n const [actions, setActions] = useState<ActionFixtureMap>(() => toActionMap(initialActions))\n\n const enable = useCallback(() => setEnabled(true), [])\n const disable = useCallback(() => setEnabled(false), [])\n const toggle = useCallback(() => {\n setEnabled((prev) => !prev)\n return !enabled\n }, [enabled])\n\n const setLoader = useCallback((path: string, handler: LoaderFixtureHandler) => {\n setLoaders((prev) => new Map(prev).set(path, handler))\n }, [])\n\n const removeLoader = useCallback((path: string) => {\n setLoaders((prev) => {\n const next = new Map(prev)\n next.delete(path)\n return next\n })\n }, [])\n\n const setAction = useCallback((path: string, handler: ActionFixtureHandler) => {\n setActions((prev) => new Map(prev).set(path, handler))\n }, [])\n\n const removeAction = useCallback((path: string) => {\n setActions((prev) => {\n const next = new Map(prev)\n next.delete(path)\n return next\n })\n }, [])\n\n const clearFixtures = useCallback(() => {\n setLoaders(new Map())\n setActions(new Map())\n }, [])\n\n const value = useMemo<DemoRemixContextValue>(\n () => ({\n enabled,\n loaders,\n actions,\n delay,\n enable,\n disable,\n toggle,\n setLoader,\n removeLoader,\n setAction,\n removeAction,\n clearFixtures,\n }),\n [\n enabled,\n loaders,\n actions,\n delay,\n enable,\n disable,\n toggle,\n setLoader,\n removeLoader,\n setAction,\n removeAction,\n clearFixtures,\n ]\n )\n\n return <DemoRemixContext.Provider value={value}>{children}</DemoRemixContext.Provider>\n}\n\n/**\n * Hook to access demo remix state and controls\n *\n * @example\n * function DemoModeToggle() {\n * const { enabled, toggle } = useDemoRemix()\n * return (\n * <button onClick={toggle}>\n * Demo Mode: {enabled ? 'ON' : 'OFF'}\n * </button>\n * )\n * }\n */\nexport function useDemoRemix(): DemoRemixContextValue {\n const context = useContext(DemoRemixContext)\n if (!context) {\n throw new Error('useDemoRemix must be used within a DemoRemixProvider')\n }\n return context\n}\n\n/**\n * Hook to check if demo mode is enabled\n *\n * @example\n * function DataDisplay() {\n * const isDemo = useIsDemoRemixMode()\n * return isDemo ? <DemoBanner /> : null\n * }\n */\nexport function useIsDemoRemixMode(): boolean {\n const context = useContext(DemoRemixContext)\n return context?.enabled ?? false\n}\n\n/**\n * Get the demo remix context (may be null if not in provider)\n *\n * Use this for optional demo mode integration.\n */\nexport function useDemoRemixOptional(): DemoRemixContextValue | null {\n return useContext(DemoRemixContext)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC0CO,SAAS,iBACd,SAC0C;AAC1C,QAAM,EAAE,QAAQ,YAAY,MAAM,OAAO,SAAS,QAAQ,GAAG,OAAO,IAAI;AAExE,SAAO,OAAO,SAAyC;AAErD,UAAM,UAAU,MAAM,UAAU,KAAK,OAAO;AAC5C,QAAI,CAAC,SAAS;AACZ,aAAO,OAAO,IAAI;AAAA,IACpB;AAGA,QAAI,YAAY,QAAW;AACzB,aAAO,OAAO,IAAI;AAAA,IACpB;AAGA,UAAM,UAAgC;AAAA,MACpC,QAAQ,KAAK;AAAA,MACb,SAAS,KAAK;AAAA,MACd,MAAM,IAAI,IAAI,KAAK,QAAQ,GAAG,EAAE;AAAA,IAClC;AAGA,aAAS,OAAO;AAGhB,QAAI,QAAQ,GAAG;AACb,YAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,KAAK,CAAC;AAAA,IAC3D;AAGA,WAAO,eAAe,SAAS,OAAO;AAAA,EACxC;AACF;AAiCO,SAAS,iBACd,SAC0C;AAC1C,QAAM,EAAE,QAAQ,YAAY,MAAM,OAAO,SAAS,QAAQ,GAAG,OAAO,IAA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AM;AACtC,eAAW,oBAAI,IAAI,CAAC;AACpB,eAAW,oBAAI,IAAI,CAAC;AAAA,EACtB,GAAG,CAAC,CAAC;AAEL,QAAM,YAAQ;AAAA,IACZ,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO,4CAAC,iBAAiB,UAAjB,EAA0B,OAAe,UAAS;AAC5D;AAeO,SAAS,eAAsC;AACpD,QAAM,cAAU,yBAAW,gBAAgB;AAC3C,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,sDAAsD;AAAA,EACxE;AACA,SAAO;AACT;AAWO,SAAS,qBAA8B;AAC5C,QAAM,cAAU,yBAAW,gBAAgB;AAC3C,SAAO,SAAS,WAAW;AAC7B;AAOO,SAAS,uBAAqD;AACnE,aAAO,yBAAW,gBAAgB;AACpC;","names":["isMethodActionHandlers"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/wrappers.ts","../src/fixtures.ts","../src/provider.tsx"],"sourcesContent":["/**\n * @demokit-ai/remix\n *\n * Remix adapter for DemoKit.\n * Demo-aware loader and action mocking for Remix applications.\n *\n * Since Remix loaders run on the server, demo mode detection happens server-side\n * via cookies, headers, or environment variables. This package provides both\n * server-side utilities and client-side state management.\n *\n * ## Server-Side Usage\n *\n * For loaders and actions, use the server utilities:\n *\n * @example\n * // In your loader file\n * import { createDemoLoader } from '@demokit-ai/remix'\n * import { isDemoMode } from '@demokit-ai/remix/server'\n *\n * export const loader = createDemoLoader({\n * loader: async ({ params }) => {\n * const user = await db.users.findUnique({ where: { id: params.id } })\n * return json({ user })\n * },\n * isEnabled: isDemoMode,\n * fixture: ({ params }) => ({\n * user: { id: params.id, name: 'Demo User', email: 'demo@example.com' }\n * }),\n * })\n *\n * @example\n * // Action with method-specific fixtures\n * import { createDemoAction } from '@demokit-ai/remix'\n * import { isDemoMode } from '@demokit-ai/remix/server'\n *\n * export const action = createDemoAction({\n * action: async ({ request }) => {\n * const formData = await request.formData()\n * return json(await db.users.update({ ... }))\n * },\n * isEnabled: isDemoMode,\n * fixture: {\n * PUT: ({ formData }) => json({ updated: true, name: formData?.get('name') }),\n * DELETE: ({ params }) => json({ deleted: true, id: params.id }),\n * },\n * })\n *\n * ## Direct Demo Mode Check\n *\n * For more control, use isDemoMode directly:\n *\n * @example\n * import { isDemoMode, getDemoData } from '@demokit-ai/remix/server'\n *\n * export async function loader({ request, params }: LoaderFunctionArgs) {\n * if (isDemoMode(request)) {\n * return json({\n * user: { id: params.id, name: 'Demo User' }\n * })\n * }\n * return json({\n * user: await db.users.findFirst({ where: { id: params.id } })\n * })\n * }\n *\n * ## Fixture Store (Centralized)\n *\n * For larger apps, use a centralized fixture store:\n *\n * @example\n * // In entry.server.tsx or root.tsx loader\n * import { setupDemoFixtures } from '@demokit-ai/remix/server'\n *\n * setupDemoFixtures({\n * loaders: {\n * '/users': [{ id: '1', name: 'Demo User' }],\n * '/users/:id': ({ params }) => ({ id: params.id, name: 'Demo User' }),\n * '/projects': async () => fetchDemoProjects(),\n * },\n * actions: {\n * '/users': {\n * POST: ({ formData }) => ({ id: crypto.randomUUID(), name: formData?.get('name') }),\n * },\n * },\n * })\n *\n * ## Client-Side State (Optional)\n *\n * For client-side demo mode toggle UI:\n *\n * @example\n * import { DemoRemixProvider, useDemoRemix } from '@demokit-ai/remix'\n *\n * export default function App() {\n * return (\n * <DemoRemixProvider enabled={isDemoFromCookie}>\n * <Outlet />\n * <DemoControls />\n * </DemoRemixProvider>\n * )\n * }\n *\n * function DemoControls() {\n * const { enabled, toggle } = useDemoRemix()\n * return (\n * <button onClick={toggle}>\n * Demo: {enabled ? 'ON' : 'OFF'}\n * </button>\n * )\n * }\n *\n * ## Cookie-Based Demo Mode\n *\n * Enable demo mode via URL parameter or cookie:\n *\n * @example\n * // Enable with URL: /any-page?demo=true\n * // Enable with cookie: Set 'demokit-demo-mode=true' cookie\n * // Enable with header: Set 'x-demokit-demo-mode: true' header\n * // Enable globally: Set DEMOKIT_DEMO_MODE=true env var\n *\n * @packageDocumentation\n */\n\n// Wrapper utilities (client + server compatible)\nexport { createDemoLoader, createDemoAction, withDemoLoader, withDemoAction } from './wrappers'\n\n// Fixture utilities\nexport {\n FixtureStore,\n createFixtureStore,\n defineRemixLoaderFixtures,\n defineRemixActionFixtures,\n defineRemixFixtures,\n} from './fixtures'\n\n// Provider and hooks (client-side)\nexport {\n DemoRemixProvider,\n useDemoRemix,\n useIsDemoRemixMode,\n useDemoRemixOptional,\n} from './provider'\n\n// Types\nexport type {\n LoaderFixtureContext,\n ActionFixtureContext,\n LoaderFixtureHandler,\n ActionFixtureHandler,\n LoaderFixtureMap,\n LoaderFixtureMapObject,\n ActionFixtureMap,\n ActionFixtureMapObject,\n MethodActionHandlers,\n CreateDemoLoaderOptions,\n CreateDemoActionOptions,\n DemoRouteOptions,\n DemoRemixState,\n DemoRemixProviderConfig,\n DemoRemixProviderProps,\n DemoModeOptions,\n FixtureStoreConfig,\n RemixResponse,\n} from './types'\n","import type { LoaderFunctionArgs, ActionFunctionArgs } from '@remix-run/node'\nimport type {\n CreateDemoLoaderOptions,\n CreateDemoActionOptions,\n LoaderFixtureContext,\n ActionFixtureContext,\n ActionFixtureHandler,\n MethodActionHandlers,\n} from './types'\n\n/**\n * Create a demo-aware loader function for Remix\n *\n * Returns a loader that intercepts requests when demo mode is enabled\n * and returns fixture data instead of calling the real loader.\n * Demo mode is checked server-side via cookies, headers, or request context.\n *\n * @example\n * // Basic usage with inline fixture\n * export const loader = createDemoLoader({\n * loader: async ({ params }) => {\n * const user = await db.users.findUnique({ where: { id: params.id } })\n * return json({ user })\n * },\n * isEnabled: (request) => request.headers.get('cookie')?.includes('demo=true') ?? false,\n * fixture: ({ params }) => ({\n * user: { id: params.id, name: 'Demo User', email: 'demo@example.com' }\n * }),\n * })\n *\n * @example\n * // With cookie-based detection\n * import { isDemoMode } from '@demokit-ai/remix/server'\n *\n * export const loader = createDemoLoader({\n * loader: realLoader,\n * isEnabled: (request) => isDemoMode(request),\n * fixture: demoData,\n * delay: 200, // Simulate 200ms network latency\n * })\n */\nexport function createDemoLoader<T = unknown>(\n options: CreateDemoLoaderOptions<T>\n): (args: LoaderFunctionArgs) => Promise<T> {\n const { loader, isEnabled = () => false, fixture, delay = 0, onDemo } = options\n\n return async (args: LoaderFunctionArgs): Promise<T> => {\n // Check if demo mode is enabled (async to support cookie parsing)\n const enabled = await isEnabled(args.request)\n if (!enabled) {\n return loader(args)\n }\n\n // If no fixture provided, fall back to real loader\n if (fixture === undefined) {\n return loader(args)\n }\n\n // Build context for fixture handler\n const context: LoaderFixtureContext = {\n params: args.params,\n request: args.request,\n path: new URL(args.request.url).pathname,\n }\n\n // Notify callback\n onDemo?.(context)\n\n // Apply delay if configured\n if (delay > 0) {\n await new Promise((resolve) => setTimeout(resolve, delay))\n }\n\n // Execute fixture\n return executeFixture(fixture, context)\n }\n}\n\n/**\n * Create a demo-aware action function for Remix\n *\n * Returns an action that intercepts requests when demo mode is enabled\n * and returns fixture data instead of calling the real action.\n *\n * @example\n * // Basic usage with inline fixture\n * export const action = createDemoAction({\n * action: async ({ request }) => {\n * const formData = await request.formData()\n * const user = await db.users.create({ data: Object.fromEntries(formData) })\n * return json({ user })\n * },\n * isEnabled: (request) => request.headers.get('cookie')?.includes('demo=true') ?? false,\n * fixture: async ({ formData }) => ({\n * user: { id: crypto.randomUUID(), ...Object.fromEntries(formData!) }\n * }),\n * })\n *\n * @example\n * // With method-specific fixtures\n * export const action = createDemoAction({\n * action: realAction,\n * isEnabled: isDemoMode,\n * fixture: {\n * POST: ({ formData }) => json({ created: true, id: crypto.randomUUID() }),\n * DELETE: ({ params }) => json({ deleted: true, id: params.id }),\n * },\n * })\n */\nexport function createDemoAction<T = unknown>(\n options: CreateDemoActionOptions<T>\n): (args: ActionFunctionArgs) => Promise<T> {\n const { action, isEnabled = () => false, fixture, delay = 0, onDemo } = options\n\n return async (args: ActionFunctionArgs): Promise<T> => {\n // Check if demo mode is enabled (async to support cookie parsing)\n const enabled = await isEnabled(args.request)\n if (!enabled) {\n return action(args)\n }\n\n // If no fixture provided, fall back to real action\n if (fixture === undefined) {\n return action(args)\n }\n\n // Parse form data for convenience\n let formData: FormData | undefined\n try {\n formData = await args.request.clone().formData()\n } catch {\n // Not form data, that's fine\n }\n\n // Build context for fixture handler\n const context: ActionFixtureContext = {\n params: args.params,\n request: args.request,\n path: new URL(args.request.url).pathname,\n formData,\n }\n\n // Notify callback\n onDemo?.(context)\n\n // Apply delay if configured\n if (delay > 0) {\n await new Promise((resolve) => setTimeout(resolve, delay))\n }\n\n // Check if fixture is method-specific\n if (isMethodActionHandlers(fixture)) {\n const method = args.request.method.toUpperCase() as keyof MethodActionHandlers\n const handler = fixture[method]\n if (handler) {\n return executeFixture(handler, context) as Promise<T>\n }\n // No handler for this method, fall back to real action\n return action(args)\n }\n\n // Execute fixture\n return executeFixture(fixture as ActionFixtureHandler<T>, context)\n }\n}\n\n/**\n * Execute a fixture handler (static value or function)\n */\nasync function executeFixture<T, C extends LoaderFixtureContext | ActionFixtureContext>(\n fixture: T | ((context: C) => T | Promise<T>),\n context: C\n): Promise<T> {\n if (typeof fixture === 'function') {\n return (fixture as (context: C) => T | Promise<T>)(context)\n }\n return fixture\n}\n\n/**\n * Type guard for method action handlers\n */\nfunction isMethodActionHandlers(fixture: unknown): fixture is MethodActionHandlers {\n if (typeof fixture !== 'object' || fixture === null) {\n return false\n }\n const methods = ['POST', 'PUT', 'PATCH', 'DELETE']\n return methods.some((method) => method in fixture)\n}\n\n/**\n * Helper to create a demo loader with context from request\n *\n * Simplified version that uses request-based demo mode detection.\n *\n * @example\n * import { withDemoLoader, isDemoMode } from '@demokit-ai/remix'\n *\n * export const loader = withDemoLoader(\n * async ({ params }) => {\n * return json(await db.users.findUnique({ where: { id: params.id } }))\n * },\n * {\n * isEnabled: isDemoMode,\n * fixture: ({ params }) => ({ id: params.id, name: 'Demo User' }),\n * }\n * )\n */\nexport function withDemoLoader<T = unknown>(\n loader: (args: LoaderFunctionArgs) => T | Promise<T>,\n options: Omit<CreateDemoLoaderOptions<T>, 'loader'>\n): (args: LoaderFunctionArgs) => Promise<T> {\n return createDemoLoader({ ...options, loader })\n}\n\n/**\n * Helper to create a demo action with context from request\n *\n * Simplified version that uses request-based demo mode detection.\n *\n * @example\n * import { withDemoAction, isDemoMode } from '@demokit-ai/remix'\n *\n * export const action = withDemoAction(\n * async ({ request }) => {\n * const formData = await request.formData()\n * return json(await db.users.create({ data: Object.fromEntries(formData) }))\n * },\n * {\n * isEnabled: isDemoMode,\n * fixture: ({ formData }) => ({ id: crypto.randomUUID(), name: formData?.get('name') }),\n * }\n * )\n */\nexport function withDemoAction<T = unknown>(\n action: (args: ActionFunctionArgs) => T | Promise<T>,\n options: Omit<CreateDemoActionOptions<T>, 'action'>\n): (args: ActionFunctionArgs) => Promise<T> {\n return createDemoAction({ ...options, action })\n}\n","import { matchUrl, type MatchResult } from '@demokit-ai/core'\nimport type {\n LoaderFixtureMapObject,\n ActionFixtureMapObject,\n LoaderFixtureHandler,\n ActionFixtureHandler,\n MethodActionHandlers,\n FixtureStoreConfig,\n} from './types'\n\n/**\n * Server-side fixture store for managing demo data\n *\n * Use this to centralize fixture definitions for your Remix app.\n * Works with the demo mode detection utilities.\n */\nexport class FixtureStore {\n private loaders: LoaderFixtureMapObject = {}\n private actions: ActionFixtureMapObject = {}\n\n constructor(config?: FixtureStoreConfig) {\n if (config?.loaders) {\n this.loaders = { ...config.loaders }\n }\n if (config?.actions) {\n this.actions = { ...config.actions }\n }\n }\n\n /**\n * Register a loader fixture\n */\n setLoader(path: string, handler: LoaderFixtureHandler): this {\n this.loaders[path] = handler\n return this\n }\n\n /**\n * Register an action fixture\n */\n setAction(path: string, handler: ActionFixtureHandler | MethodActionHandlers): this {\n this.actions[path] = handler\n return this\n }\n\n /**\n * Get a loader fixture for a path\n */\n getLoader(path: string): LoaderFixtureHandler | undefined {\n // Try exact match first\n if (path in this.loaders) {\n return this.loaders[path]\n }\n\n // Try pattern matching\n for (const [pattern, handler] of Object.entries(this.loaders)) {\n const fullPattern = pattern.startsWith('GET ') ? pattern : `GET ${pattern}`\n const result = matchUrl(fullPattern, 'GET', path)\n if (result) {\n return handler\n }\n }\n\n return undefined\n }\n\n /**\n * Get an action fixture for a path and method\n */\n getAction(path: string, method: string): ActionFixtureHandler | undefined {\n // Try exact match first\n if (path in this.actions) {\n return resolveActionHandler(this.actions[path], method)\n }\n\n // Try pattern matching\n for (const [pattern, fixture] of Object.entries(this.actions)) {\n const fullPattern = /^(GET|POST|PUT|PATCH|DELETE)\\s/.test(pattern)\n ? pattern\n : `${method} ${pattern}`\n const result = matchUrl(fullPattern, method, path)\n if (result) {\n return resolveActionHandler(fixture, method)\n }\n }\n\n return undefined\n }\n\n /**\n * Find loader fixture with match info\n */\n findLoader(path: string): { handler: LoaderFixtureHandler; match: MatchResult } | null {\n // Try exact match first\n if (path in this.loaders) {\n return {\n handler: this.loaders[path],\n match: { matched: true, params: {} },\n }\n }\n\n // Try pattern matching\n for (const [pattern, handler] of Object.entries(this.loaders)) {\n const fullPattern = pattern.startsWith('GET ') ? pattern : `GET ${pattern}`\n const result = matchUrl(fullPattern, 'GET', path)\n if (result) {\n return { handler, match: result }\n }\n }\n\n return null\n }\n\n /**\n * Find action fixture with match info\n */\n findAction(\n path: string,\n method: string\n ): { handler: ActionFixtureHandler; match: MatchResult } | null {\n // Try exact match first\n if (path in this.actions) {\n const handler = resolveActionHandler(this.actions[path], method)\n if (handler) {\n return {\n handler,\n match: { matched: true, params: {} },\n }\n }\n }\n\n // Try pattern matching\n for (const [pattern, fixture] of Object.entries(this.actions)) {\n const fullPattern = /^(GET|POST|PUT|PATCH|DELETE)\\s/.test(pattern)\n ? pattern\n : `${method} ${pattern}`\n const result = matchUrl(fullPattern, method, path)\n if (result) {\n const handler = resolveActionHandler(fixture, method)\n if (handler) {\n return { handler, match: result }\n }\n }\n }\n\n return null\n }\n\n /**\n * Get all loader fixtures\n */\n getLoaders(): LoaderFixtureMapObject {\n return { ...this.loaders }\n }\n\n /**\n * Get all action fixtures\n */\n getActions(): ActionFixtureMapObject {\n return { ...this.actions }\n }\n\n /**\n * Clear all fixtures\n */\n clear(): void {\n this.loaders = {}\n this.actions = {}\n }\n}\n\n/**\n * Resolve action handler based on method\n */\nfunction resolveActionHandler(\n fixture: ActionFixtureHandler | MethodActionHandlers,\n method: string\n): ActionFixtureHandler | undefined {\n if (isMethodActionHandlers(fixture)) {\n const upperMethod = method.toUpperCase() as keyof MethodActionHandlers\n return fixture[upperMethod]\n }\n return fixture\n}\n\n/**\n * Type guard for method action handlers\n */\nfunction isMethodActionHandlers(fixture: unknown): fixture is MethodActionHandlers {\n if (typeof fixture !== 'object' || fixture === null) {\n return false\n }\n const methods = ['POST', 'PUT', 'PATCH', 'DELETE']\n return methods.some((method) => method in fixture)\n}\n\n/**\n * Create a fixture store with initial fixtures\n *\n * @example\n * import { createFixtureStore } from '@demokit-ai/remix/server'\n *\n * export const fixtures = createFixtureStore({\n * loaders: {\n * '/users': [{ id: '1', name: 'Demo User' }],\n * '/users/:id': ({ params }) => ({ id: params.id, name: 'Demo User' }),\n * },\n * actions: {\n * '/users': {\n * POST: ({ formData }) => ({ id: crypto.randomUUID(), name: formData?.get('name') }),\n * },\n * '/users/:id': {\n * PUT: ({ formData }) => ({ updated: true }),\n * DELETE: ({ params }) => ({ deleted: true, id: params.id }),\n * },\n * },\n * })\n */\nexport function createFixtureStore(config?: FixtureStoreConfig): FixtureStore {\n return new FixtureStore(config)\n}\n\n/**\n * Define loader fixtures with type inference\n *\n * @example\n * const loaders = defineRemixLoaderFixtures({\n * '/users': [{ id: '1', name: 'Demo User' }],\n * '/users/:id': ({ params }) => ({ id: params.id, name: 'Demo User' }),\n * '/projects': async () => fetchDemoProjects(),\n * })\n */\nexport function defineRemixLoaderFixtures<T extends LoaderFixtureMapObject>(fixtures: T): T {\n return fixtures\n}\n\n/**\n * Define action fixtures with type inference\n *\n * @example\n * const actions = defineRemixActionFixtures({\n * '/users': {\n * POST: ({ formData }) => ({ id: crypto.randomUUID(), name: formData?.get('name') }),\n * },\n * '/users/:id': {\n * PUT: ({ formData }) => ({ updated: true }),\n * DELETE: ({ params }) => ({ deleted: true, id: params.id }),\n * },\n * })\n */\nexport function defineRemixActionFixtures<T extends ActionFixtureMapObject>(fixtures: T): T {\n return fixtures\n}\n\n/**\n * Define complete Remix fixtures (loaders + actions)\n *\n * @example\n * const { loaders, actions } = defineRemixFixtures({\n * loaders: {\n * '/users': [{ id: '1', name: 'Demo User' }],\n * },\n * actions: {\n * '/users': ({ formData }) => ({ created: true }),\n * },\n * })\n */\nexport function defineRemixFixtures<\n L extends LoaderFixtureMapObject,\n A extends ActionFixtureMapObject,\n>(config: { loaders?: L; actions?: A }): { loaders: L; actions: A } {\n return {\n loaders: (config.loaders ?? {}) as L,\n actions: (config.actions ?? {}) as A,\n }\n}\n","import { createContext, useContext, useMemo, useState, useCallback } from 'react'\nimport type {\n DemoRemixProviderProps,\n DemoRemixState,\n LoaderFixtureMap,\n ActionFixtureMap,\n LoaderFixtureMapObject,\n ActionFixtureMapObject,\n LoaderFixtureHandler,\n ActionFixtureHandler,\n} from './types'\n\n/**\n * Context value for demo remix state\n */\ninterface DemoRemixContextValue extends DemoRemixState {\n /** Enable demo mode */\n enable: () => void\n /** Disable demo mode */\n disable: () => void\n /** Toggle demo mode */\n toggle: () => boolean\n /** Set a loader fixture */\n setLoader: (path: string, handler: LoaderFixtureHandler) => void\n /** Remove a loader fixture */\n removeLoader: (path: string) => void\n /** Set an action fixture */\n setAction: (path: string, handler: ActionFixtureHandler) => void\n /** Remove an action fixture */\n removeAction: (path: string) => void\n /** Clear all fixtures */\n clearFixtures: () => void\n /** Get delay setting */\n delay: number\n}\n\nconst DemoRemixContext = createContext<DemoRemixContextValue | null>(null)\n\n/**\n * Convert object fixture map to Map\n */\nfunction toLoaderMap(obj?: LoaderFixtureMapObject): LoaderFixtureMap {\n if (!obj) return new Map()\n return new Map(Object.entries(obj))\n}\n\n/**\n * Convert object fixture map to Map\n */\nfunction toActionMap(obj?: ActionFixtureMapObject): ActionFixtureMap {\n if (!obj) return new Map()\n return new Map(Object.entries(obj))\n}\n\n/**\n * Provider for demo remix state (client-side)\n *\n * Wrap your Remix app with this provider to enable client-side fixture management\n * and demo mode toggle. For server-side demo mode detection, use the server utilities.\n *\n * @example\n * import { DemoRemixProvider } from '@demokit-ai/remix'\n *\n * const loaders = {\n * '/users': [{ id: '1', name: 'Demo User' }],\n * '/users/:id': ({ params }) => ({ id: params.id, name: 'Demo User' }),\n * }\n *\n * const actions = {\n * '/users': ({ formData }) => ({\n * id: crypto.randomUUID(),\n * name: formData?.get('name'),\n * }),\n * }\n *\n * export default function App() {\n * return (\n * <DemoRemixProvider loaders={loaders} actions={actions} enabled>\n * <Outlet />\n * </DemoRemixProvider>\n * )\n * }\n */\nexport function DemoRemixProvider({\n children,\n enabled: initialEnabled = false,\n loaders: initialLoaders,\n actions: initialActions,\n delay = 0,\n}: DemoRemixProviderProps) {\n const [enabled, setEnabled] = useState(initialEnabled)\n const [loaders, setLoaders] = useState<LoaderFixtureMap>(() => toLoaderMap(initialLoaders))\n const [actions, setActions] = useState<ActionFixtureMap>(() => toActionMap(initialActions))\n\n const enable = useCallback(() => setEnabled(true), [])\n const disable = useCallback(() => setEnabled(false), [])\n const toggle = useCallback(() => {\n setEnabled((prev) => !prev)\n return !enabled\n }, [enabled])\n\n const setLoader = useCallback((path: string, handler: LoaderFixtureHandler) => {\n setLoaders((prev) => new Map(prev).set(path, handler))\n }, [])\n\n const removeLoader = useCallback((path: string) => {\n setLoaders((prev) => {\n const next = new Map(prev)\n next.delete(path)\n return next\n })\n }, [])\n\n const setAction = useCallback((path: string, handler: ActionFixtureHandler) => {\n setActions((prev) => new Map(prev).set(path, handler))\n }, [])\n\n const removeAction = useCallback((path: string) => {\n setActions((prev) => {\n const next = new Map(prev)\n next.delete(path)\n return next\n })\n }, [])\n\n const clearFixtures = useCallback(() => {\n setLoaders(new Map())\n setActions(new Map())\n }, [])\n\n const value = useMemo<DemoRemixContextValue>(\n () => ({\n enabled,\n loaders,\n actions,\n delay,\n enable,\n disable,\n toggle,\n setLoader,\n removeLoader,\n setAction,\n removeAction,\n clearFixtures,\n }),\n [\n enabled,\n loaders,\n actions,\n delay,\n enable,\n disable,\n toggle,\n setLoader,\n removeLoader,\n setAction,\n removeAction,\n clearFixtures,\n ]\n )\n\n return <DemoRemixContext.Provider value={value}>{children}</DemoRemixContext.Provider>\n}\n\n/**\n * Hook to access demo remix state and controls\n *\n * @example\n * function DemoModeToggle() {\n * const { enabled, toggle } = useDemoRemix()\n * return (\n * <button onClick={toggle}>\n * Demo Mode: {enabled ? 'ON' : 'OFF'}\n * </button>\n * )\n * }\n */\nexport function useDemoRemix(): DemoRemixContextValue {\n const context = useContext(DemoRemixContext)\n if (!context) {\n throw new Error('useDemoRemix must be used within a DemoRemixProvider')\n }\n return context\n}\n\n/**\n * Hook to check if demo mode is enabled\n *\n * @example\n * function DataDisplay() {\n * const isDemo = useIsDemoRemixMode()\n * return isDemo ? <DemoBanner /> : null\n * }\n */\nexport function useIsDemoRemixMode(): boolean {\n const context = useContext(DemoRemixContext)\n return context?.enabled ?? false\n}\n\n/**\n * Get the demo remix context (may be null if not in provider)\n *\n * Use this for optional demo mode integration.\n */\nexport function useDemoRemixOptional(): DemoRemixContextValue | null {\n return useContext(DemoRemixContext)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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