@typed/navigation 0.17.0 → 0.18.1

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.
Files changed (115) hide show
  1. package/.nvmrc +1 -0
  2. package/biome.json +39 -0
  3. package/dist/Blocking.d.ts +23 -0
  4. package/dist/Blocking.js +41 -0
  5. package/dist/Blocking.js.map +1 -0
  6. package/dist/Destination.d.ts +11 -0
  7. package/dist/Destination.js +10 -0
  8. package/dist/Destination.js.map +1 -0
  9. package/dist/Error.d.ts +33 -0
  10. package/dist/Error.js +22 -0
  11. package/dist/Error.js.map +1 -0
  12. package/dist/Event.d.ts +45 -0
  13. package/dist/Event.js +17 -0
  14. package/dist/Event.js.map +1 -0
  15. package/dist/Forms.d.ts +79 -0
  16. package/dist/Forms.js +111 -0
  17. package/dist/Forms.js.map +1 -0
  18. package/dist/Handler.d.ts +6 -0
  19. package/dist/Handler.js +2 -0
  20. package/dist/Handler.js.map +1 -0
  21. package/dist/{dts/Layer.d.ts → Layer.d.ts} +11 -8
  22. package/dist/{esm/Layer.js → Layer.js} +2 -2
  23. package/dist/Layer.js.map +1 -0
  24. package/dist/NavigateOptions.d.ts +7 -0
  25. package/dist/NavigateOptions.js +7 -0
  26. package/dist/NavigateOptions.js.map +1 -0
  27. package/dist/Navigation.d.ts +79 -0
  28. package/dist/Navigation.js +49 -0
  29. package/dist/Navigation.js.map +1 -0
  30. package/dist/NavigationType.d.ts +3 -0
  31. package/dist/NavigationType.js +3 -0
  32. package/dist/NavigationType.js.map +1 -0
  33. package/dist/ProposedDestination.d.ts +13 -0
  34. package/dist/ProposedDestination.js +4 -0
  35. package/dist/ProposedDestination.js.map +1 -0
  36. package/dist/Url.d.ts +13 -0
  37. package/dist/Url.js +72 -0
  38. package/dist/Url.js.map +1 -0
  39. package/dist/index.d.ts +12 -0
  40. package/dist/index.js +13 -0
  41. package/dist/index.js.map +1 -0
  42. package/dist/internal/fromWindow.d.ts +4 -0
  43. package/dist/internal/fromWindow.js +358 -0
  44. package/dist/internal/fromWindow.js.map +1 -0
  45. package/dist/internal/memory.d.ts +6 -0
  46. package/dist/internal/memory.js +59 -0
  47. package/dist/internal/memory.js.map +1 -0
  48. package/dist/internal/shared.d.ts +109 -0
  49. package/dist/{esm/internal → internal}/shared.js +134 -165
  50. package/dist/internal/shared.js.map +1 -0
  51. package/package.json +35 -52
  52. package/readme.md +243 -0
  53. package/src/Blocking.ts +65 -65
  54. package/src/Destination.ts +14 -0
  55. package/src/Error.ts +28 -0
  56. package/src/Event.ts +26 -0
  57. package/src/Forms.ts +216 -0
  58. package/src/Handler.ts +16 -0
  59. package/src/Layer.ts +20 -9
  60. package/src/NavigateOptions.ts +9 -0
  61. package/src/Navigation.test.ts +697 -0
  62. package/src/Navigation.ts +133 -468
  63. package/src/NavigationType.ts +5 -0
  64. package/src/ProposedDestination.ts +8 -0
  65. package/src/Url.ts +106 -0
  66. package/src/index.ts +12 -17
  67. package/src/internal/fromWindow.ts +250 -180
  68. package/src/internal/memory.ts +62 -49
  69. package/src/internal/shared.ts +238 -305
  70. package/tsconfig.json +30 -0
  71. package/Blocking/package.json +0 -6
  72. package/LICENSE +0 -21
  73. package/Layer/package.json +0 -6
  74. package/Navigation/package.json +0 -6
  75. package/README.md +0 -5
  76. package/dist/cjs/Blocking.js +0 -58
  77. package/dist/cjs/Blocking.js.map +0 -1
  78. package/dist/cjs/Layer.js +0 -27
  79. package/dist/cjs/Layer.js.map +0 -1
  80. package/dist/cjs/Navigation.js +0 -275
  81. package/dist/cjs/Navigation.js.map +0 -1
  82. package/dist/cjs/index.js +0 -39
  83. package/dist/cjs/index.js.map +0 -1
  84. package/dist/cjs/internal/fromWindow.js +0 -421
  85. package/dist/cjs/internal/fromWindow.js.map +0 -1
  86. package/dist/cjs/internal/memory.js +0 -72
  87. package/dist/cjs/internal/memory.js.map +0 -1
  88. package/dist/cjs/internal/shared.js +0 -522
  89. package/dist/cjs/internal/shared.js.map +0 -1
  90. package/dist/dts/Blocking.d.ts +0 -34
  91. package/dist/dts/Blocking.d.ts.map +0 -1
  92. package/dist/dts/Layer.d.ts.map +0 -1
  93. package/dist/dts/Navigation.d.ts +0 -462
  94. package/dist/dts/Navigation.d.ts.map +0 -1
  95. package/dist/dts/index.d.ts +0 -17
  96. package/dist/dts/index.d.ts.map +0 -1
  97. package/dist/dts/internal/fromWindow.d.ts +0 -12
  98. package/dist/dts/internal/fromWindow.d.ts.map +0 -1
  99. package/dist/dts/internal/memory.d.ts +0 -6
  100. package/dist/dts/internal/memory.d.ts.map +0 -1
  101. package/dist/dts/internal/shared.d.ts +0 -114
  102. package/dist/dts/internal/shared.d.ts.map +0 -1
  103. package/dist/esm/Blocking.js +0 -46
  104. package/dist/esm/Blocking.js.map +0 -1
  105. package/dist/esm/Layer.js.map +0 -1
  106. package/dist/esm/Navigation.js +0 -237
  107. package/dist/esm/Navigation.js.map +0 -1
  108. package/dist/esm/index.js +0 -17
  109. package/dist/esm/index.js.map +0 -1
  110. package/dist/esm/internal/fromWindow.js +0 -310
  111. package/dist/esm/internal/fromWindow.js.map +0 -1
  112. package/dist/esm/internal/memory.js +0 -56
  113. package/dist/esm/internal/memory.js.map +0 -1
  114. package/dist/esm/internal/shared.js.map +0 -1
  115. package/dist/esm/package.json +0 -4
