dtwo 3.1.2 → 3.2.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.
Files changed (64) hide show
  1. package/LICENSE +21 -21
  2. package/app.d.ts +1 -1
  3. package/bin/dtwo.mjs +2 -2
  4. package/config.cjs +7 -7
  5. package/config.d.ts +2 -2
  6. package/config.mjs +5 -5
  7. package/dist/app/components/client-only.mjs +75 -75
  8. package/dist/app/components/dev-only.mjs +11 -11
  9. package/dist/app/components/dtwo-error-boundary.mjs +1 -1
  10. package/dist/app/components/dtwo-error-page.kdu +46 -46
  11. package/dist/app/components/dtwo-island.mjs +3 -1
  12. package/dist/app/components/dtwo-loading-indicator.mjs +5 -3
  13. package/dist/app/components/dtwo-root.kdu +5 -3
  14. package/dist/app/components/island-renderer.mjs +1 -1
  15. package/dist/app/components/layout.mjs +1 -1
  16. package/dist/app/composables/component.mjs +1 -1
  17. package/dist/app/composables/error.d.ts +1 -1
  18. package/dist/app/composables/fetch.d.ts +7 -6
  19. package/dist/app/composables/fetch.mjs +7 -1
  20. package/dist/app/composables/head.d.ts +2 -0
  21. package/dist/app/composables/head.mjs +1 -0
  22. package/dist/app/composables/index.d.ts +3 -1
  23. package/dist/app/composables/index.mjs +2 -1
  24. package/dist/app/composables/payload.mjs +6 -6
  25. package/dist/app/composables/preload.mjs +1 -1
  26. package/dist/app/composables/router.mjs +1 -1
  27. package/dist/app/composables/ssr.d.ts +1 -0
  28. package/dist/app/composables/ssr.mjs +7 -0
  29. package/dist/app/config.d.ts +1 -1
  30. package/dist/app/dtwo.d.ts +5 -2
  31. package/dist/app/dtwo.mjs +5 -0
  32. package/dist/app/entry-spa.d.ts +2 -0
  33. package/dist/app/entry-spa.mjs +2 -0
  34. package/dist/app/entry.mjs +1 -1
  35. package/dist/app/index.d.ts +0 -2
  36. package/dist/app/index.mjs +0 -1
  37. package/dist/app/plugins/chunk-reload.client.d.ts +2 -0
  38. package/dist/app/plugins/chunk-reload.client.mjs +26 -0
  39. package/dist/app/plugins/cross-origin-prefetch.client.mjs +2 -1
  40. package/dist/app/plugins/debug.mjs +1 -1
  41. package/dist/app/plugins/payload.client.mjs +3 -1
  42. package/dist/app/plugins/preload.server.mjs +1 -1
  43. package/dist/app/plugins/router.d.ts +1 -1
  44. package/dist/app/plugins/router.mjs +5 -2
  45. package/dist/app/types/augments.d.ts +28 -28
  46. package/dist/components/runtime/server-component.mjs +4 -1
  47. package/dist/core/runtime/hole/renderer.mjs +6 -2
  48. package/dist/head/runtime/composables.d.ts +1 -1
  49. package/dist/head/runtime/composables.mjs +1 -1
  50. package/dist/head/runtime/index.d.ts +1 -1
  51. package/dist/head/runtime/lib/kduse-head.plugin.mjs +1 -1
  52. package/dist/index.d.ts +1 -1
  53. package/dist/index.mjs +9173 -271
  54. package/dist/pages/runtime/app.kdu +5 -5
  55. package/dist/pages/runtime/page.mjs +1 -1
  56. package/dist/pages/runtime/plugins/prefetch.client.mjs +2 -1
  57. package/dist/pages/runtime/plugins/router.mjs +6 -2
  58. package/dist/pages/runtime/router.options.mjs +1 -1
  59. package/dist/pages/runtime/validate.mjs +23 -2
  60. package/package.json +31 -27
  61. package/schema.d.ts +1 -0
  62. package/schema.mjs +1 -0
  63. package/types.d.ts +1 -1
  64. package/README.md +0 -7
