char/avril

(wip) why'd you have to go and make things so complicaaaaated?

git clone https://git.t4t.associates/char/avril

Charlotte Somdeslop: consolidate public type and registry test utils7325e8c

main
1.3 KiB39 linesraw
1use std::convert::Infallible;
2
3use avril_core::{Extension, Op, PublicModule};
4
5pub fn init() -> Extension {
6    Extension {
7        name: "ext:path",
8        dependencies: &["ext:base", "ext:file", "ext:url"],
9        ops: vec![Op::new("op_path_platform", |(): ()| {
10            Ok::<_, Infallible>(if cfg!(windows) { "win32" } else { "posix" })
11        })],
12        modules: const {
13            &[
14                (
15                    "ext:path/api.js",
16                    include_str!(concat!(env!("OUT_DIR"), "/api.js")),
17                ),
18                (
19                    "ext:path/lexical.js",
20                    include_str!(concat!(env!("OUT_DIR"), "/lexical.js")),
21                ),
22                (
23                    "ext:path/urls.js",
24                    include_str!(concat!(env!("OUT_DIR"), "/urls.js")),
25                ),
26                PUBLIC_MODULES[0].module,
27                PUBLIC_MODULES[1].module,
28                PUBLIC_MODULES[2].module,
29            ]
30        },
31        entry_point: None,
32    }
33}
34
35pub const PUBLIC_MODULES: &[PublicModule] = &[
36    avril_core::public_module!("avril:path", "ext:path", "main"),
37    avril_core::public_module!("avril:path/posix", "ext:path", "posix"),
38    avril_core::public_module!("avril:path/win32", "ext:path", "win32"),
39];