package/.nvmrc ADDED
@@ -0,0 +1 @@
1
+ 22
package/biome.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "organizeImports": {
3
+ "enabled": true
4
+ },
5
+ "linter": {
6
+ "enabled": true,
7
+ "include": [
8
+ "src/**/*.ts"
9
+ ],
10
+ "rules": {
11
+ "recommended": true,
12
+ "suspicious": {
13
+ "noExplicitAny": "off",
14
+ "noAssignInExpressions": "off",
15
+ "noShadowRestrictedNames": "off"
16
+ },
17
+ "style": {
18
+ "noParameterAssign": "off",
19
+ "noUselessElse": "off"
20
+ },
21
+ "complexity": {
22
+ "noBannedTypes": "off"
23
+ }
24
+ }
25
+ },
26
+ "formatter": {
27
+ "enabled": true,
28
+ "indentStyle": "space",
29
+ "indentWidth": 2,
30
+ "lineWidth": 100
31
+ },
32
+ "javascript": {
33
+ "formatter": {
34
+ "quoteStyle": "single",
35
+ "trailingCommas": "all",
36
+ "semicolons": "asNeeded"
37
+ }
38
+ }
39
+ }
@@ -0,0 +1,23 @@
1
+ import * as LazyRef from '@typed/lazy-ref';
2
+ import { Stream } from 'effect';
3
+ import * as Effect from 'effect/Effect';
4
+ import * as Option from 'effect/Option';
5
+ import type * as Scope from 'effect/Scope';
6
+ import type { Destination } from './Destination.js';
7
+ import { CancelNavigation, type RedirectError } from './Error.js';
8
+ import type { TransitionEvent } from './Event.js';
9
+ import type { NavigateOptions } from './NavigateOptions.js';
10
+ import { Navigation } from './Navigation.js';
11
+ export interface BlockNavigation extends LazyRef.Computed<Option.Option<Blocking>> {
12
+ readonly isBlocking: LazyRef.Computed<boolean>;
13
+ readonly whenBlocked: <A, E, R>(handler: (blocking: Blocking) => Effect.Effect<A, E, R>, options?: Parameters<typeof Stream.flatMap>[2]) => Effect.Effect<void, E, R>;
14
+ }
15
+ export interface Blocking extends TransitionEvent {
16
+ readonly cancel: Effect.Effect<Destination>;
17
+ readonly confirm: Effect.Effect<Destination>;
18
+ readonly redirect: (urlOrPath: string | URL, options?: NavigateOptions) => Effect.Effect<Destination>;
19
+ }
20
+ export interface UseBlockNavigationParams<R = never> {
21
+ readonly shouldBlock?: (event: TransitionEvent) => Effect.Effect<boolean, RedirectError | CancelNavigation, R>;
22
+ }
23
+ export declare const useBlockNavigation: <R = never>(params?: UseBlockNavigationParams<R>) => Effect.Effect<BlockNavigation, never, Navigation | R | Scope.Scope>;
@@ -0,0 +1,41 @@
1
+ import * as LazyRef from '@typed/lazy-ref';
2
+ import { Stream } from 'effect';
3
+ import * as Data from 'effect/Data';
4
+ import * as Deferred from 'effect/Deferred';
5
+ import * as Effect from 'effect/Effect';
6
+ import * as Option from 'effect/Option';
7
+ import { CancelNavigation } from './Error.js';
8
+ import { Navigation, redirectToPath } from './Navigation.js';
9
+ const Unblocked = Data.struct({ _tag: 'Unblocked' });
10
+ const Blocked = (event) => Effect.map(Deferred.make(), (deferred) => Data.struct({ _tag: 'Blocked', deferred, event }));
11
+ export const useBlockNavigation = (params = {}) => Effect.gen(function* () {
12
+ const navigation = yield* Navigation;
13
+ const blockState = yield* LazyRef.of(Unblocked);
14
+ yield* navigation.beforeNavigation((event) => LazyRef.modifyEffect(blockState, (state) => Effect.gen(function* () {
15
+ // Can't block twice
16
+ if (state._tag === 'Blocked')
17
+ return [Option.none(), state];
18
+ if (params.shouldBlock && !(yield* params.shouldBlock(event))) {
19
+ return [Option.none(), state];
20
+ }
21
+ const updated = yield* Blocked(event);
22
+ return [Option.some(Deferred.await(updated.deferred)), updated];
23
+ })));
24
+ const computed = LazyRef.map(blockState, (s) => {
25
+ return s._tag === 'Blocked' ? Option.some(blockedToBlocking(navigation, s)) : Option.none();
26
+ });
27
+ const blockNavigation = Object.assign(computed, {
28
+ isBlocking: LazyRef.map(blockState, (s) => s._tag === 'Blocked'),
29
+ whenBlocked: (handler, options) => Stream.filterMap(computed.changes, (blocking) => blocking).pipe(Stream.flatMap(handler, options), Stream.runDrain),
30
+ });
31
+ return blockNavigation;
32
+ });
33
+ function blockedToBlocking(navigation, state) {
34
+ return {
35
+ ...state.event,
36
+ cancel: Effect.zipRight(Deferred.failSync(state.deferred, () => new CancelNavigation()), navigation.currentEntry),
37
+ confirm: Effect.zipRight(Deferred.succeed(state.deferred, undefined), navigation.currentEntry),
38
+ redirect: (url, options) => Effect.zipRight(Deferred.fail(state.deferred, redirectToPath(url, options)), navigation.currentEntry),
39
+ };
40
+ }
41
+ //# sourceMappingURL=Blocking.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Blocking.js","sourceRoot":"","sources":["../src/Blocking.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,O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,GAAG,KAAK,CAAC,KAAK;QACd,MAAM,EAAE,MAAM,CAAC,QAAQ,CACrB,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,gBAAgB,EAAE,CAAC,EAC/D,UAAU,CAAC,YAAY,CACxB;QACD,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,SAAS,CAAC,EAAE,UAAU,CAAC,YAAY,CAAC;QAC9F,QAAQ,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CACzB,MAAM,CAAC,QAAQ,CACb,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,EAC3D,UAAU,CAAC,YAAY,CACxB;KACJ,CAAA;AACH,CAAC"}
@@ -0,0 +1,11 @@
1
+ import * as Schema from 'effect/Schema';
2
+ export declare const Destination: Schema.Struct<{
3
+ id: typeof Schema.UUID;
4
+ key: typeof Schema.UUID;
5
+ url: Schema.transformOrFail<typeof Schema.String, Schema.instanceOf<URL>, never>;
6
+ state: typeof Schema.Unknown;
7
+ sameDocument: typeof Schema.Boolean;
8
+ }>;
9
+ export type DestinationEncoded = Schema.Schema.Encoded<typeof Destination>;
10
+ export interface Destination extends Schema.Schema.Type<typeof Destination> {
11
+ }
@@ -0,0 +1,10 @@
1
+ import * as Schema from 'effect/Schema';
2
+ import { Url } from './Url.js';
3
+ export const Destination = Schema.Struct({
4
+ id: Schema.UUID,
5
+ key: Schema.UUID,
6
+ url: Url,
7
+ state: Schema.Unknown,
8
+ sameDocument: Schema.Boolean,
9
+ });
10
+ //# sourceMappingURL=Destination.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Destination.js","sourceRoot":"","sources":["../src/Destination.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAE9B,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC;IACvC,EAAE,EAAE,MAAM,CAAC,IAAI;IACf,GAAG,EAAE,MAAM,CAAC,IAAI;IAChB,GAAG,EAAE,GAAG;IACR,KAAK,EAAE,MAAM,CAAC,OAAO;IACrB,YAAY,EAAE,MAAM,CAAC,OAAO;CAC7B,CAAC,CAAA"}
@@ -0,0 +1,33 @@
1
+ import * as Schema from 'effect/Schema';
2
+ declare const NavigationError_base: Schema.TaggedErrorClass<NavigationError, "NavigationError", {
3
+ readonly _tag: Schema.tag<"NavigationError">;
4
+ } & {
5
+ cause: typeof Schema.Unknown;
6
+ }>;
7
+ export declare class NavigationError extends NavigationError_base {
8
+ static is: (u: unknown, overrideOptions?: import("effect/SchemaAST").ParseOptions | number) => u is NavigationError;
9
+ }
10
+ declare const RedirectError_base: Schema.TaggedErrorClass<RedirectError, "RedirectError", {
11
+ readonly _tag: Schema.tag<"RedirectError">;
12
+ } & {
13
+ path: Schema.Union<[typeof Schema.String, Schema.transformOrFail<typeof Schema.String, Schema.instanceOf<URL>, never>]>;
14
+ options: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>;
15
+ }>;
16
+ export declare class RedirectError extends RedirectError_base {
17
+ static is: (u: unknown, overrideOptions?: import("effect/SchemaAST").ParseOptions | number) => u is RedirectError;
18
+ }
19
+ declare const CancelNavigation_base: Schema.TaggedErrorClass<CancelNavigation, "CancelNavigation", {
20
+ readonly _tag: Schema.tag<"CancelNavigation">;
21
+ }>;
22
+ export declare class CancelNavigation extends CancelNavigation_base {
23
+ static is: (u: unknown, overrideOptions?: import("effect/SchemaAST").ParseOptions | number) => u is CancelNavigation;
24
+ }
25
+ declare const FormSubmitError_base: Schema.TaggedErrorClass<FormSubmitError, "FormSubmitError", {
26
+ readonly _tag: Schema.tag<"FormSubmitError">;
27
+ } & {
28
+ cause: typeof Schema.Unknown;
29
+ }>;
30
+ export declare class FormSubmitError extends FormSubmitError_base {
31
+ static is: (u: unknown, overrideOptions?: import("effect/SchemaAST").ParseOptions | number) => u is FormSubmitError;
32
+ }
33
+ export {};
package/dist/Error.js ADDED
@@ -0,0 +1,22 @@
1
+ import * as Schema from 'effect/Schema';
2
+ import { Url } from './Url.js';
3
+ export class NavigationError extends Schema.TaggedError()('NavigationError', {
4
+ cause: Schema.Unknown,
5
+ }) {
6
+ static is = Schema.is(NavigationError);
7
+ }
8
+ export class RedirectError extends Schema.TaggedError()('RedirectError', {
9
+ path: Schema.Union(Schema.String, Url),
10
+ options: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.Unknown })),
11
+ }) {
12
+ static is = Schema.is(RedirectError);
13
+ }
14
+ export class CancelNavigation extends Schema.TaggedError()('CancelNavigation', {}) {
15
+ static is = Schema.is(CancelNavigation);
16
+ }
17
+ export class FormSubmitError extends Schema.TaggedError()('FormSubmitError', {
18
+ cause: Schema.Unknown,
19
+ }) {
20
+ static is = Schema.is(FormSubmitError);
21
+ }
22
+ //# sourceMappingURL=Error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Error.js","sourceRoot":"","sources":["../src/Error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAE9B,MAAM,OAAO,eAAgB,SAAQ,MAAM,CAAC,WAAW,EAAmB,CAAC,iBAAiB,EAAE;IAC5F,KAAK,EAAE,MAAM,CAAC,OAAO;CACtB,CAAC;IACA,MAAM,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE,CAAC,eAAe,CAAC,CAAA;;AAGxC,MAAM,OAAO,aAAc,SAAQ,MAAM,CAAC,WAAW,EAAiB,CAAC,eAAe,EAAE;IACtF,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;CACvF,CAAC;IACA,MAAM,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE,CAAC,aAAa,CAAC,CAAA;;AAGtC,MAAM,OAAO,gBAAiB,SAAQ,MAAM,CAAC,WAAW,EAAoB,CAC1E,kBAAkB,EAClB,EAAE,CACH;IACC,MAAM,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAA;;AAGzC,MAAM,OAAO,eAAgB,SAAQ,MAAM,CAAC,WAAW,EAAmB,CAAC,iBAAiB,EAAE;IAC5F,KAAK,EAAE,MAAM,CAAC,OAAO;CACtB,CAAC;IACA,MAAM,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE,CAAC,eAAe,CAAC,CAAA"}
@@ -0,0 +1,45 @@
1
+ import * as Schema from 'effect/Schema';
2
+ export declare const TransitionEvent: Schema.Struct<{
3
+ type: Schema.Literal<["push", "replace", "reload", "traverse"]>;
4
+ from: Schema.Struct<{
5
+ id: typeof Schema.UUID;
6
+ key: typeof Schema.UUID;
7
+ url: Schema.transformOrFail<typeof Schema.String, Schema.instanceOf<URL>, never>;
8
+ state: typeof Schema.Unknown;
9
+ sameDocument: typeof Schema.Boolean;
10
+ }>;
11
+ delta: typeof Schema.Number;
12
+ to: Schema.Union<[Schema.SchemaClass<{
13
+ readonly url: URL;
14
+ readonly state: unknown;
15
+ readonly sameDocument: boolean;
16
+ }, {
17
+ readonly url: string;
18
+ readonly state: unknown;
19
+ readonly sameDocument: boolean;
20
+ }, never>, Schema.Struct<{
21
+ id: typeof Schema.UUID;
22
+ key: typeof Schema.UUID;
23
+ url: Schema.transformOrFail<typeof Schema.String, Schema.instanceOf<URL>, never>;
24
+ state: typeof Schema.Unknown;
25
+ sameDocument: typeof Schema.Boolean;
26
+ }>]>;
27
+ info: typeof Schema.Unknown;
28
+ }>;
29
+ export type TransitionEventEncoded = Schema.Schema.Encoded<typeof TransitionEvent>;
30
+ export interface TransitionEvent extends Schema.Schema.Type<typeof TransitionEvent> {
31
+ }
32
+ export declare const NavigationEvent: Schema.Struct<{
33
+ type: Schema.Literal<["push", "replace", "reload", "traverse"]>;
34
+ destination: Schema.Struct<{
35
+ id: typeof Schema.UUID;
36
+ key: typeof Schema.UUID;
37
+ url: Schema.transformOrFail<typeof Schema.String, Schema.instanceOf<URL>, never>;
38
+ state: typeof Schema.Unknown;
39
+ sameDocument: typeof Schema.Boolean;
40
+ }>;
41
+ info: typeof Schema.Unknown;
42
+ }>;
43
+ export type NavigationEventEncoded = Schema.Schema.Encoded<typeof NavigationEvent>;
44
+ export interface NavigationEvent extends Schema.Schema.Type<typeof NavigationEvent> {
45
+ }
package/dist/Event.js ADDED
@@ -0,0 +1,17 @@
1
+ import * as Schema from 'effect/Schema';
2
+ import { Destination } from './Destination.js';
3
+ import { NavigationType } from './NavigationType.js';
4
+ import { ProposedDestination } from './ProposedDestination.js';
5
+ export const TransitionEvent = Schema.Struct({
6
+ type: NavigationType,
7
+ from: Destination,
8
+ delta: Schema.Number,
9
+ to: Schema.Union(ProposedDestination, Destination),
10
+ info: Schema.Unknown,
11
+ });
12
+ export const NavigationEvent = Schema.Struct({
13
+ type: NavigationType,
14
+ destination: Destination,
15
+ info: Schema.Unknown,
16
+ });
17
+ //# sourceMappingURL=Event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Event.js","sourceRoot":"","sources":["../src/Event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAE9D,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC;IAC3C,IAAI,EAAE,cAAc;IACpB,IAAI,EAAE,WAAW;IACjB,KAAK,EAAE,MAAM,CAAC,MAAM;IACpB,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,mBAAmB,EAAE,WAAW,CAAC;IAClD,IAAI,EAAE,MAAM,CAAC,OAAO;CACrB,CAAC,CAAA;AAMF,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC;IAC3C,IAAI,EAAE,cAAc;IACpB,WAAW,EAAE,WAAW;IACxB,IAAI,EAAE,MAAM,CAAC,OAAO;CACrB,CAAC,CAAA"}
@@ -0,0 +1,79 @@
1
+ import type { HttpBody } from '@effect/platform';
2
+ import type { Options } from '@effect/platform/HttpClientRequest';
3
+ import * as Schema from 'effect/Schema';
4
+ import type * as Types from 'effect/Types';
5
+ import type { NavigateOptions } from './NavigateOptions.js';
6
+ export declare const BlobFromSelf: Schema.instanceOf<Blob>;
7
+ export type BlobFromSelf = typeof BlobFromSelf.Type;
8
+ export declare const BlobFrom: Schema.TaggedStruct<"Blob", {
9
+ type: typeof Schema.String;
10
+ size: typeof Schema.Number;
11
+ data: Schema.Schema<Uint8Array<ArrayBufferLike>, readonly number[], never>;
12
+ }>;
13
+ export type BlobEncoded = typeof BlobFrom.Encoded;
14
+ export type BlobFrom = typeof BlobFrom.Type;
15
+ export declare const Blob: Schema.Schema<Blob, BlobEncoded>;
16
+ export declare const FileFromSelf: Schema.instanceOf<File>;
17
+ export type FileFromSelf = typeof FileFromSelf.Type;
18
+ export declare const FileFrom: Schema.TaggedStruct<"File", {
19
+ name: typeof Schema.String;
20
+ size: typeof Schema.Number;
21
+ type: typeof Schema.String;
22
+ lastModified: typeof Schema.DateFromNumber;
23
+ data: Schema.Schema<Uint8Array<ArrayBufferLike>, readonly number[], never>;
24
+ }>;
25
+ export type FileEncoded = typeof FileFrom.Encoded;
26
+ export type FileFrom = typeof FileFrom.Type;
27
+ export declare const File: Schema.Schema<File, FileEncoded>;
28
+ export declare const FormDataFromSelf: Schema.instanceOf<FormData>;
29
+ export type FormDataFromSelf = typeof FormDataFromSelf.Type;
30
+ export declare const FormDataEntryValue: Schema.Union<[Schema.Schema<Blob, {
31
+ readonly type: string;
32
+ readonly _tag: "Blob";
33
+ readonly size: number;
34
+ readonly data: readonly number[];
35
+ }, never>, Schema.Schema<File, {
36
+ readonly type: string;
37
+ readonly _tag: "File";
38
+ readonly name: string;
39
+ readonly size: number;
40
+ readonly data: readonly number[];
41
+ readonly lastModified: number;
42
+ }, never>, typeof Schema.String]>;
43
+ export type FormDataEntryValue = typeof FormDataEntryValue.Type;
44
+ export type FormDataEntryValueEncoded = typeof FormDataEntryValue.Encoded;
45
+ export declare const FormDataFrom: Schema.Record$<typeof Schema.String, Schema.Union<[Schema.Schema<Blob, {
46
+ readonly type: string;
47
+ readonly _tag: "Blob";
48
+ readonly size: number;
49
+ readonly data: readonly number[];
50
+ }, never>, Schema.Schema<File, {
51
+ readonly type: string;
52
+ readonly _tag: "File";
53
+ readonly name: string;
54
+ readonly size: number;
55
+ readonly data: readonly number[];
56
+ readonly lastModified: number;
57
+ }, never>, typeof Schema.String]>>;
58
+ export type FormDataEncoded = typeof FormDataFrom.Encoded;
59
+ export type FormDataFrom = typeof FormDataFrom.Type;
60
+ export declare const FormData: Schema.Schema<FormData, FormDataEncoded>;
61
+ type AnySchemaEncoded<T> = Schema.Schema<any, T, any> | Schema.Schema<any, T, never>;
62
+ type AnyFormDataFieldSchema = AnySchemaEncoded<string> | AnySchemaEncoded<Blob> | AnySchemaEncoded<File> | AnySchemaEncoded<string | null> | AnySchemaEncoded<Blob | null> | AnySchemaEncoded<File | null>;
63
+ type FormDataFields = Record<string, AnyFormDataFieldSchema>;
64
+ export declare function schemaFormData<const Fields extends FormDataFields>(fields: Fields): Schema.Schema<{
65
+ readonly [K in keyof Schema.Struct.Type<Fields>]: Schema.Struct.Type<Fields>[K];
66
+ }, FormData, Schema.Schema.Context<Fields[keyof Fields]>>;
67
+ export type FormGetSubmit = Types.Simplify<Options.NoBody & NavigateOptions & {
68
+ readonly method: 'get';
69
+ readonly name: string;
70
+ readonly action?: string | URL;
71
+ }>;
72
+ export type FormPostSubmit = Types.Simplify<Omit<FormGetSubmit, 'method'> & {
73
+ readonly method: 'post';
74
+ readonly body?: HttpBody.HttpBody;
75
+ }>;
76
+ export type FormSubmit = FormGetSubmit | FormPostSubmit;
77
+ export declare const FormDataFromUrlSearchParams: Schema.Schema<FormData, URLSearchParams>;
78
+ export declare const UrlSearchParamsToFormData: Schema.Schema<URLSearchParams, FormData>;
79
+ export {};
package/dist/Forms.js ADDED
@@ -0,0 +1,111 @@
1
+ import * as Array from 'effect/Array';
2
+ import * as Effect from 'effect/Effect';
3
+ import * as ParseResult from 'effect/ParseResult';
4
+ import * as Schema from 'effect/Schema';
5
+ import * as SchemaAST from 'effect/SchemaAST';
6
+ import { UrlSearchParamsFromSelf } from './Url.js';
7
+ export const BlobFromSelf = Schema.instanceOf(globalThis.Blob);
8
+ export const BlobFrom = Schema.TaggedStruct('Blob', {
9
+ type: Schema.String,
10
+ size: Schema.Number,
11
+ data: Schema.Uint8Array,
12
+ });
13
+ export const Blob = BlobFrom.pipe(Schema.transformOrFail(BlobFromSelf, {
14
+ strict: true,
15
+ decode: (blob) => Effect.succeed(new globalThis.Blob([blob.data], { type: blob.type })),
16
+ encode: (blob) => Effect.promise(() => blob
17
+ .arrayBuffer()
18
+ .then((data) => BlobFrom.make({ type: blob.type, size: blob.size, data: new Uint8Array(data) }))),
19
+ }));
20
+ export const FileFromSelf = Schema.instanceOf(globalThis.File);
21
+ export const FileFrom = Schema.TaggedStruct('File', {
22
+ name: Schema.String,
23
+ size: Schema.Number,
24
+ type: Schema.String,
25
+ lastModified: Schema.DateFromNumber,
26
+ data: Schema.Uint8Array,
27
+ });
28
+ export const File = FileFrom.pipe(Schema.transformOrFail(FileFromSelf, {
29
+ strict: true,
30
+ decode: (file) => Effect.succeed(new globalThis.File([file.data], file.name, {
31
+ type: file.type,
32
+ lastModified: file.lastModified.getTime(),
33
+ })),
34
+ encode: (file) => Effect.promise(() => file.arrayBuffer().then((data) => FileFrom.make({
35
+ name: file.name,
36
+ size: file.size,
37
+ type: file.type,
38
+ lastModified: new Date(file.lastModified),
39
+ data: new Uint8Array(data),
40
+ }))),
41
+ }));
42
+ export const FormDataFromSelf = Schema.instanceOf(globalThis.FormData);
43
+ export const FormDataEntryValue = Schema.Union(Blob, File, Schema.String);
44
+ export const FormDataFrom = Schema.Record({
45
+ key: Schema.String,
46
+ value: FormDataEntryValue,
47
+ });
48
+ export const FormData = FormDataFrom.pipe(Schema.transform(FormDataFromSelf, {
49
+ strict: true,
50
+ decode: structToFormData,
51
+ encode: formDataToStruct,
52
+ }));
53
+ export function schemaFormData(fields) {
54
+ return Schema.transform(FormDataFromSelf, Schema.Struct(fields), {
55
+ strict: false,
56
+ decode: formDataToStruct,
57
+ encode: structToFormData,
58
+ });
59
+ }
60
+ function formDataToStruct(formData) {
61
+ const record = {};
62
+ formData.forEach((value, key) => {
63
+ record[key] = value;
64
+ });
65
+ return record;
66
+ }
67
+ function structToFormData(struct) {
68
+ const formData = new globalThis.FormData();
69
+ for (const [key, value] of Object.entries(struct)) {
70
+ formData.append(key, value);
71
+ }
72
+ return formData;
73
+ }
74
+ export const FormDataFromUrlSearchParams = UrlSearchParamsFromSelf.pipe(Schema.transformOrFail(FormDataFromSelf, {
75
+ strict: true,
76
+ decode: (searchParams) => Effect.succeed(searchParamsToFormData(searchParams)),
77
+ encode: (formData) => Effect.gen(function* () {
78
+ const searchParams = new globalThis.URLSearchParams();
79
+ const errors = [];
80
+ for (const [key, value] of Object.entries(formDataToStruct(formData))) {
81
+ if (typeof value === 'string') {
82
+ searchParams.set(key, value);
83
+ }
84
+ else {
85
+ errors.push(new ParseResult.Type(SchemaAST.stringKeyword, value, `Expected string at '${key}' but found ${value instanceof globalThis.File ? 'File' : 'Blob'}`));
86
+ }
87
+ }
88
+ if (Array.isNonEmptyReadonlyArray(errors)) {
89
+ return yield* ParseResult.fail(new ParseResult.Composite(SchemaAST.stringKeyword, formData, errors));
90
+ }
91
+ return searchParams;
92
+ }),
93
+ }));
94
+ export const UrlSearchParamsToFormData = swap(FormDataFromUrlSearchParams);
95
+ function searchParamsToFormData(searchParams) {
96
+ const formData = new globalThis.FormData();
97
+ searchParams.forEach((value, key) => {
98
+ formData.append(key, value);
99
+ });
100
+ return formData;
101
+ }
102
+ function swap(schema) {
103
+ const encode = ParseResult.encode(schema);
104
+ const decode = ParseResult.decode(schema);
105
+ return Schema.transformOrFail(Schema.typeSchema(schema), Schema.encodedSchema(schema), {
106
+ strict: true,
107
+ decode: encode,
108
+ encode: decode,
109
+ });
110
+ }
111
+ //# sourceMappingURL=Forms.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Forms.js","sourceRoot":"","sources":["../src/Forms.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,WAAW,MAAM,oBAAoB,CAAA;AACjD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,kBAAkB,CAAA;AAG7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA;AAElD,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;AAG9D,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE;IAClD,IAAI,EAAE,MAAM,CAAC,MAAM;IACnB,IAAI,EAAE,MAAM,CAAC,MAAM;IACnB,IAAI,EAAE,MAAM,CAAC,UAAU;CACxB,CAAC,CAAA;AAKF,MAAM,CAAC,MAAM,IAAI,GAAqC,QAAQ,CAAC,IAAI,CACjE,MAAM,CAAC,eAAe,CAAC,YAAY,EAAE;IACnC,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,CAAC,MAAM,CAAC,EAAE;QACrF,MAAM,EAAE,IAAI;QACZ,MAAM,EAAE,MAAM;QACd,MAAM,EAAE,MAAM;KACf,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type * as Effect from 'effect/Effect';
2
+ import type * as Option from 'effect/Option';
3
+ import type { CancelNavigation, RedirectError } from './Error.js';
4
+ import type { NavigationEvent, TransitionEvent } from './Event.js';
5
+ export type BeforeNavigationHandler<R, R2> = (event: TransitionEvent) => Effect.Effect<void | Option.Option<Effect.Effect<unknown, RedirectError | CancelNavigation, R2>>, RedirectError | CancelNavigation, R>;
6
+ export type NavigationHandler<R, R2> = (event: NavigationEvent) => Effect.Effect<void | Option.Option<Effect.Effect<unknown, never, R2>>, never, R>;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Handler.js","sourceRoot":"","sources":["../src/Handler.ts"],"names":[],"mappings":""}
@@ -1,13 +1,17 @@
1
1
  /**
2
2
  * @since 1.0.0
3
3
  */
