@wyrly/core 1.0.4 → 1.0.5
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 +110 -0
- package/esm/_dnt.shims.d.ts +1 -5
- package/esm/_dnt.shims.d.ts.map +1 -1
- package/esm/_dnt.shims.js +1 -5
- package/esm/i18n.d.ts.map +1 -1
- package/esm/i18n.js +14 -1
- package/package.json +22 -9
package/README.md
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# @wyrly/core
|
|
2
|
+
|
|
3
|
+
Explicit DI for modern TypeScript — typed tokens, standard decorators, and request scopes.
|
|
4
|
+
|
|
5
|
+
**Runtimes:** [Deno 2.x (JSR)](#install-deno--jsr) ·
|
|
6
|
+
[Node.js 20+ / Bun (npm)](#install-nodejs--bun--npm)
|
|
7
|
+
|
|
8
|
+
Japanese: [README.ja.md](./README.ja.md)
|
|
9
|
+
|
|
10
|
+
## Runtimes
|
|
11
|
+
|
|
12
|
+
| Runtime | Registry | Import |
|
|
13
|
+
| ------------ | ------------------------------------------------ | ------------------------ |
|
|
14
|
+
| **Deno 2.x** | [JSR `@wyrly/core`](https://jsr.io/@wyrly/core) | `jsr:@wyrly/core@^1.0.5` |
|
|
15
|
+
| Node.js 20+ | [npm](https://www.npmjs.com/package/@wyrly/core) | `@wyrly/core` |
|
|
16
|
+
| Bun | npm (same package) | `@wyrly/core` |
|
|
17
|
+
|
|
18
|
+
Published to **JSR and npm** from the same source. Deno users should prefer JSR; Node/Bun users use
|
|
19
|
+
npm.
|
|
20
|
+
|
|
21
|
+
## Install (Deno / JSR)
|
|
22
|
+
|
|
23
|
+
```jsonc
|
|
24
|
+
// deno.json
|
|
25
|
+
{
|
|
26
|
+
"imports": {
|
|
27
|
+
"@wyrly/core": "jsr:@wyrly/core@^1.0.5"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
# or add with Deno 2.x
|
|
34
|
+
deno add jsr:@wyrly/core
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import { createContainer, Injectable, token } from "@wyrly/core";
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
See also on [jsr.io/@wyrly/core](https://jsr.io/@wyrly/core).
|
|
42
|
+
|
|
43
|
+
## Install (Node.js / Bun / npm)
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
npm install @wyrly/core
|
|
47
|
+
# bun add @wyrly/core
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
import { createContainer, Injectable, token } from "@wyrly/core";
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Requirements
|
|
55
|
+
|
|
56
|
+
- **TypeScript 5+** with
|
|
57
|
+
[standard (TC39) decorators](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-0.html#decorators)
|
|
58
|
+
(`experimentalDecorators: false`)
|
|
59
|
+
- **ESM** (`"type": "module"` recommended on Node/Bun)
|
|
60
|
+
- **Deno 2.x**, **Node.js 20+**, **Bun**, or bundlers that support the above
|
|
61
|
+
|
|
62
|
+
No `reflect-metadata`, no `emitDecoratorMetadata`, no parameter decorators.
|
|
63
|
+
|
|
64
|
+
## Quick start
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
import { createContainer, Injectable, token } from "@wyrly/core";
|
|
68
|
+
|
|
69
|
+
const RepoToken = token<{ findById(id: string): Promise<unknown> }>("Repo");
|
|
70
|
+
|
|
71
|
+
@Injectable({ deps: [RepoToken], lifetime: "scoped" })
|
|
72
|
+
class GetUser {
|
|
73
|
+
constructor(private readonly repo: { findById(id: string): Promise<unknown> }) {}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const container = createContainer();
|
|
77
|
+
container.register(RepoToken, {
|
|
78
|
+
useValue: { findById: async () => null },
|
|
79
|
+
lifetime: "scoped",
|
|
80
|
+
});
|
|
81
|
+
container.register(GetUser);
|
|
82
|
+
|
|
83
|
+
const scope = container.createScope();
|
|
84
|
+
try {
|
|
85
|
+
scope.resolve(GetUser);
|
|
86
|
+
} finally {
|
|
87
|
+
await scope.dispose();
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Documentation
|
|
92
|
+
|
|
93
|
+
- [API reference](https://github.com/valid-lab/wyrly/blob/main/API.md)
|
|
94
|
+
- [Monorepo README](https://github.com/valid-lab/wyrly/blob/main/README.md)
|
|
95
|
+
- [Publishing & runtimes](https://github.com/valid-lab/wyrly/blob/main/PUBLISHING.md)
|
|
96
|
+
|
|
97
|
+
## Related packages
|
|
98
|
+
|
|
99
|
+
| Package | Deno (JSR) | npm | Description |
|
|
100
|
+
| ---------------- | ---------- | --- | --------------------------------- |
|
|
101
|
+
| `@wyrly/core` | yes | yes | Core container, tokens, lifetimes |
|
|
102
|
+
| `@wyrly/express` | yes | yes | Express 5 middleware |
|
|
103
|
+
| `@wyrly/hono` | yes | yes | Hono middleware |
|
|
104
|
+
| `@wyrly/graphql` | yes | yes | GraphQL request scope |
|
|
105
|
+
| `@wyrly/next` | yes | yes | Next.js App Router |
|
|
106
|
+
| `@wyrly/fresh` | yes | — | Fresh 2.x (JSR only) |
|
|
107
|
+
|
|
108
|
+
## License
|
|
109
|
+
|
|
110
|
+
Apache-2.0 — see [LICENSE](https://github.com/valid-lab/wyrly/blob/main/LICENSE).
|
package/esm/_dnt.shims.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export { Deno } from "@deno/shim-deno";
|
|
3
|
-
export declare const dntGlobalThis: Omit<typeof globalThis, "Deno"> & {
|
|
4
|
-
Deno: typeof Deno;
|
|
5
|
-
};
|
|
1
|
+
export declare const dntGlobalThis: Omit<typeof globalThis, never>;
|
|
6
2
|
//# sourceMappingURL=_dnt.shims.d.ts.map
|
package/esm/_dnt.shims.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_dnt.shims.d.ts","sourceRoot":"","sources":["../src/_dnt.shims.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"_dnt.shims.d.ts","sourceRoot":"","sources":["../src/_dnt.shims.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,gCAA2C,CAAC"}
|
package/esm/_dnt.shims.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export { Deno } from "@deno/shim-deno";
|
|
3
|
-
const dntGlobals = {
|
|
4
|
-
Deno,
|
|
5
|
-
};
|
|
1
|
+
const dntGlobals = {};
|
|
6
2
|
export const dntGlobalThis = createMergeProxy(globalThis, dntGlobals);
|
|
7
3
|
function createMergeProxy(baseObj, extObj) {
|
|
8
4
|
return new Proxy(baseObj, {
|
package/esm/i18n.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../src/i18n.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;AAEjC,wEAAwE;AACxE,eAAO,MAAM,cAAc,EAAE,MAAa,CAAC;AAE3C,gEAAgE;AAChE,MAAM,MAAM,qBAAqB,GAC7B,uBAAuB,GACvB,6BAA6B,GAC7B,6BAA6B,GAC7B,qBAAqB,GACrB,iBAAiB,CAAC;AAEtB,gEAAgE;AAChE,MAAM,MAAM,gBAAgB,GACxB,kBAAkB,GAClB,oBAAoB,GACpB,eAAe,GACf,mBAAmB,GACnB,mBAAmB,GACnB,kCAAkC,GAClC,kCAAkC,GAClC,2CAA2C,GAC3C,wBAAwB,CAAC;AAE7B,qEAAqE;AACrE,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAItD;
|
|
1
|
+
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../src/i18n.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;AAEjC,wEAAwE;AACxE,eAAO,MAAM,cAAc,EAAE,MAAa,CAAC;AAE3C,gEAAgE;AAChE,MAAM,MAAM,qBAAqB,GAC7B,uBAAuB,GACvB,6BAA6B,GAC7B,6BAA6B,GAC7B,qBAAqB,GACrB,iBAAiB,CAAC;AAEtB,gEAAgE;AAChE,MAAM,MAAM,gBAAgB,GACxB,kBAAkB,GAClB,oBAAoB,GACpB,eAAe,GACf,mBAAmB,GACnB,mBAAmB,GACnB,kCAAkC,GAClC,kCAAkC,GAClC,2CAA2C,GAC3C,wBAAwB,CAAC;AAE7B,qEAAqE;AACrE,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAItD;AAqBD,oEAAoE;AACpE,wBAAgB,aAAa,CAAC,OAAO,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CA0BnE;AAED,sEAAsE;AACtE,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,qBAAqB,EAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,MAAM,EAAE,MAAM,GACb,MAAM,CAsBR;AAED,mEAAmE;AACnE,wBAAgB,YAAY,CAC1B,IAAI,EAAE,gBAAgB,EACtB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,MAAM,EAAE,MAAM,GACb,MAAM,CA6CR;AAED,+DAA+D;AAC/D,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAI3D;AAED,gEAAgE;AAChE,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAI5D"}
|
package/esm/i18n.js
CHANGED
|
@@ -11,7 +11,20 @@ export function normalizeLocaleTag(tag) {
|
|
|
11
11
|
}
|
|
12
12
|
function envGet(key) {
|
|
13
13
|
try {
|
|
14
|
-
|
|
14
|
+
const proc = dntShim.dntGlobalThis
|
|
15
|
+
.process;
|
|
16
|
+
const fromProcess = proc?.env?.[key];
|
|
17
|
+
if (fromProcess !== undefined)
|
|
18
|
+
return fromProcess;
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
// ignore
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
const runtime = dntShim.dntGlobalThis;
|
|
25
|
+
const env = runtime["Deno"]
|
|
26
|
+
?.env;
|
|
27
|
+
return env?.get(key);
|
|
15
28
|
}
|
|
16
29
|
catch {
|
|
17
30
|
return undefined;
|
package/package.json
CHANGED
|
@@ -1,13 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wyrly/core",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Explicit DI for modern TypeScript
|
|
3
|
+
"version": "1.0.5",
|
|
4
|
+
"description": "Explicit DI for modern TypeScript — typed tokens, standard decorators, request scopes",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"wyrly",
|
|
7
|
+
"dependency-injection",
|
|
8
|
+
"di",
|
|
9
|
+
"typescript",
|
|
10
|
+
"inversion-of-control",
|
|
11
|
+
"ioc",
|
|
12
|
+
"deno",
|
|
13
|
+
"jsr",
|
|
14
|
+
"decorators",
|
|
15
|
+
"clean-architecture",
|
|
16
|
+
"ddd",
|
|
17
|
+
"scoped",
|
|
18
|
+
"container"
|
|
19
|
+
],
|
|
20
|
+
"homepage": "https://github.com/valid-lab/wyrly/tree/main/packages/core",
|
|
5
21
|
"repository": {
|
|
6
22
|
"type": "git",
|
|
7
23
|
"url": "git+https://github.com/valid-lab/wyrly.git",
|
|
8
24
|
"directory": "packages/core"
|
|
9
25
|
},
|
|
10
26
|
"license": "Apache-2.0",
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/valid-lab/wyrly/issues"
|
|
29
|
+
},
|
|
11
30
|
"module": "./esm/mod.js",
|
|
12
31
|
"exports": {
|
|
13
32
|
".": {
|
|
@@ -16,11 +35,5 @@
|
|
|
16
35
|
},
|
|
17
36
|
"scripts": {},
|
|
18
37
|
"sideEffects": false,
|
|
19
|
-
"dependencies": {
|
|
20
|
-
"@deno/shim-deno": "~0.18.0"
|
|
21
|
-
},
|
|
22
|
-
"devDependencies": {
|
|
23
|
-
"@types/node": "^20.9.0"
|
|
24
|
-
},
|
|
25
38
|
"_generatedBy": "dnt@dev"
|
|
26
|
-
}
|
|
39
|
+
}
|