@absolutejs/absolute 0.20.0-beta.169 → 0.20.0-beta.170
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/CHANGELOG.md +80 -0
- package/README.md +232 -0
- package/changelog.json +228 -0
- package/dist/angular/browser.js +7 -8
- package/dist/angular/browser.js.map +6 -5
- package/dist/angular/components/core/streamingSlotRegistrar.js +6 -2
- package/dist/angular/components/core/streamingSlotRegistry.js +7 -3
- package/dist/angular/index.js +555 -156
- package/dist/angular/index.js.map +29 -23
- package/dist/angular/server.js +555 -156
- package/dist/angular/server.js.map +29 -23
- package/dist/build/buildWorker.js +14 -8
- package/dist/build.js +4949 -1941
- package/dist/build.js.map +72 -42
- package/dist/cli/{add-7azr0c83.js → add-6a7pjkn9.js} +11 -7
- package/dist/cli/{analyze-3cyek6v3.js → analyze-606fshwa.js} +1 -1
- package/dist/cli/{build-25rz8v25.js → build-g81xqbb9.js} +1 -1
- package/dist/cli/{compile-4jnfxts9.js → compile-9y1w9zpj.js} +3 -3
- package/dist/cli/config/server.js +10699 -1538
- package/dist/cli/{dev-9tk5hn2e.js → dev-hyeb89hp.js} +5 -1
- package/dist/cli/{doctor-4nv2c2j3.js → doctor-h55y9hj1.js} +1 -1
- package/dist/cli/{generate-v75p2fct.js → generate-20x1pkf7.js} +4 -4
- package/dist/cli/{htmx-427swtdz.js → htmx-6mz2h7k1.js} +2 -2
- package/dist/cli/{index-bhbs6d5z.js → index-32ge2w1f.js} +12 -4
- package/dist/cli/{index-a4ws2jwd.js → index-3wz3mktm.js} +1 -1
- package/dist/cli/{index-b7hjgknf.js → index-9sksd8c8.js} +13 -4
- package/dist/cli/{index-eyzwc7gz.js → index-qbrzvmh9.js} +4 -2
- package/dist/cli/index-qw98g1p6.js +269 -0
- package/dist/cli/{index-434b7j4a.js → index-vtp20gwf.js} +69 -1
- package/dist/cli/{index-h7qhz02e.js → index-wk0pyxrg.js} +3 -0
- package/dist/cli/{index-k3y8cb6c.js → index-z6f43b20.js} +1 -1
- package/dist/cli/index.js +16 -16
- package/dist/cli/{islands-8sgky9gh.js → islands-dc54e5y1.js} +1 -1
- package/dist/cli/{ls-4m4yqwww.js → ls-b6zz24nt.js} +1 -1
- package/dist/cli/{mobile-hcxjr2gf.js → mobile-ajnnvqtv.js} +3 -3
- package/dist/cli/prerender-fqpp0m1j.js +10 -0
- package/dist/cli/{remove-1ycjx85k.js → remove-t8x1mrxg.js} +4 -4
- package/dist/cli/{start-mbaejxhm.js → start-d6p831ny.js} +3 -3
- package/dist/cli/{typecheck-dr068pmh.js → typecheck-stbt0qt5.js} +6 -1
- package/dist/cli/{workspace-1sycp9g1.js → workspace-61hh6jq1.js} +1 -1
- package/dist/client/chunks/index-6b66nzyf.js +381 -0
- package/dist/client/chunks/index-6b66nzyf.js.map +11 -0
- package/dist/client/chunks/{islands-rc28k5sx.js → islands-s2ta5ajb.js} +5 -2
- package/dist/client/chunks/{islands-rc28k5sx.js.map → islands-s2ta5ajb.js.map} +7 -6
- package/dist/client/index.js +160 -3
- package/dist/client/index.js.map +6 -4
- package/dist/client/navigation.js +764 -0
- package/dist/client/navigation.js.map +10 -0
- package/dist/client/prefetch.js +33 -375
- package/dist/client/prefetch.js.map +3 -4
- package/dist/core/streamingSlotRegistrar.js +5 -2
- package/dist/core/streamingSlotRegistrar.js.map +5 -4
- package/dist/core/streamingSlotRegistry.js +5 -2
- package/dist/core/streamingSlotRegistry.js.map +5 -4
- package/dist/dev/client/cspNonce.ts +28 -0
- package/dist/dev/client/handlers/html.ts +4 -3
- package/dist/dev/client/handlers/htmx.ts +3 -2
- package/dist/dev/client/handlers/svelte.ts +15 -90
- package/dist/dev/client/syncDevtools.ts +2 -1
- package/dist/dev/serverBootstrap.js +11 -4
- package/dist/i18n/index.js +543 -0
- package/dist/i18n/index.js.map +15 -0
- package/dist/index.js +6339 -2233
- package/dist/index.js.map +89 -54
- package/dist/islands/index.js +282 -40
- package/dist/islands/index.js.map +14 -10
- package/dist/mobile/browser.js +7 -2
- package/dist/mobile/browser.js.map +5 -4
- package/dist/mobile/index.js +7 -2
- package/dist/mobile/index.js.map +5 -4
- package/dist/mobile/remoteMacAgentEntry.js +1 -1
- package/dist/react/components/browser/index.js +94 -4
- package/dist/react/components/index.js +150 -10
- package/dist/react/components/index.js.map +15 -10
- package/dist/react/hooks/index.js +479 -13
- package/dist/react/hooks/index.js.map +12 -4
- package/dist/react/index.js +769 -166
- package/dist/react/index.js.map +32 -21
- package/dist/react/router/browser.js +21 -4
- package/dist/react/router/browser.js.map +5 -4
- package/dist/react/router/index.js +21 -4
- package/dist/react/router/index.js.map +5 -4
- package/dist/react/server.js +597 -203
- package/dist/react/server.js.map +25 -15
- package/dist/src/angular/zoneRuntime.d.ts +5 -0
- package/dist/src/build/buildReactServerComponents.d.ts +22 -0
- package/dist/src/build/downlevelAsyncForZone.d.ts +1 -0
- package/dist/src/build/fileRoutes.d.ts +65 -0
- package/dist/src/build/fonts/buildFonts.d.ts +25 -0
- package/dist/src/build/fonts/fallbackMetrics.d.ts +13 -0
- package/dist/src/build/fonts/googleFonts.d.ts +18 -0
- package/dist/src/build/fonts/injectFontTags.d.ts +7 -0
- package/dist/src/build/fonts/parseFontMetrics.d.ts +4 -0
- package/dist/src/build/generateReactIndexes.d.ts +7 -1
- package/dist/src/build/htmlIncludes.d.ts +16 -0
- package/dist/src/build/inlineSourceMapComment.d.ts +1 -0
- package/dist/src/build/scanConventions.d.ts +3 -0
- package/dist/src/build/vitals.d.ts +21 -0
- package/dist/src/client/formActions.d.ts +29 -0
- package/dist/src/client/index.d.ts +2 -0
- package/dist/src/client/navigation.d.ts +16 -0
- package/dist/src/client/prefetch.d.ts +2 -30
- package/dist/src/core/build.d.ts +2 -2
- package/dist/src/core/cspNonce.d.ts +12 -0
- package/dist/src/core/fileRouteAdapter.d.ts +15 -0
- package/dist/src/core/fileRoutes.d.ts +5 -0
- package/dist/src/core/formActionFlash.d.ts +25 -0
- package/dist/src/core/formActions.d.ts +249 -0
- package/dist/src/core/index.d.ts +5 -0
- package/dist/src/core/partialPrerender.d.ts +28 -0
- package/dist/src/core/partialPrerenderServe.d.ts +24 -0
- package/dist/src/core/precompressed.d.ts +11 -1
- package/dist/src/core/prerenderNonce.d.ts +9 -0
- package/dist/src/core/productionRuntime.d.ts +4 -2
- package/dist/src/core/serverOnlyStaticFiles.d.ts +8 -0
- package/dist/src/core/staticHtmlNonce.d.ts +2 -0
- package/dist/src/core/vitals.d.ts +108 -0
- package/dist/src/dev/angular/fastHmrCompiler.d.ts +1 -1
- package/dist/src/dev/client/cspNonce.d.ts +2 -0
- package/dist/src/dev/fileRouteRefresher.d.ts +5 -0
- package/dist/src/dev/importCost/instrument.d.ts +1 -1
- package/dist/src/dev/reactServerComponentsRebuild.d.ts +3 -0
- package/dist/src/i18n/defineMessages.d.ts +5 -0
- package/dist/src/i18n/formatMessage.d.ts +26 -0
- package/dist/src/i18n/index.d.ts +6 -0
- package/dist/src/i18n/intlCache.d.ts +5 -0
- package/dist/src/i18n/routing.d.ts +28 -0
- package/dist/src/i18n/translator.d.ts +11 -0
- package/dist/src/mobile/androidRelease.d.ts +2 -2
- package/dist/src/mobile/iosRelease.d.ts +4 -4
- package/dist/src/mobile/materializedBundle.d.ts +1 -1
- package/dist/src/mobile/mobileInspect.d.ts +1 -1
- package/dist/src/mobile/releaseArtifact.d.ts +2 -2
- package/dist/src/mobile/remoteMacProtocol.d.ts +2 -2
- package/dist/src/plugins/i18n.d.ts +30 -0
- package/dist/src/plugins/index.d.ts +2 -1
- package/dist/src/plugins/secureHeaders.d.ts +48 -0
- package/dist/src/react/components/Head.d.ts +1 -1
- package/dist/src/react/components/StreamSlot.browser.d.ts +1 -0
- package/dist/src/react/components/StreamSlot.d.ts +5 -1
- package/dist/src/react/components/SuspenseSlot.browser.d.ts +2 -0
- package/dist/src/react/components/SuspenseSlot.d.ts +12 -0
- package/dist/src/react/fileRoute.d.ts +18 -0
- package/dist/src/react/hooks/index.d.ts +4 -0
- package/dist/src/react/hooks/useFormAction.d.ts +42 -0
- package/dist/src/react/hooks/useI18n.d.ts +15 -0
- package/dist/src/react/index.d.ts +2 -0
- package/dist/src/react/server.d.ts +2 -0
- package/dist/src/react/serverComponents/constants.d.ts +11 -0
- package/dist/src/react/serverComponents/flightPayload.d.ts +2 -0
- package/dist/src/react/serverComponents/pageHandler.d.ts +14 -0
- package/dist/src/svelte/browser.d.ts +1 -0
- package/dist/src/svelte/fileRoute.d.ts +15 -0
- package/dist/src/svelte/i18n.d.ts +8 -0
- package/dist/src/svelte/index.d.ts +2 -0
- package/dist/src/svelte/lowerAwaitSlotSyntax.d.ts +5 -1
- package/dist/src/svelte/renderToReadableStream.d.ts +10 -2
- package/dist/src/svelte/router/browser.d.ts +3 -1
- package/dist/src/svelte/router/goto.d.ts +13 -10
- package/dist/src/svelte/router/guards.d.ts +43 -0
- package/dist/src/svelte/router/index.d.ts +3 -1
- package/dist/src/svelte/router/lazy.d.ts +17 -0
- package/dist/src/svelte/router/lazyModule.d.ts +29 -0
- package/dist/src/svelte/router/navigation.d.ts +55 -0
- package/dist/src/svelte/router/pushState.d.ts +4 -2
- package/dist/src/svelte/router/scroll.d.ts +34 -0
- package/dist/src/svelte/routerSsr.d.ts +9 -0
- package/dist/src/svelte/server.d.ts +1 -0
- package/dist/src/utils/cspNonceRef.d.ts +8 -0
- package/dist/src/utils/fontAssets.d.ts +17 -0
- package/dist/src/utils/formActionProtocol.d.ts +10 -0
- package/dist/src/utils/generateHeadElement.d.ts +1 -1
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/inlinePageCss.d.ts +18 -0
- package/dist/src/utils/loadConfig.d.ts +5 -0
- package/dist/src/utils/localeRef.d.ts +10 -0
- package/dist/src/utils/resolveConvention.d.ts +6 -1
- package/dist/src/utils/streamingSlots.d.ts +5 -0
- package/dist/src/vue/browser.d.ts +2 -0
- package/dist/src/vue/components/Image.d.ts +2 -2
- package/dist/src/vue/index.d.ts +2 -0
- package/dist/src/vue/serverDataPayload.d.ts +32 -0
- package/dist/src/vue/serverDataState.d.ts +9 -0
- package/dist/src/vue/useServerData.browser.d.ts +6 -0
- package/dist/src/vue/useServerData.d.ts +24 -0
- package/dist/svelte/browser.js +330 -3
- package/dist/svelte/browser.js.map +8 -4
- package/dist/svelte/components/AwaitSlot.svelte +5 -0
- package/dist/svelte/components/Head.svelte +50 -0
- package/dist/svelte/components/JsonLd.svelte +9 -1
- package/dist/svelte/components/StreamSlot.svelte +5 -0
- package/dist/svelte/index.js +1017 -117
- package/dist/svelte/index.js.map +38 -24
- package/dist/svelte/router/Link.svelte +40 -8
- package/dist/svelte/router/Route.svelte +157 -12
- package/dist/svelte/router/Route.svelte.d.ts +39 -5
- package/dist/svelte/router/Router.svelte +140 -25
- package/dist/svelte/router/Router.svelte.d.ts +5 -1
- package/dist/svelte/router/browser.ts +10 -0
- package/dist/svelte/router/goto.ts +15 -86
- package/dist/svelte/router/guards.ts +112 -0
- package/dist/svelte/router/index.ts +10 -0
- package/dist/svelte/router/lazy.ts +82 -0
- package/dist/svelte/router/lazyModule.ts +74 -0
- package/dist/svelte/router/navigation.ts +412 -0
- package/dist/svelte/router/pushState.ts +7 -4
- package/dist/svelte/router/scroll.ts +286 -0
- package/dist/svelte/server.js +747 -252
- package/dist/svelte/server.js.map +30 -20
- package/dist/types/angular.d.ts +2 -0
- package/dist/types/build.d.ts +37 -0
- package/dist/types/conventions.d.ts +3 -0
- package/dist/types/fileRoutes.d.ts +72 -0
- package/dist/types/fonts.d.ts +86 -0
- package/dist/types/formAction.d.ts +54 -0
- package/dist/types/globals.d.ts +10 -0
- package/dist/types/i18n.d.ts +185 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/metadata.d.ts +11 -0
- package/dist/types/navigation.d.ts +37 -0
- package/dist/types/prefetch.d.ts +10 -0
- package/dist/types/sitemap.d.ts +4 -0
- package/dist/types/svelteRouter.d.ts +89 -2
- package/dist/types/svelteRouter.ts +112 -2
- package/dist/types/vue.d.ts +46 -1
- package/dist/utils/iconVersion.ts +34 -0
- package/dist/vue/browser.js +107 -11
- package/dist/vue/browser.js.map +7 -4
- package/dist/vue/components/index.js +5 -2
- package/dist/vue/components/index.js.map +5 -4
- package/dist/vue/index.js +712 -158
- package/dist/vue/index.js.map +32 -23
- package/dist/vue/server.js +310 -79
- package/dist/vue/server.js.map +20 -15
- package/package.json +9 -1
- package/dist/cli/prerender-mfnwsvyt.js +0 -7
- package/dist/src/plugins/pageRouter.d.ts +0 -1
- /package/dist/cli/{index-j7m8pq48.js → index-rervww4p.js} +0 -0
package/dist/islands/index.js
CHANGED
|
@@ -165,7 +165,7 @@ var resolveAngularPackageDir = (specifier) => {
|
|
|
165
165
|
var init_resolveAngularPackage = () => {};
|
|
166
166
|
|
|
167
167
|
// src/utils/runtimeMode.ts
|
|
168
|
-
var ENV_VAR = "NODE_ENV", isDevelopmentRuntime = () => process.env[ENV_VAR] === "development", isProductionRuntime = () => process.env[ENV_VAR] === "production";
|
|
168
|
+
var ENV_VAR = "NODE_ENV", getNodeEnv = () => process.env[ENV_VAR], isDevelopmentRuntime = () => process.env[ENV_VAR] === "development", isProductionRuntime = () => process.env[ENV_VAR] === "production";
|
|
169
169
|
|
|
170
170
|
// src/angular/angularPatch.ts
|
|
171
171
|
var ensureHead = (doc) => {
|
|
@@ -340,6 +340,7 @@ var initDominoAdapter = (platformServer) => {
|
|
|
340
340
|
APP_BASE_HREF: common.APP_BASE_HREF,
|
|
341
341
|
bootstrapApplication: platformBrowser.bootstrapApplication,
|
|
342
342
|
Component: core.Component,
|
|
343
|
+
CSP_NONCE: core.CSP_NONCE,
|
|
343
344
|
DomSanitizer: platformBrowser.DomSanitizer,
|
|
344
345
|
ENVIRONMENT_INITIALIZER: core.ENVIRONMENT_INITIALIZER,
|
|
345
346
|
inject: core.inject,
|
|
@@ -347,6 +348,7 @@ var initDominoAdapter = (platformServer) => {
|
|
|
347
348
|
NgComponentOutlet: common.NgComponentOutlet,
|
|
348
349
|
provideClientHydration: platformBrowser.provideClientHydration,
|
|
349
350
|
provideServerRendering: platformServer.provideServerRendering,
|
|
351
|
+
provideZoneChangeDetection: core.provideZoneChangeDetection,
|
|
350
352
|
provideZonelessChangeDetection: core.provideZonelessChangeDetection,
|
|
351
353
|
reflectComponentType: core.reflectComponentType,
|
|
352
354
|
renderApplication: platformServer.renderApplication,
|
|
@@ -367,6 +369,34 @@ var init_angularDeps = __esm(() => {
|
|
|
367
369
|
init_resolveAngularPackage();
|
|
368
370
|
});
|
|
369
371
|
|
|
372
|
+
// src/utils/escapeScriptContent.ts
|
|
373
|
+
var ESCAPE_LOOKUP, ESCAPE_REGEX, escapeScriptContent = (content) => content.replace(ESCAPE_REGEX, (char) => {
|
|
374
|
+
const escaped = ESCAPE_LOOKUP[char];
|
|
375
|
+
return escaped !== undefined ? escaped : char;
|
|
376
|
+
});
|
|
377
|
+
var init_escapeScriptContent = __esm(() => {
|
|
378
|
+
ESCAPE_LOOKUP = {
|
|
379
|
+
"\u2028": "\\u2028",
|
|
380
|
+
"\u2029": "\\u2029",
|
|
381
|
+
"<": "\\u003C"
|
|
382
|
+
};
|
|
383
|
+
ESCAPE_REGEX = /[<\u2028\u2029]/g;
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
// src/utils/cspNonceRef.ts
|
|
387
|
+
var GETTER_KEY, nonceAttr = (nonce = readCspNonce()) => nonce ? ` nonce="${nonce}"` : "", nonceSvelteHeadStyles = (head, nonce = readCspNonce()) => nonce ? head.replace(/<style(?=\s+id="svelte-[^"]*")(?![^>]*\snonce=)/g, `<style nonce="${nonce}"`) : head, readCspNonce = () => {
|
|
388
|
+
const getter = Reflect.get(globalThis, GETTER_KEY);
|
|
389
|
+
if (typeof getter !== "function")
|
|
390
|
+
return;
|
|
391
|
+
const nonce = getter();
|
|
392
|
+
return typeof nonce === "string" ? nonce : undefined;
|
|
393
|
+
}, registerCspNonceGetter = (getter) => {
|
|
394
|
+
Reflect.set(globalThis, GETTER_KEY, getter);
|
|
395
|
+
};
|
|
396
|
+
var init_cspNonceRef = __esm(() => {
|
|
397
|
+
GETTER_KEY = Symbol.for("absolutejs.cspNonceGetter");
|
|
398
|
+
});
|
|
399
|
+
|
|
370
400
|
// src/utils/registerClientScript.ts
|
|
371
401
|
var scriptRegistry, requestCounter = 0, getRequestId = () => `req_${Date.now()}_${++requestCounter}`, ssrContextGetter = null, getSsrContextId = () => ssrContextGetter?.() || Object.getOwnPropertyDescriptor(globalThis, "__absolutejs_requestId")?.value, registerClientScript = (script, requestId) => {
|
|
372
402
|
const id = requestId || getSsrContextId() || getRequestId();
|
|
@@ -422,7 +452,7 @@ var scriptRegistry, requestCounter = 0, getRequestId = () => `req_${Date.now()}_
|
|
|
422
452
|
})();`;
|
|
423
453
|
}).join(`
|
|
424
454
|
`);
|
|
425
|
-
return `<script>
|
|
455
|
+
return `<script${nonceAttr()}>
|
|
426
456
|
(function() {
|
|
427
457
|
${scriptCode}
|
|
428
458
|
})();
|
|
@@ -440,6 +470,7 @@ ${scriptCode}
|
|
|
440
470
|
return scriptArray;
|
|
441
471
|
};
|
|
442
472
|
var init_registerClientScript = __esm(() => {
|
|
473
|
+
init_cspNonceRef();
|
|
443
474
|
scriptRegistry = new Map;
|
|
444
475
|
if (typeof globalThis !== "undefined") {
|
|
445
476
|
Object.assign(globalThis, { registerClientScript });
|
|
@@ -458,7 +489,7 @@ var init_browserTranslationAttributes = __esm(() => {
|
|
|
458
489
|
});
|
|
459
490
|
|
|
460
491
|
// src/core/browserTranslation.ts
|
|
461
|
-
var BASELINE_MARKER = "__ABSOLUTE_SSR_TEXT_BASELINES__", BROWSER_TRANSLATION_BASELINE_SCRIPT, browserTranslationBaselineTag = () => `<script>${BROWSER_TRANSLATION_BASELINE_SCRIPT}</script>`, injectBrowserTranslationBaseline = (html) => {
|
|
492
|
+
var BASELINE_MARKER = "__ABSOLUTE_SSR_TEXT_BASELINES__", BROWSER_TRANSLATION_BASELINE_SCRIPT, browserTranslationBaselineTag = () => `<script${nonceAttr()}>${BROWSER_TRANSLATION_BASELINE_SCRIPT}</script>`, injectBrowserTranslationBaseline = (html) => {
|
|
462
493
|
if (html.includes(BASELINE_MARKER))
|
|
463
494
|
return html;
|
|
464
495
|
const script = browserTranslationBaselineTag();
|
|
@@ -468,6 +499,7 @@ var BASELINE_MARKER = "__ABSOLUTE_SSR_TEXT_BASELINES__", BROWSER_TRANSLATION_BAS
|
|
|
468
499
|
return `${html.slice(0, closingBodyIndex)}${script}${html.slice(closingBodyIndex)}`;
|
|
469
500
|
};
|
|
470
501
|
var init_browserTranslation = __esm(() => {
|
|
502
|
+
init_cspNonceRef();
|
|
471
503
|
init_browserTranslationAttributes();
|
|
472
504
|
BROWSER_TRANSLATION_BASELINE_SCRIPT = "window.__ABSOLUTE_SSR_TEXT_BASELINES__=new WeakMap();" + "window.__ABSOLUTE_SSR_ATTRIBUTE_BASELINES__=new WeakMap();" + "{const r=document.body,b=window.__ABSOLUTE_SSR_TEXT_BASELINES__," + "a=window.__ABSOLUTE_SSR_ATTRIBUTE_BASELINES__;" + 'if(r)for(const e of [r,...r.querySelectorAll("*")]){' + "const t=new Map();for(const [i,n]of[...e.childNodes].entries())" + 'if(n.nodeType===3)t.set(i,n.nodeValue??"");if(t.size)b.set(e,t);' + `const v=new Map();for(const k of ${JSON.stringify(TRANSLATABLE_ATTRIBUTES)}){` + "const s=e.getAttribute(k);if(s!==null)v.set(k,s);}if(v.size)a.set(e,v);}}";
|
|
473
505
|
});
|
|
@@ -494,6 +526,81 @@ var buildRequestProviders = (deps, request, requestContext, responseInit) => [
|
|
|
494
526
|
{ provide: deps.RESPONSE_INIT, useValue: responseInit ?? null }
|
|
495
527
|
];
|
|
496
528
|
|
|
529
|
+
// src/angular/zoneRuntime.ts
|
|
530
|
+
var ZONE_NODE_SPECIFIER = "zone.js/node", MISSING_ZONE_MESSAGE = 'angular.changeDetection is "zone" but zone.js could not be loaded. Install it in your app (bun add zone.js).', isAngularZoneMode = () => globalThis.__absoluteAngularChangeDetection === "zone", setAngularChangeDetection = (mode) => {
|
|
531
|
+
globalThis.__absoluteAngularChangeDetection = mode ?? "zoneless";
|
|
532
|
+
}, isRecord2 = (value) => typeof value === "object" && value !== null, adoptIntoNativePromise = (NativePromise, value) => {
|
|
533
|
+
if (value instanceof NativePromise || !isRecord2(value))
|
|
534
|
+
return value;
|
|
535
|
+
const { then } = value;
|
|
536
|
+
if (typeof then !== "function")
|
|
537
|
+
return value;
|
|
538
|
+
return new NativePromise((resolve, reject) => {
|
|
539
|
+
Reflect.apply(then, value, [resolve, reject]);
|
|
540
|
+
});
|
|
541
|
+
}, wrapHandler = (NativePromise, handler) => {
|
|
542
|
+
if (typeof handler !== "function")
|
|
543
|
+
return handler;
|
|
544
|
+
return function nativePromiseHandler(...args) {
|
|
545
|
+
return adoptIntoNativePromise(NativePromise, Reflect.apply(handler, this, args));
|
|
546
|
+
};
|
|
547
|
+
}, wrapRoute = (NativePromise, route) => {
|
|
548
|
+
if (typeof route === "function")
|
|
549
|
+
return wrapHandler(NativePromise, route);
|
|
550
|
+
if (!isRecord2(route) || route instanceof Response || route instanceof Blob)
|
|
551
|
+
return route;
|
|
552
|
+
return Object.fromEntries(Object.entries(route).map(([method, handler]) => [
|
|
553
|
+
method,
|
|
554
|
+
wrapHandler(NativePromise, handler)
|
|
555
|
+
]));
|
|
556
|
+
}, wrapServeOptions = (NativePromise, options) => {
|
|
557
|
+
if (!isRecord2(options))
|
|
558
|
+
return options;
|
|
559
|
+
const wrapped = { ...options };
|
|
560
|
+
if (options.fetch)
|
|
561
|
+
wrapped.fetch = wrapHandler(NativePromise, options.fetch);
|
|
562
|
+
if (options.error)
|
|
563
|
+
wrapped.error = wrapHandler(NativePromise, options.error);
|
|
564
|
+
if (isRecord2(options.routes))
|
|
565
|
+
wrapped.routes = Object.fromEntries(Object.entries(options.routes).map(([path, route]) => [
|
|
566
|
+
path,
|
|
567
|
+
wrapRoute(NativePromise, route)
|
|
568
|
+
]));
|
|
569
|
+
return wrapped;
|
|
570
|
+
}, wrapServerReload = (NativePromise, server) => {
|
|
571
|
+
if (!isRecord2(server))
|
|
572
|
+
return;
|
|
573
|
+
const { reload } = server;
|
|
574
|
+
if (typeof reload !== "function")
|
|
575
|
+
return;
|
|
576
|
+
Reflect.set(server, "reload", (options) => Reflect.apply(reload, server, [
|
|
577
|
+
wrapServeOptions(NativePromise, options)
|
|
578
|
+
]));
|
|
579
|
+
}, patchBunServe = (NativePromise) => {
|
|
580
|
+
const originalServe = Bun.serve;
|
|
581
|
+
Reflect.set(Bun, "serve", (options) => {
|
|
582
|
+
const server = Reflect.apply(originalServe, Bun, [
|
|
583
|
+
wrapServeOptions(NativePromise, options)
|
|
584
|
+
]);
|
|
585
|
+
wrapServerReload(NativePromise, server);
|
|
586
|
+
return server;
|
|
587
|
+
});
|
|
588
|
+
wrapServerReload(NativePromise, globalThis.__absoluteBunServer);
|
|
589
|
+
}, installation = null, isPromiseConstructor = (value) => typeof value === "function", install = async () => {
|
|
590
|
+
setAngularChangeDetection("zone");
|
|
591
|
+
const savedNative = Reflect.get(globalThis, "__zone_symbol__Promise");
|
|
592
|
+
const NativePromise = isPromiseConstructor(savedNative) ? savedNative : globalThis.Promise;
|
|
593
|
+
try {
|
|
594
|
+
await import(ZONE_NODE_SPECIFIER);
|
|
595
|
+
} catch (error) {
|
|
596
|
+
throw new Error(MISSING_ZONE_MESSAGE, { cause: error });
|
|
597
|
+
}
|
|
598
|
+
patchBunServe(NativePromise);
|
|
599
|
+
}, installAngularZoneRuntime = () => {
|
|
600
|
+
installation ??= install();
|
|
601
|
+
return installation;
|
|
602
|
+
};
|
|
603
|
+
|
|
497
604
|
// src/angular/ssrRender.ts
|
|
498
605
|
var routeContextCache, cacheRouteData = (pagePath, data) => {
|
|
499
606
|
const cacheKey = pagePath.split("?")[0] ?? pagePath;
|
|
@@ -501,7 +608,7 @@ var routeContextCache, cacheRouteData = (pagePath, data) => {
|
|
|
501
608
|
}, getCachedRouteData = (pagePath) => routeContextCache.get(pagePath), selectorCache, buildProviders = (deps, sanitizer, request, requestContext, responseInit, userProviders = []) => [
|
|
502
609
|
deps.provideServerRendering(),
|
|
503
610
|
deps.provideClientHydration(deps.withHttpTransferCacheOptions(buildAbsoluteHttpTransferCacheOptions())),
|
|
504
|
-
deps.provideZonelessChangeDetection(),
|
|
611
|
+
isAngularZoneMode() ? deps.provideZoneChangeDetection({ eventCoalescing: true }) : deps.provideZonelessChangeDetection(),
|
|
505
612
|
{ provide: deps.APP_BASE_HREF, useValue: "/" },
|
|
506
613
|
{ provide: deps.DomSanitizer, useValue: sanitizer },
|
|
507
614
|
{ provide: deps.Sanitizer, useValue: sanitizer },
|
|
@@ -530,15 +637,17 @@ var routeContextCache, cacheRouteData = (pagePath, data) => {
|
|
|
530
637
|
result = injectBeforeClose(result, generateClientScriptCode(registeredScripts));
|
|
531
638
|
}
|
|
532
639
|
if (requestContext !== undefined) {
|
|
533
|
-
result = injectBeforeClose(result, `<script>window.__ABS_ANGULAR_REQUEST_CONTEXT__ = ${JSON.stringify(requestContext)};</script>`);
|
|
640
|
+
result = injectBeforeClose(result, `<script${nonceAttr()}>window.__ABS_ANGULAR_REQUEST_CONTEXT__ = ${escapeScriptContent(JSON.stringify(requestContext))};</script>`);
|
|
534
641
|
}
|
|
535
642
|
if (indexPath) {
|
|
536
643
|
const escapedIndexPath = JSON.stringify(indexPath);
|
|
537
|
-
result = injectBeforeClose(result, `<script>import(${escapedIndexPath});</script>`);
|
|
644
|
+
result = injectBeforeClose(result, `<script${nonceAttr()}>import(${escapeScriptContent(escapedIndexPath)});</script>`);
|
|
538
645
|
}
|
|
539
646
|
return result;
|
|
540
647
|
}, renderAngularApp = async (deps, PageComponent, providers, document, url = "/") => {
|
|
541
|
-
const
|
|
648
|
+
const nonce = readCspNonce();
|
|
649
|
+
const cspProviders = nonce ? [{ provide: deps.CSP_NONCE, useValue: nonce }] : [];
|
|
650
|
+
const bootstrap = (context) => deps.bootstrapApplication(PageComponent, { providers: [...providers, ...cspProviders] }, context);
|
|
542
651
|
return withSuppressedAngularDevLogs(() => deps.renderApplication(bootstrap, {
|
|
543
652
|
document,
|
|
544
653
|
platformProviders: [],
|
|
@@ -559,6 +668,8 @@ var routeContextCache, cacheRouteData = (pagePath, data) => {
|
|
|
559
668
|
}
|
|
560
669
|
};
|
|
561
670
|
var init_ssrRender = __esm(() => {
|
|
671
|
+
init_escapeScriptContent();
|
|
672
|
+
init_cspNonceRef();
|
|
562
673
|
init_registerClientScript();
|
|
563
674
|
init_browserTranslation();
|
|
564
675
|
routeContextCache = new Map;
|
|
@@ -1322,47 +1433,140 @@ var init_lowerIslandSyntax = __esm(() => {
|
|
|
1322
1433
|
});
|
|
1323
1434
|
|
|
1324
1435
|
// src/svelte/lowerAwaitSlotSyntax.ts
|
|
1325
|
-
var
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
}
|
|
1330
|
-
if (
|
|
1436
|
+
var AWAIT_STREAM_DIRECTIVE = "<!-- absolute:stream -->", DIRECTIVE_RE, BRANCH_TAG_RE, SVELTE_ONLY_MARKUP_RE, QUOTES, scanCharacter = (scan, char) => {
|
|
1437
|
+
if (scan.escaped) {
|
|
1438
|
+
scan.escaped = false;
|
|
1439
|
+
return;
|
|
1440
|
+
}
|
|
1441
|
+
if (scan.quote) {
|
|
1442
|
+
scan.escaped = char === "\\";
|
|
1443
|
+
if (char === scan.quote)
|
|
1444
|
+
scan.quote = null;
|
|
1445
|
+
return;
|
|
1446
|
+
}
|
|
1447
|
+
if (QUOTES.has(char))
|
|
1448
|
+
scan.quote = char;
|
|
1449
|
+
if (char === "{")
|
|
1450
|
+
scan.depth += 1;
|
|
1451
|
+
if (char === "}")
|
|
1452
|
+
scan.depth -= 1;
|
|
1453
|
+
}, findTagEnd = (source, start) => {
|
|
1454
|
+
const scan = { depth: 0, escaped: false, quote: null };
|
|
1455
|
+
for (let index = start;index < source.length; index += 1) {
|
|
1456
|
+
scanCharacter(scan, source[index] ?? "");
|
|
1457
|
+
if (scan.depth === 0)
|
|
1458
|
+
return index + 1;
|
|
1459
|
+
}
|
|
1460
|
+
return -1;
|
|
1461
|
+
}, topLevelTags = (markup) => {
|
|
1462
|
+
const tags = [];
|
|
1463
|
+
let index = markup.indexOf("{");
|
|
1464
|
+
while (index !== -1) {
|
|
1465
|
+
const end = findTagEnd(markup, index);
|
|
1466
|
+
if (end === -1)
|
|
1467
|
+
break;
|
|
1468
|
+
tags.push({ end, start: index, text: markup.slice(index, end) });
|
|
1469
|
+
index = markup.indexOf("{", end);
|
|
1470
|
+
}
|
|
1471
|
+
return tags;
|
|
1472
|
+
}, escapeTemplateLiteral = (value) => value.replaceAll("\\", "\\\\").replaceAll("`", "\\`").replaceAll("${", "\\${"), markupToTemplateLiteral = (markup) => {
|
|
1473
|
+
const parts = topLevelTags(markup.trim());
|
|
1474
|
+
const trimmed = markup.trim();
|
|
1475
|
+
let cursor = 0;
|
|
1476
|
+
let literal = "";
|
|
1477
|
+
for (const { end, start, text } of parts) {
|
|
1478
|
+
literal += escapeTemplateLiteral(trimmed.slice(cursor, start));
|
|
1479
|
+
literal += `\${${text.slice(1, -1).trim()}}`;
|
|
1480
|
+
cursor = end;
|
|
1481
|
+
}
|
|
1482
|
+
literal += escapeTemplateLiteral(trimmed.slice(cursor));
|
|
1483
|
+
return `\`${literal}\``;
|
|
1484
|
+
}, fail = (filePath, message) => {
|
|
1485
|
+
throw new Error(`${filePath ? `${filePath}: ` : ""}${message} (${AWAIT_STREAM_DIRECTIVE} streams plain HTML; remove the directive to let Svelte render the block and hydrate it)`);
|
|
1486
|
+
}, assertPlainHtml = (markup, branch, filePath) => {
|
|
1487
|
+
const withoutExpressions = topLevelTags(markup).reduceRight((text, { end, start }) => text.slice(0, start) + text.slice(end), markup);
|
|
1488
|
+
const nestedTag = topLevelTags(markup).find(({ text }) => /^\{[#:/@]/.test(text));
|
|
1489
|
+
if (nestedTag || SVELTE_ONLY_MARKUP_RE.test(withoutExpressions)) {
|
|
1490
|
+
fail(filePath, `the ${branch} branch of a streamed {#await} holds Svelte markup (${nestedTag?.text ?? withoutExpressions.match(SVELTE_ONLY_MARKUP_RE)?.[0]}\u2026)`);
|
|
1491
|
+
}
|
|
1492
|
+
}, parseStreamedAwait = (source, start, filePath) => {
|
|
1493
|
+
if (!source.startsWith("{#await", start)) {
|
|
1494
|
+
fail(filePath, `${AWAIT_STREAM_DIRECTIVE} must come directly before an {#await} block`);
|
|
1495
|
+
}
|
|
1496
|
+
const headerEnd = findTagEnd(source, start);
|
|
1497
|
+
if (headerEnd === -1)
|
|
1498
|
+
fail(filePath, "unterminated {#await} tag");
|
|
1499
|
+
const expression = source.slice(start + "{#await".length, headerEnd - 1).trim();
|
|
1500
|
+
if (!expression)
|
|
1501
|
+
fail(filePath, "{#await} without an expression");
|
|
1502
|
+
if (/\s(?:then|catch)\b/.test(` ${expression}`)) {
|
|
1503
|
+
fail(filePath, "a streamed {#await} needs a pending branch; the shorthand {#await \u2026 then \u2026} has none");
|
|
1504
|
+
}
|
|
1505
|
+
const close = source.indexOf("{/await}", headerEnd);
|
|
1506
|
+
if (close === -1)
|
|
1507
|
+
fail(filePath, "{#await} without a matching {/await}");
|
|
1508
|
+
const body = source.slice(headerEnd, close);
|
|
1509
|
+
const branchTags = topLevelTags(body).filter(({ text }) => /^\{:/.test(text));
|
|
1510
|
+
const [thenTag, catchTag, extra] = branchTags;
|
|
1511
|
+
const thenMatch = thenTag?.text.match(BRANCH_TAG_RE);
|
|
1512
|
+
const catchMatch = catchTag?.text.match(BRANCH_TAG_RE);
|
|
1513
|
+
if (!thenTag || thenMatch?.[1] !== "then" || catchTag && catchMatch?.[1] !== "catch" || extra) {
|
|
1514
|
+
fail(filePath, "a streamed {#await} takes exactly one {:then} and at most one {:catch}, in that order");
|
|
1515
|
+
}
|
|
1516
|
+
const pendingMarkup = body.slice(0, thenTag?.start);
|
|
1517
|
+
const thenMarkup = body.slice(thenTag?.end, catchTag?.start);
|
|
1518
|
+
const catchMarkup = catchTag ? body.slice(catchTag.end) : undefined;
|
|
1519
|
+
assertPlainHtml(pendingMarkup, "pending", filePath);
|
|
1520
|
+
assertPlainHtml(thenMarkup, "then", filePath);
|
|
1521
|
+
if (catchMarkup !== undefined)
|
|
1522
|
+
assertPlainHtml(catchMarkup, "catch", filePath);
|
|
1523
|
+
return {
|
|
1524
|
+
catchIdentifier: catchMatch?.[2],
|
|
1525
|
+
catchMarkup,
|
|
1526
|
+
end: close + "{/await}".length,
|
|
1527
|
+
expression,
|
|
1528
|
+
pendingMarkup,
|
|
1529
|
+
thenIdentifier: thenMatch?.[2],
|
|
1530
|
+
thenMarkup
|
|
1531
|
+
};
|
|
1532
|
+
}, renderSlot = (block, slotId, dynamic) => {
|
|
1533
|
+
const thenValueIdentifier = block.thenIdentifier ?? "__awaitValue";
|
|
1534
|
+
const catchValueIdentifier = block.catchIdentifier ?? "__awaitError";
|
|
1535
|
+
const catchBranch = block.catchMarkup === undefined ? "catch (_absoluteAwaitError) { throw _absoluteAwaitError; }" : `catch (${catchValueIdentifier}) { return ${markupToTemplateLiteral(block.catchMarkup)}; }`;
|
|
1536
|
+
return `<AbsoluteAwaitSlot id="${slotId}"${dynamic ? " dynamic" : ""} fallbackHtml={${markupToTemplateLiteral(block.pendingMarkup)}} resolve={async () => { try { const ${thenValueIdentifier} = await (${block.expression}); return ${markupToTemplateLiteral(block.thenMarkup)}; } ${catchBranch} }} />`;
|
|
1537
|
+
}, IMPORT_LINE = 'import AbsoluteAwaitSlot from "@absolutejs/absolute/svelte/components/AwaitSlot.svelte";', lowerSvelteAwaitSlotSyntax = (source, filePath) => {
|
|
1538
|
+
if (!source.includes("absolute:stream")) {
|
|
1331
1539
|
return { code: source, transformed: false };
|
|
1332
1540
|
}
|
|
1541
|
+
let lowered = "";
|
|
1542
|
+
let cursor = 0;
|
|
1333
1543
|
let awaitIndex = 0;
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
}
|
|
1544
|
+
for (const directive of source.matchAll(DIRECTIVE_RE)) {
|
|
1545
|
+
const awaitStart = directive.index + directive[0].length;
|
|
1546
|
+
if (awaitStart < cursor)
|
|
1547
|
+
continue;
|
|
1548
|
+
const block = parseStreamedAwait(source, awaitStart, filePath);
|
|
1340
1549
|
const slotId = `absolute-svelte-await-${awaitIndex.toString(BASE_36_RADIX)}`;
|
|
1341
1550
|
awaitIndex += 1;
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
const rejectedHtml = typeof catchMarkup === "string" ? markupToTemplateLiteral(catchMarkup) : null;
|
|
1348
|
-
const catchBranch = rejectedHtml ? `catch (${catchValueIdentifier}) { return ${rejectedHtml}; }` : "catch (_absoluteAwaitError) { throw _absoluteAwaitError; }";
|
|
1349
|
-
return `<AbsoluteAwaitSlot id="${slotId}" fallbackHtml={${fallbackHtml}} resolve={async () => { try { const ${thenValueIdentifier} = await (${trimmedAwaitExpression}); return ${resolvedHtml}; } ${catchBranch} }} />`;
|
|
1350
|
-
});
|
|
1351
|
-
if (!transformed) {
|
|
1551
|
+
lowered += source.slice(cursor, directive.index);
|
|
1552
|
+
lowered += renderSlot(block, slotId, directive[1] !== undefined);
|
|
1553
|
+
cursor = block.end;
|
|
1554
|
+
}
|
|
1555
|
+
if (awaitIndex === 0) {
|
|
1352
1556
|
return { code: source, transformed: false };
|
|
1353
1557
|
}
|
|
1354
|
-
|
|
1558
|
+
lowered += source.slice(cursor);
|
|
1355
1559
|
if (lowered.includes("<script")) {
|
|
1356
1560
|
return {
|
|
1357
1561
|
code: lowered.replace(/<script(\s[^>]*)?>/, (match) => `${match}
|
|
1358
|
-
${
|
|
1562
|
+
${IMPORT_LINE}
|
|
1359
1563
|
`),
|
|
1360
1564
|
transformed: true
|
|
1361
1565
|
};
|
|
1362
1566
|
}
|
|
1363
1567
|
return {
|
|
1364
1568
|
code: `<script lang="ts">
|
|
1365
|
-
${
|
|
1569
|
+
${IMPORT_LINE}
|
|
1366
1570
|
</script>
|
|
1367
1571
|
${lowered}`,
|
|
1368
1572
|
transformed: true
|
|
@@ -1370,7 +1574,10 @@ ${lowered}`,
|
|
|
1370
1574
|
};
|
|
1371
1575
|
var init_lowerAwaitSlotSyntax = __esm(() => {
|
|
1372
1576
|
init_constants();
|
|
1373
|
-
|
|
1577
|
+
DIRECTIVE_RE = /<!--\s*absolute:stream(\s+dynamic)?\s*-->\s*/g;
|
|
1578
|
+
BRANCH_TAG_RE = /^\{:(then|catch)(?:\s+([A-Za-z_$][\w$]*))?\s*\}$/;
|
|
1579
|
+
SVELTE_ONLY_MARKUP_RE = /\{[#:/@]|<[A-Z]|<svelte:/;
|
|
1580
|
+
QUOTES = new Set(['"', "'", "`"]);
|
|
1374
1581
|
});
|
|
1375
1582
|
|
|
1376
1583
|
// src/build/stylePreprocessor.ts
|
|
@@ -1562,7 +1769,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
1562
1769
|
const config = normalizePostcssModule(loaded);
|
|
1563
1770
|
const value = typeof config === "function" ? await config({
|
|
1564
1771
|
cwd: process.cwd(),
|
|
1565
|
-
env:
|
|
1772
|
+
env: getNodeEnv()
|
|
1566
1773
|
}) : config;
|
|
1567
1774
|
return normalizePostcssModule(value) ?? {};
|
|
1568
1775
|
}, normalizePostcssPlugins = (plugins) => {
|
|
@@ -1928,10 +2135,10 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
1928
2135
|
return resolveCssImportsSync(result.css, dirname2(filePath), new Set([filePath]));
|
|
1929
2136
|
}
|
|
1930
2137
|
if (language === "less") {
|
|
1931
|
-
throw new Error(`Unable to compile ${filePath}: Less
|
|
2138
|
+
throw new Error(`Unable to compile ${filePath} synchronously: Less only has an async compiler. Compile it with compileStyleFileIfNeeded() instead.`);
|
|
1932
2139
|
}
|
|
1933
2140
|
if (language === "stylus") {
|
|
1934
|
-
throw new Error(`Unable to compile ${filePath}: Stylus
|
|
2141
|
+
throw new Error(`Unable to compile ${filePath} synchronously: Stylus only has an async compiler. Compile it with compileStyleFileIfNeeded() instead.`);
|
|
1935
2142
|
}
|
|
1936
2143
|
return resolveCssImportsSync(rawContents, dirname2(filePath), new Set([filePath]));
|
|
1937
2144
|
};
|
|
@@ -1949,6 +2156,32 @@ var init_stylePreprocessor = __esm(() => {
|
|
|
1949
2156
|
CSS_IMPORT_PATTERN = /@import\s+["']([^"']+)["']\s*;?/g;
|
|
1950
2157
|
});
|
|
1951
2158
|
|
|
2159
|
+
// src/svelte/router/lazyModule.ts
|
|
2160
|
+
var LAZY_RESOLVED_KEY, LAZY_SOURCE_EXPORT = "__ABSOLUTE_SVELTE_SOURCE__", isRecord3 = (value) => typeof value === "object" && value !== null, isComponent = (value) => typeof value === "function", toLazyComponent = (value) => {
|
|
2161
|
+
if (isComponent(value))
|
|
2162
|
+
return value;
|
|
2163
|
+
if (!isRecord3(value))
|
|
2164
|
+
return;
|
|
2165
|
+
const fallback = value.default;
|
|
2166
|
+
return isComponent(fallback) ? fallback : undefined;
|
|
2167
|
+
}, readSourceFrom = (value) => {
|
|
2168
|
+
if (!isRecord3(value) && !isComponent(value))
|
|
2169
|
+
return;
|
|
2170
|
+
const source = Reflect.get(value, LAZY_SOURCE_EXPORT);
|
|
2171
|
+
return typeof source === "string" ? source : undefined;
|
|
2172
|
+
}, lazyModuleRegistration = (sourceId, specifier) => `
|
|
2173
|
+
;(globalThis[Symbol.for("absolutejs.svelte.lazy-modules")] ??= new Map()).set(${JSON.stringify(sourceId)}, () => import(${JSON.stringify(specifier)}));`, readLazySource = (value) => {
|
|
2174
|
+
const fromValue = readSourceFrom(value);
|
|
2175
|
+
if (fromValue !== undefined)
|
|
2176
|
+
return fromValue;
|
|
2177
|
+
if (!isRecord3(value))
|
|
2178
|
+
return;
|
|
2179
|
+
return readSourceFrom(value.default);
|
|
2180
|
+
};
|
|
2181
|
+
var init_lazyModule = __esm(() => {
|
|
2182
|
+
LAZY_RESOLVED_KEY = Symbol.for("absolutejs.svelte.lazy-resolved");
|
|
2183
|
+
});
|
|
2184
|
+
|
|
1952
2185
|
// src/core/svelteServerModule.ts
|
|
1953
2186
|
import { mkdir as mkdir2, readdir as readdir2 } from "fs/promises";
|
|
1954
2187
|
import { basename, dirname as dirname3, extname as extname2, join as join6, relative as relative3, resolve as resolve4 } from "path";
|
|
@@ -2058,11 +2291,11 @@ var serverCacheRoot2, compiledModuleCache2, originalSourcePathCache, transpiler,
|
|
|
2058
2291
|
const resolutionSourcePath = await resolveOriginalSourcePath(sourcePath);
|
|
2059
2292
|
const source = await Bun.file(sourcePath).text();
|
|
2060
2293
|
const { compile, preprocess } = await import("svelte/compiler");
|
|
2061
|
-
const loweredAwaitSource = lowerSvelteAwaitSlotSyntax(source);
|
|
2294
|
+
const loweredAwaitSource = lowerSvelteAwaitSlotSyntax(source, sourcePath);
|
|
2062
2295
|
const loweredSource = lowerSvelteIslandSyntax(loweredAwaitSource.code, "server");
|
|
2063
2296
|
const preprocessed = await preprocess(loweredSource.code, createSvelteStylePreprocessor());
|
|
2064
2297
|
let transpiled = sourcePath.endsWith(".ts") || sourcePath.endsWith(".svelte.ts") ? transpiler.transformSync(preprocessed.code) : preprocessed.code;
|
|
2065
|
-
const childImportSpecs = Array.from(transpiled.matchAll(/from\s
|
|
2298
|
+
const childImportSpecs = Array.from(new Set(Array.from(transpiled.matchAll(/(?:from\s+|\bimport\s*\(\s*)['"]([^'"]+)['"]/g)).map((match) => match[1]).filter((value) => value !== undefined)));
|
|
2066
2299
|
const resolvedChildModules = await Promise.all(childImportSpecs.map((spec) => resolveSvelteImport(spec, resolutionSourcePath)));
|
|
2067
2300
|
const resolvedModuleImports = await Promise.all(childImportSpecs.map((spec) => resolveRelativeModule(spec, resolutionSourcePath)));
|
|
2068
2301
|
const childModulePaths = new Map;
|
|
@@ -2109,6 +2342,14 @@ var serverCacheRoot2, compiledModuleCache2, originalSourcePathCache, transpiler,
|
|
|
2109
2342
|
for (const [spec, resolvedModuleImport] of rewrittenModulePaths) {
|
|
2110
2343
|
compiledCode = compiledCode.replaceAll(spec, resolvedModuleImport);
|
|
2111
2344
|
}
|
|
2345
|
+
const sourceId = JSON.stringify(relative3(process.cwd(), resolutionSourcePath).replace(/\\/g, "/"));
|
|
2346
|
+
const componentName = /export default function ([\w$]+)\s*\(/.exec(compiledCode)?.[1];
|
|
2347
|
+
compiledCode += `
|
|
2348
|
+
export const ${LAZY_SOURCE_EXPORT} = ${sourceId};`;
|
|
2349
|
+
if (componentName) {
|
|
2350
|
+
compiledCode += `
|
|
2351
|
+
${componentName}.${LAZY_SOURCE_EXPORT} = ${sourceId};`;
|
|
2352
|
+
}
|
|
2112
2353
|
const compiledModulePath = getCachedModulePath2(sourcePath);
|
|
2113
2354
|
await mkdir2(dirname3(compiledModulePath), { recursive: true });
|
|
2114
2355
|
await writeIfChanged(compiledModulePath, compiledCode);
|
|
@@ -2120,6 +2361,7 @@ var init_svelteServerModule = __esm(() => {
|
|
|
2120
2361
|
init_lowerIslandSyntax();
|
|
2121
2362
|
init_lowerAwaitSlotSyntax();
|
|
2122
2363
|
init_stylePreprocessor();
|
|
2364
|
+
init_lazyModule();
|
|
2123
2365
|
serverCacheRoot2 = join6(process.cwd(), ".absolutejs", "islands", "svelte");
|
|
2124
2366
|
compiledModuleCache2 = new Map;
|
|
2125
2367
|
originalSourcePathCache = new Map;
|
|
@@ -2269,7 +2511,7 @@ var init_islandMarkupAttributes = __esm(() => {
|
|
|
2269
2511
|
var islandSequence = 0, resolvedServerComponentCache, resolvedServerBuildComponentCache, nextIslandId = () => {
|
|
2270
2512
|
islandSequence += 1;
|
|
2271
2513
|
return `island-${islandSequence}`;
|
|
2272
|
-
},
|
|
2514
|
+
}, isRecord4 = (value) => typeof value === "object" && value !== null, isReactServerIslandComponent = (value) => typeof value === "function", isSvelteServerIslandComponent = (value) => typeof value === "function", isVueServerIslandComponent = (value) => typeof value === "function" || isRecord4(value), isAngularServerIslandComponent = (value) => typeof value === "function", resolveBuildReferencePath = (source, registryPath) => {
|
|
2273
2515
|
if (source.startsWith("file://"))
|
|
2274
2516
|
return new URL(source).pathname;
|
|
2275
2517
|
if (source.startsWith("."))
|
|
@@ -2524,5 +2766,5 @@ export {
|
|
|
2524
2766
|
renderIslandMarkup
|
|
2525
2767
|
};
|
|
2526
2768
|
|
|
2527
|
-
//# debugId=
|
|
2769
|
+
//# debugId=EE798A65D10BA6F664756E2164756E21
|
|
2528
2770
|
//# sourceMappingURL=index.js.map
|