@absolutejs/absolute 0.19.0-beta.1114 → 0.19.0-beta.1116

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 (90) hide show
  1. package/dist/angular/browser.js +53 -47
  2. package/dist/angular/browser.js.map +5 -5
  3. package/dist/angular/components/core/streamingSlotRegistrar.js +1 -1
  4. package/dist/angular/components/core/streamingSlotRegistry.js +2 -2
  5. package/dist/angular/hmrPreserveCore.ts +73 -34
  6. package/dist/angular/index.js +63 -58
  7. package/dist/angular/index.js.map +10 -10
  8. package/dist/angular/server.js +20 -38
  9. package/dist/angular/server.js.map +8 -8
  10. package/dist/build.js +601 -547
  11. package/dist/build.js.map +32 -32
  12. package/dist/cli/config/client.js +8 -8
  13. package/dist/cli/config/server.js +87 -75
  14. package/dist/cli/index.js +146 -127
  15. package/dist/client/index.js +1 -19
  16. package/dist/client/index.js.map +3 -3
  17. package/dist/core/streamingSlotRegistrar.js +1 -19
  18. package/dist/core/streamingSlotRegistrar.js.map +2 -2
  19. package/dist/core/streamingSlotRegistry.js +1 -19
  20. package/dist/core/streamingSlotRegistry.js.map +2 -2
  21. package/dist/dev/client/errorOverlay.ts +11 -10
  22. package/dist/dev/client/handlers/angularHmrShim.ts +6 -6
  23. package/dist/dev/client/handlers/angularRemount.ts +64 -44
  24. package/dist/dev/client/hmrClient.ts +31 -26
  25. package/dist/dev/client/hmrToast.ts +2 -4
  26. package/dist/dev/serverBootstrap.js +36 -0
  27. package/dist/index.js +742 -615
  28. package/dist/index.js.map +39 -38
  29. package/dist/islands/browser.js +1 -19
  30. package/dist/islands/browser.js.map +2 -2
  31. package/dist/islands/index.js +1 -19
  32. package/dist/islands/index.js.map +3 -3
  33. package/dist/react/browser.js +1 -19
  34. package/dist/react/browser.js.map +2 -2
  35. package/dist/react/components/index.js +1 -19
  36. package/dist/react/components/index.js.map +2 -2
  37. package/dist/react/hooks/index.js +1 -19
  38. package/dist/react/hooks/index.js.map +2 -2
  39. package/dist/react/index.js +15 -37
  40. package/dist/react/index.js.map +7 -7
  41. package/dist/react/jsxDevRuntimeCompat.js +1 -19
  42. package/dist/react/jsxDevRuntimeCompat.js.map +2 -2
  43. package/dist/react/router/browser.js +1 -19
  44. package/dist/react/router/browser.js.map +2 -2
  45. package/dist/react/router/index.js +1 -19
  46. package/dist/react/router/index.js.map +2 -2
  47. package/dist/react/server.js +15 -37
  48. package/dist/react/server.js.map +6 -6
  49. package/dist/src/angular/hmrPreserveCore.d.ts +2 -2
  50. package/dist/src/cli/config/absolute/resolveAbsoluteConfig.d.ts +1 -1
  51. package/dist/src/cli/config/auth/resolveAuthSettings.d.ts +1 -1
  52. package/dist/src/cli/config/packageJson/resolvePackageJson.d.ts +1 -2
  53. package/dist/src/cli/config/schema/fromType.d.ts +1 -2
  54. package/dist/src/cli/config/server.d.ts +2 -2
  55. package/dist/src/core/build.d.ts +3 -2
  56. package/dist/src/core/prepare.d.ts +1 -0
  57. package/dist/src/dev/angular/fastHmrCompiler.d.ts +4 -2
  58. package/dist/src/dev/serverBootstrap.d.ts +1 -0
  59. package/dist/src/dev/serverEntryWatcher.d.ts +3 -3
  60. package/dist/src/dev/webSocket.d.ts +1 -1
  61. package/dist/src/plugins/hmr.d.ts +1 -0
  62. package/dist/src/svelte/router/matchPath.d.ts +2 -2
  63. package/dist/src/utils/defineConvention.d.ts +2 -2
  64. package/dist/src/utils/inlinePageCss.d.ts +1 -1
  65. package/dist/src/utils/isTestSourcePath.d.ts +1 -0
  66. package/dist/svelte/browser.js +1 -19
  67. package/dist/svelte/browser.js.map +2 -2
  68. package/dist/svelte/index.js +15 -36
  69. package/dist/svelte/index.js.map +8 -8
  70. package/dist/svelte/router/Link.svelte.d.ts +3 -3
  71. package/dist/svelte/router/Route.svelte.d.ts +5 -5
  72. package/dist/svelte/router/Router.svelte.d.ts +3 -3
  73. package/dist/svelte/router/matchPath.ts +25 -20
  74. package/dist/svelte/router/prefetchCache.ts +6 -4
  75. package/dist/svelte/router/viewTransitions.ts +22 -12
  76. package/dist/svelte/server.js +15 -36
  77. package/dist/svelte/server.js.map +7 -7
  78. package/dist/types/angular.d.ts +1 -1
  79. package/dist/types/globals.d.ts +5 -0
  80. package/dist/vue/browser.js +1 -19
  81. package/dist/vue/browser.js.map +2 -2
  82. package/dist/vue/components/Image.js +1 -19
  83. package/dist/vue/components/Image.js.map +2 -2
  84. package/dist/vue/components/index.js +1 -19
  85. package/dist/vue/components/index.js.map +2 -2
  86. package/dist/vue/index.js +41 -55
  87. package/dist/vue/index.js.map +10 -10
  88. package/dist/vue/server.js +32 -48
  89. package/dist/vue/server.js.map +8 -8
  90. package/package.json +285 -19
