@primate/core 0.3.4 → 0.4.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 +5 -19
- package/lib/private/App.js +13 -75
- package/lib/private/Binder.d.ts +1 -3
- package/lib/private/Flags.d.ts +7 -0
- package/lib/private/Flags.js +7 -0
- package/lib/private/Module.d.ts +2 -2
- package/lib/private/backend/TAG.d.ts +1 -1
- package/lib/private/backend/TAG.js +1 -1
- package/lib/private/build/App.d.ts +34 -0
- package/lib/private/build/App.js +103 -0
- package/lib/private/build/client/index.d.ts +3 -0
- package/lib/private/build/client/index.js +95 -0
- package/lib/private/build/client/plugin/alias.d.ts +4 -0
- package/lib/private/build/client/plugin/alias.js +12 -0
- package/lib/private/build/client/plugin/entrypoint.d.ts +4 -0
- package/lib/private/build/client/plugin/entrypoint.js +15 -0
- package/lib/private/build/client/plugin/frontend.d.ts +4 -0
- package/lib/private/build/client/plugin/frontend.js +15 -0
- package/lib/private/build/client/plugin/server-stamp.d.ts +4 -0
- package/lib/private/build/client/plugin/server-stamp.js +14 -0
- package/lib/private/build/client/reload.d.ts +7 -0
- package/lib/private/build/client/reload.js +6 -0
- package/lib/private/{hook/build.d.ts → build/hook.d.ts} +2 -2
- package/lib/private/build/hook.js +49 -0
- package/lib/private/build/index.d.ts +4 -0
- package/lib/private/{build.js → build/index.js} +7 -5
- package/lib/private/build/server/index.d.ts +3 -0
- package/lib/private/build/server/index.js +89 -0
- package/lib/private/build/server/plugin/assets.d.ts +4 -0
- package/lib/private/build/server/plugin/assets.js +67 -0
- package/lib/private/build/server/plugin/config.d.ts +4 -0
- package/lib/private/build/server/plugin/config.js +43 -0
- package/lib/private/build/server/plugin/database-default.d.ts +4 -0
- package/lib/private/build/server/plugin/database-default.js +48 -0
- package/lib/private/build/server/plugin/frontend.d.ts +4 -0
- package/lib/private/build/server/plugin/frontend.js +21 -0
- package/lib/private/build/server/plugin/hot-reload.d.ts +4 -0
- package/lib/private/build/server/plugin/hot-reload.js +36 -0
- package/lib/private/build/server/plugin/native-addons.d.ts +4 -0
- package/lib/private/build/server/plugin/native-addons.js +55 -0
- package/lib/private/build/server/plugin/node-imports.d.ts +4 -0
- package/lib/private/build/server/plugin/node-imports.js +32 -0
- package/lib/private/build/server/plugin/requires.d.ts +4 -0
- package/lib/private/build/server/plugin/requires.js +30 -0
- package/lib/private/build/server/plugin/roots.d.ts +4 -0
- package/lib/private/build/server/plugin/roots.js +18 -0
- package/lib/private/build/server/plugin/route.d.ts +4 -0
- package/lib/private/build/server/plugin/route.js +56 -0
- package/lib/private/build/server/plugin/store-wrap.d.ts +4 -0
- package/lib/private/build/server/plugin/store-wrap.js +33 -0
- package/lib/private/build/server/plugin/store.d.ts +4 -0
- package/lib/private/build/server/plugin/store.js +47 -0
- package/lib/private/build/server/plugin/stores.d.ts +4 -0
- package/lib/private/build/server/plugin/stores.js +25 -0
- package/lib/private/build/server/plugin/view.d.ts +4 -0
- package/lib/private/build/server/plugin/view.js +64 -0
- package/lib/private/build/server/plugin/views.d.ts +4 -0
- package/lib/private/build/server/plugin/views.js +36 -0
- package/lib/private/build/server/plugin/virtual-pages.d.ts +4 -0
- package/lib/private/build/server/plugin/virtual-pages.js +41 -0
- package/lib/private/build/server/plugin/virtual-routes.d.ts +4 -0
- package/lib/private/build/server/plugin/virtual-routes.js +46 -0
- package/lib/private/build/server/plugin/wasm.d.ts +4 -0
- package/lib/private/build/server/plugin/wasm.js +36 -0
- package/lib/private/client/Data.d.ts +2 -0
- package/lib/private/client/app.js +4 -1
- package/lib/private/config/index.d.ts +0 -2
- package/lib/private/config/schema.d.ts +4 -6
- package/lib/private/config/schema.js +9 -19
- package/lib/private/database/Store.d.ts +4 -1
- package/lib/private/database/Store.js +8 -2
- package/lib/private/database/test.js +8 -8
- package/lib/private/frontend/Module.d.ts +4 -3
- package/lib/private/frontend/Module.js +47 -50
- package/lib/private/frontend/Publish.d.ts +1 -1
- package/lib/private/i18n/Module.d.ts +1 -1
- package/lib/private/i18n/Module.js +2 -2
- package/lib/private/location.d.ts +0 -6
- package/lib/private/location.js +0 -12
- package/lib/private/module/BuildHook.d.ts +1 -1
- package/lib/private/module/NextBuild.d.ts +1 -1
- package/lib/private/module/NextServe.d.ts +1 -1
- package/lib/private/paths.d.ts +5 -0
- package/lib/private/paths.js +30 -0
- package/lib/private/reducer.d.ts +2 -2
- package/lib/private/request/route.d.ts +1 -1
- package/lib/private/request/route.js +6 -8
- package/lib/private/response/ResponseFunction.d.ts +1 -1
- package/lib/private/response/binary.d.ts +1 -1
- package/lib/private/response/json.d.ts +1 -1
- package/lib/private/response/sse.d.ts +1 -1
- package/lib/private/response/text.d.ts +1 -1
- package/lib/private/response/view.d.ts +6 -9
- package/lib/private/response/view.js +12 -8
- package/lib/private/response.d.ts +1 -1
- package/lib/private/route/router.d.ts +3 -2
- package/lib/private/route/router.js +5 -4
- package/lib/private/{ServeApp.d.ts → serve/App.d.ts} +5 -22
- package/lib/private/{ServeApp.js → serve/App.js} +106 -35
- package/lib/private/{ServeInit.d.ts → serve/Init.d.ts} +16 -12
- package/lib/private/serve/Init.js +2 -0
- package/lib/private/{hook/serve.d.ts → serve/hook.d.ts} +2 -2
- package/lib/private/{hook/serve.js → serve/hook.js} +1 -1
- package/lib/private/serve/index.d.ts +5 -0
- package/lib/private/serve/index.js +6 -0
- package/lib/private/{builtin/DevModule.d.ts → serve/module/Dev.d.ts} +2 -2
- package/lib/private/{builtin/DevModule.js → serve/module/Dev.js} +4 -6
- package/lib/private/{builtin/HandleModule.d.ts → serve/module/Handle.d.ts} +2 -2
- package/lib/private/{builtin/HandleModule.js → serve/module/Handle.js} +2 -2
- package/lib/private/session/SessionModule.d.ts +3 -2
- package/lib/private/session/SessionModule.js +47 -24
- package/lib/private/session/index.d.ts +11 -8
- package/lib/private/session/index.js +5 -3
- package/lib/private/session/schema.d.ts +2 -4
- package/lib/private/session/schema.js +14 -16
- package/lib/private/target/Manager.js +5 -1
- package/lib/private/wasm/instantiate.js +2 -2
- package/lib/public/BuildApp.d.ts +1 -1
- package/lib/public/BuildApp.js +1 -1
- package/lib/public/Flags.d.ts +2 -0
- package/lib/public/Flags.js +2 -0
- package/lib/public/ServeApp.d.ts +1 -1
- package/lib/public/ServeApp.js +1 -1
- package/lib/public/build.d.ts +1 -1
- package/lib/public/build.js +1 -1
- package/lib/public/serve.d.ts +1 -1
- package/lib/public/serve.js +1 -1
- package/package.json +6 -7
- package/lib/private/BindingContext.d.ts +0 -3
- package/lib/private/BindingContext.js +0 -2
- package/lib/private/BuildApp.d.ts +0 -31
- package/lib/private/BuildApp.js +0 -130
- package/lib/private/Loader.d.ts +0 -17
- package/lib/private/Loader.js +0 -47
- package/lib/private/ServeInit.js +0 -2
- package/lib/private/build.d.ts +0 -4
- package/lib/private/config/config/app.d.ts +0 -3
- package/lib/private/config/config/app.js +0 -3
- package/lib/private/config/config/database/index.d.ts +0 -3
- package/lib/private/config/config/database/index.js +0 -3
- package/lib/private/config/config/session.d.ts +0 -3
- package/lib/private/config/config/session.js +0 -3
- package/lib/private/frontend/bundle-server.d.ts +0 -13
- package/lib/private/frontend/bundle-server.js +0 -48
- package/lib/private/hook/build.js +0 -260
- package/lib/private/serve.d.ts +0 -5
- package/lib/private/serve.js +0 -8
- package/lib/private/session/InMemoryManager.d.ts +0 -9
- package/lib/private/session/InMemoryManager.js +0 -23
- package/lib/private/session/Manager.d.ts +0 -9
- package/lib/private/session/Manager.js +0 -4
- package/lib/private/target/web.d.ts +0 -4
- package/lib/private/target/web.js +0 -58
- package/lib/public/Loader.d.ts +0 -2
- package/lib/public/Loader.js +0 -2
- package/lib/public/session/Manager.d.ts +0 -2
- package/lib/public/session/Manager.js +0 -2
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import FileRef from "@rcompat/fs/FileRef";
|
|
2
|
+
export default function plugin_server_store(app) {
|
|
3
|
+
return {
|
|
4
|
+
name: "primate/server/store",
|
|
5
|
+
setup(build) {
|
|
6
|
+
build.onResolve({ filter: /^app:store\// }, args => {
|
|
7
|
+
const name = args.path.slice("app:store/".length).replace(/\.(js|ts)$/, "");
|
|
8
|
+
return { path: name, namespace: "primate-store-wrapper" };
|
|
9
|
+
});
|
|
10
|
+
build.onLoad({ filter: /.*/, namespace: "primate-store-wrapper" }, args => {
|
|
11
|
+
const name = args.path;
|
|
12
|
+
return {
|
|
13
|
+
contents: `
|
|
14
|
+
import database from "app:database";
|
|
15
|
+
import wrap from "primate/database/wrap";
|
|
16
|
+
import schema from "store:${name}";
|
|
17
|
+
export default wrap("${name}", schema, database);
|
|
18
|
+
`,
|
|
19
|
+
loader: "js",
|
|
20
|
+
resolveDir: app.path.stores.path,
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
build.onResolve({ filter: /^store:/ }, async (args) => {
|
|
24
|
+
const name = args.path.slice("store:".length);
|
|
25
|
+
for (const ext of app.extensions) {
|
|
26
|
+
const file = new FileRef(`${app.path.stores.path}/${name}${ext}`);
|
|
27
|
+
if (await file.exists()) {
|
|
28
|
+
// special namespace to bypass auto-wrap
|
|
29
|
+
return { path: file.path, namespace: "primate-store-raw" };
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
});
|
|
34
|
+
build.onLoad({ filter: /.*/, namespace: "primate-store-raw" }, async (args) => {
|
|
35
|
+
const file = new FileRef(args.path);
|
|
36
|
+
const source = await file.text();
|
|
37
|
+
return {
|
|
38
|
+
contents: source,
|
|
39
|
+
loader: args.path.endsWith(".ts") ? "ts" : "js",
|
|
40
|
+
resolveDir: file.directory.path,
|
|
41
|
+
watchFiles: [file.path],
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import FileRef from "@rcompat/fs/FileRef";
|
|
2
|
+
const jts_re = /\.[jt]s$/;
|
|
3
|
+
export default function plugin_server_stores(app) {
|
|
4
|
+
const base = app.path.stores;
|
|
5
|
+
return {
|
|
6
|
+
name: "primate/server/stores",
|
|
7
|
+
setup(build) {
|
|
8
|
+
build.onResolve({ filter: /^app:stores$/ }, () => {
|
|
9
|
+
return { path: "stores-virtual", namespace: "primate-stores" };
|
|
10
|
+
});
|
|
11
|
+
build.onLoad({ filter: /.*/, namespace: "primate-stores" }, async () => {
|
|
12
|
+
const stores = await Promise.all((await base.collect(file => jts_re.test(file.path)))
|
|
13
|
+
.map(async (path) => `${path}`.replace(base.toString(), _ => "")));
|
|
14
|
+
const contents = `
|
|
15
|
+
const stores = {};
|
|
16
|
+
${stores.map(path => path.slice(1, -".js".length)).map((bare, i) => `import * as store${i} from "${FileRef.webpath(`app:store/${bare}`)}";
|
|
17
|
+
stores["${FileRef.webpath(bare)}"] = store${i}.default;`).join("\n")}
|
|
18
|
+
export default stores;
|
|
19
|
+
`;
|
|
20
|
+
return { contents, loader: "js", resolveDir: app.root.path };
|
|
21
|
+
});
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=stores.js.map
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import FileRef from "@rcompat/fs/FileRef";
|
|
2
|
+
export default function plugin_server_view(app) {
|
|
3
|
+
return {
|
|
4
|
+
name: "primate/server/view",
|
|
5
|
+
setup(build) {
|
|
6
|
+
build.onResolve({ filter: /.*/ }, async (args) => {
|
|
7
|
+
// only care about our wrapped route modules
|
|
8
|
+
if (args.namespace !== "primate-route")
|
|
9
|
+
return null;
|
|
10
|
+
// avoid recursion when we call build.resolve ourselves
|
|
11
|
+
if (args.pluginData === "primate-view-inner")
|
|
12
|
+
return null;
|
|
13
|
+
// let esbuild resolve this import as usual
|
|
14
|
+
const result = await build.resolve(args.path, {
|
|
15
|
+
resolveDir: args.resolveDir,
|
|
16
|
+
kind: args.kind,
|
|
17
|
+
pluginData: "primate-view-inner",
|
|
18
|
+
});
|
|
19
|
+
// couldn't resolve, don't interfere
|
|
20
|
+
if (result.errors.length > 0 || !result.path)
|
|
21
|
+
return null;
|
|
22
|
+
const resolved = new FileRef(result.path);
|
|
23
|
+
// must live under app.path.views (e.g. app/views/...)
|
|
24
|
+
const views_root = app.path.views.path;
|
|
25
|
+
if (!resolved.path.startsWith(views_root + "/"))
|
|
26
|
+
return null;
|
|
27
|
+
return {
|
|
28
|
+
path: resolved.debase(app.path.views).path.replace(/^[\\/]/, ""),
|
|
29
|
+
namespace: "primate-view-wrapper",
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
build.onLoad({ filter: /.*/, namespace: "primate-view-wrapper" }, async (args) => {
|
|
33
|
+
const name = args.path;
|
|
34
|
+
return {
|
|
35
|
+
contents: `export default ${JSON.stringify(name)};`,
|
|
36
|
+
loader: "js",
|
|
37
|
+
resolveDir: app.path.views.path,
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
build.onResolve({ filter: /^view:/ }, async (args) => {
|
|
41
|
+
const name = args.path.slice("view:".length);
|
|
42
|
+
for (const ext of app.extensions) {
|
|
43
|
+
const file = new FileRef(`${app.path.views.path}/${name}${ext}`);
|
|
44
|
+
if (await file.exists()) {
|
|
45
|
+
return { path: file.path, namespace: "primate-view-original" };
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return null;
|
|
49
|
+
});
|
|
50
|
+
build.onLoad({ filter: /.*/, namespace: "primate-view-original" }, async (args) => {
|
|
51
|
+
const file = new FileRef(args.path);
|
|
52
|
+
const binder = app.binder(file);
|
|
53
|
+
if (!binder)
|
|
54
|
+
return null;
|
|
55
|
+
const contents = await binder(file, {
|
|
56
|
+
build: { id: app.id },
|
|
57
|
+
context: "views",
|
|
58
|
+
});
|
|
59
|
+
return { contents, loader: "js", resolveDir: file.directory.path };
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=view.js.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import FileRef from "@rcompat/fs/FileRef";
|
|
2
|
+
export default function plugin_server_views(app) {
|
|
3
|
+
return {
|
|
4
|
+
name: "primate/server/views",
|
|
5
|
+
setup(build) {
|
|
6
|
+
build.onResolve({ filter: /^app:views/ }, () => {
|
|
7
|
+
return { path: "views-virtual", namespace: "primate-views" };
|
|
8
|
+
});
|
|
9
|
+
build.onLoad({ filter: /.*/, namespace: "primate-views" }, async () => {
|
|
10
|
+
const files = await app.path.views.collect();
|
|
11
|
+
const roots = Object.keys(app.roots);
|
|
12
|
+
const contents = `
|
|
13
|
+
const view = [];
|
|
14
|
+
${files.map((file, i) => {
|
|
15
|
+
const path = app.basename(file, app.path.views);
|
|
16
|
+
return `
|
|
17
|
+
import * as view${i} from "${FileRef.webpath(`view:${path}`)}";
|
|
18
|
+
view.push(["${FileRef.webpath(path)}", view${i}]);`;
|
|
19
|
+
}).join("\n")}
|
|
20
|
+
|
|
21
|
+
${roots.map((filename, i) => `
|
|
22
|
+
import * as root${i} from "app:root/${filename}";
|
|
23
|
+
view.push(["${filename}", root${i}]);
|
|
24
|
+
`).join("\n")}
|
|
25
|
+
|
|
26
|
+
export default view;`;
|
|
27
|
+
return {
|
|
28
|
+
contents,
|
|
29
|
+
loader: "js",
|
|
30
|
+
resolveDir: app.root.path,
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=views.js.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import pkg from "@rcompat/fs/project/package";
|
|
2
|
+
const core_pkg = await pkg(import.meta.url);
|
|
3
|
+
const core_root = core_pkg.directory;
|
|
4
|
+
export default function plugin_server_virtual_pages(app) {
|
|
5
|
+
return {
|
|
6
|
+
name: "primate/server/virtual/pages",
|
|
7
|
+
setup(build) {
|
|
8
|
+
build.onResolve({ filter: /^app:pages$/ }, () => {
|
|
9
|
+
return { path: "pages-virtual", namespace: "primate-pages" };
|
|
10
|
+
});
|
|
11
|
+
build.onLoad({ filter: /.*/, namespace: "primate-pages" }, async () => {
|
|
12
|
+
const html = /^.*\.html$/ui;
|
|
13
|
+
const is_html = (file) => html.test(file.path);
|
|
14
|
+
const defaults = core_root.join("lib", "private", "defaults");
|
|
15
|
+
const pages = {};
|
|
16
|
+
for (const file of await defaults.collect(is_html))
|
|
17
|
+
pages[file.name] = file;
|
|
18
|
+
if (await app.path.pages.exists()) {
|
|
19
|
+
for (const file of await app.path.pages.collect(is_html))
|
|
20
|
+
pages[file.name] = file;
|
|
21
|
+
}
|
|
22
|
+
const entries = await Promise.all(Object.entries(pages).map(async ([name, file]) => {
|
|
23
|
+
const text = await file.text();
|
|
24
|
+
return `"${name}": ${JSON.stringify(text)}`;
|
|
25
|
+
}));
|
|
26
|
+
const contents = `
|
|
27
|
+
const pages = {
|
|
28
|
+
${entries.join(",\n")}
|
|
29
|
+
};
|
|
30
|
+
export default pages;
|
|
31
|
+
`;
|
|
32
|
+
return {
|
|
33
|
+
contents,
|
|
34
|
+
loader: "js",
|
|
35
|
+
resolveDir: app.root.path,
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=virtual-pages.js.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export default function plugin_server_virtual_routes(app) {
|
|
2
|
+
const extension_pattern = new RegExp(`(${app.extensions.map(e => e.replace(".", "\\.")).join("|")})$`);
|
|
3
|
+
const is_route_file = (f) => !f.name.endsWith("~") &&
|
|
4
|
+
!f.name.startsWith(".") &&
|
|
5
|
+
extension_pattern.test(f.path);
|
|
6
|
+
return {
|
|
7
|
+
name: "primate/server/virtual/routes",
|
|
8
|
+
setup(build) {
|
|
9
|
+
const routes_path = app.path.routes;
|
|
10
|
+
build.onResolve({ filter: /^app:routes$/ }, () => {
|
|
11
|
+
return { path: "routes-virtual", namespace: "primate-routes" };
|
|
12
|
+
});
|
|
13
|
+
build.onLoad({ filter: /.*/, namespace: "primate-routes" }, async () => {
|
|
14
|
+
const route_files = await routes_path.collect(is_route_file);
|
|
15
|
+
const watchDirs = new Set();
|
|
16
|
+
const findDirs = async (dir) => {
|
|
17
|
+
watchDirs.add(dir.path);
|
|
18
|
+
const entries = await dir.list();
|
|
19
|
+
for (const entry of entries) {
|
|
20
|
+
if (await entry.isDirectory()) {
|
|
21
|
+
await findDirs(entry);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
await findDirs(app.path.routes);
|
|
26
|
+
const contents = `
|
|
27
|
+
const route = [];
|
|
28
|
+
${route_files.map((file, i) => {
|
|
29
|
+
const path = app.basename(file, app.path.routes);
|
|
30
|
+
return `const route${i} = (await import("app:route/${path}")).default;
|
|
31
|
+
route.push(["${path}", route${i}]);`;
|
|
32
|
+
}).join("\n")}
|
|
33
|
+
export default route;
|
|
34
|
+
`;
|
|
35
|
+
return {
|
|
36
|
+
contents,
|
|
37
|
+
loader: "js",
|
|
38
|
+
resolveDir: app.root.path,
|
|
39
|
+
watchDirs: [...watchDirs],
|
|
40
|
+
watchFiles: route_files.map(f => f.path),
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=virtual-routes.js.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export default function plugin_server_wasm(app) {
|
|
2
|
+
return {
|
|
3
|
+
name: "primate/server/wasm",
|
|
4
|
+
setup(build) {
|
|
5
|
+
const re = /^app:wasm\/(.+)\.wasm$/;
|
|
6
|
+
build.onResolve({ filter: re }, args => {
|
|
7
|
+
const match = re.exec(args.path);
|
|
8
|
+
if (!match)
|
|
9
|
+
return;
|
|
10
|
+
if (app.mode === "development")
|
|
11
|
+
return {
|
|
12
|
+
path: match[1],
|
|
13
|
+
namespace: "wasm-dev",
|
|
14
|
+
};
|
|
15
|
+
else
|
|
16
|
+
return {
|
|
17
|
+
path: app.runpath("wasm", match[1]).path + ".wasm",
|
|
18
|
+
namespace: "file",
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
build.onLoad({ filter: /.*/, namespace: "wasm-dev" }, async (args) => {
|
|
22
|
+
const wasm_file = app.runpath("wasm", args.path + ".wasm");
|
|
23
|
+
return {
|
|
24
|
+
contents: `
|
|
25
|
+
import FileRef from "primate/fs/FileRef";
|
|
26
|
+
const file = new FileRef("${wasm_file.path}");
|
|
27
|
+
export default await file.bytes();
|
|
28
|
+
`,
|
|
29
|
+
loader: "js",
|
|
30
|
+
resolveDir: app.root.path,
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=wasm.js.map
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type Dict from "@rcompat/type/Dict";
|
|
2
|
+
import type Mode from "#Mode";
|
|
2
3
|
type ClientData<T extends Dict = Dict> = {
|
|
3
4
|
view: string;
|
|
4
5
|
request: Dict;
|
|
5
6
|
spa: boolean;
|
|
6
7
|
ssr: boolean;
|
|
8
|
+
mode: Mode;
|
|
7
9
|
} & T;
|
|
8
10
|
export type { ClientData as default };
|
|
9
11
|
//# sourceMappingURL=Data.d.ts.map
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
// @ts-expect-error esbuild vfs
|
|
2
|
-
import
|
|
2
|
+
import stamp from "server:stamp";
|
|
3
|
+
console.log(stamp);
|
|
4
|
+
// @ts-expect-error esbuild vfs
|
|
5
|
+
import * as frontends from "app:frontends";
|
|
3
6
|
class ClientApp {
|
|
4
7
|
start() {
|
|
5
8
|
const hydration = document.getElementById("hydration")?.textContent;
|
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
import Module from "#Module";
|
|
2
2
|
import FileRef from "@rcompat/fs/FileRef";
|
|
3
3
|
declare const _default: import("pema").ObjectType<{
|
|
4
|
-
build: import("pema").OptionalType<import("pema/record").RecordType<import("pema/string").StringType, import("pema/unknown").UnknownType>>;
|
|
5
|
-
bundle: import("pema").DefaultType<import("pema/array").ArrayType<import("pema/string").StringType>, string[]>;
|
|
6
4
|
http: import("pema").ObjectType<{
|
|
7
|
-
csp: import("pema").OptionalType<import("pema/record").RecordType<import("pema/string").StringType, import("pema
|
|
5
|
+
csp: import("pema").OptionalType<import("pema/record").RecordType<import("pema/string").StringType, import("pema").ArrayType<import("pema/string").StringType>>>;
|
|
8
6
|
headers: import("pema").OptionalType<import("pema/record").RecordType<import("pema/string").StringType, import("pema/string").StringType>>;
|
|
9
7
|
host: import("pema").DefaultType<import("pema/string").StringType, "localhost">;
|
|
10
8
|
port: import("pema").DefaultType<import("pema/uint").UintType<"u32">, 6161>;
|
|
11
9
|
ssl: import("pema").ObjectType<{
|
|
12
|
-
cert: import("pema").OptionalType<import("pema/union").UnionType<[import("pema
|
|
13
|
-
key: import("pema").OptionalType<import("pema/union").UnionType<[import("pema
|
|
10
|
+
cert: import("pema").OptionalType<import("pema/union").UnionType<[import("pema").ConstructorType<typeof FileRef>, import("pema/string").StringType]>>;
|
|
11
|
+
key: import("pema").OptionalType<import("pema/union").UnionType<[import("pema").ConstructorType<typeof FileRef>, import("pema/string").StringType]>>;
|
|
14
12
|
}>;
|
|
15
13
|
static: import("pema").ObjectType<{
|
|
16
14
|
root: import("pema").DefaultType<import("pema/string").StringType, "/">;
|
|
17
15
|
}>;
|
|
18
16
|
}>;
|
|
19
|
-
modules: import("pema").OptionalType<import("pema
|
|
17
|
+
modules: import("pema").OptionalType<import("pema").ArrayType<import("pema").ConstructorType<typeof Module>>>;
|
|
20
18
|
request: import("pema").ObjectType<{
|
|
21
19
|
body: import("pema").ObjectType<{
|
|
22
20
|
parse: import("pema").DefaultType<import("pema/boolean").BooleanType, true>;
|
|
@@ -1,34 +1,24 @@
|
|
|
1
1
|
import Module from "#Module";
|
|
2
2
|
import FileRef from "@rcompat/fs/FileRef";
|
|
3
3
|
import p from "pema";
|
|
4
|
-
import array from "pema/array";
|
|
5
|
-
import boolean from "pema/boolean";
|
|
6
|
-
import constructor from "pema/constructor";
|
|
7
|
-
import record from "pema/record";
|
|
8
|
-
import string from "pema/string";
|
|
9
|
-
import uint from "pema/uint";
|
|
10
|
-
import union from "pema/union";
|
|
11
|
-
import unknown from "pema/unknown";
|
|
12
4
|
export default p({
|
|
13
|
-
build: record(string, unknown).optional(),
|
|
14
|
-
bundle: p.array(p.string).default([]),
|
|
15
5
|
http: {
|
|
16
|
-
csp: record(string, array(string)).optional(),
|
|
17
|
-
headers: record(string, string).optional(),
|
|
18
|
-
host: string.default("localhost"),
|
|
19
|
-
port: uint.port().default(6161),
|
|
6
|
+
csp: p.record(p.string, p.array(p.string)).optional(),
|
|
7
|
+
headers: p.record(p.string, p.string).optional(),
|
|
8
|
+
host: p.string.default("localhost"),
|
|
9
|
+
port: p.uint.port().default(6161),
|
|
20
10
|
ssl: {
|
|
21
|
-
cert: union(FileRef, string).optional(),
|
|
22
|
-
key: union(FileRef, string).optional(),
|
|
11
|
+
cert: p.union(FileRef, p.string).optional(),
|
|
12
|
+
key: p.union(FileRef, p.string).optional(),
|
|
23
13
|
},
|
|
24
14
|
static: {
|
|
25
|
-
root: string.default("/"),
|
|
15
|
+
root: p.string.default("/"),
|
|
26
16
|
},
|
|
27
17
|
},
|
|
28
|
-
modules: array(constructor(Module)).optional(),
|
|
18
|
+
modules: p.array(p.constructor(Module)).optional(),
|
|
29
19
|
request: {
|
|
30
20
|
body: {
|
|
31
|
-
parse: boolean.default(true),
|
|
21
|
+
parse: p.boolean.default(true),
|
|
32
22
|
},
|
|
33
23
|
},
|
|
34
24
|
});
|
|
@@ -9,6 +9,7 @@ import type Id from "pema/Id";
|
|
|
9
9
|
import type InferStore from "pema/InferStore";
|
|
10
10
|
import type StoreId from "pema/StoreId";
|
|
11
11
|
import type StoreSchema from "pema/StoreSchema";
|
|
12
|
+
import StoreType from "pema/StoreType";
|
|
12
13
|
type X<T> = {
|
|
13
14
|
[K in keyof T]: T[K];
|
|
14
15
|
} & {};
|
|
@@ -51,11 +52,13 @@ export default class DatabaseStore<S extends StoreSchema> implements Serializabl
|
|
|
51
52
|
readonly Schema: Schema<S>;
|
|
52
53
|
constructor(schema: S, config?: Config);
|
|
53
54
|
static new<S extends StoreSchema>(schema: S, config?: Config): DatabaseStore<S>;
|
|
54
|
-
get
|
|
55
|
+
get collection(): {
|
|
55
56
|
create: () => import("@rcompat/type/MaybePromise").default<void>;
|
|
56
57
|
delete: () => import("@rcompat/type/MaybePromise").default<void>;
|
|
57
58
|
};
|
|
58
59
|
get infer(): InferStore<S>;
|
|
60
|
+
get schema(): S;
|
|
61
|
+
get type(): StoreType<S>;
|
|
59
62
|
get database(): Database;
|
|
60
63
|
get types(): Types;
|
|
61
64
|
get name(): string;
|
|
@@ -26,7 +26,7 @@ export default class DatabaseStore {
|
|
|
26
26
|
.map(([key, value]) => [key, value.datatype]));
|
|
27
27
|
this.#name = config.name;
|
|
28
28
|
this.#database = config.database;
|
|
29
|
-
this.#nullables = new Set(Object.entries(this.#type.
|
|
29
|
+
this.#nullables = new Set(Object.entries(this.#type.properties)
|
|
30
30
|
.filter(([, v]) => v.nullable)
|
|
31
31
|
.map(([k]) => k));
|
|
32
32
|
}
|
|
@@ -63,7 +63,7 @@ export default class DatabaseStore {
|
|
|
63
63
|
types: this.#types,
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
|
-
get
|
|
66
|
+
get collection() {
|
|
67
67
|
const database = this.database;
|
|
68
68
|
const name = this.name;
|
|
69
69
|
const schema = this.#schema;
|
|
@@ -75,6 +75,12 @@ export default class DatabaseStore {
|
|
|
75
75
|
get infer() {
|
|
76
76
|
return undefined;
|
|
77
77
|
}
|
|
78
|
+
get schema() {
|
|
79
|
+
return this.#schema;
|
|
80
|
+
}
|
|
81
|
+
get type() {
|
|
82
|
+
return this.#type;
|
|
83
|
+
}
|
|
78
84
|
[wrap](name, database) {
|
|
79
85
|
this.#database ??= database;
|
|
80
86
|
this.#name ??= name;
|
|
@@ -64,26 +64,26 @@ export default (database) => {
|
|
|
64
64
|
u8: u8.optional(),
|
|
65
65
|
}, { database, name: "type" });
|
|
66
66
|
const bootstrap = async (tester) => {
|
|
67
|
-
await User.
|
|
67
|
+
await User.collection.create();
|
|
68
68
|
for (const user of Object.values(users)) {
|
|
69
69
|
await User.insert(user);
|
|
70
70
|
}
|
|
71
71
|
await tester();
|
|
72
|
-
await User.
|
|
72
|
+
await User.collection.delete();
|
|
73
73
|
};
|
|
74
74
|
const typestrap = async (tester) => {
|
|
75
|
-
await Type.
|
|
75
|
+
await Type.collection.create();
|
|
76
76
|
await tester();
|
|
77
|
-
await Type.
|
|
77
|
+
await Type.collection.delete();
|
|
78
78
|
};
|
|
79
79
|
test.case("insert", async (assert) => {
|
|
80
|
-
await User.
|
|
80
|
+
await User.collection.create();
|
|
81
81
|
const donald = await User.insert({ age: 30, name: "Donald" });
|
|
82
82
|
assert(await User.has(donald.id)).true();
|
|
83
83
|
const ryan = await User.insert({ age: 40, name: "Ryan" });
|
|
84
84
|
assert(await User.has(donald.id)).true();
|
|
85
85
|
assert(await User.has(ryan.id)).true();
|
|
86
|
-
await User.
|
|
86
|
+
await User.collection.delete();
|
|
87
87
|
});
|
|
88
88
|
test.case("find - basic query", async (assert) => {
|
|
89
89
|
await bootstrap(async () => {
|
|
@@ -658,7 +658,7 @@ export default (database) => {
|
|
|
658
658
|
order: u8.optional(),
|
|
659
659
|
name: string,
|
|
660
660
|
}, { database, name: "select" }); // deliberately reserved-like table name
|
|
661
|
-
await Reserved.
|
|
661
|
+
await Reserved.collection.create();
|
|
662
662
|
const a = await Reserved.insert({ name: "alpha", order: 1 });
|
|
663
663
|
const b = await Reserved.insert({ name: "beta", order: 2 });
|
|
664
664
|
const got = await Reserved.find({ name: "alpha" });
|
|
@@ -672,7 +672,7 @@ export default (database) => {
|
|
|
672
672
|
// and delete to complete the cycle
|
|
673
673
|
const d = await Reserved.delete({ id: a.id });
|
|
674
674
|
assert(d).equals(1);
|
|
675
|
-
await Reserved.
|
|
675
|
+
await Reserved.collection.delete();
|
|
676
676
|
});
|
|
677
677
|
};
|
|
678
678
|
//# sourceMappingURL=test.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type App from "#App";
|
|
2
|
-
import type BuildApp from "#
|
|
2
|
+
import type BuildApp from "#build/App";
|
|
3
3
|
import type Render from "#frontend/Render";
|
|
4
4
|
import type ServerView from "#frontend/ServerView";
|
|
5
5
|
import type ViewResponse from "#frontend/ViewResponse";
|
|
@@ -7,7 +7,7 @@ import Module from "#Module";
|
|
|
7
7
|
import type Next from "#module/Next";
|
|
8
8
|
import type NextBuild from "#module/NextBuild";
|
|
9
9
|
import type NextServe from "#module/NextServe";
|
|
10
|
-
import type ServeApp from "#
|
|
10
|
+
import type ServeApp from "#serve/App";
|
|
11
11
|
import FileRef from "@rcompat/fs/FileRef";
|
|
12
12
|
import type MaybePromise from "@rcompat/type/MaybePromise";
|
|
13
13
|
export default abstract class FrontendModule<S = ServerView> extends Module {
|
|
@@ -31,7 +31,7 @@ export default abstract class FrontendModule<S = ServerView> extends Module {
|
|
|
31
31
|
};
|
|
32
32
|
conditions: string[];
|
|
33
33
|
static schema: import("pema").ObjectType<{
|
|
34
|
-
fileExtensions: import("pema").OptionalType<import("pema
|
|
34
|
+
fileExtensions: import("pema").OptionalType<import("pema").ArrayType<import("pema/string").StringType>>;
|
|
35
35
|
spa: import("pema").DefaultType<import("pema/boolean").BooleanType, true>;
|
|
36
36
|
ssr: import("pema").DefaultType<import("pema/boolean").BooleanType, true>;
|
|
37
37
|
}>;
|
|
@@ -56,6 +56,7 @@ export default abstract class FrontendModule<S = ServerView> extends Module {
|
|
|
56
56
|
serve(app: ServeApp, next: NextServe): MaybePromise<ServeApp>;
|
|
57
57
|
publish(app: BuildApp): void;
|
|
58
58
|
init<T extends App>(app: T, next: Next<T>): MaybePromise<T>;
|
|
59
|
+
prebuild(app: BuildApp): void;
|
|
59
60
|
build(app: BuildApp, next: NextBuild): Promise<BuildApp>;
|
|
60
61
|
}
|
|
61
62
|
//# sourceMappingURL=Module.d.ts.map
|