@raubjo/architect-core 0.1.0 → 0.1.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 (67) hide show
  1. package/README.md +162 -0
  2. package/bun.lock +82 -1
  3. package/package.json +54 -6
  4. package/src/cache/cache.ts +2 -2
  5. package/src/cache/manager.ts +93 -83
  6. package/src/config/adapters/esm.ts +26 -0
  7. package/src/config/clone.ts +5 -5
  8. package/src/config/env.global.d.ts +2 -1
  9. package/src/config/env.ts +53 -55
  10. package/src/config/env_test.helpers.ts +58 -0
  11. package/src/config/repository.ts +180 -142
  12. package/src/container/adapters/builtin.ts +347 -0
  13. package/src/container/adapters/inversify.ts +123 -0
  14. package/src/container/contract.ts +58 -0
  15. package/src/container/runtime.ts +149 -0
  16. package/src/filesystem/adapters/local.ts +92 -83
  17. package/src/filesystem/adapters/local_test.helpers.ts +50 -0
  18. package/src/filesystem/filesystem.ts +11 -11
  19. package/src/foundation/application.ts +205 -175
  20. package/src/foundation/application_test.helpers.ts +31 -0
  21. package/src/index.ts +15 -6
  22. package/src/react.ts +2 -0
  23. package/src/renderers/adapters/react.tsx +35 -0
  24. package/src/renderers/adapters/solid.tsx +32 -0
  25. package/src/renderers/adapters/svelte.ts +44 -0
  26. package/src/renderers/adapters/vue.ts +28 -0
  27. package/src/renderers/contract.ts +15 -0
  28. package/src/runtimes/react.tsx +24 -12
  29. package/src/runtimes/solid.tsx +30 -0
  30. package/src/runtimes/svelte.ts +23 -0
  31. package/src/runtimes/vue.ts +20 -0
  32. package/src/solid.ts +2 -0
  33. package/src/storage/adapters/contract.ts +10 -0
  34. package/src/storage/adapters/indexed-db.ts +170 -156
  35. package/src/storage/adapters/local-storage.ts +34 -34
  36. package/src/storage/adapters/memory.ts +25 -25
  37. package/src/storage/manager.ts +65 -61
  38. package/src/storage/storage.ts +1 -8
  39. package/src/support/facades/cache.ts +40 -40
  40. package/src/support/facades/config.ts +78 -48
  41. package/src/support/facades/facade.ts +43 -28
  42. package/src/support/facades/storage.ts +41 -41
  43. package/src/support/service-provider.ts +11 -11
  44. package/src/support/str.ts +94 -90
  45. package/src/support/str_test.helpers.ts +26 -0
  46. package/src/svelte.ts +2 -0
  47. package/src/vue.ts +2 -0
  48. package/tsconfig.json +16 -0
  49. package/coverage/lcov.info +0 -1078
  50. package/src/config/app.ts +0 -5
  51. package/src/rendering/adapters/react.tsx +0 -27
  52. package/src/rendering/renderer.ts +0 -13
  53. package/src/support/providers/config-service-provider.ts +0 -19
  54. package/tests/application.test.ts +0 -236
  55. package/tests/cache-facade.test.ts +0 -45
  56. package/tests/cache.test.ts +0 -68
  57. package/tests/config-clone.test.ts +0 -31
  58. package/tests/config-env.test.ts +0 -88
  59. package/tests/config-facade.test.ts +0 -96
  60. package/tests/config-repository.test.ts +0 -124
  61. package/tests/facade-base.test.ts +0 -80
  62. package/tests/filesystem.test.ts +0 -81
  63. package/tests/runtime-react.test.tsx +0 -37
  64. package/tests/service-provider.test.ts +0 -23
  65. package/tests/storage-facade.test.ts +0 -46
  66. package/tests/storage.test.ts +0 -264
  67. package/tests/str.test.ts +0 -73
