@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.
- package/README.md +162 -0
- package/bun.lock +82 -1
- package/package.json +54 -6
- package/src/cache/cache.ts +2 -2
- package/src/cache/manager.ts +93 -83
- package/src/config/adapters/esm.ts +26 -0
- package/src/config/clone.ts +5 -5
- package/src/config/env.global.d.ts +2 -1
- package/src/config/env.ts +53 -55
- package/src/config/env_test.helpers.ts +58 -0
- package/src/config/repository.ts +180 -142
- package/src/container/adapters/builtin.ts +347 -0
- package/src/container/adapters/inversify.ts +123 -0
- package/src/container/contract.ts +58 -0
- package/src/container/runtime.ts +149 -0
- package/src/filesystem/adapters/local.ts +92 -83
- package/src/filesystem/adapters/local_test.helpers.ts +50 -0
- package/src/filesystem/filesystem.ts +11 -11
- package/src/foundation/application.ts +205 -175
- package/src/foundation/application_test.helpers.ts +31 -0
- package/src/index.ts +15 -6
- package/src/react.ts +2 -0
- package/src/renderers/adapters/react.tsx +35 -0
- package/src/renderers/adapters/solid.tsx +32 -0
- package/src/renderers/adapters/svelte.ts +44 -0
- package/src/renderers/adapters/vue.ts +28 -0
- package/src/renderers/contract.ts +15 -0
- package/src/runtimes/react.tsx +24 -12
- package/src/runtimes/solid.tsx +30 -0
- package/src/runtimes/svelte.ts +23 -0
- package/src/runtimes/vue.ts +20 -0
- package/src/solid.ts +2 -0
- package/src/storage/adapters/contract.ts +10 -0
- package/src/storage/adapters/indexed-db.ts +170 -156
- package/src/storage/adapters/local-storage.ts +34 -34
- package/src/storage/adapters/memory.ts +25 -25
- package/src/storage/manager.ts +65 -61
- package/src/storage/storage.ts +1 -8
- package/src/support/facades/cache.ts +40 -40
- package/src/support/facades/config.ts +78 -48
- package/src/support/facades/facade.ts +43 -28
- package/src/support/facades/storage.ts +41 -41
- package/src/support/service-provider.ts +11 -11
- package/src/support/str.ts +94 -90
- package/src/support/str_test.helpers.ts +26 -0
- package/src/svelte.ts +2 -0
- package/src/vue.ts +2 -0
- package/tsconfig.json +16 -0
- package/coverage/lcov.info +0 -1078
- package/src/config/app.ts +0 -5
- package/src/rendering/adapters/react.tsx +0 -27
- package/src/rendering/renderer.ts +0 -13
- package/src/support/providers/config-service-provider.ts +0 -19
- package/tests/application.test.ts +0 -236
- package/tests/cache-facade.test.ts +0 -45
- package/tests/cache.test.ts +0 -68
- package/tests/config-clone.test.ts +0 -31
- package/tests/config-env.test.ts +0 -88
- package/tests/config-facade.test.ts +0 -96
- package/tests/config-repository.test.ts +0 -124
- package/tests/facade-base.test.ts +0 -80
- package/tests/filesystem.test.ts +0 -81
- package/tests/runtime-react.test.tsx +0 -37
- package/tests/service-provider.test.ts +0 -23
- package/tests/storage-facade.test.ts +0 -46
- package/tests/storage.test.ts +0 -264
- package/tests/str.test.ts +0 -73
package/src/support/str.ts
CHANGED
|
@@ -1,126 +1,130 @@
|
|
|
1
1
|
function splitWords(value: string): string[] {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
const normalized = value
|
|
3
|
+
.replace(/([a-z0-9])([A-Z])/g, "$1 $2")
|
|
4
|
+
.replace(/[_\-.]+/g, " ")
|
|
5
|
+
.trim();
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
if (!normalized) {
|
|
8
|
+
return [];
|
|
9
|
+
}
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
return normalized.split(/\s+/);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
function normalizeForSlug(value: string): string {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
static lower(value: string): string {
|
|
27
|
-
return value.toLowerCase();
|
|
28
|
-
}
|
|
24
|
+
constructor() {}
|
|
29
25
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
static lower(value: string): string {
|
|
27
|
+
return value.toLowerCase();
|
|
28
|
+
}
|
|
33
29
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
static upper(value: string): string {
|
|
31
|
+
return value.toUpperCase();
|
|
32
|
+
}
|
|
37
33
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
static length(value: string): number {
|
|
35
|
+
return value.length;
|
|
36
|
+
}
|
|
41
37
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
75
|
-
|
|
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
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
91
|
+
static kebab(value: string): string {
|
|
92
|
+
return Str.snake(value, "-");
|
|
93
|
+
}
|
|
82
94
|
|
|
83
|
-
|
|
84
|
-
|
|
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
|
-
|
|
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
|
-
|
|
95
|
-
|
|
106
|
+
static camel(value: string): string {
|
|
107
|
+
const studly = Str.studly(value);
|
|
108
|
+
if (!studly) {
|
|
109
|
+
return "";
|
|
110
|
+
}
|
|
96
111
|
|
|
97
|
-
|
|
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
|
-
|
|
104
|
-
|
|
115
|
+
static slug(value: string, separator = "-"): string {
|
|
116
|
+
const slugged = normalizeForSlug(value);
|
|
117
|
+
if (separator === "-") {
|
|
118
|
+
return slugged;
|
|
119
|
+
}
|
|
105
120
|
|
|
106
|
-
|
|
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
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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
package/src/vue.ts
ADDED
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
|
+
}
|