@primate/core 0.7.4 → 0.8.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.
- package/lib/private/App.d.ts +128 -65
- package/lib/private/Bag.d.ts +11 -0
- package/lib/private/Bag.js +31 -0
- package/lib/private/Flags.d.ts +5 -5
- package/lib/private/Flags.js +2 -1
- package/lib/private/app/Facade.client.d.ts +20 -0
- package/lib/private/app/Facade.client.js +30 -0
- package/lib/private/app/{Facade.d.ts → Facade.server.d.ts} +141 -72
- package/lib/private/app/{Facade.js → Facade.server.js} +12 -4
- package/lib/private/build/App.d.ts +0 -2
- package/lib/private/build/App.js +0 -7
- package/lib/private/build/client/index.js +29 -27
- package/lib/private/build/client/plugin/frontend.js +1 -1
- package/lib/private/build/hook.js +0 -3
- package/lib/private/build/server/index.js +5 -18
- package/lib/private/build/server/plugin/native-addons.d.ts +1 -1
- package/lib/private/build/server/plugin/native-addons.js +1 -1
- package/lib/private/client/create-form.d.ts +13 -9
- package/lib/private/client/create-form.js +21 -4
- package/lib/private/client/transport.js +0 -2
- package/lib/private/config/index.d.ts +6 -2
- package/lib/private/config/schema.d.ts +28 -21
- package/lib/private/config/schema.js +5 -3
- package/lib/private/cookie.d.ts +5 -5
- package/lib/private/db/errors.d.ts +82 -82
- package/lib/private/db/migrate/store.d.ts +2 -2
- package/lib/private/db/primary.d.ts +1 -1
- package/lib/private/db/sql.d.ts +1 -1
- package/lib/private/errors.d.ts +80 -68
- package/lib/private/errors.js +22 -0
- package/lib/private/frontend.d.ts +7 -7
- package/lib/private/frontend.js +7 -10
- package/lib/private/i18n/API.d.ts +14 -18
- package/lib/private/i18n/config.client.d.ts +7 -0
- package/lib/private/i18n/config.client.js +130 -0
- package/lib/private/i18n/config.server.d.ts +7 -0
- package/lib/private/i18n/{index/server.js → config.server.js} +31 -23
- package/lib/private/i18n/constant/COOKIE_NAME.d.ts +1 -1
- package/lib/private/i18n/constant/DEFAULT_LOCALE.d.ts +1 -1
- package/lib/private/i18n/constant/DEFAULT_PERSIST_MODE.d.ts +1 -1
- package/lib/private/i18n/constant/PERSIST_HEADER.d.ts +1 -1
- package/lib/private/i18n/constant/PERSIST_METHOD.d.ts +1 -1
- package/lib/private/i18n/constant/PERSIST_STORAGE_KEY.d.ts +1 -1
- package/lib/private/i18n/index.d.ts +42 -0
- package/lib/private/i18n/index.js +6 -0
- package/lib/private/i18n/missing.d.ts +5 -0
- package/lib/private/i18n/missing.js +38 -0
- package/lib/private/i18n/module.js +36 -52
- package/lib/private/i18n/schema.d.ts +4 -4
- package/lib/private/loader.d.ts +5 -0
- package/lib/private/loader.js +28 -0
- package/lib/private/logger.d.ts +1 -1
- package/lib/private/request/RequestBag.d.ts +12 -13
- package/lib/private/request/RequestBag.js +5 -4
- package/lib/private/request/RequestView.d.ts +5 -5
- package/lib/private/request/RequestView.js +0 -1
- package/lib/private/response/view.d.ts +1 -0
- package/lib/private/response/view.js +0 -7
- package/lib/private/route/Handler.d.ts +1 -1
- package/lib/private/route/NarrowedRequest.d.ts +6 -1
- package/lib/private/route/Options.d.ts +2 -1
- package/lib/private/route/hook.d.ts +1 -2
- package/lib/private/route/router.d.ts +9 -9
- package/lib/private/route/router.js +9 -0
- package/lib/private/route.client.d.ts +21 -12
- package/lib/private/route.client.js +9 -4
- package/lib/private/route.d.ts +3 -0
- package/lib/private/route.js +2 -0
- package/lib/private/serve/App.d.ts +2 -13
- package/lib/private/serve/App.js +63 -46
- package/lib/private/serve/Init.d.ts +0 -3
- package/lib/private/server/TAG.d.ts +1 -1
- package/lib/private/session/config.client.d.ts +4 -0
- package/lib/private/session/config.client.js +24 -0
- package/lib/private/session/config.server.d.ts +15 -0
- package/lib/private/session/config.server.js +44 -0
- package/lib/private/session/index.d.ts +2 -14
- package/lib/private/session/index.js +2 -43
- package/lib/private/session/schema.d.ts +5 -5
- package/lib/private/store/PrimaryKey.d.ts +1 -1
- package/lib/private/store.client.d.ts +13 -0
- package/lib/private/store.client.js +9 -0
- package/lib/private/store.d.ts +2 -0
- package/lib/private/target/Manager.d.ts +2 -0
- package/lib/private/target/Manager.js +29 -5
- package/lib/private/target/Target.d.ts +2 -0
- package/lib/public/i18n.d.ts +3 -0
- package/lib/public/{i18n/config.js → i18n.js} +1 -1
- package/lib/public/loader.d.ts +2 -0
- package/lib/public/loader.js +2 -0
- package/lib/public/response.d.ts +1 -1
- package/lib/public/{session/config.d.ts → session.d.ts} +1 -1
- package/lib/public/{session/config.js → session.js} +1 -1
- package/package.json +27 -13
- package/lib/private/app/Facade.browser.d.ts +0 -11
- package/lib/private/app/Facade.browser.js +0 -19
- package/lib/private/build/server/plugin/store.d.ts +0 -4
- package/lib/private/build/server/plugin/store.js +0 -25
- package/lib/private/build/server/plugin/stores.d.ts +0 -4
- package/lib/private/build/server/plugin/stores.js +0 -28
- package/lib/private/i18n/index/client.d.ts +0 -9
- package/lib/private/i18n/index/client.js +0 -152
- package/lib/private/i18n/index/server.d.ts +0 -9
- package/lib/private/i18n/symbol/internal.d.ts +0 -3
- package/lib/private/i18n/symbol/internal.js +0 -3
- package/lib/public/i18n/API.d.ts +0 -2
- package/lib/public/i18n/API.js +0 -2
- package/lib/public/i18n/Catalogs.d.ts +0 -2
- package/lib/public/i18n/Catalogs.js +0 -2
- package/lib/public/i18n/ContextData.d.ts +0 -2
- package/lib/public/i18n/ContextData.js +0 -2
- package/lib/public/i18n/config.d.ts +0 -2
- package/lib/public/i18n/locale.d.ts +0 -2
- package/lib/public/i18n/locale.js +0 -2
- package/lib/public/i18n/sInternal.d.ts +0 -2
- package/lib/public/i18n/sInternal.js +0 -2
- package/lib/public/route/hook.d.ts +0 -2
- package/lib/public/route/hook.js +0 -2
- /package/lib/private/i18n/{index/types.d.ts → types.d.ts} +0 -0
- /package/lib/private/i18n/{index/types.js → types.js} +0 -0
package/lib/private/store.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ declare namespace store {
|
|
|
7
7
|
foreign: typeof import("./store/ForeignKey.js").default.new;
|
|
8
8
|
primary: typeof import("./store/PrimaryKey.js").default.new;
|
|
9
9
|
};
|
|
10
|
+
}
|
|
11
|
+
declare namespace store {
|
|
10
12
|
var relation: {
|
|
11
13
|
one: <const N extends string, const FK extends string>(options: {
|
|
12
14
|
table: N;
|
|
@@ -1,12 +1,30 @@
|
|
|
1
1
|
import E from "#errors";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import runtime from "@rcompat/runtime";
|
|
3
|
+
const node = {
|
|
4
|
+
name: "node",
|
|
4
5
|
runner: () => { },
|
|
5
|
-
target: "
|
|
6
|
+
target: "node",
|
|
7
|
+
conditions: ["node"],
|
|
8
|
+
externals: ["node:*"],
|
|
6
9
|
};
|
|
10
|
+
const deno = {
|
|
11
|
+
name: "deno",
|
|
12
|
+
runner: () => { },
|
|
13
|
+
target: "deno",
|
|
14
|
+
conditions: ["deno", "node"],
|
|
15
|
+
externals: ["node:*"],
|
|
16
|
+
};
|
|
17
|
+
const bun = {
|
|
18
|
+
name: "bun",
|
|
19
|
+
runner: () => { },
|
|
20
|
+
target: "bun",
|
|
21
|
+
conditions: ["bun", "node"],
|
|
22
|
+
externals: ["bun:*", "node:*"],
|
|
23
|
+
};
|
|
24
|
+
const TARGETS = [node, deno, bun];
|
|
7
25
|
export default class TargetManager {
|
|
8
|
-
#name =
|
|
9
|
-
#targets = [
|
|
26
|
+
#name = runtime.name;
|
|
27
|
+
#targets = [...TARGETS];
|
|
10
28
|
#app;
|
|
11
29
|
constructor(app) {
|
|
12
30
|
this.#app = app;
|
|
@@ -17,6 +35,12 @@ export default class TargetManager {
|
|
|
17
35
|
get target() {
|
|
18
36
|
return this.get().target;
|
|
19
37
|
}
|
|
38
|
+
get conditions() {
|
|
39
|
+
return this.get().conditions;
|
|
40
|
+
}
|
|
41
|
+
get externals() {
|
|
42
|
+
return this.get().externals;
|
|
43
|
+
}
|
|
20
44
|
has(name) {
|
|
21
45
|
return this.#targets
|
|
22
46
|
.find(target => target.name === name) !== undefined;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default } from "#i18n/index";
|
|
2
|
-
//# sourceMappingURL=
|
|
2
|
+
//# sourceMappingURL=i18n.js.map
|
package/lib/public/response.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ declare const response: {
|
|
|
6
6
|
binary: typeof binary;
|
|
7
7
|
error: typeof error;
|
|
8
8
|
json: (body: unknown, init?: ResponseInit) => (app: import("./index.js").ServeApp) => import("@rcompat/type").MaybePromise<Response>;
|
|
9
|
-
redirect: (location: string, status?:
|
|
9
|
+
redirect: (location: string, status?: 300 | 301 | 302 | 303 | 304 | 307 | 308) => import("./index.js").ResponseFunction;
|
|
10
10
|
sse: (body: {
|
|
11
11
|
close?(): undefined;
|
|
12
12
|
open(events: {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default } from "#session/index";
|
|
2
|
-
//# sourceMappingURL=
|
|
2
|
+
//# sourceMappingURL=session.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default } from "#session/index";
|
|
2
|
-
//# sourceMappingURL=
|
|
2
|
+
//# sourceMappingURL=session.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primate/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "The universal web framework",
|
|
5
5
|
"homepage": "https://primate.run",
|
|
6
6
|
"bugs": "https://github.com/primate-run/primate/issues",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"@rcompat/cli": "^0.24.0",
|
|
23
23
|
"@rcompat/crypto": "^0.21.0",
|
|
24
24
|
"@rcompat/dict": "^0.10.0",
|
|
25
|
-
"@rcompat/env": "^0.22.
|
|
25
|
+
"@rcompat/env": "^0.22.2",
|
|
26
26
|
"@rcompat/error": "^0.8.0",
|
|
27
27
|
"@rcompat/fn": "^0.10.0",
|
|
28
28
|
"@rcompat/fs": "^0.33.2",
|
|
@@ -35,13 +35,32 @@
|
|
|
35
35
|
"@rcompat/symbol": "^0.2.0",
|
|
36
36
|
"@rcompat/type": "^0.17.0",
|
|
37
37
|
"esbuild": "^0.28.0",
|
|
38
|
-
"pema": "^0.
|
|
38
|
+
"pema": "^0.8.0"
|
|
39
39
|
},
|
|
40
40
|
"imports": {
|
|
41
|
-
"#i18n/
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
"#i18n/config": {
|
|
42
|
+
"browser": {
|
|
43
|
+
"@primate/source": "./src/private/i18n/config.client.ts",
|
|
44
|
+
"default": "./lib/private/i18n/config.client.js"
|
|
45
|
+
},
|
|
46
|
+
"@primate/source": "./src/private/i18n/config.server.ts",
|
|
47
|
+
"default": "./lib/private/i18n/config.server.js"
|
|
48
|
+
},
|
|
49
|
+
"#session/config": {
|
|
50
|
+
"browser": {
|
|
51
|
+
"@primate/source": "./src/private/session/config.client.ts",
|
|
52
|
+
"default": "./lib/private/session/config.client.js"
|
|
53
|
+
},
|
|
54
|
+
"@primate/source": "./src/private/session/config.server.ts",
|
|
55
|
+
"default": "./lib/private/session/config.server.js"
|
|
56
|
+
},
|
|
57
|
+
"#app/Facade": {
|
|
58
|
+
"browser": {
|
|
59
|
+
"@primate/source": "./src/private/app/Facade.client.ts",
|
|
60
|
+
"default": "./lib/private/app/Facade.client.js"
|
|
61
|
+
},
|
|
62
|
+
"@primate/source": "./src/private/app/Facade.server.ts",
|
|
63
|
+
"default": "./lib/private/app/Facade.server.js"
|
|
45
64
|
},
|
|
46
65
|
"#*": {
|
|
47
66
|
"@primate/source": "./src/private/*.ts",
|
|
@@ -49,11 +68,6 @@
|
|
|
49
68
|
}
|
|
50
69
|
},
|
|
51
70
|
"exports": {
|
|
52
|
-
"./AppFacade": {
|
|
53
|
-
"@primate/source": "./src/public/AppFacade.ts",
|
|
54
|
-
"browser": "./lib/private/app/Facade.browser.js",
|
|
55
|
-
"default": "./lib/public/AppFacade.js"
|
|
56
|
-
},
|
|
57
71
|
"./route": {
|
|
58
72
|
"types": "./lib/public/route.client.js",
|
|
59
73
|
"@primate/source": "./src/public/route.ts",
|
|
@@ -80,7 +94,7 @@
|
|
|
80
94
|
}
|
|
81
95
|
},
|
|
82
96
|
"scripts": {
|
|
83
|
-
"build": "npm run clean &&
|
|
97
|
+
"build": "npm run clean && tsgo && cp -a src/private/defaults lib/private",
|
|
84
98
|
"clean": "rm -rf ./lib",
|
|
85
99
|
"lint": "eslint .",
|
|
86
100
|
"test": "npx proby"
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Browser stub for AppFacade.
|
|
3
|
-
* env must never be called in frontend code, ecrets must not leak to clients
|
|
4
|
-
*/
|
|
5
|
-
export default class AppFacade {
|
|
6
|
-
config(_path: string): never;
|
|
7
|
-
env(_key: string): never;
|
|
8
|
-
view(_name: string): never;
|
|
9
|
-
get root(): never;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=Facade.browser.d.ts.map
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Browser stub for AppFacade.
|
|
3
|
-
* env must never be called in frontend code, ecrets must not leak to clients
|
|
4
|
-
*/
|
|
5
|
-
export default class AppFacade {
|
|
6
|
-
config(_path) {
|
|
7
|
-
throw new Error("AppFacade.config() is not available in the browser");
|
|
8
|
-
}
|
|
9
|
-
env(_key) {
|
|
10
|
-
throw new Error("AppFacade.env() is server-only. Do not call env() in frontend/browser code.");
|
|
11
|
-
}
|
|
12
|
-
view(_name) {
|
|
13
|
-
throw new Error("AppFacade.view() is not available in the browser");
|
|
14
|
-
}
|
|
15
|
-
get root() {
|
|
16
|
-
throw new Error("AppFacade.root is not available in the browser");
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=Facade.browser.js.map
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import fs from "@rcompat/fs";
|
|
2
|
-
export default function plugin_server_store(app) {
|
|
3
|
-
return {
|
|
4
|
-
name: "primate/server/store",
|
|
5
|
-
setup(build) {
|
|
6
|
-
build.onLoad({ filter: /.*/ }, async (args) => {
|
|
7
|
-
if (args.namespace !== "file")
|
|
8
|
-
return null;
|
|
9
|
-
if (!/\.([tj]s)$/.test(args.path))
|
|
10
|
-
return null;
|
|
11
|
-
const file = fs.ref(args.path);
|
|
12
|
-
const stores_root = app.path.stores.path;
|
|
13
|
-
if (!file.path.startsWith(stores_root + "/"))
|
|
14
|
-
return null;
|
|
15
|
-
return {
|
|
16
|
-
contents: await file.text(),
|
|
17
|
-
loader: args.path.endsWith(".ts") ? "ts" : "js",
|
|
18
|
-
resolveDir: file.directory.path,
|
|
19
|
-
watchFiles: [file.path],
|
|
20
|
-
};
|
|
21
|
-
});
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=store.js.map
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import fs from "@rcompat/fs";
|
|
2
|
-
export default function plugin_server_stores(app) {
|
|
3
|
-
const base = app.path.stores;
|
|
4
|
-
return {
|
|
5
|
-
name: "primate/server/stores",
|
|
6
|
-
setup(build) {
|
|
7
|
-
build.onResolve({ filter: /^app:stores$/ }, () => {
|
|
8
|
-
return { path: "stores-virtual", namespace: "primate-stores" };
|
|
9
|
-
});
|
|
10
|
-
build.onLoad({ filter: /.*/, namespace: "primate-stores" }, async () => {
|
|
11
|
-
const files = await base.files({ recursive: true, filter: /\.[jt]s$/ });
|
|
12
|
-
const contents = `
|
|
13
|
-
const stores = {};
|
|
14
|
-
${files.map((file, i) => {
|
|
15
|
-
const bare = fs.webpath(`${file}`
|
|
16
|
-
.replace(base.toString(), "")
|
|
17
|
-
.replace(/\.[jt]s$/, "").slice(1));
|
|
18
|
-
return `import * as store${i} from "${file}";
|
|
19
|
-
stores["${bare}"] = store${i}.default;`;
|
|
20
|
-
}).join("\n")}
|
|
21
|
-
export default stores;
|
|
22
|
-
`;
|
|
23
|
-
return { contents, loader: "js", resolveDir: app.root.path };
|
|
24
|
-
});
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=stores.js.map
|