@@ -1,126 +1,130 @@
1
1
  function splitWords(value: string): string[] {
2
- const normalized = value
3
- .replace(/([a-z0-9])([A-Z])/g, "$1 $2")
4
- .replace(/[_\-.]+/g, " ")
5
- .trim();
2
+ const normalized = value
3
+ .replace(/([a-z0-9])([A-Z])/g, "$1 $2")
4
+ .replace(/[_\-.]+/g, " ")
5
+ .trim();
6
6
 
7
- if (!normalized) {
8
- return [];
9
- }
7
+ if (!normalized) {
8
+ return [];
9
+ }
10
10
 
11
- return normalized.split(/\s+/);
11
+ return normalized.split(/\s+/);
12
12
  }
13
13
 
14
14
  function normalizeForSlug(value: string): string {
15
- return value
16
- .normalize("NFKD")
17
- .replace(/[\u0300-\u036f]/g, "")
18
- .toLowerCase()
19
- .replace(/[^a-z0-9]+/g, "-")
20
- .replace(/^-+|-+$/g, "");
15
+ return value
16
+ .normalize("NFKD")
17
+ .replace(/[\u0300-\u036f]/g, "")
18
+ .toLowerCase()
19
+ .replace(/[^a-z0-9]+/g, "-")
20
+ .replace(/^-+|-+$/g, "");
21
21
  }
22
22
 