@@ -1,5 +1,5 @@
1
- <template>
2
- <DtwoLayout>
3
- <DtwoPage />
4
- </DtwoLayout>
5
- </template>
1
+ <template>
2
+ <DtwoLayout>
3
+ <DtwoPage />
4
+ </DtwoLayout>
5
+ </template>
@@ -2,7 +2,7 @@ import { computed, defineComponent, h, provide, reactive, onMounted, nextTick, S
2
2
  import { RouterView } from "kdu-router";
3
3
  import { defu } from "defu";
4
4
  import { generateRouteKey, wrapInKeepAlive } from "./utils.mjs";
5
- import { useDtwoApp } from "#app";
5
+ import { useDtwoApp } from "#app/dtwo";
6
6
  import { _wrapIf } from "#app/components/utils";
7
7
  import { appPageTransition as defaultPageTransition, appKeepalive as defaultKeepaliveConfig } from "#build/dtwo.config.mjs";
8
8
  export default defineComponent({
@@ -1,5 +1,6 @@
1
1
  import { hasProtocol } from "ufo";
2
- import { defineDtwoPlugin, useDtwoApp, useRouter } from "#app";
2
+ import { defineDtwoPlugin, useDtwoApp } from "#app/dtwo";
3
+ import { useRouter } from "#app/composables/router";
3
4
  import layouts from "#build/layouts";
4
5
  import { namedMiddleware } from "#build/middleware";
5
6
  export default defineDtwoPlugin(() => {
@@ -7,7 +7,11 @@ import {
7
7
  } from "kdu-router";
8
8
  import { createError } from "h3";
9
9
  import { withoutBase, isEqual } from "ufo";
10
- import { callWithDtwo, defineDtwoPlugin, useRuntimeConfig, showError, clearError, navigateTo, useError, useState, useRequestEvent } from "#app";
10
+ import { callWithDtwo, defineDtwoPlugin, useRuntimeConfig } from "#app/dtwo";
11
+ import { showError, clearError, useError } from "#app/composables/error";
12
+ import { useRequestEvent } from "#app/composables/ssr";
13
+ import { useState } from "#app/composables/state";
14
+ import { navigateTo } from "#app/composables/router";
11
15
  import _routes from "#build/routes";
12
16
  import routerOptions from "#build/router.options";
13
17
  import { globalMiddleware, namedMiddleware } from "#build/middleware";
@@ -132,7 +136,7 @@ export default defineDtwoPlugin(async (dtwoApp) => {
132
136
  })]);
133
137
  } else if (process.server) {
134
138
  const currentURL = to.fullPath || "/";
135
- if (!isEqual(currentURL, initialURL)) {
139
+ if (!isEqual(currentURL, initialURL, { trailingSlash: true })) {
136
140
  const event = await callWithDtwo(dtwoApp, useRequestEvent);
137
141
  const options = { redirectCode: event.node.res.statusCode !== 200 ? event.node.res.statusCode || 302 : 302 };
138
142
  await callWithDtwo(dtwoApp, navigateTo, [currentURL, options]);
@@ -1,5 +1,5 @@
1
1
  import { nextTick } from "kdu";
2
- import { useDtwoApp } from "#app";
2
+ import { useDtwoApp } from "#app/dtwo";
3
3
  import { appPageTransition as defaultPageTransition } from "#build/dtwo.config.mjs";
4
4
  export default {
5
5
  scrollBehavior(to, from, savedPosition) {
@@ -1,11 +1,32 @@
1
- import { defineDtwoRouteMiddleware } from "#app";
1
+ import { createError, showError } from "#app/composables/error";
2
+ import { callWithDtwo, useDtwoApp } from "#app/dtwo";
3
+ import { defineDtwoRouteMiddleware, useRouter } from "#app/composables/router";
2
4
  export default defineDtwoRouteMiddleware(async (to) => {
3
5
  if (!to.meta?.validate) {
4
6
  return;
5
7
  }
8
+ const dtwoApp = useDtwoApp();
9
+ const router = useRouter();
6
10
  const result = await Promise.resolve(to.meta.validate(to));
7
11
  if (result === true) {
8
12
  return;
9
13
  }
10
- return result;
14
+ if (process.server) {
15
+ return result;
16
+ }
17
+ const error = createError({
18
+ statusCode: 404,
19
+ statusMessage: `Page Not Found: ${to.fullPath}`
20
+ });
21
+ const unsub = router.beforeResolve((final) => {
22
+ unsub();
23
+ if (final === to) {
24
+ const unsub2 = router.afterEach(async () => {
25
+ unsub2();
26
+ await callWithDtwo(dtwoApp, showError, [error]);
27
+ window.history.pushState({}, "", to.fullPath);
28
+ });
29
+ return false;
30
+ }
31
+ });
11
32
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtwo",
3
- "version": "3.1.2",
3
+ "version": "3.2.1",
4
4
  "repository": "d2js/dtwo",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -13,9 +13,13 @@
13
13
  "exports": {
14
14
  ".": "./dist/index.mjs",
15
15
  "./config": {
16
+ "types": "./config.d.ts",
16
17
  "import": "./config.mjs",
17
- "require": "./config.cjs",
18
- "types": "./config.d.ts"
18
+ "require": "./config.cjs"
19
+ },
20
+ "./schema": {
21
+ "types": "./schema.d.ts",
22
+ "import": "./schema.mjs"
19
23
  },
20
24
  "./app": "./dist/app/index.mjs",
21
25
  "./package.json": "./package.json"
@@ -30,53 +34,53 @@
30
34
  "bin",
31
35
  "types.d.ts",
32
36
  "dist",
33
- "config.*"
37
+ "config.*",
38
+ "schema.*"
34
39
  ],
35
40
  "dependencies": {
36
41
  "@d2js/devalue": "2.0.2",
37
- "@dtwo/kit": "3.1.2",
38
- "@dtwo/schema": "3.1.2",
39
- "@dtwo/telemetry": "2.1.8",
42
+ "@dtwo/kit": "3.2.1",
43
+ "@dtwo/schema": "3.2.1",
44
+ "@dtwo/telemetry": "2.1.10",
40
45
  "@dtwo/ui-templates": "1.1.1",
41
- "@dtwo/unplugin": "1.0.0",
42
- "@dtwo/wite-builder": "3.1.2",
43
- "@kdhead/ssr": "1.0.20",
46
+ "@dtwo/unplugin": "1.4.0",
47
+ "@dtwo/lahm-builder": "3.2.1",
48
+ "@kdhead/ssr": "1.8.10",
44
49
  "@kdujs/reactivity": "3.2.48",
45
50
  "@kdujs/shared": "3.2.48",
46
- "@kduse/head": "1.0.24",
51
+ "@kduse/head": "1.3.1-1",
47
52
  "chokidar": "3.5.3",
48
53
  "cookie-es": "0.5.0",
49
54
  "defu": "6.1.2",
50
55
  "destr": "1.2.2",
51
- "dtwc": "3.1.2",
56
+ "dtwc": "3.2.1",
52
57
  "escape-string-regexp": "5.0.0",
53
58
  "estree-walker": "3.0.3",
54
59
  "fs-extra": "11.1.0",
55
60
  "globby": "13.1.3",
56
- "h3": "1.1.0",
61
+ "h3": "1.5.0",
57
62
  "hash-sum": "2.0.0",
58
- "holepack": "2.1.1",
63
+ "holepack": "2.2.2",
59
64
  "hookable": "5.4.2",
60
- "jiti": "1.16.2",
61
- "kdhead": "1.0.20",
62
- "kdimport": "2.1.0",
65
+ "jiti": "1.17.1",
66
+ "kdhead": "1.8.10",
67
+ "kdimport": "2.2.4",
63
68
  "kdu": "3.2.48",
64
- "kdu-bundle-renderer": "1.0.0",
69
+ "kdu-bundle-renderer": "1.0.2-1",
65
70
  "kdu-devtools-stub": "0.1.0",
66
71
  "kdu-router": "4.1.6",
67
72
  "knitwork": "1.0.0",
68
- "magic-string": "0.27.0",
69
- "mlly": "1.1.0",
70
- "ofetch": "1.0.0",
73
+ "magic-string": "0.29.0",
74
+ "mlly": "1.1.1",
75
+ "ofetch": "1.0.1",
71
76
  "ohash": "1.0.0",
72
77
  "pathe": "1.1.0",
73
78
  "perfect-debounce": "0.1.3",
74
79
  "scule": "1.0.0",
75
- "strip-literal": "1.0.0",
76
- "ufo": "1.0.1",
77
- "ultrahtml": "1.2.0",
78
- "unctx": "2.1.1",
79
- "unenv": "1.0.3",
80
+ "strip-literal": "1.0.1",
81
+ "ufo": "1.1.0",
82
+ "unctx": "2.1.2",
83
+ "unenv": "1.2.0",
80
84
  "untyped": "1.2.2"
81
85
  },
82
86
  "devDependencies": {
@@ -85,7 +89,7 @@
85
89
  "unbuild": "1.1.1"
86
90
  },
87
91
  "engines": {
88
- "node": "^14.16.0 || ^16.10.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
92
+ "node": "^14.18.0 || ^16.10.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
89
93
  },
90
94
  "scripts": {}
91
95
  }
package/schema.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from '@dtwo/schema'
package/schema.mjs ADDED
@@ -0,0 +1 @@
1
+ export * from '@dtwo/schema'
package/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /// <reference types="holepack" />
2
2
  export * from './dist/index'
3
3
 
4
- import type { SchemaDefinition } from '@dtwo/schema'
4
+ import type { SchemaDefinition } from 'dtwo/schema'
5
5
 
6
6
  declare global {
7
7
  const defineDtwoConfig: typeof import('dtwo/config')['defineDtwoConfig']
package/README.md DELETED
@@ -1,7 +0,0 @@
1
- # Dtwo
2
-
3
- Dtwo 3: **The Intuitive Web Framework** ✨
4
-
5
- ## License
6
-
7
- [MIT](./LICENSE)