@jfdevelops/react-layout 0.22.0 → 0.23.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.
Files changed (119) hide show
  1. package/dist/create-config/create-resource-links.cjs +42 -22
  2. package/dist/create-config/create-resource-links.cjs.map +1 -1
  3. package/dist/create-config/create-resource-links.d.cts +25 -2
  4. package/dist/create-config/create-resource-links.d.cts.map +1 -1
  5. package/dist/create-config/create-resource-links.d.mts +25 -2
  6. package/dist/create-config/create-resource-links.d.mts.map +1 -1
  7. package/dist/create-config/create-resource-links.mjs +43 -22
  8. package/dist/create-config/create-resource-links.mjs.map +1 -1
  9. package/dist/create-config/define-layout.cjs +29 -9
  10. package/dist/create-config/define-layout.cjs.map +1 -1
  11. package/dist/create-config/define-layout.d.cts +13 -1
  12. package/dist/create-config/define-layout.d.cts.map +1 -1
  13. package/dist/create-config/define-layout.d.mts +13 -1
  14. package/dist/create-config/define-layout.d.mts.map +1 -1
  15. package/dist/create-config/define-layout.mjs +30 -10
  16. package/dist/create-config/define-layout.mjs.map +1 -1
  17. package/dist/create-config/for-paths/builder.cjs +6 -6
  18. package/dist/create-config/for-paths/builder.cjs.map +1 -1
  19. package/dist/create-config/for-paths/builder.mjs +6 -6
  20. package/dist/create-config/for-paths/builder.mjs.map +1 -1
  21. package/dist/create-config/for-resource.cjs +2 -1
  22. package/dist/create-config/for-resource.cjs.map +1 -1
  23. package/dist/create-config/for-resource.d.cts.map +1 -1
  24. package/dist/create-config/for-resource.d.mts.map +1 -1
  25. package/dist/create-config/for-resource.mjs +2 -1
  26. package/dist/create-config/for-resource.mjs.map +1 -1
  27. package/dist/create-config/for-resources/create-for-resources.cjs +15 -14
  28. package/dist/create-config/for-resources/create-for-resources.cjs.map +1 -1
  29. package/dist/create-config/for-resources/create-for-resources.mjs +15 -14
  30. package/dist/create-config/for-resources/create-for-resources.mjs.map +1 -1
  31. package/dist/create-config/index.d.cts +2 -2
  32. package/dist/create-config/index.d.mts +2 -2
  33. package/dist/errors/invalid-component.cjs +15 -7
  34. package/dist/errors/invalid-component.cjs.map +1 -1
  35. package/dist/errors/invalid-component.d.cts +106 -10
  36. package/dist/errors/invalid-component.d.cts.map +1 -1
  37. package/dist/errors/invalid-component.d.mts +106 -10
  38. package/dist/errors/invalid-component.d.mts.map +1 -1
  39. package/dist/errors/invalid-component.mjs +15 -7
  40. package/dist/errors/invalid-component.mjs.map +1 -1
  41. package/dist/errors/invalid-config.cjs +8 -3
  42. package/dist/errors/invalid-config.cjs.map +1 -1
  43. package/dist/errors/invalid-config.d.cts +96 -6
  44. package/dist/errors/invalid-config.d.cts.map +1 -1
  45. package/dist/errors/invalid-config.d.mts +96 -6
  46. package/dist/errors/invalid-config.d.mts.map +1 -1
  47. package/dist/errors/invalid-config.mjs +8 -3
  48. package/dist/errors/invalid-config.mjs.map +1 -1
  49. package/dist/errors/invalid-path.cjs +11 -5
  50. package/dist/errors/invalid-path.cjs.map +1 -1
  51. package/dist/errors/invalid-path.d.cts +100 -8
  52. package/dist/errors/invalid-path.d.cts.map +1 -1
  53. package/dist/errors/invalid-path.d.mts +100 -8
  54. package/dist/errors/invalid-path.d.mts.map +1 -1
  55. package/dist/errors/invalid-path.mjs +11 -5
  56. package/dist/errors/invalid-path.mjs.map +1 -1
  57. package/dist/errors/invalid-resource.cjs +11 -5
  58. package/dist/errors/invalid-resource.cjs.map +1 -1
  59. package/dist/errors/invalid-resource.d.cts +100 -8
  60. package/dist/errors/invalid-resource.d.cts.map +1 -1
  61. package/dist/errors/invalid-resource.d.mts +100 -8
  62. package/dist/errors/invalid-resource.d.mts.map +1 -1
  63. package/dist/errors/invalid-resource.mjs +11 -5
  64. package/dist/errors/invalid-resource.mjs.map +1 -1
  65. package/dist/errors/invalid-sub-resource.cjs +12 -5
  66. package/dist/errors/invalid-sub-resource.cjs.map +1 -1
  67. package/dist/errors/invalid-sub-resource.d.cts +103 -9
  68. package/dist/errors/invalid-sub-resource.d.cts.map +1 -1
  69. package/dist/errors/invalid-sub-resource.d.mts +103 -9
  70. package/dist/errors/invalid-sub-resource.d.mts.map +1 -1
  71. package/dist/errors/invalid-sub-resource.mjs +12 -5
  72. package/dist/errors/invalid-sub-resource.mjs.map +1 -1
  73. package/dist/errors/layout-configuration-error.cjs +17 -0
  74. package/dist/errors/layout-configuration-error.cjs.map +1 -0
  75. package/dist/errors/layout-configuration-error.d.cts +99 -0
  76. package/dist/errors/layout-configuration-error.d.cts.map +1 -0
  77. package/dist/errors/layout-configuration-error.d.mts +99 -0
  78. package/dist/errors/layout-configuration-error.d.mts.map +1 -0
  79. package/dist/errors/layout-configuration-error.mjs +17 -0
  80. package/dist/errors/layout-configuration-error.mjs.map +1 -0
  81. package/dist/errors/missing-path-variable.cjs +12 -5
  82. package/dist/errors/missing-path-variable.cjs.map +1 -1
  83. package/dist/errors/missing-path-variable.d.cts +99 -7
  84. package/dist/errors/missing-path-variable.d.cts.map +1 -1
  85. package/dist/errors/missing-path-variable.d.mts +99 -7
  86. package/dist/errors/missing-path-variable.d.mts.map +1 -1
  87. package/dist/errors/missing-path-variable.mjs +12 -5
  88. package/dist/errors/missing-path-variable.mjs.map +1 -1
  89. package/dist/errors/missing-resource-provider.cjs +12 -0
  90. package/dist/errors/missing-resource-provider.cjs.map +1 -0
  91. package/dist/errors/missing-resource-provider.d.cts +91 -0
  92. package/dist/errors/missing-resource-provider.d.cts.map +1 -0
  93. package/dist/errors/missing-resource-provider.d.mts +91 -0
  94. package/dist/errors/missing-resource-provider.d.mts.map +1 -0
  95. package/dist/errors/missing-resource-provider.mjs +12 -0
  96. package/dist/errors/missing-resource-provider.mjs.map +1 -0
  97. package/dist/errors/react-layout-error.cjs +38 -43
  98. package/dist/errors/react-layout-error.cjs.map +1 -1
  99. package/dist/errors/react-layout-error.d.cts +81 -38
  100. package/dist/errors/react-layout-error.d.cts.map +1 -1
  101. package/dist/errors/react-layout-error.d.mts +81 -38
  102. package/dist/errors/react-layout-error.d.mts.map +1 -1
  103. package/dist/errors/react-layout-error.mjs +39 -43
  104. package/dist/errors/react-layout-error.mjs.map +1 -1
  105. package/dist/index.cjs +6 -3
  106. package/dist/index.d.cts +6 -3
  107. package/dist/index.d.mts +6 -3
  108. package/dist/index.mjs +6 -4
  109. package/dist/node_modules/.pnpm/@jfdevelops_create-error@0.2.0_patch_hash_afc71b16c3f866f54416d30f467784ddc31736feb04f281a5fc4772ea422f4a9/node_modules/@jfdevelops/create-error/dist/types.d.cts +107 -0
  110. package/dist/node_modules/.pnpm/@jfdevelops_create-error@0.2.0_patch_hash_afc71b16c3f866f54416d30f467784ddc31736feb04f281a5fc4772ea422f4a9/node_modules/@jfdevelops/create-error/dist/types.d.cts.map +1 -0
  111. package/dist/node_modules/.pnpm/@jfdevelops_create-error@0.2.0_patch_hash_afc71b16c3f866f54416d30f467784ddc31736feb04f281a5fc4772ea422f4a9/node_modules/@jfdevelops/create-error/dist/types.d.mts +107 -0
  112. package/dist/node_modules/.pnpm/@jfdevelops_create-error@0.2.0_patch_hash_afc71b16c3f866f54416d30f467784ddc31736feb04f281a5fc4772ea422f4a9/node_modules/@jfdevelops/create-error/dist/types.d.mts.map +1 -0
  113. package/dist/resource.cjs +2 -1
  114. package/dist/resource.cjs.map +1 -1
  115. package/dist/resource.d.cts.map +1 -1
  116. package/dist/resource.d.mts.map +1 -1
  117. package/dist/resource.mjs +3 -1
  118. package/dist/resource.mjs.map +1 -1
  119. package/package.json +8 -6