23
23
  export default class Str {
24
- constructor() {}
25
-
26
- static lower(value: string): string {
27
- return value.toLowerCase();
28
- }
24
+ constructor() {}
29
25
 
30
- static upper(value: string): string {
31
- return value.toUpperCase();
32
- }
26
+ static lower(value: string): string {
27
+ return value.toLowerCase();
28
+ }
33
29
 
34
- static length(value: string): number {
35
- return value.length;
36
- }
30
+ static upper(value: string): string {
31
+ return value.toUpperCase();
32
+ }
37
33
 
38
- static contains(haystack: string, needle: string | string[], ignoreCase = false): boolean {
39
- const source = ignoreCase ? haystack.toLowerCase() : haystack;
40
- const needles = Array.isArray(needle) ? needle : [needle];
34
+ static length(value: string): number {
35
+ return value.length;
36
+ }
41
37
 
42
- for (const part of needles) {
43
- const target = ignoreCase ? part.toLowerCase() : part;
44
- if (source.includes(target)) {
45
- return true;
46
- }
38
+ static contains(
39
+ haystack: string,
40
+ needle: string | string[],
41
+ ignoreCase = false,
42
+ ): boolean {
43
+ const source = ignoreCase ? haystack.toLowerCase() : haystack;
44
+ const needles = Array.isArray(needle) ? needle : [needle];
45
+
46
+ for (const part of needles) {
47
+ const target = ignoreCase ? part.toLowerCase() : part;
48
+ if (source.includes(target)) {
49
+ return true;
50
+ }
51
+ }
52
+
53
+ return false;
47
54
  }
48
55
 
49
- return false;
50
- }
56
+ static startsWith(haystack: string, needle: string | string[]): boolean {
57
+ const needles = Array.isArray(needle) ? needle : [needle];
58
+ for (const part of needles) {
59
+ if (haystack.startsWith(part)) {
60
+ return true;
61
+ }
62
+ }
51
63
 
52
- static startsWith(haystack: string, needle: string | string[]): boolean {
53
- const needles = Array.isArray(needle) ? needle : [needle];
54
- for (const part of needles) {
55
- if (haystack.startsWith(part)) {
56
- return true;
57
- }
64
+ return false;
58
65
  }
59
66
 
60
- return false;
61
- }
67
+ static endsWith(haystack: string, needle: string | string[]): boolean {
68
+ const needles = Array.isArray(needle) ? needle : [needle];
69
+ for (const part of needles) {
70
+ if (haystack.endsWith(part)) {
71
+ return true;
72
+ }
73
+ }
62
74
 
63
- static endsWith(haystack: string, needle: string | string[]): boolean {
64
- const needles = Array.isArray(needle) ? needle : [needle];
65
- for (const part of needles) {
66
- if (haystack.endsWith(part)) {
67
- return true;
68
- }
75
+ return false;
69
76
  }
70
77
 
71
- return false;
72
- }
78
+ static replace(
79
+ search: string | RegExp,
80
+ replace: string,
81
+ subject: string,
82
+ ): string {
83
+ return subject.replace(search, replace);
84
+ }
73
85
 
74
- static replace(search: string | RegExp, replace: string, subject: string): string {
75
- return subject.replace(search, replace);
76
- }
86
+ static snake(value: string, separator = "_"): string {
87
+ const words = splitWords(value).map((word) => word.toLowerCase());
88
+ return words.join(separator);
89
+ }
77
90
 
78
- static snake(value: string, separator = "_"): string {
79
- const words = splitWords(value).map((word) => word.toLowerCase());
80
- return words.join(separator);
81
- }
91
+ static kebab(value: string): string {
92
+ return Str.snake(value, "-");
93
+ }
82
94
 
83
- static kebab(value: string): string {
84
- return Str.snake(value, "-");
85
- }
95
+ static studly(value: string): string {
96
+ const words = splitWords(value);
97
+ let output = "";
98
+ for (const word of words) {
99
+ output +=
100
+ word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
101
+ }
86
102
 
87
- static studly(value: string): string {
88
- const words = splitWords(value);
89
- let output = "";
90
- for (const word of words) {
91
- output += word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
103
+ return output;
92
104
  }
93
105
 
94
- return output;
95
- }
106
+ static camel(value: string): string {
107
+ const studly = Str.studly(value);
108
+ if (!studly) {
109
+ return "";
110
+ }
96
111
 
97
- static camel(value: string): string {
98
- const studly = Str.studly(value);
99
- if (!studly) {
100
- return "";
112
+ return studly.charAt(0).toLowerCase() + studly.slice(1);
101
113
  }
102
114
 
103
- return studly.charAt(0).toLowerCase() + studly.slice(1);
104
- }
115
+ static slug(value: string, separator = "-"): string {
116
+ const slugged = normalizeForSlug(value);
117
+ if (separator === "-") {
118
+ return slugged;
119
+ }
105
120
 
106
- static slug(value: string, separator = "-"): string {
107
- const slugged = normalizeForSlug(value);
108
- if (separator === "-") {
109
- return slugged;
121
+ return slugged.replace(/-/g, separator);
110
122
  }
111
-
112
- return slugged.replace(/-/g, separator);
113
- }
114
123
  }
115
124
 
116
125
  export function registerGlobalStr(): void {
117
- const globalScope = globalThis as { Str?: typeof Str };
118
- if (typeof globalScope.Str === "undefined") {
119
- globalScope.Str = Str;
120
- }
126
+ const globalScope = globalThis as { Str?: typeof Str };
127
+ if (typeof globalScope.Str === "undefined") {
128
+ globalScope.Str = Str;
129
+ }
121
130
  }
122
-
123
- export const __strTesting = {
124
- normalizeForSlug,
125
- splitWords,
126
- };
@@ -0,0 +1,26 @@
1
+ function splitWords(value: string): string[] {
2
+ const normalized = value
3
+ .replace(/([a-z0-9])([A-Z])/g, "$1 $2")
4
+ .replace(/[_\-.]+/g, " ")
5
+ .trim();
6
+
7
+ if (!normalized) {
8
+ return [];
9
+ }
10
+
11
+ return normalized.split(/\s+/);
12
+ }
13
+
14
+ function normalizeForSlug(value: string): string {
15
+ return value
16
+ .normalize("NFKD")
17
+ .replace(/[\u0300-\u036f]/g, "")
18
+ .toLowerCase()
19
+ .replace(/[^a-z0-9]+/g, "-")
20
+ .replace(/^-+|-+$/g, "");
21
+ }
22
+
23
+ export const strTestingHelpers = {
24
+ normalizeForSlug,
25
+ splitWords,
26
+ };
package/src/svelte.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { containerKey, provideContainer, useService } from "./runtimes/svelte";
2
+ export { default as Renderer } from "./renderers/adapters/svelte";
package/src/vue.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { useService } from "./runtimes/vue";
2
+ export { default as Renderer } from "./renderers/adapters/vue";
package/tsconfig.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "Bundler",
6
+ "jsx": "react-jsx",
7
+ "strict": true,
8
+ "types": ["bun-types"],
9
+ "paths": {
10
+ "@/*": ["./src/*"]
11
+ },
12
+ "skipLibCheck": true,
13
+ "noEmit": true
14
+ },
15
+ "include": ["src", "tests"]
16
+ }