@absolutejs/absolute 0.19.0-beta.675 → 0.19.0-beta.677

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.
@@ -0,0 +1,103 @@
1
+ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, NgZone, inject, signal } from '@angular/core';
2
+ import { DomSanitizer } from '@angular/platform-browser';
3
+ import { isStreamingSlotCollectionActive, registerStreamingSlot, warnMissingStreamingSlotCollector } from './core/streamingSlotRegistrar.js';
4
+ import * as i0 from "@angular/core";
5
+ const isObjectRecord = (value) => Boolean(value) && typeof value === 'object';
6
+ const isHtmlPayload = (payload) => isObjectRecord(payload) && typeof payload.html === 'string';
7
+ const resolvePayloadHtml = (payload) => {
8
+ if (isHtmlPayload(payload)) {
9
+ return payload.html;
10
+ }
11
+ return typeof payload === 'string' ? payload : '';
12
+ };
13
+ export class StreamSlotComponent {
14
+ constructor() {
15
+ this.cdr = inject(ChangeDetectorRef);
16
+ this.sanitizer = inject(DomSanitizer);
17
+ this.zone = inject(NgZone);
18
+ this.slotConsumer = (payload) => {
19
+ this.zone.run(() => {
20
+ this.currentHtml.set(this.sanitizer.bypassSecurityTrustHtml(resolvePayloadHtml(payload)));
21
+ this.cdr.markForCheck();
22
+ });
23
+ return true;
24
+ };
25
+ this.fallbackHtml = '';
26
+ this.currentHtml = signal('', ...(ngDevMode ? [{ debugName: "currentHtml" }] : /* istanbul ignore next */ []));
27
+ }
28
+ ngOnInit() {
29
+ if (isStreamingSlotCollectionActive()) {
30
+ this.currentHtml.set(this.sanitizer.bypassSecurityTrustHtml(this.fallbackHtml));
31
+ registerStreamingSlot({
32
+ errorHtml: this.errorHtml,
33
+ fallbackHtml: this.fallbackHtml,
34
+ id: this.id,
35
+ resolve: this.resolve,
36
+ timeoutMs: this.timeoutMs
37
+ });
38
+ return;
39
+ }
40
+ warnMissingStreamingSlotCollector('StreamSlot');
41
+ if (typeof window === 'undefined') {
42
+ this.currentHtml.set(this.sanitizer.bypassSecurityTrustHtml(this.fallbackHtml));
43
+ return;
44
+ }
45
+ const consumers = (window.__ABS_SLOT_CONSUMERS__ =
46
+ window.__ABS_SLOT_CONSUMERS__ ?? {});
47
+ consumers[this.id] = this.slotConsumer;
48
+ this.currentHtml.set(this.sanitizer.bypassSecurityTrustHtml(this.fallbackHtml));
49
+ const pendingPayload = window.__ABS_SLOT_PENDING__?.[this.id];
50
+ if (pendingPayload !== undefined) {
51
+ this.slotConsumer(pendingPayload);
52
+ delete window.__ABS_SLOT_PENDING__?.[this.id];
53
+ }
54
+ }
55
+ ngOnDestroy() {
56
+ if (typeof window === 'undefined')
57
+ return;
58
+ if (window.__ABS_SLOT_CONSUMERS__) {
59
+ delete window.__ABS_SLOT_CONSUMERS__[this.id];
60
+ }
61
+ }
62
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: StreamSlotComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
63
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.6", type: StreamSlotComponent, isStandalone: true, selector: "abs-stream-slot", inputs: { className: "className", errorHtml: "errorHtml", fallbackHtml: "fallbackHtml", id: "id", resolve: "resolve", timeoutMs: "timeoutMs" }, ngImport: i0, template: `
64
+ <div
65
+ [attr.id]="id"
66
+ [attr.class]="className"
67
+ data-absolute-raw-slot="true"
68
+ data-absolute-slot="true"
69
+ [innerHTML]="currentHtml()"
70
+ ></div>
71
+ `, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
72
+ }
73
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: StreamSlotComponent, decorators: [{
74
+ type: Component,
75
+ args: [{
76
+ changeDetection: ChangeDetectionStrategy.OnPush,
77
+ selector: 'abs-stream-slot',
78
+ standalone: true,
79
+ template: `
80
+ <div
81
+ [attr.id]="id"
82
+ [attr.class]="className"
83
+ data-absolute-raw-slot="true"
84
+ data-absolute-slot="true"
85
+ [innerHTML]="currentHtml()"
86
+ ></div>
87
+ `
88
+ }]
89
+ }], propDecorators: { className: [{
90
+ type: Input
91
+ }], errorHtml: [{
92
+ type: Input
93
+ }], fallbackHtml: [{
94
+ type: Input
95
+ }], id: [{
96
+ type: Input,
97
+ args: [{ required: true }]
98
+ }], resolve: [{
99
+ type: Input,
100
+ args: [{ required: true }]
101
+ }], timeoutMs: [{
102
+ type: Input
103
+ }] } });
package/dist/build.js CHANGED
@@ -180662,6 +180662,26 @@ var init_rebuildTrigger = __esm(() => {
180662
180662
  HMR_SCRIPT_PATTERN = /<script>window\.__HMR_FRAMEWORK__[\s\S]*?<\/script>\s*<script data-hmr-client>[\s\S]*?<\/script>/;
180663
180663
  });
180664
180664
 
180665
+ // src/utils/startupTimings.ts
180666
+ var startupTimingsEnabled, formatStartupTimingBlock = (title, steps) => {
180667
+ const totalDuration = steps.reduce((sum, step) => sum + step.durationMs, 0);
180668
+ return [
180669
+ title,
180670
+ ...steps.map((step) => ` - ${step.label}: ${getDurationString(step.durationMs)}`),
180671
+ ` Total: ${getDurationString(totalDuration)}`
180672
+ ].join(`
180673
+ `);
180674
+ }, logStartupTimingBlock = (title, steps) => {
180675
+ if (!startupTimingsEnabled || steps.length === 0) {
180676
+ return;
180677
+ }
180678
+ console.log(formatStartupTimingBlock(title, steps));
180679
+ };
180680
+ var init_startupTimings = __esm(() => {
180681
+ init_getDurationString();
180682
+ startupTimingsEnabled = process.env.ABSOLUTE_STARTUP_TIMINGS === "1" || process.env.ABSOLUTE_STARTUP_TIMINGS === "true";
180683
+ });
180684
+
180665
180685
  // src/build/buildDepVendor.ts
180666
180686
  var exports_buildDepVendor = {};
180667
180687
  __export(exports_buildDepVendor, {
@@ -180967,9 +180987,21 @@ var FRAMEWORK_DIR_KEYS, collectDepVendorSourceDirs = (config) => {
180967
180987
  await handleCachedReload();
180968
180988
  return cached;
180969
180989
  }
180990
+ const startupSteps = [];
180991
+ const recordStep = (label, startedAt) => {
180992
+ startupSteps.push({
180993
+ label,
180994
+ durationMs: performance.now() - startedAt
180995
+ });
180996
+ };
180997
+ let stepStartedAt = performance.now();
180970
180998
  const state = createHMRState(config);
180999
+ recordStep("create HMR state", stepStartedAt);
181000
+ stepStartedAt = performance.now();
180971
181001
  const watchPaths = getWatchPaths(config, state.resolvedPaths);
180972
181002
  buildInitialDependencyGraph(state.dependencyGraph, watchPaths);
181003
+ recordStep("initialize dependency graph", stepStartedAt);
181004
+ stepStartedAt = performance.now();
180973
181005
  if (config.reactDirectory) {
180974
181006
  setDevVendorPaths(computeVendorPaths());
180975
181007
  }
@@ -180985,7 +181017,10 @@ var FRAMEWORK_DIR_KEYS, collectDepVendorSourceDirs = (config) => {
180985
181017
  const sourceDirs = collectDepVendorSourceDirs(config);
180986
181018
  const { computeDepVendorPaths: computeDepVendorPaths2 } = await Promise.resolve().then(() => (init_buildDepVendor(), exports_buildDepVendor));
180987
181019
  globalThis.__depVendorPaths = await computeDepVendorPaths2(sourceDirs);
181020
+ recordStep("prepare vendor paths", stepStartedAt);
181021
+ stepStartedAt = performance.now();
180988
181022
  await resolveAbsoluteVersion2();
181023
+ recordStep("resolve version", stepStartedAt);
180989
181024
  const buildStart = performance.now();
180990
181025
  const buildResult = await build({
180991
181026
  ...config,
@@ -180997,11 +181032,15 @@ var FRAMEWORK_DIR_KEYS, collectDepVendorSourceDirs = (config) => {
180997
181032
  });
180998
181033
  const manifest = buildResult.manifest ?? {};
180999
181034
  const conventions = buildResult.conventions ?? {};
181035
+ recordStep("initial build", buildStart);
181000
181036
  if (Object.keys(manifest).length === 0) {
181001
181037
  console.log("\u26A0\uFE0F Manifest is empty - this is OK for HTML/HTMX-only projects");
181002
181038
  }
181039
+ stepStartedAt = performance.now();
181003
181040
  await populateAssetStore(state.assetStore, manifest, state.resolvedPaths.buildDir);
181004
181041
  cleanStaleAssets(state.assetStore, manifest, state.resolvedPaths.buildDir);
181042
+ recordStep("populate asset store", stepStartedAt);
181043
+ stepStartedAt = performance.now();
181005
181044
  const buildReactVendorTask = config.reactDirectory ? buildReactVendor(state.resolvedPaths.buildDir).then(async () => {
181006
181045
  const vendorDir = resolve30(state.resolvedPaths.buildDir, "react", "vendor");
181007
181046
  await loadVendorFiles(state.assetStore, vendorDir, "react");
@@ -181039,19 +181078,25 @@ var FRAMEWORK_DIR_KEYS, collectDepVendorSourceDirs = (config) => {
181039
181078
  buildVueVendorTask,
181040
181079
  buildDepVendorTask
181041
181080
  ]);
181081
+ recordStep("build vendor bundles", stepStartedAt);
181082
+ stepStartedAt = performance.now();
181042
181083
  const { warmCompilers: warmCompilers2 } = await Promise.resolve().then(() => (init_moduleServer(), exports_moduleServer));
181043
181084
  await warmCompilers2({
181044
181085
  svelte: Boolean(config.svelteDirectory),
181045
181086
  vue: Boolean(config.vueDirectory)
181046
181087
  });
181088
+ recordStep("warm compilers", stepStartedAt);
181047
181089
  state.manifest = manifest;
181090
+ stepStartedAt = performance.now();
181048
181091
  startFileWatching(state, config, (filePath) => {
181049
181092
  queueFileChange(state, filePath, config, (newBuildResult) => {
181050
181093
  Object.assign(manifest, newBuildResult.manifest);
181051
181094
  state.manifest = manifest;
181052
181095
  });
181053
181096
  });
181097
+ recordStep("start file watching", stepStartedAt);
181054
181098
  globalThis.__hmrBuildDuration = performance.now() - buildStart;
181099
+ logStartupTimingBlock("AbsoluteJS devBuild timing", startupSteps);
181055
181100
  const result = {
181056
181101
  conventions,
181057
181102
  hmrState: state,
@@ -181075,6 +181120,7 @@ var init_devBuild = __esm(() => {
181075
181120
  init_assetStore();
181076
181121
  init_rebuildTrigger();
181077
181122
  init_logger();
181123
+ init_startupTimings();
181078
181124
  FRAMEWORK_DIR_KEYS = [
181079
181125
  "reactDirectory",
181080
181126
  "svelteDirectory",
@@ -181093,5 +181139,5 @@ export {
181093
181139
  build
181094
181140
  };
181095
181141
 
181096
- //# debugId=D556DCD8242176E164756E2164756E21
181142
+ //# debugId=D027877FF10FEE0264756E2164756E21
181097
181143
  //# sourceMappingURL=build.js.map