dtwo 2.17.0 → 3.0.0-rc.14
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/LICENSE +1 -1
- package/README.md +2 -41
- package/app.d.ts +1 -0
- package/bin/dtwo.mjs +2 -0
- package/config.cjs +7 -0
- package/config.d.ts +4 -0
- package/config.mjs +5 -0
- package/dist/app/compat/capi.d.ts +4 -0
- package/dist/app/compat/capi.mjs +19 -0
- package/dist/app/compat/kdu-demi.d.ts +4 -0
- package/dist/app/compat/kdu-demi.mjs +4 -0
- package/dist/app/components/client-only.d.mts +22 -0
- package/dist/app/components/client-only.mjs +75 -0
- package/dist/app/components/dev-only.d.mts +4 -0
- package/dist/app/components/dev-only.mjs +11 -0
- package/dist/app/components/dtwo-error-boundary.d.ts +8 -0
- package/dist/app/components/dtwo-error-boundary.mjs +21 -0
- package/dist/app/components/dtwo-error-page.kdu +46 -0
- package/dist/app/components/dtwo-link.d.ts +33 -0
- package/dist/app/components/dtwo-link.mjs +248 -0
- package/dist/app/components/dtwo-loading-indicator.d.ts +43 -0
- package/dist/app/components/dtwo-loading-indicator.mjs +107 -0
- package/dist/app/components/dtwo-root.kdu +35 -0
- package/dist/app/components/index.d.ts +2 -0
- package/dist/app/components/index.mjs +1 -0
- package/dist/app/components/layout.d.ts +17 -0
- package/dist/app/components/layout.mjs +66 -0
- package/dist/app/components/server-placeholder.d.ts +2 -0
- package/dist/app/components/server-placeholder.mjs +7 -0
- package/dist/app/components/utils.d.ts +11 -0
- package/dist/app/components/utils.mjs +9 -0
- package/dist/app/composables/asyncData.d.ts +40 -0
- package/dist/app/composables/asyncData.mjs +169 -0
- package/dist/app/composables/component.d.ts +3 -0
- package/dist/app/composables/component.mjs +46 -0
- package/dist/app/composables/cookie.d.ts +12 -0
- package/dist/app/composables/cookie.mjs +58 -0
- package/dist/app/composables/error.d.ts +17 -0
- package/dist/app/composables/error.mjs +31 -0
- package/dist/app/composables/fetch.d.ts +15 -0
- package/dist/app/composables/fetch.mjs +66 -0
- package/dist/app/composables/hydrate.d.ts +8 -0
- package/dist/app/composables/hydrate.mjs +14 -0
- package/dist/app/composables/index.d.ts +16 -0
- package/dist/app/composables/index.mjs +11 -0
- package/dist/app/composables/payload.d.ts +8 -0
- package/dist/app/composables/payload.mjs +58 -0
- package/dist/app/composables/preload.d.ts +17 -0
- package/dist/app/composables/preload.mjs +41 -0
- package/dist/app/composables/router.d.ts +28 -0
- package/dist/app/composables/router.mjs +111 -0
- package/dist/app/composables/ssr.d.ts +6 -0
- package/dist/app/composables/ssr.mjs +23 -0
- package/dist/app/composables/state.d.ts +9 -0
- package/dist/app/composables/state.mjs +27 -0
- package/dist/app/config.d.ts +13 -0
- package/dist/app/config.mjs +56 -0
- package/dist/app/dtwo.d.ts +122 -0
- package/dist/app/dtwo.mjs +168 -0
- package/dist/app/entry.async.d.ts +2 -0
- package/dist/app/entry.async.mjs +5 -0
- package/dist/app/entry.d.ts +3 -0
- package/dist/app/entry.mjs +59 -0
- package/dist/app/index.d.ts +10 -0
- package/dist/app/index.mjs +7 -0
- package/dist/app/plugins/cross-origin-prefetch.client.d.ts +2 -0
- package/dist/app/plugins/cross-origin-prefetch.client.mjs +28 -0
- package/dist/app/plugins/debug.d.ts +2 -0
- package/dist/app/plugins/debug.mjs +5 -0
- package/dist/app/plugins/payload.client.d.ts +2 -0
- package/dist/app/plugins/payload.client.mjs +22 -0
- package/dist/app/plugins/preload.server.d.ts +2 -0
- package/dist/app/plugins/preload.server.mjs +10 -0
- package/dist/app/plugins/router.d.ts +53 -0
- package/dist/app/plugins/router.mjs +176 -0
- package/dist/app/types/augments.d.ts +28 -0
- package/dist/core/runtime/hole/error.d.ts +3 -0
- package/dist/core/runtime/hole/error.mjs +58 -0
- package/dist/core/runtime/hole/paths.d.ts +4 -0
- package/dist/core/runtime/hole/paths.mjs +15 -0
- package/dist/core/runtime/hole/renderer.d.ts +16 -0
- package/dist/core/runtime/hole/renderer.mjs +219 -0
- package/dist/head/runtime/components.d.ts +796 -0
- package/dist/head/runtime/components.mjs +209 -0
- package/dist/head/runtime/composables.d.ts +10 -0
- package/dist/head/runtime/composables.mjs +4 -0
- package/dist/head/runtime/index.d.ts +4 -0
- package/dist/head/runtime/index.mjs +1 -0
- package/dist/head/runtime/lib/kdu-meta.plugin.d.ts +2 -0
- package/dist/head/runtime/lib/kdu-meta.plugin.mjs +31 -0
- package/dist/head/runtime/lib/kduse-head.plugin.d.ts +2 -0
- package/dist/head/runtime/lib/kduse-head.plugin.mjs +35 -0
- package/dist/head/runtime/types.d.ts +7 -0
- package/dist/head/runtime/types.mjs +0 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.mjs +2274 -0
- package/dist/pages/runtime/app.kdu +5 -0
- package/dist/pages/runtime/composables.d.ts +42 -0
- package/dist/pages/runtime/composables.mjs +8 -0
- package/dist/pages/runtime/index.d.ts +1 -0
- package/dist/pages/runtime/index.mjs +1 -0
- package/dist/pages/runtime/page-placeholder.d.ts +4 -0
- package/dist/pages/runtime/page-placeholder.mjs +10 -0
- package/dist/pages/runtime/page.d.ts +15 -0
- package/dist/pages/runtime/page.mjs +107 -0
- package/dist/pages/runtime/router.d.ts +8 -0
- package/dist/pages/runtime/router.mjs +152 -0
- package/dist/pages/runtime/router.options.d.ts +2 -0
- package/dist/pages/runtime/router.options.mjs +51 -0
- package/dist/pages/runtime/utils.d.ts +9 -0
- package/dist/pages/runtime/utils.mjs +12 -0
- package/dist/pages/runtime/validate.d.ts +2 -0
- package/dist/pages/runtime/validate.mjs +11 -0
- package/package.json +79 -42
- package/types.d.ts +15 -0
- package/bin/dtwo.js +0 -10
- package/dist/dtwo.js +0 -37
- package/webpack.config.js +0 -4
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { defineComponent } from "kdu";
|
|
2
|
+
import { useHead } from "./composables.mjs";
|
|
3
|
+
const removeUndefinedProps = (props) => Object.fromEntries(Object.entries(props).filter(([, value]) => value !== void 0));
|
|
4
|
+
const setupForUseMeta = (metaFactory, renderChild) => (props, ctx) => {
|
|
5
|
+
useHead(() => metaFactory({ ...removeUndefinedProps(props), ...ctx.attrs }, ctx));
|
|
6
|
+
return () => renderChild ? ctx.slots.default?.() : null;
|
|
7
|
+
};
|
|
8
|
+
const globalProps = {
|
|
9
|
+
accesskey: String,
|
|
10
|
+
autocapitalize: String,
|
|
11
|
+
autofocus: {
|
|
12
|
+
type: Boolean,
|
|
13
|
+
default: void 0
|
|
14
|
+
},
|
|
15
|
+
class: String,
|
|
16
|
+
contenteditable: {
|
|
17
|
+
type: Boolean,
|
|
18
|
+
default: void 0
|
|
19
|
+
},
|
|
20
|
+
contextmenu: String,
|
|
21
|
+
dir: String,
|
|
22
|
+
draggable: {
|
|
23
|
+
type: Boolean,
|
|
24
|
+
default: void 0
|
|
25
|
+
},
|
|
26
|
+
enterkeyhint: String,
|
|
27
|
+
exportparts: String,
|
|
28
|
+
hidden: {
|
|
29
|
+
type: Boolean,
|
|
30
|
+
default: void 0
|
|
31
|
+
},
|
|
32
|
+
id: String,
|
|
33
|
+
inputmode: String,
|
|
34
|
+
is: String,
|
|
35
|
+
itemid: String,
|
|
36
|
+
itemprop: String,
|
|
37
|
+
itemref: String,
|
|
38
|
+
itemscope: String,
|
|
39
|
+
itemtype: String,
|
|
40
|
+
lang: String,
|
|
41
|
+
nonce: String,
|
|
42
|
+
part: String,
|
|
43
|
+
slot: String,
|
|
44
|
+
spellcheck: {
|
|
45
|
+
type: Boolean,
|
|
46
|
+
default: void 0
|
|
47
|
+
},
|
|
48
|
+
style: String,
|
|
49
|
+
tabindex: String,
|
|
50
|
+
title: String,
|
|
51
|
+
translate: String
|
|
52
|
+
};
|
|
53
|
+
export const NoScript = defineComponent({
|
|
54
|
+
name: "NoScript",
|
|
55
|
+
inheritAttrs: false,
|
|
56
|
+
props: {
|
|
57
|
+
...globalProps,
|
|
58
|
+
title: String,
|
|
59
|
+
body: Boolean,
|
|
60
|
+
renderPriority: [String, Number]
|
|
61
|
+
},
|
|
62
|
+
setup: setupForUseMeta((props, { slots }) => {
|
|
63
|
+
const noscript = { ...props };
|
|
64
|
+
const textContent = (slots.default?.() || []).filter(({ children }) => children).map(({ children }) => children).join("");
|
|
65
|
+
if (textContent) {
|
|
66
|
+
noscript.children = textContent;
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
noscript: [noscript]
|
|
70
|
+
};
|
|
71
|
+
})
|
|
72
|
+
});
|
|
73
|
+
export const Link = defineComponent({
|
|
74
|
+
name: "Link",
|
|
75
|
+
inheritAttrs: false,
|
|
76
|
+
props: {
|
|
77
|
+
...globalProps,
|
|
78
|
+
as: String,
|
|
79
|
+
crossorigin: String,
|
|
80
|
+
disabled: Boolean,
|
|
81
|
+
fetchpriority: String,
|
|
82
|
+
href: String,
|
|
83
|
+
hreflang: String,
|
|
84
|
+
imagesizes: String,
|
|
85
|
+
imagesrcset: String,
|
|
86
|
+
integrity: String,
|
|
87
|
+
media: String,
|
|
88
|
+
prefetch: {
|
|
89
|
+
type: Boolean,
|
|
90
|
+
default: void 0
|
|
91
|
+
},
|
|
92
|
+
referrerpolicy: String,
|
|
93
|
+
rel: String,
|
|
94
|
+
sizes: String,
|
|
95
|
+
title: String,
|
|
96
|
+
type: String,
|
|
97
|
+
methods: String,
|
|
98
|
+
target: String,
|
|
99
|
+
body: Boolean,
|
|
100
|
+
renderPriority: [String, Number]
|
|
101
|
+
},
|
|
102
|
+
setup: setupForUseMeta((link) => ({
|
|
103
|
+
link: [link]
|
|
104
|
+
}))
|
|
105
|
+
});
|
|
106
|
+
export const Base = defineComponent({
|
|
107
|
+
name: "Base",
|
|
108
|
+
inheritAttrs: false,
|
|
109
|
+
props: {
|
|
110
|
+
...globalProps,
|
|
111
|
+
href: String,
|
|
112
|
+
target: String
|
|
113
|
+
},
|
|
114
|
+
setup: setupForUseMeta((base) => ({
|
|
115
|
+
base
|
|
116
|
+
}))
|
|
117
|
+
});
|
|
118
|
+
export const Title = defineComponent({
|
|
119
|
+
name: "Title",
|
|
120
|
+
inheritAttrs: false,
|
|
121
|
+
setup: setupForUseMeta((_, { slots }) => {
|
|
122
|
+
const title = slots.default?.()?.[0]?.children || null;
|
|
123
|
+
if (process.dev && title && typeof title !== "string") {
|
|
124
|
+
console.error("<Title> can only take a string in its default slot.");
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
title
|
|
128
|
+
};
|
|
129
|
+
})
|
|
130
|
+
});
|
|
131
|
+
export const Meta = defineComponent({
|
|
132
|
+
name: "Meta",
|
|
133
|
+
inheritAttrs: false,
|
|
134
|
+
props: {
|
|
135
|
+
...globalProps,
|
|
136
|
+
charset: String,
|
|
137
|
+
content: String,
|
|
138
|
+
httpEquiv: String,
|
|
139
|
+
name: String,
|
|
140
|
+
body: Boolean,
|
|
141
|
+
renderPriority: [String, Number]
|
|
142
|
+
},
|
|
143
|
+
setup: setupForUseMeta((props) => {
|
|
144
|
+
const meta = { ...props };
|
|
145
|
+
if (meta.httpEquiv) {
|
|
146
|
+
meta["http-equiv"] = meta.httpEquiv;
|
|
147
|
+
delete meta.httpEquiv;
|
|
148
|
+
}
|
|
149
|
+
return {
|
|
150
|
+
meta: [meta]
|
|
151
|
+
};
|
|
152
|
+
})
|
|
153
|
+
});
|
|
154
|
+
export const Style = defineComponent({
|
|
155
|
+
name: "Style",
|
|
156
|
+
inheritAttrs: false,
|
|
157
|
+
props: {
|
|
158
|
+
...globalProps,
|
|
159
|
+
type: String,
|
|
160
|
+
media: String,
|
|
161
|
+
nonce: String,
|
|
162
|
+
title: String,
|
|
163
|
+
scoped: {
|
|
164
|
+
type: Boolean,
|
|
165
|
+
default: void 0
|
|
166
|
+
},
|
|
167
|
+
body: Boolean,
|
|
168
|
+
renderPriority: [String, Number]
|
|
169
|
+
},
|
|
170
|
+
setup: setupForUseMeta((props, { slots }) => {
|
|
171
|
+
const style = { ...props };
|
|
172
|
+
const textContent = slots.default?.()?.[0]?.children;
|
|
173
|
+
if (textContent) {
|
|
174
|
+
if (process.dev && typeof textContent !== "string") {
|
|
175
|
+
console.error("<Style> can only take a string in its default slot.");
|
|
176
|
+
}
|
|
177
|
+
style.children = textContent;
|
|
178
|
+
}
|
|
179
|
+
return {
|
|
180
|
+
style: [style]
|
|
181
|
+
};
|
|
182
|
+
})
|
|
183
|
+
});
|
|
184
|
+
export const Head = defineComponent({
|
|
185
|
+
name: "Head",
|
|
186
|
+
inheritAttrs: false,
|
|
187
|
+
setup: (_props, ctx) => () => ctx.slots.default?.()
|
|
188
|
+
});
|
|
189
|
+
export const Html = defineComponent({
|
|
190
|
+
name: "Html",
|
|
191
|
+
inheritAttrs: false,
|
|
192
|
+
props: {
|
|
193
|
+
...globalProps,
|
|
194
|
+
manifest: String,
|
|
195
|
+
version: String,
|
|
196
|
+
xmlns: String,
|
|
197
|
+
renderPriority: [String, Number]
|
|
198
|
+
},
|
|
199
|
+
setup: setupForUseMeta((htmlAttrs) => ({ htmlAttrs }), true)
|
|
200
|
+
});
|
|
201
|
+
export const Body = defineComponent({
|
|
202
|
+
name: "Body",
|
|
203
|
+
inheritAttrs: false,
|
|
204
|
+
props: {
|
|
205
|
+
...globalProps,
|
|
206
|
+
renderPriority: [String, Number]
|
|
207
|
+
},
|
|
208
|
+
setup: setupForUseMeta((bodyAttrs) => ({ bodyAttrs }), true)
|
|
209
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HeadEntryOptions, UseHeadInput, ActiveHeadEntry } from '@kduse/head';
|
|
2
|
+
import type { HeadAugmentations } from '@dtwo/schema';
|
|
3
|
+
/**
|
|
4
|
+
* You can pass in a meta object, which has keys corresponding to meta tags:
|
|
5
|
+
* `title`, `base`, `script`, `style`, `meta` and `link`, as well as `htmlAttrs` and `bodyAttrs`.
|
|
6
|
+
*
|
|
7
|
+
* Alternatively, for reactive meta state, you can pass in a function
|
|
8
|
+
* that returns a meta object.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useHead<T extends HeadAugmentations>(input: UseHeadInput<T>, options?: HeadEntryOptions): ActiveHeadEntry<UseHeadInput<T>> | void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./composables.mjs";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createApp } from "kdu";
|
|
2
|
+
import { createMetaManager } from "kdu-meta";
|
|
3
|
+
import { defineDtwoPlugin } from "#app";
|
|
4
|
+
import { appHead } from "#build/dtwo.config.mjs";
|
|
5
|
+
export default defineDtwoPlugin((dtwoApp) => {
|
|
6
|
+
const manager = createMetaManager(process.server);
|
|
7
|
+
manager.addMeta(appHead);
|
|
8
|
+
dtwoApp.kduApp.use(manager);
|
|
9
|
+
dtwoApp._useHead = (meta) => manager.addMeta(meta);
|
|
10
|
+
if (process.client) {
|
|
11
|
+
const teleportTarget = document.createElement("div");
|
|
12
|
+
teleportTarget.id = "head-target";
|
|
13
|
+
document.body.appendChild(teleportTarget);
|
|
14
|
+
createApp({ render: () => manager.render({}) }).mount("#head-target");
|
|
15
|
+
}
|
|
16
|
+
if (process.server) {
|
|
17
|
+
dtwoApp.ssrContext.renderMeta = async () => {
|
|
18
|
+
const { renderMetaToString } = await import("kdu-meta/ssr");
|
|
19
|
+
dtwoApp.ssrContext.teleports = dtwoApp.ssrContext.teleports || {};
|
|
20
|
+
await renderMetaToString(dtwoApp.app, dtwoApp.ssrContext);
|
|
21
|
+
return {
|
|
22
|
+
htmlAttrs: dtwoApp.ssrContext.teleports.htmlAttrs || "",
|
|
23
|
+
headAttrs: dtwoApp.ssrContext.teleports.headAttrs || "",
|
|
24
|
+
bodyAttrs: dtwoApp.ssrContext.teleports.bodyAttrs || "",
|
|
25
|
+
headTags: dtwoApp.ssrContext.teleports.head || "",
|
|
26
|
+
bodyScriptsPrepend: dtwoApp.ssrContext.teleports["body-prepend"] || "",
|
|
27
|
+
bodyScripts: dtwoApp.ssrContext.teleports.body || ""
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createHead, useHead } from "@kduse/head";
|
|
2
|
+
import { defineDtwoPlugin } from "#app";
|
|
3
|
+
import { appHead } from "#build/dtwo.config.mjs";
|
|
4
|
+
export default defineDtwoPlugin((dtwoApp) => {
|
|
5
|
+
const head = createHead();
|
|
6
|
+
head.push(appHead);
|
|
7
|
+
dtwoApp.kduApp.use(head);
|
|
8
|
+
if (process.client) {
|
|
9
|
+
let pauseDOMUpdates = true;
|
|
10
|
+
const unpauseDom = () => {
|
|
11
|
+
pauseDOMUpdates = false;
|
|
12
|
+
head.internalHooks.callHook("entries:updated", head.kdhead);
|
|
13
|
+
};
|
|
14
|
+
head.internalHooks.hook("dom:beforeRender", (context) => {
|
|
15
|
+
context.shouldRender = !pauseDOMUpdates;
|
|
16
|
+
});
|
|
17
|
+
dtwoApp.hooks.hook("page:start", () => {
|
|
18
|
+
pauseDOMUpdates = true;
|
|
19
|
+
});
|
|
20
|
+
dtwoApp.hooks.hook("page:finish", unpauseDom);
|
|
21
|
+
dtwoApp.hooks.hook("app:mounted", unpauseDom);
|
|
22
|
+
}
|
|
23
|
+
dtwoApp._useHead = useHead;
|
|
24
|
+
if (process.server) {
|
|
25
|
+
dtwoApp.ssrContext.renderMeta = async () => {
|
|
26
|
+
const { renderSSRHead } = await import("@kdhead/ssr");
|
|
27
|
+
const meta = await renderSSRHead(head.kdhead);
|
|
28
|
+
return {
|
|
29
|
+
...meta,
|
|
30
|
+
bodyScriptsPrepend: meta.bodyTagsOpen,
|
|
31
|
+
bodyScripts: meta.bodyTags
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type Props = Readonly<Record<string, any>>;
|
|
2
|
+
export type FetchPriority = 'high' | 'low' | 'auto';
|
|
3
|
+
export type CrossOrigin = '' | 'anonymous' | 'use-credentials';
|
|
4
|
+
export type HTTPEquiv = 'content-security-policy' | 'content-type' | 'default-style' | 'refresh' | 'x-ua-compatible';
|
|
5
|
+
export type ReferrerPolicy = '' | 'no-referrer' | 'no-referrer-when-downgrade' | 'same-origin' | 'origin' | 'strict-origin' | 'origin-when-cross-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url';
|
|
6
|
+
export type LinkRelationship = 'alternate' | 'author' | 'canonical' | 'dns-prefetch' | 'help' | 'icon' | 'license' | 'manifest' | 'me' | 'modulepreload' | 'next' | 'pingback' | 'preconnect' | 'prefetch' | 'preload' | 'prerender' | 'prev' | 'search' | 'stylesheet' | (string & {});
|
|
7
|
+
export type Target = '_blank' | '_self' | '_parent' | '_top' | (string & {});
|
|
File without changes
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DtwoOptions, Dtwo } from '@dtwo/schema';
|
|
2
|
+
import { LoadDtwoOptions } from '@dtwo/kit';
|
|
3
|
+
|
|
4
|
+
declare function createDtwo(options: DtwoOptions): Dtwo;
|
|
5
|
+
declare function loadDtwo(opts: LoadDtwoOptions): Promise<Dtwo>;
|
|
6
|
+
|
|
7
|
+
declare function build(dtwo: Dtwo): Promise<void>;
|
|
8
|
+
|
|
9
|
+
export { build, createDtwo, loadDtwo };
|