@@ -1,4 +1,4 @@
1
- import type { Snippet } from 'svelte';
1
+ import { SvelteComponent, type Snippet } from 'svelte';
2
2
  import type { LinkPrefetchMode } from '../../types/svelteRouter';
3
3
 
4
4
  type LinkProps = {
@@ -16,6 +16,6 @@ type LinkProps = {
16
16
  declare const __propDef: { props: LinkProps };
17
17
  type Props = typeof __propDef.props;
18
18
 
19
- import { SvelteComponent } from 'svelte';
19
+ class Link extends SvelteComponent<Props> {}
20
20
 
21
- export default class Link extends SvelteComponent<Props> {}
21
+ export { Link as default };
@@ -1,4 +1,4 @@
1
- import type { Snippet } from 'svelte';
1
+ import { SvelteComponent, type Snippet } from 'svelte';
2
2
  import type { ExtractRouteParams } from '../../types/svelteRouter';
3
3
 
4
4
  type RouteProps<Path extends string> = {
@@ -6,8 +6,8 @@ type RouteProps<Path extends string> = {
6
6
  content: Snippet<[ExtractRouteParams<Path>]>;
7
7
  };
8
8
 
9
- import { SvelteComponent } from 'svelte';
9
+ class Route<Path extends string = string> extends SvelteComponent<
10
+ RouteProps<Path>
11
+ > {}
10
12
 
11
- export default class Route<
12
- Path extends string = string
13
- > extends SvelteComponent<RouteProps<Path>> {}
13
+ export { Route as default };
@@ -1,4 +1,4 @@
1
- import type { Snippet } from 'svelte';
1
+ import { SvelteComponent, type Snippet } from 'svelte';
2
2
  import type { RouterMode } from '../../types/svelteRouter';
3
3
 
4
4
  type RouterProps = {
@@ -11,6 +11,6 @@ type RouterProps = {
11
11
  declare const __propDef: { props: RouterProps };
12
12
  type Props = typeof __propDef.props;
13
13
 
14
- import { SvelteComponent } from 'svelte';
14
+ class Router extends SvelteComponent<Props> {}
15
15
 
16
- export default class Router extends SvelteComponent<Props> {}
16
+ export { Router as default };
@@ -12,11 +12,18 @@ type CompiledPattern = {
12
12
  segments: CompiledSegment[];
13
13
  score: number;
14
14
  };
15
+ type RouteMatchBuilder = <Path extends string>(
16
+ params: Record<string, string | undefined>
17
+ ) => RouteMatchResult<ExtractRouteParams<Path>>;
15
18
 
16
19
  const STATIC_SEGMENT_WEIGHT = 100;
17
20
  const PARAM_SEGMENT_WEIGHT = 10;
18
21
  const WILDCARD_SEGMENT_WEIGHT = 1;
19
22
  const OPTIONAL_PENALTY = 1;
23
+ const buildRouteMatch: RouteMatchBuilder = (params) => ({
24
+ matched: true,
25
+ params: Object.assign(Object.create(null), params)
26
+ });
20
27
 
21
28
  const splitPath = (path: string) => {
22
29
  const trimmed = path.replace(/^\/+/, '').replace(/\/+$/, '');
@@ -46,12 +53,12 @@ const compileSegment = (raw: string): CompiledSegment => {
46
53
  * Higher score = more specific (longer static prefix beats parameterised).
47
54
  */
48
55
  export const comparePatterns = (
49
- a: { score: number; index: number },
50
- b: { score: number; index: number }
56
+ left: { score: number; index: number },
57
+ right: { score: number; index: number }
51
58
  ) => {
52
- if (a.score !== b.score) return b.score - a.score;
59
+ if (left.score !== right.score) return right.score - left.score;
53
60
 
54
- return a.index - b.index;
61
+ return left.index - right.index;
55
62
  };
56
63
  export const compilePattern = (pattern: string): CompiledPattern => {
57
64
  const segments = splitPath(pattern).map(compileSegment);
@@ -89,21 +96,22 @@ export const matchPattern = <Path extends string>(
89
96
  const pathSegments = splitPath(pathname);
90
97
  const params: Record<string, string | undefined> = {};
91
98
 
92
- let pi = 0;
93
- for (let si = 0; si < pattern.segments.length; si++) {
94
- const segment = pattern.segments[si];
99
+ let pathIndex = 0;
100
+ for (
101
+ let segmentIndex = 0;
102
+ segmentIndex < pattern.segments.length;
103
+ segmentIndex++
104
+ ) {
105
+ const segment = pattern.segments[segmentIndex];
95
106
  if (!segment) continue;
96
107
 
97
108
  if (segment.kind === 'wildcard') {
98
- params['wildcard'] = pathSegments.slice(pi).join('/');
109
+ params['wildcard'] = pathSegments.slice(pathIndex).join('/');
99
110
 
100
- return {
101
- matched: true,
102
- params: params as ExtractRouteParams<Path>
103
- };
111
+ return buildRouteMatch<Path>(params);
104
112
  }
105
113
 
106
- const candidate = pathSegments[pi];
114
+ const candidate = pathSegments[pathIndex];
107
115
 
108
116
  if (candidate === undefined) {
109
117
  if (segment.kind === 'param' && segment.optional) {
@@ -116,21 +124,18 @@ export const matchPattern = <Path extends string>(
116
124
 
117
125
  if (segment.kind === 'static') {
118
126
  if (segment.value !== candidate) return { matched: false };
119
- pi++;
127
+ pathIndex++;
120
128
  continue;
121
129
  }
122
130
 
123
131
  // param
124
132
  params[segment.name] = candidate;
125
- pi++;
133
+ pathIndex++;
126
134
  }
127
135
 
128
- if (pi !== pathSegments.length) {
136
+ if (pathIndex !== pathSegments.length) {
129
137
  return { matched: false };
130
138
  }
131
139
 
132
- return {
133
- matched: true,
134
- params: params as ExtractRouteParams<Path>
135
- };
140
+ return buildRouteMatch<Path>(params);
136
141
  };
@@ -11,11 +11,13 @@ const cache = new Map<string, CacheEntry>();
11
11
  const isSlowConnection = () => {
12
12
  if (typeof navigator === 'undefined') return false;
13
13
 
14
- const { connection } = navigator as Navigator & {
15
- connection?: { saveData?: boolean };
16
- };
14
+ const connection = Reflect.get(navigator, 'connection');
17
15
 
18
- return connection?.saveData === true;
16
+ return (
17
+ typeof connection === 'object' &&
18
+ connection !== null &&
19
+ Reflect.get(connection, 'saveData') === true
20
+ );
19
21
  };
20
22
 
21
23
  const prefersReducedData = () => {
@@ -1,14 +1,7 @@
1
- type StartViewTransition = (callback: () => void | Promise<void>) => {
2
- finished: Promise<void>;
3
- };
4
-
5
1
  const supportsViewTransitions = () => {
6
2
  if (typeof document === 'undefined') return false;
7
3
 
8
- return (
9
- typeof (document as { startViewTransition?: StartViewTransition })
10
- .startViewTransition === 'function'
11
- );
4
+ return typeof Reflect.get(document, 'startViewTransition') === 'function';
12
5
  };
13
6
 
14
7
  /**
@@ -28,8 +21,25 @@ export const withViewTransition = async (
28
21
  // Call as a method on `document` (NOT as an extracted bare function) —
29
22
  // `document.startViewTransition` requires `this === document` or it
30
23
  // throws "Illegal invocation".
31
- const doc = document as Document & {
32
- startViewTransition: StartViewTransition;
33
- };
34
- await doc.startViewTransition(() => mutate()).finished;
24
+ const startViewTransition: unknown = Reflect.get(
25
+ document,
26
+ 'startViewTransition'
27
+ );
28
+ if (typeof startViewTransition !== 'function') {
29
+ await mutate();
30
+
31
+ return;
32
+ }
33
+ const transitionResult: unknown = Reflect.apply(
34
+ startViewTransition,
35
+ document,
36
+ [() => mutate()]
37
+ );
38
+ if (
39
+ typeof transitionResult === 'object' &&
40
+ transitionResult !== null &&
41
+ 'finished' in transitionResult
42
+ ) {
43
+ await transitionResult.finished;
44
+ }
35
45
  };
@@ -3,7 +3,6 @@ var __create = Object.create;
3
3
  var __getProtoOf = Object.getPrototypeOf;
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
7
  function __accessProp(key) {
9
8
  return this[key];
@@ -30,23 +29,6 @@ var __toESM = (mod, isNodeMode, target) => {
30
29
  cache.set(mod, to);
31
30
  return to;
32
31
  };
33
- var __toCommonJS = (from) => {
34
- var entry = (__moduleCache ??= new WeakMap).get(from), desc;
35
- if (entry)
36
- return entry;
37
- entry = __defProp({}, "__esModule", { value: true });
38
- if (from && typeof from === "object" || typeof from === "function") {
39
- for (var key of __getOwnPropNames(from))
40
- if (!__hasOwnProp.call(entry, key))
41
- __defProp(entry, key, {
42
- get: __accessProp.bind(from, key),
43
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
44
- });
45
- }
46
- __moduleCache.set(from, entry);
47
- return entry;
48
- };
49
- var __moduleCache;
50
32
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
51
33
  var __returnValue = (v) => v;
52
34
  function __exportSetter(name, newValue) {
@@ -1073,22 +1055,20 @@ __export(exports_devRouteRegistrationCallsite, {
1073
1055
  });
1074
1056
  import { AsyncLocalStorage } from "async_hooks";
1075
1057
  import { Elysia } from "elysia";
1076
- var ROUTE_CALLSITE_STORAGE_KEY, ROUTE_CALLSITE_PATCHED_KEY, ROUTE_METHOD_NAMES, PAGE_HANDLER_NAMES, pageHandlerWrappers, handlerSourceMentionsPageHelper = (handler) => {
1058
+ var ROUTE_CALLSITE_STORAGE_KEY, ROUTE_CALLSITE_PATCHED_KEY, ROUTE_METHOD_NAMES, PAGE_HANDLER_NAMES, pageHandlerWrappers, isPageHandlerFunction = (value) => typeof value === "function", handlerSourceMentionsPageHelper = (handler) => {
1077
1059
  const source = handler.toString();
1078
1060
  return PAGE_HANDLER_NAMES.some((name) => source.includes(name));
1079
1061
  }, getOriginalPageHandlerSource = (handler) => {
1080
- if (typeof handler !== "function")
1062
+ if (!isPageHandlerFunction(handler))
1081
1063
  return;
1082
- const fn = handler;
1083
- const info = pageHandlerWrappers.get(fn);
1084
- return (info?.originalHandler ?? fn).toString();
1064
+ const info = pageHandlerWrappers.get(handler);
1065
+ return (info?.originalHandler ?? handler).toString();
1085
1066
  }, isPageHandler = (handler) => {
1086
- if (typeof handler !== "function")
1067
+ if (!isPageHandlerFunction(handler))
1087
1068
  return false;
1088
- const fn = handler;
1089
- if (pageHandlerWrappers.has(fn))
1069
+ if (pageHandlerWrappers.has(handler))
1090
1070
  return true;
1091
- return handlerSourceMentionsPageHelper(fn);
1071
+ return handlerSourceMentionsPageHelper(handler);
1092
1072
  }, isObjectRecord3 = (value) => Boolean(value) && typeof value === "object", isAsyncLocalStorage2 = (value) => isObjectRecord3(value) && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function", isRouteMethod = (value) => typeof value === "function", getRouteCallsiteStorage = () => {
1093
1073
  const value = Reflect.get(globalThis, ROUTE_CALLSITE_STORAGE_KEY);
1094
1074
  if (value === null || typeof value === "undefined") {
@@ -1125,7 +1105,7 @@ var ROUTE_CALLSITE_STORAGE_KEY, ROUTE_CALLSITE_PATCHED_KEY, ROUTE_METHOD_NAMES,
1125
1105
  }, createPatchedRouteMethod = (originalMethod, methodName) => function patchedRouteMethod(path, handler, ...rest) {
1126
1106
  const callsite = captureRouteRegistrationCallsite();
1127
1107
  const wrapped = wrapRouteHandlerWithCallsite(handler, callsite);
1128
- if (methodName === "get" && typeof handler === "function" && typeof wrapped === "function" && handlerSourceMentionsPageHelper(handler)) {
1108
+ if (methodName === "get" && isPageHandlerFunction(handler) && isPageHandlerFunction(wrapped) && handlerSourceMentionsPageHelper(handler)) {
1129
1109
  pageHandlerWrappers.set(wrapped, {
1130
1110
  originalHandler: handler
1131
1111
  });
@@ -2164,8 +2144,8 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
2164
2144
  }, isDev = () => true, buildErrorProps = (error) => {
2165
2145
  if (error instanceof Error) {
2166
2146
  return {
2167
- name: error.name,
2168
2147
  message: error.message,
2148
+ name: error.name,
2169
2149
  ...isDev() && error.stack ? { stack: error.stack } : {}
2170
2150
  };
2171
2151
  }
@@ -2249,7 +2229,7 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
2249
2229
  let conventionPath = resolveErrorConventionPath(framework, pageName);
2250
2230
  if (!conventionPath && error instanceof Error && error.stack) {
2251
2231
  for (const match of error.stack.matchAll(/^\s*at\s+([A-Za-z_$][\w$]*)/gm)) {
2252
- const candidate = match[1];
2232
+ const [, candidate] = match;
2253
2233
  if (!candidate)
2254
2234
  continue;
2255
2235
  conventionPath = resolveErrorConventionPath(framework, candidate);
@@ -2397,9 +2377,9 @@ var init_resolveConvention = __esm(() => {
2397
2377
  import { basename as basename3 } from "path";
2398
2378
  var SPA_ROUTES_KEY = "__absoluteSpaRoutes", setSpaRouteManifest = (hosts) => {
2399
2379
  Reflect.set(globalThis, SPA_ROUTES_KEY, hosts);
2400
- }, getSpaRouteManifest = () => {
2380
+ }, isRuntimeSpaHost = (value) => typeof value === "object" && value !== null && typeof Reflect.get(value, "framework") === "string", getSpaRouteManifest = () => {
2401
2381
  const value = Reflect.get(globalThis, SPA_ROUTES_KEY);
2402
- return Array.isArray(value) ? value : [];
2382
+ return Array.isArray(value) ? value.filter(isRuntimeSpaHost) : [];
2403
2383
  }, normalizePath = (path) => {
2404
2384
  const withLeadingSlash = path.startsWith("/") ? path : `/${path}`;
2405
2385
  const trimmed = withLeadingSlash.replace(/\/+$/, "");
@@ -2982,9 +2962,8 @@ var primeSvelteStream = async (stream) => {
2982
2962
  };
2983
2963
  var restorePrimedStream = (firstChunk, reader) => new ReadableStream({
2984
2964
  start(controller) {
2985
- if (!firstChunk.done) {
2965
+ if (!firstChunk.done)
2986
2966
  controller.enqueue(firstChunk.value);
2987
- }
2988
2967
  if (firstChunk.done) {
2989
2968
  controller.close();
2990
2969
  return;
@@ -3011,7 +2990,7 @@ var handleSveltePageRequest = async (input) => {
3011
2990
  const resolvedPagePath = input.pagePath;
3012
2991
  const userProps = input.props;
3013
2992
  const requestPathname = resolveRequestPathname(input.request);
3014
- const resolvedProps = requestPathname !== undefined && (!userProps || !("url" in userProps)) ? {
2993
+ const resolvedProps = requestPathname !== undefined && (!isRecord2(userProps) || !("url" in userProps)) ? {
3015
2994
  ...userProps ?? {},
3016
2995
  url: requestPathname
3017
2996
  } : userProps;
@@ -3089,5 +3068,5 @@ export {
3089
3068
  handleSveltePageRequest
3090
3069
  };
3091
3070
 
3092
- //# debugId=69BC322A2C427FAC64756E2164756E21
3071
+ //# debugId=C944595BEA2DB73664756E2164756E21
3093
3072
  //# sourceMappingURL=server.js.map