4
- import type * as Effect from "effect/Effect";
5
- import type * as Layer from "effect/Layer";
6
- import type { BeforeNavigationEvent, Destination, Navigation, NavigationError } from "./Navigation.js";
4
+ import type { GetRandomValues } from '@typed/id';
5
+ import type * as Effect from 'effect/Effect';
6
+ import type * as Layer from 'effect/Layer';
7
+ import type { Destination } from './Destination.js';
8
+ import type { NavigationError } from './Error.js';
9
+ import type { TransitionEvent } from './Event.js';
10
+ import type { Navigation } from './Navigation.js';
7
11
  /**
8
12
  * @since 1.0.0
9
13
  */
10
- export declare const fromWindow: Layer.Layer<Navigation, never, Window>;
14
+ export declare const fromWindow: (window: Window) => Layer.Layer<Navigation, never, GetRandomValues>;
11
15
  /**
12
16
  * @since 1.0.0
13
17
  */
@@ -22,7 +26,7 @@ export interface MemoryOptions {
22
26
  /**
23
27
  * @since 1.0.0
24
28
  */
25
- export declare const memory: (options: MemoryOptions) => Layer.Layer<Navigation>;
29
+ export declare const memory: (options: MemoryOptions) => Layer.Layer<Navigation, never, GetRandomValues>;
26
30
  /**
27
31
  * @since 1.0.0
28
32
  */
@@ -37,9 +41,8 @@ export interface InitialMemoryOptions {
37
41
  /**
38
42
  * @since 1.0.0
39
43
  */
40
- export declare const initialMemory: (options: InitialMemoryOptions) => Layer.Layer<Navigation>;
44
+ export declare const initialMemory: (options: InitialMemoryOptions) => Layer.Layer<Navigation, never, GetRandomValues>;
41
45
  /**
42
46
  * @since 1.0.0
43
47
  */
44
- export type Commit = (to: Destination, event: BeforeNavigationEvent) => Effect.Effect<void, NavigationError>;
45
- //# sourceMappingURL=Layer.d.ts.map
48
+ export type Commit = (to: Destination, event: TransitionEvent) => Effect.Effect<void, NavigationError>;
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * @since 1.0.0
3
3
  */
4
- import * as internalFromWindow from "./internal/fromWindow.js";
5
- import * as internalMemory from "./internal/memory.js";
4
+ import * as internalFromWindow from './internal/fromWindow.js';
5
+ import * as internalMemory from './internal/memory.js';
6
6
  /**
7
7
  * @since 1.0.0
8
8
  */
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Layer.js","sourceRoot":"","sources":["../src/Layer.ts"],"names":[],"mappings":"AAAA;;GAEG;AAQH,OAAO,KAAK,kBAAkB,MAAM,0BAA0B,CAAA;AAC9D,OAAO,KAAK,cAAc,MAAM,sBAAsB,CAAA;AAGtD;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GACrB,kBAAkB,CAAC,UAAU,CAAA;AAc/B;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GACjB,cAAc,CAAC,MAAM,CAAA;AAcvB;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAE6B,cAAc,CAAC,aAAa,CAAA"}
@@ -0,0 +1,7 @@
1
+ import * as Schema from 'effect/Schema';
2
+ export declare const NavigateOptions: Schema.Struct<{
3
+ history: Schema.optional<Schema.Literal<["replace", "push", "auto"]>>;
4
+ state: Schema.optional<typeof Schema.Unknown>;
5
+ info: Schema.optional<typeof Schema.Unknown>;
6
+ }>;
7
+ export type NavigateOptions = Schema.Schema.Type<typeof NavigateOptions>;
@@ -0,0 +1,7 @@
1
+ import * as Schema from 'effect/Schema';
2
+ export const NavigateOptions = Schema.Struct({
3
+ history: Schema.optional(Schema.Union(Schema.Literal('replace', 'push', 'auto'))),
4
+ state: Schema.optional(Schema.Unknown),
5
+ info: Schema.optional(Schema.Unknown),
6
+ });
7
+ //# sourceMappingURL=NavigateOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NavigateOptions.js","sourceRoot":"","sources":["../src/NavigateOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC;IAC3C,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACjF,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC;IACtC,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC;CACtC,CAAC,CAAA"}