@primate/vue 0.15.0 → 0.16.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/lib/app.d.ts +5 -0
- package/lib/index.d.ts +2 -0
- package/lib/private/client/Data.d.ts +5 -0
- package/lib/private/client/Data.js +2 -0
- package/lib/private/client/Payload.d.ts +7 -0
- package/lib/private/client/Payload.js +2 -0
- package/lib/private/client/app.d.ts +2 -8
- package/lib/private/client/app.js +13 -22
- package/lib/private/client/form.d.ts +2 -1
- package/lib/private/client/form.js +15 -8
- package/lib/private/client/index.d.ts +48 -0
- package/lib/private/client/index.js +5 -0
- package/lib/private/client/root.d.ts +21 -0
- package/lib/private/client/root.js +27 -0
- package/lib/private/compile.d.ts +4 -0
- package/lib/private/compile.js +46 -36
- package/lib/private/create-root.js +7 -3
- package/lib/private/default.d.ts +7 -0
- package/lib/private/default.js +18 -0
- package/lib/private/init.d.ts +5 -0
- package/lib/private/init.js +15 -0
- package/lib/private/request/store.d.ts +74 -0
- package/lib/private/request/store.js +4 -0
- package/lib/private/runtime.d.ts +7 -0
- package/lib/private/runtime.js +4 -0
- package/lib/public/app.d.ts +73 -0
- package/lib/public/app.js +4 -0
- package/lib/public/client.d.ts +1 -47
- package/lib/public/client.js +1 -4
- package/lib/public/default.d.ts +1 -3
- package/lib/public/default.js +1 -2
- package/lib/public/runtime.d.ts +1 -3
- package/lib/public/runtime.js +1 -2
- package/package.json +13 -8
- package/lib/private/Default.d.ts +0 -16
- package/lib/private/Default.js +0 -20
- package/lib/private/Runtime.d.ts +0 -11
- package/lib/private/Runtime.js +0 -16
package/lib/app.d.ts
ADDED
package/lib/index.d.ts
ADDED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { Dict } from "@rcompat/type";
|
|
3
|
-
type Data = ClientData<{
|
|
4
|
-
views: string[];
|
|
5
|
-
props: Dict[];
|
|
6
|
-
}>;
|
|
1
|
+
import type Data from "#client/Data";
|
|
7
2
|
export default class VueApp {
|
|
8
|
-
static mount(_view: string, data:
|
|
3
|
+
static mount(_view: string, data: Data): void;
|
|
9
4
|
}
|
|
10
|
-
export {};
|
|
11
5
|
//# sourceMappingURL=app.d.ts.map
|
|
@@ -1,31 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import root from "vue:root";
|
|
4
|
-
import * as views from "vue:views";
|
|
5
|
-
function resolve(names) {
|
|
6
|
-
return names.map(n => views[n]);
|
|
7
|
-
}
|
|
8
|
-
const make_app = (ssr, data, update) => {
|
|
9
|
-
const create = ssr ? createSSRApp : createApp;
|
|
10
|
-
return create(root, {
|
|
11
|
-
p: {
|
|
12
|
-
views: resolve(data.views),
|
|
13
|
-
props: data.props,
|
|
14
|
-
request: data.request,
|
|
15
|
-
update,
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
};
|
|
1
|
+
import root from "#client/root";
|
|
2
|
+
import client from "@primate/core/client";
|
|
19
3
|
export default class VueApp {
|
|
20
4
|
static mount(_view, data) {
|
|
21
|
-
let app =
|
|
5
|
+
let app = root[data.ssr ? "ssr" : "csr"](root.toProps(data));
|
|
22
6
|
app.mount("#app");
|
|
23
7
|
if (data.spa) {
|
|
24
|
-
|
|
8
|
+
const start = () => client.boot((next, update) => {
|
|
25
9
|
app.unmount();
|
|
26
|
-
app =
|
|
10
|
+
app = root.csr(root.toProps(next, update));
|
|
27
11
|
app.mount("#app");
|
|
28
|
-
|
|
12
|
+
update?.();
|
|
13
|
+
});
|
|
14
|
+
if (document.readyState === "loading") {
|
|
15
|
+
window.addEventListener("DOMContentLoaded", start, { once: true });
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
start();
|
|
19
|
+
}
|
|
29
20
|
}
|
|
30
21
|
}
|
|
31
22
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { FormInit } from "@primate/core/client";
|
|
2
2
|
import type { Dict } from "@rcompat/type";
|
|
3
3
|
type FormView<Values extends Dict> = {
|
|
4
4
|
id: string;
|
|
5
5
|
submitting: boolean;
|
|
6
|
+
submitted: boolean;
|
|
6
7
|
submit: (event?: Event) => Promise<void>;
|
|
7
8
|
errors: readonly string[];
|
|
8
9
|
field: <K extends keyof Values & string>(name: K) => {
|
|
@@ -1,31 +1,38 @@
|
|
|
1
1
|
import core from "@primate/core/client";
|
|
2
2
|
import { onUnmounted, shallowRef } from "vue";
|
|
3
3
|
function form(init) {
|
|
4
|
-
const { initial, ...form_init } = init ?? {};
|
|
4
|
+
const { initial, ...form_init } = (init ?? {});
|
|
5
5
|
const controller = core.createForm(form_init);
|
|
6
|
-
const values = initial ?? {};
|
|
6
|
+
const values = (initial ?? {});
|
|
7
7
|
const snapshot = shallowRef(controller.read());
|
|
8
|
-
const unsub = controller.subscribe(next => {
|
|
8
|
+
const unsub = controller.subscribe((next) => {
|
|
9
9
|
snapshot.value = next;
|
|
10
10
|
});
|
|
11
11
|
onUnmounted(unsub);
|
|
12
12
|
return {
|
|
13
|
-
id
|
|
13
|
+
get id() {
|
|
14
|
+
return snapshot.value.id;
|
|
15
|
+
},
|
|
14
16
|
get submitting() {
|
|
15
17
|
return snapshot.value.submitting;
|
|
16
18
|
},
|
|
17
|
-
|
|
19
|
+
get submitted() {
|
|
20
|
+
return snapshot.value.submitted;
|
|
21
|
+
},
|
|
22
|
+
submit(event) {
|
|
23
|
+
return controller.submit(event);
|
|
24
|
+
},
|
|
18
25
|
get errors() {
|
|
19
26
|
return snapshot.value.errors.form;
|
|
20
27
|
},
|
|
21
28
|
field(name) {
|
|
22
29
|
const key = name;
|
|
23
|
-
const
|
|
30
|
+
const errors = snapshot.value.errors.fields[key] ?? [];
|
|
24
31
|
return {
|
|
25
32
|
name: key,
|
|
26
33
|
value: values[name],
|
|
27
|
-
error:
|
|
28
|
-
errors
|
|
34
|
+
error: errors[0] ?? null,
|
|
35
|
+
errors,
|
|
29
36
|
};
|
|
30
37
|
},
|
|
31
38
|
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import form from "#client/form";
|
|
2
|
+
declare const client: {
|
|
3
|
+
form: typeof form;
|
|
4
|
+
field: <T>(initial: T) => {
|
|
5
|
+
delete: (url: string, options?: {
|
|
6
|
+
headers?: import("@rcompat/type").Dict<string>;
|
|
7
|
+
map?: ((v: T) => import("@rcompat/type").JSONValue) | undefined;
|
|
8
|
+
path?: import("@rcompat/type").JSONPointer;
|
|
9
|
+
} | undefined) => {
|
|
10
|
+
error: import("vue").Ref<null | import("@primate/core/client").ValidationError>;
|
|
11
|
+
loading: import("vue").Ref<boolean>;
|
|
12
|
+
update: (updater: import("@primate/core/client").ValidateUpdater<T>) => Promise<void>;
|
|
13
|
+
value: import("vue").Ref<T, T>;
|
|
14
|
+
};
|
|
15
|
+
patch: (url: string, options?: {
|
|
16
|
+
headers?: import("@rcompat/type").Dict<string>;
|
|
17
|
+
map?: ((v: T) => import("@rcompat/type").JSONValue) | undefined;
|
|
18
|
+
path?: import("@rcompat/type").JSONPointer;
|
|
19
|
+
} | undefined) => {
|
|
20
|
+
error: import("vue").Ref<null | import("@primate/core/client").ValidationError>;
|
|
21
|
+
loading: import("vue").Ref<boolean>;
|
|
22
|
+
update: (updater: import("@primate/core/client").ValidateUpdater<T>) => Promise<void>;
|
|
23
|
+
value: import("vue").Ref<T, T>;
|
|
24
|
+
};
|
|
25
|
+
post: (url: string, options?: {
|
|
26
|
+
headers?: import("@rcompat/type").Dict<string>;
|
|
27
|
+
map?: ((v: T) => import("@rcompat/type").JSONValue) | undefined;
|
|
28
|
+
path?: import("@rcompat/type").JSONPointer;
|
|
29
|
+
} | undefined) => {
|
|
30
|
+
error: import("vue").Ref<null | import("@primate/core/client").ValidationError>;
|
|
31
|
+
loading: import("vue").Ref<boolean>;
|
|
32
|
+
update: (updater: import("@primate/core/client").ValidateUpdater<T>) => Promise<void>;
|
|
33
|
+
value: import("vue").Ref<T, T>;
|
|
34
|
+
};
|
|
35
|
+
put: (url: string, options?: {
|
|
36
|
+
headers?: import("@rcompat/type").Dict<string>;
|
|
37
|
+
map?: ((v: T) => import("@rcompat/type").JSONValue) | undefined;
|
|
38
|
+
path?: import("@rcompat/type").JSONPointer;
|
|
39
|
+
} | undefined) => {
|
|
40
|
+
error: import("vue").Ref<null | import("@primate/core/client").ValidationError>;
|
|
41
|
+
loading: import("vue").Ref<boolean>;
|
|
42
|
+
update: (updater: import("@primate/core/client").ValidateUpdater<T>) => Promise<void>;
|
|
43
|
+
value: import("vue").Ref<T, T>;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
export default client;
|
|
48
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type Data from "#client/Data";
|
|
2
|
+
import type { Dict } from "@rcompat/type";
|
|
3
|
+
import type { App, Component } from "vue";
|
|
4
|
+
export type RootProps = {
|
|
5
|
+
views: Component[];
|
|
6
|
+
props: Dict[];
|
|
7
|
+
request: Data["request"] & {
|
|
8
|
+
url: URL;
|
|
9
|
+
};
|
|
10
|
+
update?: () => void;
|
|
11
|
+
};
|
|
12
|
+
declare function toProps(data: Data, update?: () => void): RootProps;
|
|
13
|
+
declare function csr(props: RootProps): App;
|
|
14
|
+
declare function ssr(props: RootProps): App;
|
|
15
|
+
declare const root: {
|
|
16
|
+
toProps: typeof toProps;
|
|
17
|
+
csr: typeof csr;
|
|
18
|
+
ssr: typeof ssr;
|
|
19
|
+
};
|
|
20
|
+
export default root;
|
|
21
|
+
//# sourceMappingURL=root.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createApp, createSSRApp } from "vue";
|
|
2
|
+
import RootView from "vue:root";
|
|
3
|
+
import * as Views from "vue:views";
|
|
4
|
+
function toProps(data, update) {
|
|
5
|
+
return {
|
|
6
|
+
views: data.views.map((name) => Views[name]),
|
|
7
|
+
props: data.props,
|
|
8
|
+
request: {
|
|
9
|
+
...data.request,
|
|
10
|
+
url: new URL(data.request.url),
|
|
11
|
+
},
|
|
12
|
+
update,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function csr(props) {
|
|
16
|
+
return createApp(RootView, { p: props });
|
|
17
|
+
}
|
|
18
|
+
function ssr(props) {
|
|
19
|
+
return createSSRApp(RootView, { p: props });
|
|
20
|
+
}
|
|
21
|
+
const root = {
|
|
22
|
+
toProps,
|
|
23
|
+
csr,
|
|
24
|
+
ssr,
|
|
25
|
+
};
|
|
26
|
+
export default root;
|
|
27
|
+
//# sourceMappingURL=root.js.map
|
package/lib/private/compile.d.ts
CHANGED
package/lib/private/compile.js
CHANGED
|
@@ -1,51 +1,61 @@
|
|
|
1
1
|
import presets from "@primate/core/build/presets";
|
|
2
2
|
import transform from "@primate/core/build/transform";
|
|
3
|
-
import { compileScript, compileTemplate, parse, } from "vue/compiler-sfc";
|
|
3
|
+
import { compileScript, compileStyle, compileTemplate, parse, } from "vue/compiler-sfc";
|
|
4
4
|
const genDefaultAs = "__SCRIPT__";
|
|
5
5
|
const id_size = 8;
|
|
6
6
|
const analyze = ({ script, scriptSetup }) => {
|
|
7
7
|
return {
|
|
8
8
|
has_script: script !== null || scriptSetup !== null,
|
|
9
9
|
inline: scriptSetup !== null,
|
|
10
|
-
|
|
10
|
+
is_ts: script?.lang === "ts" || scriptSetup?.lang === "ts",
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
|
+
const compile_sfc = (text) => {
|
|
14
|
+
const id = crypto.randomUUID().slice(0, id_size);
|
|
15
|
+
const { descriptor } = parse(text);
|
|
16
|
+
const { has_script, inline, is_ts } = analyze(descriptor);
|
|
17
|
+
let module;
|
|
18
|
+
if (inline) {
|
|
19
|
+
const script = compileScript(descriptor, {
|
|
20
|
+
genDefaultAs,
|
|
21
|
+
id,
|
|
22
|
+
inlineTemplate: true,
|
|
23
|
+
});
|
|
24
|
+
module = `
|
|
25
|
+
${script.content}
|
|
26
|
+
export default { ...__SCRIPT__ };
|
|
27
|
+
`;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
const template = compileTemplate({
|
|
31
|
+
filename: "",
|
|
32
|
+
id,
|
|
33
|
+
source: descriptor.template?.content ?? "",
|
|
34
|
+
});
|
|
35
|
+
const script = has_script
|
|
36
|
+
? compileScript(descriptor, { genDefaultAs, id, inlineTemplate: false })
|
|
37
|
+
: { content: `const ${genDefaultAs} = {}` };
|
|
38
|
+
module = `
|
|
39
|
+
${template.code}
|
|
40
|
+
${script.content}
|
|
41
|
+
export default { ...__SCRIPT__, render };
|
|
42
|
+
`;
|
|
43
|
+
}
|
|
44
|
+
const js = is_ts ? transform(module, presets.typescript).code : module;
|
|
45
|
+
const css = descriptor.styles.map(style => compileStyle({
|
|
46
|
+
filename: "",
|
|
47
|
+
id,
|
|
48
|
+
source: style.content,
|
|
49
|
+
scoped: style.scoped ?? false,
|
|
50
|
+
}).code).join("\n");
|
|
51
|
+
return { js, css };
|
|
52
|
+
};
|
|
13
53
|
export default {
|
|
54
|
+
client(text) {
|
|
55
|
+
return compile_sfc(text);
|
|
56
|
+
},
|
|
14
57
|
server(text) {
|
|
15
|
-
|
|
16
|
-
const { descriptor } = parse(text);
|
|
17
|
-
const { has_script, inline, is_typescript } = analyze(descriptor);
|
|
18
|
-
let module;
|
|
19
|
-
if (inline) {
|
|
20
|
-
// for <script setup>, compile with inlineTemplate to get both script and
|
|
21
|
-
// render
|
|
22
|
-
const script = compileScript(descriptor, {
|
|
23
|
-
genDefaultAs,
|
|
24
|
-
id,
|
|
25
|
-
inlineTemplate: true,
|
|
26
|
-
});
|
|
27
|
-
module = `
|
|
28
|
-
${script.content}
|
|
29
|
-
export default { ...__SCRIPT__ };
|
|
30
|
-
`;
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
// For regular components, compile template and script separately
|
|
34
|
-
const template = compileTemplate({
|
|
35
|
-
filename: "",
|
|
36
|
-
id,
|
|
37
|
-
source: descriptor.template?.content ?? "",
|
|
38
|
-
});
|
|
39
|
-
const script = has_script
|
|
40
|
-
? compileScript(descriptor, { genDefaultAs, id, inlineTemplate: false })
|
|
41
|
-
: { content: `const ${genDefaultAs} = {}` };
|
|
42
|
-
module = `
|
|
43
|
-
${template.code}
|
|
44
|
-
${script.content}
|
|
45
|
-
export default { ...__SCRIPT__, render };
|
|
46
|
-
`;
|
|
47
|
-
}
|
|
48
|
-
return is_typescript ? transform(module, presets.typescript).code : module;
|
|
58
|
+
return compile_sfc(text).js;
|
|
49
59
|
},
|
|
50
60
|
};
|
|
51
61
|
//# sourceMappingURL=compile.js.map
|
|
@@ -11,9 +11,12 @@ export default (depth, i18n_active) => {
|
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
13
|
const body = depth > 0 ? build_view(0) : "h(\"div\")";
|
|
14
|
-
const vueImports = `
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
const vueImports = `
|
|
15
|
+
import {
|
|
16
|
+
defineComponent, h${i18n_active ? ", ref, onMounted, onUnmounted" : ""}
|
|
17
|
+
} from "vue";
|
|
18
|
+
import { setRequest } from "@primate/vue/app";
|
|
19
|
+
`;
|
|
17
20
|
const i18nImports = i18n_active
|
|
18
21
|
? `
|
|
19
22
|
import t from "#i18n";
|
|
@@ -45,6 +48,7 @@ export default defineComponent({
|
|
|
45
48
|
${i18nSetup}
|
|
46
49
|
return () => {
|
|
47
50
|
const p = props.p;
|
|
51
|
+
setRequest(props.p.request);
|
|
48
52
|
return ${body};
|
|
49
53
|
};
|
|
50
54
|
},
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import compile from "#compile";
|
|
2
|
+
import create_root from "#create-root";
|
|
3
|
+
import init from "#init";
|
|
4
|
+
import frontend from "@primate/core/frontend";
|
|
5
|
+
export default frontend({
|
|
6
|
+
...init,
|
|
7
|
+
root: {
|
|
8
|
+
create: create_root,
|
|
9
|
+
},
|
|
10
|
+
css: {
|
|
11
|
+
filter: /\.vuecss$/,
|
|
12
|
+
},
|
|
13
|
+
compile: {
|
|
14
|
+
client: (text, _, root) => root ? { js: text, css: "" } : compile.client(text),
|
|
15
|
+
server: (text, file) => file.path.startsWith("root:") ? text : compile.server(text),
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
//# sourceMappingURL=default.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createSSRApp } from "vue";
|
|
2
|
+
import { renderToString } from "vue/server-renderer";
|
|
3
|
+
const module = {
|
|
4
|
+
name: "vue",
|
|
5
|
+
extensions: [".vue"],
|
|
6
|
+
layouts: true,
|
|
7
|
+
client: true,
|
|
8
|
+
async render(view, props) {
|
|
9
|
+
const app = createSSRApp(view, { p: { ...props } });
|
|
10
|
+
const html = await renderToString(app);
|
|
11
|
+
return { body: `<div id="app">${html}</div>` };
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
export default module;
|
|
15
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { RequestPublic } from "@primate/core";
|
|
2
|
+
declare const store: import("vue").Ref<{
|
|
3
|
+
cookies: import("@rcompat/type").Dict<string>;
|
|
4
|
+
headers: import("@rcompat/type").Dict<string>;
|
|
5
|
+
query: import("@rcompat/type").Dict<string>;
|
|
6
|
+
url: {
|
|
7
|
+
hash: string;
|
|
8
|
+
host: string;
|
|
9
|
+
hostname: string;
|
|
10
|
+
href: string;
|
|
11
|
+
toString: () => string;
|
|
12
|
+
readonly origin: string;
|
|
13
|
+
password: string;
|
|
14
|
+
pathname: string;
|
|
15
|
+
port: string;
|
|
16
|
+
protocol: string;
|
|
17
|
+
search: string;
|
|
18
|
+
readonly searchParams: {
|
|
19
|
+
readonly size: number;
|
|
20
|
+
append: (name: string, value: string) => void;
|
|
21
|
+
delete: (name: string, value?: string) => void;
|
|
22
|
+
get: (name: string) => string | null;
|
|
23
|
+
getAll: (name: string) => string[];
|
|
24
|
+
has: (name: string, value?: string) => boolean;
|
|
25
|
+
set: (name: string, value: string) => void;
|
|
26
|
+
sort: () => void;
|
|
27
|
+
toString: () => string;
|
|
28
|
+
forEach: (callbackfn: (value: string, key: string, parent: URLSearchParams) => void, thisArg?: any) => void;
|
|
29
|
+
entries: () => URLSearchParamsIterator<[string, string]>;
|
|
30
|
+
keys: () => URLSearchParamsIterator<string>;
|
|
31
|
+
values: () => URLSearchParamsIterator<string>;
|
|
32
|
+
[Symbol.iterator]: () => URLSearchParamsIterator<[string, string]>;
|
|
33
|
+
};
|
|
34
|
+
username: string;
|
|
35
|
+
toJSON: () => string;
|
|
36
|
+
};
|
|
37
|
+
}, RequestPublic | {
|
|
38
|
+
cookies: import("@rcompat/type").Dict<string>;
|
|
39
|
+
headers: import("@rcompat/type").Dict<string>;
|
|
40
|
+
query: import("@rcompat/type").Dict<string>;
|
|
41
|
+
url: {
|
|
42
|
+
hash: string;
|
|
43
|
+
host: string;
|
|
44
|
+
hostname: string;
|
|
45
|
+
href: string;
|
|
46
|
+
toString: () => string;
|
|
47
|
+
readonly origin: string;
|
|
48
|
+
password: string;
|
|
49
|
+
pathname: string;
|
|
50
|
+
port: string;
|
|
51
|
+
protocol: string;
|
|
52
|
+
search: string;
|
|
53
|
+
readonly searchParams: {
|
|
54
|
+
readonly size: number;
|
|
55
|
+
append: (name: string, value: string) => void;
|
|
56
|
+
delete: (name: string, value?: string) => void;
|
|
57
|
+
get: (name: string) => string | null;
|
|
58
|
+
getAll: (name: string) => string[];
|
|
59
|
+
has: (name: string, value?: string) => boolean;
|
|
60
|
+
set: (name: string, value: string) => void;
|
|
61
|
+
sort: () => void;
|
|
62
|
+
toString: () => string;
|
|
63
|
+
forEach: (callbackfn: (value: string, key: string, parent: URLSearchParams) => void, thisArg?: any) => void;
|
|
64
|
+
entries: () => URLSearchParamsIterator<[string, string]>;
|
|
65
|
+
keys: () => URLSearchParamsIterator<string>;
|
|
66
|
+
values: () => URLSearchParamsIterator<string>;
|
|
67
|
+
[Symbol.iterator]: () => URLSearchParamsIterator<[string, string]>;
|
|
68
|
+
};
|
|
69
|
+
username: string;
|
|
70
|
+
toJSON: () => string;
|
|
71
|
+
};
|
|
72
|
+
}>;
|
|
73
|
+
export default store;
|
|
74
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export declare function useRequest(): import("vue").Ref<{
|
|
2
|
+
cookies: import("@rcompat/type").Dict<string>;
|
|
3
|
+
headers: import("@rcompat/type").Dict<string>;
|
|
4
|
+
query: import("@rcompat/type").Dict<string>;
|
|
5
|
+
url: {
|
|
6
|
+
hash: string;
|
|
7
|
+
host: string;
|
|
8
|
+
hostname: string;
|
|
9
|
+
href: string;
|
|
10
|
+
toString: () => string;
|
|
11
|
+
readonly origin: string;
|
|
12
|
+
password: string;
|
|
13
|
+
pathname: string;
|
|
14
|
+
port: string;
|
|
15
|
+
protocol: string;
|
|
16
|
+
search: string;
|
|
17
|
+
readonly searchParams: {
|
|
18
|
+
readonly size: number;
|
|
19
|
+
append: (name: string, value: string) => void;
|
|
20
|
+
delete: (name: string, value?: string) => void;
|
|
21
|
+
get: (name: string) => string | null;
|
|
22
|
+
getAll: (name: string) => string[];
|
|
23
|
+
has: (name: string, value?: string) => boolean;
|
|
24
|
+
set: (name: string, value: string) => void;
|
|
25
|
+
sort: () => void;
|
|
26
|
+
toString: () => string;
|
|
27
|
+
forEach: (callbackfn: (value: string, key: string, parent: URLSearchParams) => void, thisArg?: any) => void;
|
|
28
|
+
entries: () => URLSearchParamsIterator<[string, string]>;
|
|
29
|
+
keys: () => URLSearchParamsIterator<string>;
|
|
30
|
+
values: () => URLSearchParamsIterator<string>;
|
|
31
|
+
[Symbol.iterator]: () => URLSearchParamsIterator<[string, string]>;
|
|
32
|
+
};
|
|
33
|
+
username: string;
|
|
34
|
+
toJSON: () => string;
|
|
35
|
+
};
|
|
36
|
+
}, import("@primate/core/index").RequestPublic | {
|
|
37
|
+
cookies: import("@rcompat/type").Dict<string>;
|
|
38
|
+
headers: import("@rcompat/type").Dict<string>;
|
|
39
|
+
query: import("@rcompat/type").Dict<string>;
|
|
40
|
+
url: {
|
|
41
|
+
hash: string;
|
|
42
|
+
host: string;
|
|
43
|
+
hostname: string;
|
|
44
|
+
href: string;
|
|
45
|
+
toString: () => string;
|
|
46
|
+
readonly origin: string;
|
|
47
|
+
password: string;
|
|
48
|
+
pathname: string;
|
|
49
|
+
port: string;
|
|
50
|
+
protocol: string;
|
|
51
|
+
search: string;
|
|
52
|
+
readonly searchParams: {
|
|
53
|
+
readonly size: number;
|
|
54
|
+
append: (name: string, value: string) => void;
|
|
55
|
+
delete: (name: string, value?: string) => void;
|
|
56
|
+
get: (name: string) => string | null;
|
|
57
|
+
getAll: (name: string) => string[];
|
|
58
|
+
has: (name: string, value?: string) => boolean;
|
|
59
|
+
set: (name: string, value: string) => void;
|
|
60
|
+
sort: () => void;
|
|
61
|
+
toString: () => string;
|
|
62
|
+
forEach: (callbackfn: (value: string, key: string, parent: URLSearchParams) => void, thisArg?: any) => void;
|
|
63
|
+
entries: () => URLSearchParamsIterator<[string, string]>;
|
|
64
|
+
keys: () => URLSearchParamsIterator<string>;
|
|
65
|
+
values: () => URLSearchParamsIterator<string>;
|
|
66
|
+
[Symbol.iterator]: () => URLSearchParamsIterator<[string, string]>;
|
|
67
|
+
};
|
|
68
|
+
username: string;
|
|
69
|
+
toJSON: () => string;
|
|
70
|
+
};
|
|
71
|
+
}>;
|
|
72
|
+
export declare const setRequest: (value: any) => void;
|
|
73
|
+
//# sourceMappingURL=app.d.ts.map
|
package/lib/public/client.d.ts
CHANGED
|
@@ -1,48 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
declare const client: {
|
|
3
|
-
form: typeof form;
|
|
4
|
-
field: <T>(initial: T) => {
|
|
5
|
-
delete: (url: string, options?: {
|
|
6
|
-
headers?: import("@rcompat/type").Dict<string>;
|
|
7
|
-
map?: ((v: T) => import("@rcompat/type").JSONValue) | undefined;
|
|
8
|
-
path?: import("@rcompat/type").JSONPointer;
|
|
9
|
-
} | undefined) => {
|
|
10
|
-
error: import("vue").Ref<null | import("@primate/core/client").ValidationError>;
|
|
11
|
-
loading: import("vue").Ref<boolean>;
|
|
12
|
-
update: (updater: import("@primate/core/client").ValidateUpdater<T>) => Promise<void>;
|
|
13
|
-
value: import("vue").Ref<T, T>;
|
|
14
|
-
};
|
|
15
|
-
patch: (url: string, options?: {
|
|
16
|
-
headers?: import("@rcompat/type").Dict<string>;
|
|
17
|
-
map?: ((v: T) => import("@rcompat/type").JSONValue) | undefined;
|
|
18
|
-
path?: import("@rcompat/type").JSONPointer;
|
|
19
|
-
} | undefined) => {
|
|
20
|
-
error: import("vue").Ref<null | import("@primate/core/client").ValidationError>;
|
|
21
|
-
loading: import("vue").Ref<boolean>;
|
|
22
|
-
update: (updater: import("@primate/core/client").ValidateUpdater<T>) => Promise<void>;
|
|
23
|
-
value: import("vue").Ref<T, T>;
|
|
24
|
-
};
|
|
25
|
-
post: (url: string, options?: {
|
|
26
|
-
headers?: import("@rcompat/type").Dict<string>;
|
|
27
|
-
map?: ((v: T) => import("@rcompat/type").JSONValue) | undefined;
|
|
28
|
-
path?: import("@rcompat/type").JSONPointer;
|
|
29
|
-
} | undefined) => {
|
|
30
|
-
error: import("vue").Ref<null | import("@primate/core/client").ValidationError>;
|
|
31
|
-
loading: import("vue").Ref<boolean>;
|
|
32
|
-
update: (updater: import("@primate/core/client").ValidateUpdater<T>) => Promise<void>;
|
|
33
|
-
value: import("vue").Ref<T, T>;
|
|
34
|
-
};
|
|
35
|
-
put: (url: string, options?: {
|
|
36
|
-
headers?: import("@rcompat/type").Dict<string>;
|
|
37
|
-
map?: ((v: T) => import("@rcompat/type").JSONValue) | undefined;
|
|
38
|
-
path?: import("@rcompat/type").JSONPointer;
|
|
39
|
-
} | undefined) => {
|
|
40
|
-
error: import("vue").Ref<null | import("@primate/core/client").ValidationError>;
|
|
41
|
-
loading: import("vue").Ref<boolean>;
|
|
42
|
-
update: (updater: import("@primate/core/client").ValidateUpdater<T>) => Promise<void>;
|
|
43
|
-
value: import("vue").Ref<T, T>;
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
export default client;
|
|
1
|
+
export { default } from "#client/index";
|
|
48
2
|
//# sourceMappingURL=client.d.ts.map
|
package/lib/public/client.js
CHANGED
package/lib/public/default.d.ts
CHANGED
package/lib/public/default.js
CHANGED
package/lib/public/runtime.d.ts
CHANGED
package/lib/public/runtime.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primate/vue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.1",
|
|
4
4
|
"description": "Vue for Primate",
|
|
5
5
|
"homepage": "https://primate.run/docs/frontend/vue",
|
|
6
6
|
"bugs": "https://github.com/primate-run/primate/issues",
|
|
@@ -16,36 +16,41 @@
|
|
|
16
16
|
"/lib/**/*.d.ts",
|
|
17
17
|
"!/**/*.spec.*"
|
|
18
18
|
],
|
|
19
|
+
"types": "lib/index.d.ts",
|
|
19
20
|
"dependencies": {
|
|
20
|
-
"@primate/core": "^0.
|
|
21
|
+
"@primate/core": "^0.6.0"
|
|
21
22
|
},
|
|
22
23
|
"devDependencies": {
|
|
23
|
-
"@rcompat/type": "^0.
|
|
24
|
+
"@rcompat/type": "^0.11.1",
|
|
25
|
+
"@primate/test": "^0.0.0"
|
|
24
26
|
},
|
|
25
27
|
"peerDependencies": {
|
|
26
28
|
"vue": "3",
|
|
27
|
-
"primate": "^0.
|
|
29
|
+
"primate": "^0.37.0"
|
|
28
30
|
},
|
|
29
31
|
"imports": {
|
|
30
32
|
"#*": {
|
|
31
|
-
"
|
|
33
|
+
"@primate/source": "./src/private/*.ts",
|
|
32
34
|
"default": "./lib/private/*.js"
|
|
33
35
|
}
|
|
34
36
|
},
|
|
35
37
|
"exports": {
|
|
36
38
|
".": {
|
|
39
|
+
"types": "./lib/index.d.ts",
|
|
40
|
+
"@primate/source": "./src/public/default.ts",
|
|
37
41
|
"browser": "./lib/public/browser.js",
|
|
38
42
|
"runtime": "./lib/public/runtime.js",
|
|
39
43
|
"default": "./lib/public/default.js"
|
|
40
44
|
},
|
|
41
45
|
"./*": {
|
|
42
|
-
"
|
|
46
|
+
"@primate/source": "./src/public/*.ts",
|
|
43
47
|
"default": "./lib/public/*.js"
|
|
44
48
|
}
|
|
45
49
|
},
|
|
46
50
|
"scripts": {
|
|
47
|
-
"build": "npm run clean && tsc",
|
|
51
|
+
"build": "npm run clean && tsc && cp src/types/{app,index}.d.ts lib",
|
|
48
52
|
"clean": "rm -rf ./lib",
|
|
49
|
-
"lint": "eslint ."
|
|
53
|
+
"lint": "eslint .",
|
|
54
|
+
"test": "npx proby"
|
|
50
55
|
}
|
|
51
56
|
}
|
package/lib/private/Default.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import Runtime from "#Runtime";
|
|
2
|
-
import type BuildApp from "@primate/core/BuildApp";
|
|
3
|
-
import type NextBuild from "@primate/core/NextBuild";
|
|
4
|
-
export default class Default extends Runtime {
|
|
5
|
-
compile: {
|
|
6
|
-
client: (text: string, _: unknown, root: boolean) => {
|
|
7
|
-
js: string;
|
|
8
|
-
};
|
|
9
|
-
server: (text: string) => string;
|
|
10
|
-
};
|
|
11
|
-
root: {
|
|
12
|
-
create: (depth: number, i18n_active: boolean) => string;
|
|
13
|
-
};
|
|
14
|
-
build(app: BuildApp, next: NextBuild): Promise<BuildApp>;
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=Default.d.ts.map
|
package/lib/private/Default.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import compile from "#compile";
|
|
2
|
-
import create_root from "#create-root";
|
|
3
|
-
import Runtime from "#Runtime";
|
|
4
|
-
export default class Default extends Runtime {
|
|
5
|
-
compile = {
|
|
6
|
-
client: (text, _, root) => ({ js: root ? text : compile.server(text) }),
|
|
7
|
-
server: (text) => compile.server(text),
|
|
8
|
-
};
|
|
9
|
-
root = {
|
|
10
|
-
create: create_root,
|
|
11
|
-
};
|
|
12
|
-
async build(app, next) {
|
|
13
|
-
this.prebuild(app);
|
|
14
|
-
const source = this.root.create(app.depth(), app.i18n_active);
|
|
15
|
-
app.addRoot(this.rootname, source);
|
|
16
|
-
this.publish(app);
|
|
17
|
-
return next(app);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=Default.js.map
|
package/lib/private/Runtime.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import FrontendModule from "@primate/core/frontend/Module";
|
|
2
|
-
import type Render from "@primate/core/frontend/Render";
|
|
3
|
-
import { type Renderer } from "vue";
|
|
4
|
-
export default class Runtime extends FrontendModule<Renderer> {
|
|
5
|
-
name: string;
|
|
6
|
-
defaultExtensions: string[];
|
|
7
|
-
layouts: boolean;
|
|
8
|
-
client: boolean;
|
|
9
|
-
render: Render<Renderer>;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=Runtime.d.ts.map
|
package/lib/private/Runtime.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import FrontendModule from "@primate/core/frontend/Module";
|
|
2
|
-
import { createSSRApp } from "vue";
|
|
3
|
-
import { renderToString } from "vue/server-renderer";
|
|
4
|
-
export default class Runtime extends FrontendModule {
|
|
5
|
-
name = "vue";
|
|
6
|
-
defaultExtensions = [".vue"];
|
|
7
|
-
layouts = true;
|
|
8
|
-
client = true;
|
|
9
|
-
render = async (view, props) => {
|
|
10
|
-
const app = createSSRApp(view, { p: { ...props } });
|
|
11
|
-
const html = await renderToString(app);
|
|
12
|
-
return { body: `<div id="app">${html}</div>` };
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
;
|
|
16
|
-
//# sourceMappingURL=Runtime.js.map
|