@@ -1,3 +1,5 @@
1
+ let _jfdevelops_create_error = require("@jfdevelops/create-error");
2
+ let arktype = require("arktype");
1
3
 
2
4
  //#region src/errors/react-layout-error.ts
3
5
  function makeJsonSafe(value) {
@@ -6,49 +8,42 @@ function makeJsonSafe(value) {
6
8
  if (value && typeof value === "object") return Object.fromEntries(Object.entries(value).map(([key, nestedValue]) => [key, makeJsonSafe(nestedValue)]));
7
9
  return value;
8
10
  }
9
- /** Base data class for errors thrown by React Layout. */
10
- var ReactLayoutError = class extends Error {
11
- scope;
12
- context;
13
- static invariant(condition, context) {
14
- if (!condition) throw new this(typeof context === "function" ? context() : context);
15
- }
16
- constructor(context) {
17
- super();
18
- this.name = new.target.name;
19
- this.scope = context.scope;
20
- this.context = context;
21
- Object.setPrototypeOf(this, new.target.prototype);
22
- }
23
- toJSON() {
24
- return {
25
- name: this.name,
26
- code: this.code,
27
- scope: this.scope,
28
- message: this.message,
29
- context: makeJsonSafe(this.context)
30
- };
31
- }
32
- };
33
- /** Creates a context-only React Layout error class with a default renderer. */
34
- function createReactLayoutError(options) {
35
- return function createErrorWithRenderer(defaultRenderer) {
36
- return class ReactLayoutErrorWithCode extends ReactLayoutError {
37
- code = options.code;
38
- constructor(context) {
39
- const resolvedContext = {
40
- ...context,
41
- scope: options.scope
42
- };
43
- super(resolvedContext);
44
- this.message = this.renderMessage();
45
- }
46
- renderMessage(renderer) {
47
- return (renderer ?? defaultRenderer)(this.scope, this.context);
48
- }
49
- };
50
- };
51
- }
11
+ /** @internal */
12
+ const createReactLayoutError = (0, _jfdevelops_create_error.createError)({
13
+ definition: (0, arktype.type)({
14
+ code: "string",
15
+ scope: "string"
16
+ }),
17
+ data: {
18
+ property: "context",
19
+ resolve: ({ definition, input }) => typeof input === "object" && input !== null ? {
20
+ ...input,
21
+ scope: definition.scope
22
+ } : input
23
+ },
24
+ message: ({ definition, data, implementation }) => implementation({
25
+ context: data,
26
+ scope: definition.scope
27
+ }),
28
+ properties: ({ definition, data, implementation }) => ({
29
+ code: definition.code,
30
+ scope: definition.scope,
31
+ renderMessage(renderer = (scope, context) => implementation({
32
+ context,
33
+ scope
34
+ })) {
35
+ return renderer(definition.scope, data);
36
+ }
37
+ }),
38
+ toJSON: (error) => ({
39
+ name: error.name,
40
+ code: error.code,
41
+ scope: error.scope,
42
+ message: error.message,
43
+ context: makeJsonSafe(error.context)
44
+ })
45
+ });
46
+ const ReactLayoutError = createReactLayoutError.Error;
52
47
 
53
48
  //#endregion
54
49
  exports.ReactLayoutError = ReactLayoutError;
@@ -1 +1 @@
1
- {"version":3,"file":"react-layout-error.cjs","names":[],"sources":["../../src/errors/react-layout-error.ts"],"sourcesContent":["/** Options used to assign a stable code and scope to a React Layout error. */\nexport type CreateReactLayoutErrorOptions<\n Code extends string = string,\n Scope extends string = string,\n> = {\n code: Code;\n scope: Scope;\n};\n\n/** Shared context carried by every React Layout error. */\nexport interface ReactLayoutErrorContext<Scope extends string>\n extends Record<string, unknown> {\n scope: Scope;\n}\n\n/** Renders an error message from its scope and structured context. */\nexport type ErrorMessageRenderer<\n Scope extends string,\n Context extends ReactLayoutErrorContext<Scope>,\n> = (scope: Scope, context: Context) => string;\n\n/** Constructor and invariant API returned by the React Layout error factory. */\nexport interface CreatedReactLayoutError<\n Code extends string,\n Scope extends string,\n Context extends ReactLayoutErrorContext<Scope>,\n> {\n invariant: <Condition>(\n condition: Condition,\n context: Omit<Context, 'scope'> | (() => Omit<Context, 'scope'>),\n ) => asserts condition;\n new (context: Omit<Context, 'scope'>): ReactLayoutError<\n Code,\n Scope,\n Context\n > & {\n readonly code: Code;\n readonly scope: Scope;\n renderMessage(renderer?: ErrorMessageRenderer<Scope, Context>): string;\n };\n}\n\n/** Adds a default renderer to a React Layout error definition. */\nexport interface ReactLayoutErrorRendererFactory<\n Code extends string,\n Scope extends string,\n> {\n <Context extends ReactLayoutErrorContext<Scope>>(\n defaultRenderer: ErrorMessageRenderer<Scope, Context>,\n ): CreatedReactLayoutError<Code, Scope, Context>;\n}\n\nfunction makeJsonSafe(value: unknown): unknown {\n if (value === undefined) {\n return null;\n }\n\n if (Array.isArray(value)) {\n return value.map(makeJsonSafe);\n }\n\n if (value && typeof value === 'object') {\n return Object.fromEntries(\n Object.entries(value).map(([key, nestedValue]) => [\n key,\n makeJsonSafe(nestedValue),\n ]),\n );\n }\n\n return value;\n}\n\n/** Base data class for errors thrown by React Layout. */\nexport abstract class ReactLayoutError<\n Code extends string = string,\n Scope extends string = string,\n Context extends ReactLayoutErrorContext<Scope> =\n ReactLayoutErrorContext<Scope>,\n> extends Error {\n abstract readonly code: Code;\n readonly scope: Scope;\n readonly context: Context;\n\n static invariant<\n Condition,\n Context extends Record<string, unknown>,\n >(\n this: new (context: Context) => Error,\n condition: Condition,\n context: Context | (() => Context),\n ): asserts condition {\n if (!condition) {\n throw new this(typeof context === 'function' ? context() : context);\n }\n }\n\n constructor(context: Context) {\n super();\n this.name = new.target.name;\n this.scope = context.scope;\n this.context = context;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n abstract renderMessage(\n renderer?: ErrorMessageRenderer<Scope, Context>,\n ): string;\n\n toJSON() {\n return {\n name: this.name,\n code: this.code,\n scope: this.scope,\n message: this.message,\n context: makeJsonSafe(this.context),\n };\n }\n}\n\n/** Creates a context-only React Layout error class with a default renderer. */\nexport function createReactLayoutError<\n const Options extends CreateReactLayoutErrorOptions,\n>(\n options: Options,\n): ReactLayoutErrorRendererFactory<Options['code'], Options['scope']> {\n return function createErrorWithRenderer<\n Context extends ReactLayoutErrorContext<Options['scope']>,\n >(defaultRenderer: ErrorMessageRenderer<Options['scope'], Context>) {\n return class ReactLayoutErrorWithCode extends ReactLayoutError<\n Options['code'],\n Options['scope'],\n Context\n > {\n readonly code = options.code;\n\n constructor(context: Omit<Context, 'scope'>) {\n const resolvedContext = {\n ...context,\n scope: options.scope,\n } as Context;\n\n super(resolvedContext);\n this.message = this.renderMessage();\n }\n\n renderMessage(\n renderer?: ErrorMessageRenderer<Options['scope'], Context>,\n ) {\n return (renderer ?? defaultRenderer)(this.scope, this.context);\n }\n };\n };\n}\n"],"mappings":";;AAoDA,SAAS,aAAa,OAAyB;CAC7C,IAAI,UAAU,QACZ,OAAO;CAGT,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,IAAI,YAAY;CAG/B,IAAI,SAAS,OAAO,UAAU,UAC5B,OAAO,OAAO,YACZ,OAAO,QAAQ,KAAK,EAAE,KAAK,CAAC,KAAK,iBAAiB,CAChD,KACA,aAAa,WAAW,CAC1B,CAAC,CACH;CAGF,OAAO;AACT;;AAGA,IAAsB,mBAAtB,cAKU,MAAM;CAEd,AAAS;CACT,AAAS;CAET,OAAO,UAKL,WACA,SACmB;EACnB,IAAI,CAAC,WACH,MAAM,IAAI,KAAK,OAAO,YAAY,aAAa,QAAQ,IAAI,OAAO;CAEtE;CAEA,YAAY,SAAkB;EAC5B,MAAM;EACN,KAAK,OAAO,IAAI,OAAO;EACvB,KAAK,QAAQ,QAAQ;EACrB,KAAK,UAAU;EAEf,OAAO,eAAe,MAAM,IAAI,OAAO,SAAS;CAClD;CAMA,SAAS;EACP,OAAO;GACL,MAAM,KAAK;GACX,MAAM,KAAK;GACX,OAAO,KAAK;GACZ,SAAS,KAAK;GACd,SAAS,aAAa,KAAK,OAAO;EACpC;CACF;AACF;;AAGA,SAAgB,uBAGd,SACoE;CACpE,OAAO,SAAS,wBAEd,iBAAkE;EAClE,OAAO,MAAM,iCAAiC,iBAI5C;GACA,AAAS,OAAO,QAAQ;GAExB,YAAY,SAAiC;IAC3C,MAAM,kBAAkB;KACtB,GAAG;KACH,OAAO,QAAQ;IACjB;IAEA,MAAM,eAAe;IACrB,KAAK,UAAU,KAAK,cAAc;GACpC;GAEA,cACE,UACA;IACA,QAAQ,YAAY,iBAAiB,KAAK,OAAO,KAAK,OAAO;GAC/D;EACF;CACF;AACF"}
1
+ {"version":3,"file":"react-layout-error.cjs","names":[],"sources":["../../src/errors/react-layout-error.ts"],"sourcesContent":["import { createError } from '@jfdevelops/create-error';\nimport { type } from 'arktype';\n\nfunction makeJsonSafe(value: unknown): unknown {\n if (value === undefined) {\n return null;\n }\n\n if (Array.isArray(value)) {\n return value.map(makeJsonSafe);\n }\n\n if (value && typeof value === 'object') {\n return Object.fromEntries(\n Object.entries(value).map(([key, nestedValue]) => [\n key,\n makeJsonSafe(nestedValue),\n ]),\n );\n }\n\n return value;\n}\n\n/** @internal */\nexport const createReactLayoutError = createError({\n definition: type({ code: 'string', scope: 'string' }),\n data: {\n property: 'context',\n resolve: ({ definition, input }) =>\n typeof input === 'object' && input !== null\n ? { ...input, scope: definition.scope }\n : input,\n },\n message: ({ definition, data, implementation }) =>\n implementation({ context: data, scope: definition.scope }),\n properties: ({ definition, data, implementation }) => ({\n code: definition.code,\n scope: definition.scope,\n renderMessage(\n renderer: (\n scope: typeof definition.scope,\n context: typeof data,\n ) => string = (scope, context) => implementation({ context, scope }),\n ) {\n return renderer(definition.scope, data);\n },\n }),\n toJSON: (error) => ({\n name: error.name,\n code: error.code,\n scope: error.scope,\n message: error.message,\n context: makeJsonSafe(error.context),\n }),\n});\n\nexport const ReactLayoutError = createReactLayoutError.Error;\n"],"mappings":";;;;AAGA,SAAS,aAAa,OAAyB;CAC7C,IAAI,UAAU,QACZ,OAAO;CAGT,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,IAAI,YAAY;CAG/B,IAAI,SAAS,OAAO,UAAU,UAC5B,OAAO,OAAO,YACZ,OAAO,QAAQ,KAAK,EAAE,KAAK,CAAC,KAAK,iBAAiB,CAChD,KACA,aAAa,WAAW,CAC1B,CAAC,CACH;CAGF,OAAO;AACT;;AAGA,MAAa,mEAAqC;CAChD,8BAAiB;EAAE,MAAM;EAAU,OAAO;CAAS,CAAC;CACpD,MAAM;EACJ,UAAU;EACV,UAAU,EAAE,YAAY,YACtB,OAAO,UAAU,YAAY,UAAU,OACnC;GAAE,GAAG;GAAO,OAAO,WAAW;EAAM,IACpC;CACR;CACA,UAAU,EAAE,YAAY,MAAM,qBAC5B,eAAe;EAAE,SAAS;EAAM,OAAO,WAAW;CAAM,CAAC;CAC3D,aAAa,EAAE,YAAY,MAAM,sBAAsB;EACrD,MAAM,WAAW;EACjB,OAAO,WAAW;EAClB,cACE,YAGe,OAAO,YAAY,eAAe;GAAE;GAAS;EAAM,CAAC,GACnE;GACA,OAAO,SAAS,WAAW,OAAO,IAAI;EACxC;CACF;CACA,SAAS,WAAW;EAClB,MAAM,MAAM;EACZ,MAAM,MAAM;EACZ,OAAO,MAAM;EACb,SAAS,MAAM;EACf,SAAS,aAAa,MAAM,OAAO;CACrC;AACF,CAAC;AAED,MAAa,mBAAmB,uBAAuB"}
@@ -1,46 +1,89 @@
1
+ import { FamilyErrorClass } from "../node_modules/.pnpm/@jfdevelops_create-error@0.2.0_patch_hash_afc71b16c3f866f54416d30f467784ddc31736feb04f281a5fc4772ea422f4a9/node_modules/@jfdevelops/create-error/dist/types.cjs";
2
+
1
3
  //#region src/errors/react-layout-error.d.ts
2
- /** Options used to assign a stable code and scope to a React Layout error. */
3
- type CreateReactLayoutErrorOptions<Code extends string = string, Scope extends string = string> = {
4
- code: Code;
5
- scope: Scope;
6
- };
7
- /** Shared context carried by every React Layout error. */
8
- interface ReactLayoutErrorContext<Scope extends string> extends Record<string, unknown> {
9
- scope: Scope;
10
- }
11
- /** Renders an error message from its scope and structured context. */
12
- type ErrorMessageRenderer<Scope extends string, Context extends ReactLayoutErrorContext<Scope>> = (scope: Scope, context: Context) => string;
13
- /** Constructor and invariant API returned by the React Layout error factory. */
14
- interface CreatedReactLayoutError<Code extends string, Scope extends string, Context extends ReactLayoutErrorContext<Scope>> {
15
- invariant: <Condition>(condition: Condition, context: Omit<Context, 'scope'> | (() => Omit<Context, 'scope'>)) => asserts condition;
16
- new (context: Omit<Context, 'scope'>): ReactLayoutError<Code, Scope, Context> & {
17
- readonly code: Code;
18
- readonly scope: Scope;
19
- renderMessage(renderer?: ErrorMessageRenderer<Scope, Context>): string;
4
+ declare const ReactLayoutError: FamilyErrorClass<import("@jfdevelops/create-error/types").FamilyError<import("arktype/internal/variants/object.ts").ObjectType<{
5
+ code: string;
6
+ scope: string;
7
+ }, {}>, {
8
+ definition: import("arktype/internal/variants/object.ts").ObjectType<{
9
+ code: string;
10
+ scope: string;
11
+ }, {}>;
12
+ } & {
13
+ data: {
14
+ readonly property: "context";
15
+ readonly resolve: ({
16
+ definition,
17
+ input
18
+ }: import("@jfdevelops/create-error/types").ResolveContext<import("arktype/internal/variants/object.ts").ObjectType<{
19
+ code: string;
20
+ scope: string;
21
+ }, {}>>) => {
22
+ scope: string & import("@jfdevelops/create-error/types").TypeSlot<"definition", "scope">;
23
+ };
20
24
  };
21
- }
22
- /** Adds a default renderer to a React Layout error definition. */
23
- interface ReactLayoutErrorRendererFactory<Code extends string, Scope extends string> {
24
- <Context extends ReactLayoutErrorContext<Scope>>(defaultRenderer: ErrorMessageRenderer<Scope, Context>): CreatedReactLayoutError<Code, Scope, Context>;
25
- }
26
- /** Base data class for errors thrown by React Layout. */
27
- declare abstract class ReactLayoutError<Code extends string = string, Scope extends string = string, Context extends ReactLayoutErrorContext<Scope> = ReactLayoutErrorContext<Scope>> extends Error {
28
- abstract readonly code: Code;
29
- readonly scope: Scope;
30
- readonly context: Context;
31
- static invariant<Condition, Context extends Record<string, unknown>>(this: new (context: Context) => Error, condition: Condition, context: Context | (() => Context)): asserts condition;
32
- constructor(context: Context);
33
- abstract renderMessage(renderer?: ErrorMessageRenderer<Scope, Context>): string;
34
- toJSON(): {
25
+ message: ({
26
+ definition,
27
+ data,
28
+ implementation
29
+ }: import("@jfdevelops/create-error/types").BlueprintContext<import("arktype/internal/variants/object.ts").ObjectType<{
30
+ code: string;
31
+ scope: string;
32
+ }, {}>>) => string & import("@jfdevelops/create-error/types").TypeSlot<"implementationArgument", {
33
+ readonly context: import("@jfdevelops/create-error/types").DataSlot;
34
+ readonly scope: string & import("@jfdevelops/create-error/types").TypeSlot<"definition", "scope">;
35
+ }>;
36
+ } & {
37
+ properties(context: import("@jfdevelops/create-error/types").BlueprintContext<import("arktype/internal/variants/object.ts").ObjectType<{
38
+ code: string;
39
+ scope: string;
40
+ }, {}>>): {
41
+ readonly code: string & import("@jfdevelops/create-error/types").TypeSlot<"definition", "code">;
42
+ readonly scope: string & import("@jfdevelops/create-error/types").TypeSlot<"definition", "scope">;
43
+ readonly renderMessage: (renderer?: (scope: string & import("@jfdevelops/create-error/types").TypeSlot<"definition", "scope">, context: import("@jfdevelops/create-error/types").DataSlot) => string) => string;
44
+ };
45
+ } & {
46
+ toJSON(error: import("@jfdevelops/create-error/types").BlueprintErrorTemplate<NoInfer<{
47
+ data: {
48
+ readonly property: "context";
49
+ readonly resolve: ({
50
+ definition,
51
+ input
52
+ }: import("@jfdevelops/create-error/types").ResolveContext<import("arktype/internal/variants/object.ts").ObjectType<{
53
+ code: string;
54
+ scope: string;
55
+ }, {}>>) => {
56
+ scope: string & import("@jfdevelops/create-error/types").TypeSlot<"definition", "scope">;
57
+ };
58
+ };
59
+ message: ({
60
+ definition,
61
+ data,
62
+ implementation
63
+ }: import("@jfdevelops/create-error/types").BlueprintContext<import("arktype/internal/variants/object.ts").ObjectType<{
64
+ code: string;
65
+ scope: string;
66
+ }, {}>>) => string & import("@jfdevelops/create-error/types").TypeSlot<"implementationArgument", {
67
+ readonly context: import("@jfdevelops/create-error/types").DataSlot;
68
+ readonly scope: string & import("@jfdevelops/create-error/types").TypeSlot<"definition", "scope">;
69
+ }>;
70
+ } & {
71
+ properties(context: import("@jfdevelops/create-error/types").BlueprintContext<import("arktype/internal/variants/object.ts").ObjectType<{
72
+ code: string;
73
+ scope: string;
74
+ }, {}>>): {
75
+ readonly code: string & import("@jfdevelops/create-error/types").TypeSlot<"definition", "code">;
76
+ readonly scope: string & import("@jfdevelops/create-error/types").TypeSlot<"definition", "scope">;
77
+ readonly renderMessage: (renderer?: (scope: string & import("@jfdevelops/create-error/types").TypeSlot<"definition", "scope">, context: import("@jfdevelops/create-error/types").DataSlot) => string) => string;
78
+ };
79
+ }>>): {
35
80
  name: string;
36
- code: Code;
37
- scope: Scope;
81
+ code: string & import("@jfdevelops/create-error/types").TypeSlot<"definition", "code">;
82
+ scope: string & import("@jfdevelops/create-error/types").TypeSlot<"definition", "scope">;
38
83
  message: string;
39
84
  context: unknown;
40
85
  };
41
- }
42
- /** Creates a context-only React Layout error class with a default renderer. */
43
- declare function createReactLayoutError<const Options extends CreateReactLayoutErrorOptions>(options: Options): ReactLayoutErrorRendererFactory<Options['code'], Options['scope']>;
86
+ }>>;
44
87
  //#endregion
45
- export { CreateReactLayoutErrorOptions, CreatedReactLayoutError, ErrorMessageRenderer, ReactLayoutError, ReactLayoutErrorContext, ReactLayoutErrorRendererFactory, createReactLayoutError };
88
+ export { ReactLayoutError };
46
89
  //# sourceMappingURL=react-layout-error.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"react-layout-error.d.cts","names":[],"sources":["../../src/errors/react-layout-error.ts"],"mappings":";;KACY,6BAAA;EAIV,IAAA,EAAM,IAAA;EACN,KAAA,EAAO,KAAK;AAAA;;UAIG,uBAAA,+BACP,MAAM;EACd,KAAA,EAAO,KAAA;AAAA;;KAIG,oBAAA,uCAEM,uBAAA,CAAwB,KAAA,MACrC,KAAA,EAAO,KAAA,EAAO,OAAA,EAAS,OAAA;;UAGX,uBAAA,4DAGC,uBAAA,CAAwB,KAAA;EAExC,SAAA,cACE,SAAA,EAAW,SAAA,EACX,OAAA,EAAS,IAAA,CAAK,OAAA,oBAA2B,IAAA,CAAK,OAAA,wBACnC,SAAA;EAAA,KACR,OAAA,EAAS,IAAA,CAAK,OAAA,aAAoB,gBAAA,CACrC,IAAA,EACA,KAAA,EACA,OAAA;IAAA,SAES,IAAA,EAAM,IAAA;IAAA,SACN,KAAA,EAAO,KAAA;IAChB,aAAA,CAAc,QAAA,GAAW,oBAAA,CAAqB,KAAA,EAAO,OAAA;EAAA;AAAA;;UAKxC,+BAAA;EAAA,iBAIE,uBAAA,CAAwB,KAAA,GACvC,eAAA,EAAiB,oBAAA,CAAqB,KAAA,EAAO,OAAA,IAC5C,uBAAA,CAAwB,IAAA,EAAM,KAAA,EAAO,OAAA;AAAA;;uBAyBpB,gBAAA,8EAGJ,uBAAA,CAAwB,KAAA,IACtC,uBAAA,CAAwB,KAAA,WAClB,KAAA;EAAA,kBACU,IAAA,EAAM,IAAA;EAAA,SACf,KAAA,EAAO,KAAA;EAAA,SACP,OAAA,EAAS,OAAA;EAAA,OAEX,SAAA,4BAEW,MAAA,mBAEhB,IAAA,OAAW,OAAA,EAAS,OAAA,KAAY,KAAA,EAChC,SAAA,EAAW,SAAA,EACX,OAAA,EAAS,OAAA,UAAiB,OAAA,YACjB,SAAA;cAMC,OAAA,EAAS,OAAA;EAAA,SASZ,aAAA,CACP,QAAA,GAAW,oBAAA,CAAqB,KAAA,EAAO,OAAA;EAGzC,MAAA;;;;;;;;;iBAYc,sBAAA,uBACQ,6BAAA,EAEtB,OAAA,EAAS,OAAA,GACR,+BAAA,CAAgC,OAAA,UAAiB,OAAA"}
1
+ {"version":3,"file":"react-layout-error.d.cts","names":[],"sources":["../../src/errors/react-layout-error.ts"],"mappings":";;;cAyDa,gBAAA,4DAAgB,WAAA,+CAAA,UAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yCAhBrB,KAAA,oDAAK,QAAA,yBACL,OAAA,2CAAO,QAAA;EAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2CADP,KAAA,oDAAK,QAAA,yBACL,OAAA,2CAAO,QAAA;IAAA;EAAA"}
@@ -1,46 +1,89 @@
1
+ import { FamilyErrorClass } from "../node_modules/.pnpm/@jfdevelops_create-error@0.2.0_patch_hash_afc71b16c3f866f54416d30f467784ddc31736feb04f281a5fc4772ea422f4a9/node_modules/@jfdevelops/create-error/dist/types.mjs";
2
+
1
3
  //#region src/errors/react-layout-error.d.ts
2
- /** Options used to assign a stable code and scope to a React Layout error. */
3
- type CreateReactLayoutErrorOptions<Code extends string = string, Scope extends string = string> = {
4
- code: Code;
5
- scope: Scope;
6
- };
7
- /** Shared context carried by every React Layout error. */
8
- interface ReactLayoutErrorContext<Scope extends string> extends Record<string, unknown> {
9
- scope: Scope;
10
- }
11
- /** Renders an error message from its scope and structured context. */
12
- type ErrorMessageRenderer<Scope extends string, Context extends ReactLayoutErrorContext<Scope>> = (scope: Scope, context: Context) => string;
13
- /** Constructor and invariant API returned by the React Layout error factory. */
14
- interface CreatedReactLayoutError<Code extends string, Scope extends string, Context extends ReactLayoutErrorContext<Scope>> {
15
- invariant: <Condition>(condition: Condition, context: Omit<Context, 'scope'> | (() => Omit<Context, 'scope'>)) => asserts condition;
16
- new (context: Omit<Context, 'scope'>): ReactLayoutError<Code, Scope, Context> & {
17
- readonly code: Code;
18
- readonly scope: Scope;
19
- renderMessage(renderer?: ErrorMessageRenderer<Scope, Context>): string;
4
+ declare const ReactLayoutError: FamilyErrorClass<import("@jfdevelops/create-error/types").FamilyError<import("arktype/internal/variants/object.ts").ObjectType<{
5
+ code: string;
6
+ scope: string;
7
+ }, {}>, {
8
+ definition: import("arktype/internal/variants/object.ts").ObjectType<{
9
+ code: string;
10
+ scope: string;
11
+ }, {}>;
12
+ } & {
13
+ data: {
14
+ readonly property: "context";
15
+ readonly resolve: ({
16
+ definition,
17
+ input
18
+ }: import("@jfdevelops/create-error/types").ResolveContext<import("arktype/internal/variants/object.ts").ObjectType<{
19
+ code: string;
20
+ scope: string;
21
+ }, {}>>) => {
22
+ scope: string & import("@jfdevelops/create-error/types").TypeSlot<"definition", "scope">;
23
+ };
20
24
  };
21
- }
22
- /** Adds a default renderer to a React Layout error definition. */
23
- interface ReactLayoutErrorRendererFactory<Code extends string, Scope extends string> {
24
- <Context extends ReactLayoutErrorContext<Scope>>(defaultRenderer: ErrorMessageRenderer<Scope, Context>): CreatedReactLayoutError<Code, Scope, Context>;
25
- }
26
- /** Base data class for errors thrown by React Layout. */
27
- declare abstract class ReactLayoutError<Code extends string = string, Scope extends string = string, Context extends ReactLayoutErrorContext<Scope> = ReactLayoutErrorContext<Scope>> extends Error {
28
- abstract readonly code: Code;
29
- readonly scope: Scope;
30
- readonly context: Context;
31
- static invariant<Condition, Context extends Record<string, unknown>>(this: new (context: Context) => Error, condition: Condition, context: Context | (() => Context)): asserts condition;
32
- constructor(context: Context);
33
- abstract renderMessage(renderer?: ErrorMessageRenderer<Scope, Context>): string;
34
- toJSON(): {
25
+ message: ({
26
+ definition,
27
+ data,
28
+ implementation
29
+ }: import("@jfdevelops/create-error/types").BlueprintContext<import("arktype/internal/variants/object.ts").ObjectType<{
30
+ code: string;
31
+ scope: string;
32
+ }, {}>>) => string & import("@jfdevelops/create-error/types").TypeSlot<"implementationArgument", {
33
+ readonly context: import("@jfdevelops/create-error/types").DataSlot;
34
+ readonly scope: string & import("@jfdevelops/create-error/types").TypeSlot<"definition", "scope">;
35
+ }>;
36
+ } & {
37
+ properties(context: import("@jfdevelops/create-error/types").BlueprintContext<import("arktype/internal/variants/object.ts").ObjectType<{
38
+ code: string;
39
+ scope: string;
40
+ }, {}>>): {
41
+ readonly code: string & import("@jfdevelops/create-error/types").TypeSlot<"definition", "code">;
42
+ readonly scope: string & import("@jfdevelops/create-error/types").TypeSlot<"definition", "scope">;
43
+ readonly renderMessage: (renderer?: (scope: string & import("@jfdevelops/create-error/types").TypeSlot<"definition", "scope">, context: import("@jfdevelops/create-error/types").DataSlot) => string) => string;
44
+ };
45
+ } & {
46
+ toJSON(error: import("@jfdevelops/create-error/types").BlueprintErrorTemplate<NoInfer<{
47
+ data: {
48
+ readonly property: "context";
49
+ readonly resolve: ({
50
+ definition,
51
+ input
52
+ }: import("@jfdevelops/create-error/types").ResolveContext<import("arktype/internal/variants/object.ts").ObjectType<{
53
+ code: string;
54
+ scope: string;
55
+ }, {}>>) => {
56
+ scope: string & import("@jfdevelops/create-error/types").TypeSlot<"definition", "scope">;
57
+ };
58
+ };
59
+ message: ({
60
+ definition,
61
+ data,
62
+ implementation
63
+ }: import("@jfdevelops/create-error/types").BlueprintContext<import("arktype/internal/variants/object.ts").ObjectType<{
64
+ code: string;
65
+ scope: string;
66
+ }, {}>>) => string & import("@jfdevelops/create-error/types").TypeSlot<"implementationArgument", {
67
+ readonly context: import("@jfdevelops/create-error/types").DataSlot;
68
+ readonly scope: string & import("@jfdevelops/create-error/types").TypeSlot<"definition", "scope">;
69
+ }>;
70
+ } & {
71
+ properties(context: import("@jfdevelops/create-error/types").BlueprintContext<import("arktype/internal/variants/object.ts").ObjectType<{
72
+ code: string;
73
+ scope: string;
74
+ }, {}>>): {
75
+ readonly code: string & import("@jfdevelops/create-error/types").TypeSlot<"definition", "code">;
76
+ readonly scope: string & import("@jfdevelops/create-error/types").TypeSlot<"definition", "scope">;
77
+ readonly renderMessage: (renderer?: (scope: string & import("@jfdevelops/create-error/types").TypeSlot<"definition", "scope">, context: import("@jfdevelops/create-error/types").DataSlot) => string) => string;
78
+ };
79
+ }>>): {
35
80
  name: string;
36
- code: Code;
37
- scope: Scope;
81
+ code: string & import("@jfdevelops/create-error/types").TypeSlot<"definition", "code">;
82
+ scope: string & import("@jfdevelops/create-error/types").TypeSlot<"definition", "scope">;
38
83
  message: string;
39
84
  context: unknown;
40
85
  };
41
- }
42
- /** Creates a context-only React Layout error class with a default renderer. */
43
- declare function createReactLayoutError<const Options extends CreateReactLayoutErrorOptions>(options: Options): ReactLayoutErrorRendererFactory<Options['code'], Options['scope']>;
86
+ }>>;
44
87
  //#endregion
45
- export { CreateReactLayoutErrorOptions, CreatedReactLayoutError, ErrorMessageRenderer, ReactLayoutError, ReactLayoutErrorContext, ReactLayoutErrorRendererFactory, createReactLayoutError };
88
+ export { ReactLayoutError };
46
89
  //# sourceMappingURL=react-layout-error.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"react-layout-error.d.mts","names":[],"sources":["../../src/errors/react-layout-error.ts"],"mappings":";;KACY,6BAAA;EAIV,IAAA,EAAM,IAAA;EACN,KAAA,EAAO,KAAK;AAAA;;UAIG,uBAAA,+BACP,MAAM;EACd,KAAA,EAAO,KAAA;AAAA;;KAIG,oBAAA,uCAEM,uBAAA,CAAwB,KAAA,MACrC,KAAA,EAAO,KAAA,EAAO,OAAA,EAAS,OAAA;;UAGX,uBAAA,4DAGC,uBAAA,CAAwB,KAAA;EAExC,SAAA,cACE,SAAA,EAAW,SAAA,EACX,OAAA,EAAS,IAAA,CAAK,OAAA,oBAA2B,IAAA,CAAK,OAAA,wBACnC,SAAA;EAAA,KACR,OAAA,EAAS,IAAA,CAAK,OAAA,aAAoB,gBAAA,CACrC,IAAA,EACA,KAAA,EACA,OAAA;IAAA,SAES,IAAA,EAAM,IAAA;IAAA,SACN,KAAA,EAAO,KAAA;IAChB,aAAA,CAAc,QAAA,GAAW,oBAAA,CAAqB,KAAA,EAAO,OAAA;EAAA;AAAA;;UAKxC,+BAAA;EAAA,iBAIE,uBAAA,CAAwB,KAAA,GACvC,eAAA,EAAiB,oBAAA,CAAqB,KAAA,EAAO,OAAA,IAC5C,uBAAA,CAAwB,IAAA,EAAM,KAAA,EAAO,OAAA;AAAA;;uBAyBpB,gBAAA,8EAGJ,uBAAA,CAAwB,KAAA,IACtC,uBAAA,CAAwB,KAAA,WAClB,KAAA;EAAA,kBACU,IAAA,EAAM,IAAA;EAAA,SACf,KAAA,EAAO,KAAA;EAAA,SACP,OAAA,EAAS,OAAA;EAAA,OAEX,SAAA,4BAEW,MAAA,mBAEhB,IAAA,OAAW,OAAA,EAAS,OAAA,KAAY,KAAA,EAChC,SAAA,EAAW,SAAA,EACX,OAAA,EAAS,OAAA,UAAiB,OAAA,YACjB,SAAA;cAMC,OAAA,EAAS,OAAA;EAAA,SASZ,aAAA,CACP,QAAA,GAAW,oBAAA,CAAqB,KAAA,EAAO,OAAA;EAGzC,MAAA;;;;;;;;;iBAYc,sBAAA,uBACQ,6BAAA,EAEtB,OAAA,EAAS,OAAA,GACR,+BAAA,CAAgC,OAAA,UAAiB,OAAA"}
1
+ {"version":3,"file":"react-layout-error.d.mts","names":[],"sources":["../../src/errors/react-layout-error.ts"],"mappings":";;;cAyDa,gBAAA,4DAAgB,WAAA,+CAAA,UAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yCAhBrB,KAAA,oDAAK,QAAA,yBACL,OAAA,2CAAO,QAAA;EAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2CADP,KAAA,oDAAK,QAAA,yBACL,OAAA,2CAAO,QAAA;IAAA;EAAA"}
@@ -1,3 +1,6 @@
1
+ import { createError } from "@jfdevelops/create-error";
2
+ import { type } from "arktype";
3
+
1
4
  //#region src/errors/react-layout-error.ts
2
5
  function makeJsonSafe(value) {
3
6
  if (value === void 0) return null;
@@ -5,49 +8,42 @@ function makeJsonSafe(value) {
5
8
  if (value && typeof value === "object") return Object.fromEntries(Object.entries(value).map(([key, nestedValue]) => [key, makeJsonSafe(nestedValue)]));
6
9
  return value;
7
10
  }
8
- /** Base data class for errors thrown by React Layout. */
9
- var ReactLayoutError = class extends Error {
10
- scope;
11
- context;
12
- static invariant(condition, context) {
13
- if (!condition) throw new this(typeof context === "function" ? context() : context);
14
- }
15
- constructor(context) {
16
- super();
17
- this.name = new.target.name;
18
- this.scope = context.scope;
19
- this.context = context;
20
- Object.setPrototypeOf(this, new.target.prototype);
21
- }
22
- toJSON() {
23
- return {
24
- name: this.name,
25
- code: this.code,
26
- scope: this.scope,
27
- message: this.message,
28
- context: makeJsonSafe(this.context)
29
- };
30
- }
31
- };
32
- /** Creates a context-only React Layout error class with a default renderer. */
33
- function createReactLayoutError(options) {
34
- return function createErrorWithRenderer(defaultRenderer) {
35
- return class ReactLayoutErrorWithCode extends ReactLayoutError {
36
- code = options.code;
37
- constructor(context) {
38
- const resolvedContext = {
39
- ...context,
40
- scope: options.scope
41
- };
42
- super(resolvedContext);
43
- this.message = this.renderMessage();
44
- }
45
- renderMessage(renderer) {
46
- return (renderer ?? defaultRenderer)(this.scope, this.context);
47
- }
48
- };
49
- };
50
- }
11
+ /** @internal */
12
+ const createReactLayoutError = createError({
13
+ definition: type({
14
+ code: "string",
15
+ scope: "string"
16
+ }),
17
+ data: {
18
+ property: "context",
19
+ resolve: ({ definition, input }) => typeof input === "object" && input !== null ? {
20
+ ...input,
21
+ scope: definition.scope
22
+ } : input
23
+ },
24
+ message: ({ definition, data, implementation }) => implementation({
25
+ context: data,
26
+ scope: definition.scope
27
+ }),
28
+ properties: ({ definition, data, implementation }) => ({
29
+ code: definition.code,
30
+ scope: definition.scope,
31
+ renderMessage(renderer = (scope, context) => implementation({
32
+ context,
33
+ scope
34
+ })) {
35
+ return renderer(definition.scope, data);
36
+ }
37
+ }),
38
+ toJSON: (error) => ({
39
+ name: error.name,
40
+ code: error.code,
41
+ scope: error.scope,
42
+ message: error.message,
43
+ context: makeJsonSafe(error.context)
44
+ })
45
+ });
46
+ const ReactLayoutError = createReactLayoutError.Error;
51
47
 
52
48
  //#endregion
53
49
  export { ReactLayoutError, createReactLayoutError };
@@ -1 +1 @@
1
- {"version":3,"file":"react-layout-error.mjs","names":[],"sources":["../../src/errors/react-layout-error.ts"],"sourcesContent":["/** Options used to assign a stable code and scope to a React Layout error. */\nexport type CreateReactLayoutErrorOptions<\n Code extends string = string,\n Scope extends string = string,\n> = {\n code: Code;\n scope: Scope;\n};\n\n/** Shared context carried by every React Layout error. */\nexport interface ReactLayoutErrorContext<Scope extends string>\n extends Record<string, unknown> {\n scope: Scope;\n}\n\n/** Renders an error message from its scope and structured context. */\nexport type ErrorMessageRenderer<\n Scope extends string,\n Context extends ReactLayoutErrorContext<Scope>,\n> = (scope: Scope, context: Context) => string;\n\n/** Constructor and invariant API returned by the React Layout error factory. */\nexport interface CreatedReactLayoutError<\n Code extends string,\n Scope extends string,\n Context extends ReactLayoutErrorContext<Scope>,\n> {\n invariant: <Condition>(\n condition: Condition,\n context: Omit<Context, 'scope'> | (() => Omit<Context, 'scope'>),\n ) => asserts condition;\n new (context: Omit<Context, 'scope'>): ReactLayoutError<\n Code,\n Scope,\n Context\n > & {\n readonly code: Code;\n readonly scope: Scope;\n renderMessage(renderer?: ErrorMessageRenderer<Scope, Context>): string;\n };\n}\n\n/** Adds a default renderer to a React Layout error definition. */\nexport interface ReactLayoutErrorRendererFactory<\n Code extends string,\n Scope extends string,\n> {\n <Context extends ReactLayoutErrorContext<Scope>>(\n defaultRenderer: ErrorMessageRenderer<Scope, Context>,\n ): CreatedReactLayoutError<Code, Scope, Context>;\n}\n\nfunction makeJsonSafe(value: unknown): unknown {\n if (value === undefined) {\n return null;\n }\n\n if (Array.isArray(value)) {\n return value.map(makeJsonSafe);\n }\n\n if (value && typeof value === 'object') {\n return Object.fromEntries(\n Object.entries(value).map(([key, nestedValue]) => [\n key,\n makeJsonSafe(nestedValue),\n ]),\n );\n }\n\n return value;\n}\n\n/** Base data class for errors thrown by React Layout. */\nexport abstract class ReactLayoutError<\n Code extends string = string,\n Scope extends string = string,\n Context extends ReactLayoutErrorContext<Scope> =\n ReactLayoutErrorContext<Scope>,\n> extends Error {\n abstract readonly code: Code;\n readonly scope: Scope;\n readonly context: Context;\n\n static invariant<\n Condition,\n Context extends Record<string, unknown>,\n >(\n this: new (context: Context) => Error,\n condition: Condition,\n context: Context | (() => Context),\n ): asserts condition {\n if (!condition) {\n throw new this(typeof context === 'function' ? context() : context);\n }\n }\n\n constructor(context: Context) {\n super();\n this.name = new.target.name;\n this.scope = context.scope;\n this.context = context;\n\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n abstract renderMessage(\n renderer?: ErrorMessageRenderer<Scope, Context>,\n ): string;\n\n toJSON() {\n return {\n name: this.name,\n code: this.code,\n scope: this.scope,\n message: this.message,\n context: makeJsonSafe(this.context),\n };\n }\n}\n\n/** Creates a context-only React Layout error class with a default renderer. */\nexport function createReactLayoutError<\n const Options extends CreateReactLayoutErrorOptions,\n>(\n options: Options,\n): ReactLayoutErrorRendererFactory<Options['code'], Options['scope']> {\n return function createErrorWithRenderer<\n Context extends ReactLayoutErrorContext<Options['scope']>,\n >(defaultRenderer: ErrorMessageRenderer<Options['scope'], Context>) {\n return class ReactLayoutErrorWithCode extends ReactLayoutError<\n Options['code'],\n Options['scope'],\n Context\n > {\n readonly code = options.code;\n\n constructor(context: Omit<Context, 'scope'>) {\n const resolvedContext = {\n ...context,\n scope: options.scope,\n } as Context;\n\n super(resolvedContext);\n this.message = this.renderMessage();\n }\n\n renderMessage(\n renderer?: ErrorMessageRenderer<Options['scope'], Context>,\n ) {\n return (renderer ?? defaultRenderer)(this.scope, this.context);\n }\n };\n };\n}\n"],"mappings":";AAoDA,SAAS,aAAa,OAAyB;CAC7C,IAAI,UAAU,QACZ,OAAO;CAGT,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,IAAI,YAAY;CAG/B,IAAI,SAAS,OAAO,UAAU,UAC5B,OAAO,OAAO,YACZ,OAAO,QAAQ,KAAK,EAAE,KAAK,CAAC,KAAK,iBAAiB,CAChD,KACA,aAAa,WAAW,CAC1B,CAAC,CACH;CAGF,OAAO;AACT;;AAGA,IAAsB,mBAAtB,cAKU,MAAM;CAEd,AAAS;CACT,AAAS;CAET,OAAO,UAKL,WACA,SACmB;EACnB,IAAI,CAAC,WACH,MAAM,IAAI,KAAK,OAAO,YAAY,aAAa,QAAQ,IAAI,OAAO;CAEtE;CAEA,YAAY,SAAkB;EAC5B,MAAM;EACN,KAAK,OAAO,IAAI,OAAO;EACvB,KAAK,QAAQ,QAAQ;EACrB,KAAK,UAAU;EAEf,OAAO,eAAe,MAAM,IAAI,OAAO,SAAS;CAClD;CAMA,SAAS;EACP,OAAO;GACL,MAAM,KAAK;GACX,MAAM,KAAK;GACX,OAAO,KAAK;GACZ,SAAS,KAAK;GACd,SAAS,aAAa,KAAK,OAAO;EACpC;CACF;AACF;;AAGA,SAAgB,uBAGd,SACoE;CACpE,OAAO,SAAS,wBAEd,iBAAkE;EAClE,OAAO,MAAM,iCAAiC,iBAI5C;GACA,AAAS,OAAO,QAAQ;GAExB,YAAY,SAAiC;IAC3C,MAAM,kBAAkB;KACtB,GAAG;KACH,OAAO,QAAQ;IACjB;IAEA,MAAM,eAAe;IACrB,KAAK,UAAU,KAAK,cAAc;GACpC;GAEA,cACE,UACA;IACA,QAAQ,YAAY,iBAAiB,KAAK,OAAO,KAAK,OAAO;GAC/D;EACF;CACF;AACF"}
1
+ {"version":3,"file":"react-layout-error.mjs","names":[],"sources":["../../src/errors/react-layout-error.ts"],"sourcesContent":["import { createError } from '@jfdevelops/create-error';\nimport { type } from 'arktype';\n\nfunction makeJsonSafe(value: unknown): unknown {\n if (value === undefined) {\n return null;\n }\n\n if (Array.isArray(value)) {\n return value.map(makeJsonSafe);\n }\n\n if (value && typeof value === 'object') {\n return Object.fromEntries(\n Object.entries(value).map(([key, nestedValue]) => [\n key,\n makeJsonSafe(nestedValue),\n ]),\n );\n }\n\n return value;\n}\n\n/** @internal */\nexport const createReactLayoutError = createError({\n definition: type({ code: 'string', scope: 'string' }),\n data: {\n property: 'context',\n resolve: ({ definition, input }) =>\n typeof input === 'object' && input !== null\n ? { ...input, scope: definition.scope }\n : input,\n },\n message: ({ definition, data, implementation }) =>\n implementation({ context: data, scope: definition.scope }),\n properties: ({ definition, data, implementation }) => ({\n code: definition.code,\n scope: definition.scope,\n renderMessage(\n renderer: (\n scope: typeof definition.scope,\n context: typeof data,\n ) => string = (scope, context) => implementation({ context, scope }),\n ) {\n return renderer(definition.scope, data);\n },\n }),\n toJSON: (error) => ({\n name: error.name,\n code: error.code,\n scope: error.scope,\n message: error.message,\n context: makeJsonSafe(error.context),\n }),\n});\n\nexport const ReactLayoutError = createReactLayoutError.Error;\n"],"mappings":";;;;AAGA,SAAS,aAAa,OAAyB;CAC7C,IAAI,UAAU,QACZ,OAAO;CAGT,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,IAAI,YAAY;CAG/B,IAAI,SAAS,OAAO,UAAU,UAC5B,OAAO,OAAO,YACZ,OAAO,QAAQ,KAAK,EAAE,KAAK,CAAC,KAAK,iBAAiB,CAChD,KACA,aAAa,WAAW,CAC1B,CAAC,CACH;CAGF,OAAO;AACT;;AAGA,MAAa,yBAAyB,YAAY;CAChD,YAAY,KAAK;EAAE,MAAM;EAAU,OAAO;CAAS,CAAC;CACpD,MAAM;EACJ,UAAU;EACV,UAAU,EAAE,YAAY,YACtB,OAAO,UAAU,YAAY,UAAU,OACnC;GAAE,GAAG;GAAO,OAAO,WAAW;EAAM,IACpC;CACR;CACA,UAAU,EAAE,YAAY,MAAM,qBAC5B,eAAe;EAAE,SAAS;EAAM,OAAO,WAAW;CAAM,CAAC;CAC3D,aAAa,EAAE,YAAY,MAAM,sBAAsB;EACrD,MAAM,WAAW;EACjB,OAAO,WAAW;EAClB,cACE,YAGe,OAAO,YAAY,eAAe;GAAE;GAAS;EAAM,CAAC,GACnE;GACA,OAAO,SAAS,WAAW,OAAO,IAAI;EACxC;CACF;CACA,SAAS,WAAW;EAClB,MAAM,MAAM;EACZ,MAAM,MAAM;EACZ,OAAO,MAAM;EACb,SAAS,MAAM;EACf,SAAS,aAAa,MAAM,OAAO;CACrC;AACF,CAAC;AAED,MAAa,mBAAmB,uBAAuB"}
package/dist/index.cjs CHANGED
@@ -1,6 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_resource = require('./resource.cjs');
3
- const require_utils = require('./utils.cjs');
4
2
  const require_react_layout_error = require('./errors/react-layout-error.cjs');
5
3
  const require_invalid_config = require('./errors/invalid-config.cjs');
6
4
  const require_invalid_path = require('./errors/invalid-path.cjs');
@@ -8,6 +6,10 @@ const require_invalid_resource = require('./errors/invalid-resource.cjs');
8
6
  const require_invalid_sub_resource = require('./errors/invalid-sub-resource.cjs');
9
7
  const require_invalid_component = require('./errors/invalid-component.cjs');
10
8
  const require_missing_path_variable = require('./errors/missing-path-variable.cjs');
9
+ const require_missing_resource_provider = require('./errors/missing-resource-provider.cjs');
10
+ const require_layout_configuration_error = require('./errors/layout-configuration-error.cjs');
11
+ const require_resource = require('./resource.cjs');
12
+ const require_utils = require('./utils.cjs');
11
13
  const require_define_layout = require('./create-config/define-layout.cjs');
12
14
  let _jfdevelops_react_layout_composables = require("@jfdevelops/react-layout-composables");
13
15
  let _jfdevelops_react_layout_validator = require("@jfdevelops/react-layout-validator");
@@ -23,7 +25,9 @@ Object.defineProperty(exports, 'LayoutComposablePresetProvider', {
23
25
  return _jfdevelops_react_layout_composables.LayoutComposablePresetProvider;
24
26
  }
25
27
  });
28
+ exports.LayoutConfigurationError = require_layout_configuration_error.LayoutConfigurationError;
26
29
  exports.MissingPathVariableError = require_missing_path_variable.MissingPathVariableError;
30
+ exports.MissingResourceProviderError = require_missing_resource_provider.MissingResourceProviderError;
27
31
  Object.defineProperty(exports, 'PropError', {
28
32
  enumerable: true,
29
33
  get: function () {
@@ -61,7 +65,6 @@ Object.defineProperty(exports, 'createProp', {
61
65
  return _jfdevelops_react_layout_validator.createProp;
62
66
  }
63
67
  });
64
- exports.createReactLayoutError = require_react_layout_error.createReactLayoutError;
65
68
  Object.defineProperty(exports, 'defineComposableComponent', {
66
69
  enumerable: true,
67
70
  get: function () {
package/dist/index.d.cts CHANGED
@@ -6,15 +6,18 @@ import { CreateGetComponentForPath, GetComponentForPath, ResolvedPathValue } fro
6
6
  import { ForPaths, ForPathsRenderContext, RenderedPathComponent, RenderedPathComponentHOF, TargetPathBuilder } from "./create-config/for-paths/builder.cjs";
7
7
  import { IsSubResourceKey } from "./create-config/is-sub-resource-key.cjs";
8
8
  import { ComponentTypes, CreatedResourceConfig } from "./create-config/get-component.cjs";
9
- import { CreateResourceLayoutWithLayoutOptions, DefineResourceLayoutWithLayoutFn, DefineResourcesFn, DefinedResourceLayoutWithShell, LayoutRenderResourcesAccessor, LayoutResourcesAccessor, ResourceLayoutShellComponent, ResourceLayoutShellProps, ResourceSelection, ShellLayoutDefinition, ShellRenderContext, defineResourceLayout } from "./create-config/define-layout.cjs";
9
+ import { CreateResourceMap, CreateResourceMapFn } from "./create-config/create-resource-links.cjs";
10
+ import { CreateResourceLayoutWithLayoutOptions, DefineResourceLayoutWithLayoutFn, DefineResourcesFn, DefinedResourceLayoutWithShell, LayoutRenderResourcesAccessor, LayoutResourcesAccessor, ResourceLayoutProvider, ResourceLayoutProviderProps, ResourceLayoutShellComponent, ResourceLayoutShellProps, ResourceSelection, ShellLayoutDefinition, ShellRenderContext, defineResourceLayout } from "./create-config/define-layout.cjs";
10
11
  import { ResourceLayoutShellPublisher } from "./create-config/shell-context.cjs";
11
- import { CreateReactLayoutErrorOptions, CreatedReactLayoutError, ErrorMessageRenderer, ReactLayoutError, ReactLayoutErrorContext, ReactLayoutErrorRendererFactory, createReactLayoutError } from "./errors/react-layout-error.cjs";
12
+ import { ReactLayoutError } from "./errors/react-layout-error.cjs";
12
13
  import { InvalidConfigContext, InvalidConfigError } from "./errors/invalid-config.cjs";
13
14
  import { InvalidPathContext, InvalidPathError } from "./errors/invalid-path.cjs";
14
15
  import { InvalidResourceContext, InvalidResourceError } from "./errors/invalid-resource.cjs";
15
16
  import { InvalidSubResourceContext, InvalidSubResourceError } from "./errors/invalid-sub-resource.cjs";
16
17
  import { InvalidComponentContext, InvalidComponentError } from "./errors/invalid-component.cjs";
17
18
  import { MissingPathVariableContext, MissingPathVariableError } from "./errors/missing-path-variable.cjs";
19
+ import { MissingResourceProviderError } from "./errors/missing-resource-provider.cjs";
20
+ import { LayoutConfigurationError, LayoutConfigurationErrorContext } from "./errors/layout-configuration-error.cjs";
18
21
  import { AnyComposableComponent, ComposableComponent, ComposableComponentCallable, ComposableComponents, ComposableNameContext, ComposablePresetComponent, ComposablePresetComponentCallProps, ComposablePresetMeta, ComposablePresetProps, ComposableResourceLayout, CreateLayoutComposable, DefinedComposableComponentRecord, LayoutComposablePresetProvider, LayoutComposablesFactory, MakeComposable, MakeComposableOptions, MergePresetProps, PresetPropsFromComposable, RequiredPresetLayoutProps, RequiredPresetRenderProps, ResolveLayoutComposables, collectComposablePresetEntries, createComposableComponent, createLayoutComposableFactory, defineComposableComponent, makeComposable, resolveComposablePresetProps, resolveLayoutComposables } from "@jfdevelops/react-layout-composables";
19
22
  import { AnyBuiltPropDefinition, ExtractDefinitionValue, PropError, PropErrorOptions, ResolveLayoutProps, ResolveLayoutPropsAsDefined, ResolveProps, ResolvedBuiltPropShape, createPrimitivePropBuilder, createProp, isPropDefinitionShape, resolvePropDefinitionValues, validateProps } from "@jfdevelops/react-layout-validator";
20
- export { type AnyBuiltPropDefinition, type AnyComposableComponent, type BaseComponent, type ComponentTypes, type ComposableComponent, type ComposableComponentCallable, type ComposableComponents, type ComposableNameContext, type ComposablePresetComponent, type ComposablePresetComponentCallProps, type ComposablePresetMeta, type ComposablePresetProps, type ComposableResourceLayout, type CreateGetComponentForPath, type CreateLayoutComposable, type CreateReactLayoutErrorOptions, type CreateResourceLayoutWithLayoutOptions, type CreatedReactLayoutError, type CreatedResourceConfig, type DefineResourceLayoutWithLayoutFn, type DefineResourcesFn, type DefinedComposableComponentRecord, type DefinedResourceLayoutWithShell, type ErrorMessageRenderer, type ExtractDefinitionValue, type ForPaths, type ForPathsRenderContext, type GetComponentForPath, type InPropsDefinition, type InPropsFunction, type InPropsObject, type InPropsOptions, type IncludedPropBehavior, type IncludedProps, type InferredInProps, type InvalidComponentContext, InvalidComponentError, type InvalidConfigContext, InvalidConfigError, type InvalidPathContext, InvalidPathError, type InvalidResourceContext, InvalidResourceError, type InvalidSubResourceContext, InvalidSubResourceError, type IsSubResourceKey, LayoutComposablePresetProvider, type LayoutComposablesFactory, type LayoutRenderProps, type LayoutRenderResourcesAccessor, type LayoutResourceKey, type LayoutResourcesAccessor, type MakeComposable, type MakeComposableOptions, type MergeIntersection, type MergePresetProps, type MergedLayoutInProps, type MissingPathVariableContext, MissingPathVariableError, type NormalizeResource, type NormalizeResources, type ParameterizedResourcePath, type PathVariables, type PresetPropsFromComposable, PropError, type PropErrorOptions, type PropsContextRender, type PropsRenderDefinition, ReactLayoutError, type ReactLayoutErrorContext, type ReactLayoutErrorRendererFactory, type RenderedPathComponent, type RenderedPathComponentHOF, type RequiredPresetLayoutProps, type RequiredPresetRenderProps, type ResolveLayoutComposables, type ResolveLayoutProps, type ResolveLayoutPropsAsDefined, type ResolveProps, type ResolvedBuiltPropShape, type ResolvedIncludedComponentProps, type ResolvedIncludedConfigProps, type ResolvedIncludedProps, type ResolvedIncludedPropsAsDefined, type ResolvedPathValue, type ResourceDefinition, type ResourceDefinitionValue, type ResourceEnum, type ResourceLayoutComponentProps, type ResourceLayoutShellComponent, type ResourceLayoutShellProps, type ResourceLayoutShellPublisher, type ResourceSelection, type ResourceTree, type ShellLayoutDefinition, type ShellRenderContext, type Show, type TargetPathBuilder, type UnionToIntersection, collectComposablePresetEntries, createComposableComponent, createLayoutComposableFactory, createPrimitivePropBuilder, createProp, createReactLayoutError, defineComposableComponent, defineResourceLayout, isPropDefinitionShape, makeComposable, normalizeResource, normalizeResources, pick, resolveComposablePresetProps, resolveLayoutComposables, resolvePropDefinitionValues, toResourceEnum, validateProps };
23
+ export { type AnyBuiltPropDefinition, type AnyComposableComponent, type BaseComponent, type ComponentTypes, type ComposableComponent, type ComposableComponentCallable, type ComposableComponents, type ComposableNameContext, type ComposablePresetComponent, type ComposablePresetComponentCallProps, type ComposablePresetMeta, type ComposablePresetProps, type ComposableResourceLayout, type CreateGetComponentForPath, type CreateLayoutComposable, type CreateResourceLayoutWithLayoutOptions, type CreateResourceMap, type CreateResourceMapFn, type CreatedResourceConfig, type DefineResourceLayoutWithLayoutFn, type DefineResourcesFn, type DefinedComposableComponentRecord, type DefinedResourceLayoutWithShell, type ExtractDefinitionValue, type ForPaths, type ForPathsRenderContext, type GetComponentForPath, type InPropsDefinition, type InPropsFunction, type InPropsObject, type InPropsOptions, type IncludedPropBehavior, type IncludedProps, type InferredInProps, type InvalidComponentContext, InvalidComponentError, type InvalidConfigContext, InvalidConfigError, type InvalidPathContext, InvalidPathError, type InvalidResourceContext, InvalidResourceError, type InvalidSubResourceContext, InvalidSubResourceError, type IsSubResourceKey, LayoutComposablePresetProvider, type LayoutComposablesFactory, LayoutConfigurationError, type LayoutConfigurationErrorContext, type LayoutRenderProps, type LayoutRenderResourcesAccessor, type LayoutResourceKey, type LayoutResourcesAccessor, type MakeComposable, type MakeComposableOptions, type MergeIntersection, type MergePresetProps, type MergedLayoutInProps, type MissingPathVariableContext, MissingPathVariableError, MissingResourceProviderError, type NormalizeResource, type NormalizeResources, type ParameterizedResourcePath, type PathVariables, type PresetPropsFromComposable, PropError, type PropErrorOptions, type PropsContextRender, type PropsRenderDefinition, ReactLayoutError, type RenderedPathComponent, type RenderedPathComponentHOF, type RequiredPresetLayoutProps, type RequiredPresetRenderProps, type ResolveLayoutComposables, type ResolveLayoutProps, type ResolveLayoutPropsAsDefined, type ResolveProps, type ResolvedBuiltPropShape, type ResolvedIncludedComponentProps, type ResolvedIncludedConfigProps, type ResolvedIncludedProps, type ResolvedIncludedPropsAsDefined, type ResolvedPathValue, type ResourceDefinition, type ResourceDefinitionValue, type ResourceEnum, type ResourceLayoutComponentProps, type ResourceLayoutProvider, type ResourceLayoutProviderProps, type ResourceLayoutShellComponent, type ResourceLayoutShellProps, type ResourceLayoutShellPublisher, type ResourceSelection, type ResourceTree, type ShellLayoutDefinition, type ShellRenderContext, type Show, type TargetPathBuilder, type UnionToIntersection, collectComposablePresetEntries, createComposableComponent, createLayoutComposableFactory, createPrimitivePropBuilder, createProp, defineComposableComponent, defineResourceLayout, isPropDefinitionShape, makeComposable, normalizeResource, normalizeResources, pick, resolveComposablePresetProps, resolveLayoutComposables, resolvePropDefinitionValues, toResourceEnum, validateProps };