@hamur/image 0.0.0-stage → 0.0.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 (156) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +24 -2
  3. package/dist/chunks/bun-index-n7xnn0a2.js +502 -0
  4. package/dist/src/adapters/angular.js +275 -0
  5. package/dist/src/adapters/html.js +70 -0
  6. package/dist/src/adapters/preact.js +82 -0
  7. package/dist/src/adapters/react.js +84 -0
  8. package/dist/src/adapters/solid.js +93 -0
  9. package/dist/src/adapters/svelte.js +15 -0
  10. package/dist/src/adapters/vue.js +147 -0
  11. package/dist/src/index.js +1442 -0
  12. package/dist/src/server/index.js +9 -0
  13. package/dist/types/src/adapters/angular-img.d.ts +40 -0
  14. package/dist/types/src/adapters/angular-picture.d.ts +36 -0
  15. package/dist/types/src/adapters/angular.d.ts +3 -0
  16. package/dist/types/src/adapters/html-img.d.ts +10 -0
  17. package/dist/types/src/adapters/html-picture.d.ts +6 -0
  18. package/dist/types/src/adapters/html.d.ts +6 -0
  19. package/dist/types/src/adapters/preact-img.d.ts +8 -0
  20. package/dist/types/src/adapters/preact-picture.d.ts +6 -0
  21. package/dist/types/src/adapters/preact.d.ts +6 -0
  22. package/dist/types/src/adapters/react-img.d.ts +8 -0
  23. package/dist/types/src/adapters/react-picture.d.ts +6 -0
  24. package/dist/types/src/adapters/react.d.ts +6 -0
  25. package/dist/types/src/adapters/solid-img.d.ts +8 -0
  26. package/dist/types/src/adapters/solid-picture.d.ts +6 -0
  27. package/dist/types/src/adapters/solid.d.ts +6 -0
  28. package/dist/types/src/adapters/svelte.d.ts +3 -0
  29. package/dist/types/src/adapters/vue-img.d.ts +119 -0
  30. package/dist/types/src/adapters/vue-picture.d.ts +121 -0
  31. package/dist/types/src/adapters/vue.d.ts +234 -0
  32. package/dist/types/src/build/endpoint.d.ts +12 -0
  33. package/dist/types/src/build/platform.d.ts +24 -0
  34. package/dist/types/src/build/runtime.d.ts +9 -0
  35. package/dist/types/src/build/types.d.ts +4 -0
  36. package/dist/types/src/build/variants.d.ts +8 -0
  37. package/dist/types/src/domains.d.ts +27 -0
  38. package/dist/types/src/index.d.ts +9 -0
  39. package/dist/types/src/module.d.ts +3 -0
  40. package/dist/types/src/options.d.ts +15 -0
  41. package/dist/types/src/providers/bunny.d.ts +9 -0
  42. package/dist/types/src/providers/cloudflare.d.ts +9 -0
  43. package/dist/types/src/providers/cloudflareImages.d.ts +9 -0
  44. package/dist/types/src/providers/cloudinary.d.ts +9 -0
  45. package/dist/types/src/providers/contentful.d.ts +9 -0
  46. package/dist/types/src/providers/fastly.d.ts +9 -0
  47. package/dist/types/src/providers/hamur-url.d.ts +3 -0
  48. package/dist/types/src/providers/hamur.d.ts +3 -0
  49. package/dist/types/src/providers/imagekit.d.ts +9 -0
  50. package/dist/types/src/providers/imgix.d.ts +9 -0
  51. package/dist/types/src/providers/imgproxy.d.ts +9 -0
  52. package/dist/types/src/providers/ipx.d.ts +9 -0
  53. package/dist/types/src/providers/netlify.d.ts +9 -0
  54. package/dist/types/src/providers/none.d.ts +8 -0
  55. package/dist/types/src/providers/sanity.d.ts +9 -0
  56. package/dist/types/src/providers/shared.d.ts +7 -0
  57. package/dist/types/src/providers/storyblok.d.ts +9 -0
  58. package/dist/types/src/providers/strapi.d.ts +9 -0
  59. package/dist/types/src/providers/supabase.d.ts +9 -0
  60. package/dist/types/src/providers/twicpics.d.ts +9 -0
  61. package/dist/types/src/providers/uploadcare.d.ts +9 -0
  62. package/dist/types/src/providers/vercel-url.d.ts +3 -0
  63. package/dist/types/src/providers/vercel.d.ts +3 -0
  64. package/dist/types/src/providers/weserv.d.ts +9 -0
  65. package/dist/types/src/runtime/image.d.ts +28 -0
  66. package/dist/types/src/runtime/img.d.ts +71 -0
  67. package/dist/types/src/runtime/index.d.ts +9 -0
  68. package/dist/types/src/runtime/picture.d.ts +24 -0
  69. package/dist/types/src/runtime/sizes.d.ts +8 -0
  70. package/dist/types/src/runtime/source.d.ts +3 -0
  71. package/dist/types/src/server/door.d.ts +1 -0
  72. package/dist/types/src/server/endpoint.d.ts +46 -0
  73. package/dist/types/src/server/handler.d.ts +1 -0
  74. package/dist/types/src/server/index.d.ts +1 -0
  75. package/dist/types/src/server/miss-handler.d.ts +1 -0
  76. package/dist/types/src/server/miss.d.ts +1 -0
  77. package/dist/types/src/server/parse.d.ts +30 -0
  78. package/dist/types/src/server/remote.d.ts +20 -0
  79. package/dist/types/src/types.d.ts +178 -0
  80. package/package.json +114 -4
  81. package/src/adapters/Img.svelte +33 -0
  82. package/src/adapters/Picture.svelte +39 -0
  83. package/src/adapters/angular-img.ts +144 -0
  84. package/src/adapters/angular-picture.ts +146 -0
  85. package/src/adapters/angular.ts +3 -0
  86. package/src/adapters/html-img.ts +42 -0
  87. package/src/adapters/html-picture.ts +30 -0
  88. package/src/adapters/html.ts +9 -0
  89. package/src/adapters/preact-img.ts +51 -0
  90. package/src/adapters/preact-picture.ts +40 -0
  91. package/src/adapters/preact.ts +9 -0
  92. package/src/adapters/react-img.ts +54 -0
  93. package/src/adapters/react-picture.ts +49 -0
  94. package/src/adapters/react.ts +9 -0
  95. package/src/adapters/solid-img.ts +47 -0
  96. package/src/adapters/solid-picture.ts +43 -0
  97. package/src/adapters/solid.ts +9 -0
  98. package/src/adapters/svelte.ts +3 -0
  99. package/src/adapters/test/ImgCustomPage.svelte +14 -0
  100. package/src/adapters/test/ImgPage.svelte +5 -0
  101. package/src/adapters/test/ImgPreloadPage.svelte +6 -0
  102. package/src/adapters/test/PicturePage.svelte +6 -0
  103. package/src/adapters/test/PicturePreloadPage.svelte +5 -0
  104. package/src/adapters/test/support.ts +116 -0
  105. package/src/adapters/vue-img.ts +72 -0
  106. package/src/adapters/vue-picture.ts +64 -0
  107. package/src/adapters/vue.ts +7 -0
  108. package/src/build/endpoint.ts +78 -0
  109. package/src/build/platform.ts +99 -0
  110. package/src/build/runtime.ts +118 -0
  111. package/src/build/types.ts +23 -0
  112. package/src/build/variants.ts +174 -0
  113. package/src/domains.ts +84 -0
  114. package/src/env.d.ts +24 -0
  115. package/src/index.ts +23 -0
  116. package/src/module.ts +29 -0
  117. package/src/options.ts +329 -0
  118. package/src/providers/bunny.ts +21 -0
  119. package/src/providers/cloudflare.ts +22 -0
  120. package/src/providers/cloudflareImages.ts +25 -0
  121. package/src/providers/cloudinary.ts +31 -0
  122. package/src/providers/contentful.ts +26 -0
  123. package/src/providers/fastly.ts +29 -0
  124. package/src/providers/hamur-url.ts +81 -0
  125. package/src/providers/hamur.ts +8 -0
  126. package/src/providers/imagekit.ts +30 -0
  127. package/src/providers/imgix.ts +26 -0
  128. package/src/providers/imgproxy.ts +24 -0
  129. package/src/providers/ipx.ts +26 -0
  130. package/src/providers/netlify.ts +23 -0
  131. package/src/providers/none.ts +9 -0
  132. package/src/providers/sanity.ts +29 -0
  133. package/src/providers/shared.ts +17 -0
  134. package/src/providers/storyblok.ts +24 -0
  135. package/src/providers/strapi.ts +24 -0
  136. package/src/providers/supabase.ts +26 -0
  137. package/src/providers/twicpics.ts +26 -0
  138. package/src/providers/uploadcare.ts +32 -0
  139. package/src/providers/vercel-url.ts +18 -0
  140. package/src/providers/vercel.ts +8 -0
  141. package/src/providers/weserv.ts +25 -0
  142. package/src/runtime/image.ts +266 -0
  143. package/src/runtime/img.ts +241 -0
  144. package/src/runtime/index.ts +18 -0
  145. package/src/runtime/picture.ts +62 -0
  146. package/src/runtime/sizes.ts +52 -0
  147. package/src/runtime/source.ts +8 -0
  148. package/src/server/door.ts +1 -0
  149. package/src/server/endpoint.ts +428 -0
  150. package/src/server/handler.ts +33 -0
  151. package/src/server/index.ts +1 -0
  152. package/src/server/miss-handler.ts +20 -0
  153. package/src/server/miss.ts +1 -0
  154. package/src/server/parse.ts +152 -0
  155. package/src/server/remote.ts +166 -0
  156. package/src/types.ts +177 -0
@@ -0,0 +1,275 @@
1
+ // @bun
2
+ import {
3
+ placeholderStyle,
4
+ applyPlaceholder,
5
+ imagePreloadLink,
6
+ createImgEvents,
7
+ picturePreloadLink,
8
+ getImage2,
9
+ getSizes2,
10
+ imgAttributes,
11
+ pictureAttributes
12
+ } from "../../chunks/bun-index-n7xnn0a2.js";
13
+ // packages/image/src/adapters/angular-img.ts
14
+ import { Directive, ElementRef, Injector, Renderer2, DestroyRef, afterNextRender, booleanAttribute, computed, effect, inject, input, numberAttribute, runInInjectionContext, signal } from "@angular/core";
15
+ import { injectHead } from "@hamur/adapter-angular";
16
+ import * as i0 from "@angular/core";
17
+ var optionalNumber = (value) => value === undefined ? undefined : numberAttribute(value);
18
+ var strings = (attributes) => Object.fromEntries(Object.entries(attributes).map(([name, value]) => [name, value == null ? null : String(value)]));
19
+
20
+ class Img {
21
+ src = input.required(...ngDevMode ? [{ debugName: "src" }] : []);
22
+ alt = input(...ngDevMode ? [undefined, { debugName: "alt" }] : []);
23
+ width = input(...ngDevMode ? [undefined, { debugName: "width" }] : []);
24
+ height = input(...ngDevMode ? [undefined, { debugName: "height" }] : []);
25
+ sizes = input(...ngDevMode ? [undefined, { debugName: "sizes" }] : []);
26
+ densities = input(...ngDevMode ? [undefined, { debugName: "densities" }] : []);
27
+ format = input(...ngDevMode ? [undefined, { debugName: "format" }] : []);
28
+ quality = input(undefined, { ...ngDevMode ? { debugName: "quality" } : {}, transform: optionalNumber });
29
+ fit = input(...ngDevMode ? [undefined, { debugName: "fit" }] : []);
30
+ modifiers = input(...ngDevMode ? [undefined, { debugName: "modifiers" }] : []);
31
+ provider = input(...ngDevMode ? [undefined, { debugName: "provider" }] : []);
32
+ preset = input(...ngDevMode ? [undefined, { debugName: "preset" }] : []);
33
+ loading = input(...ngDevMode ? [undefined, { debugName: "loading" }] : []);
34
+ decoding = input(...ngDevMode ? [undefined, { debugName: "decoding" }] : []);
35
+ fetchpriority = input(...ngDevMode ? [undefined, { debugName: "fetchpriority" }] : []);
36
+ preload = input(false, { ...ngDevMode ? { debugName: "preload" } : {}, transform: booleanAttribute });
37
+ placeholder = input(...ngDevMode ? [undefined, { debugName: "placeholder" }] : []);
38
+ placeholderClass = input(...ngDevMode ? [undefined, { debugName: "placeholderClass" }] : []);
39
+ injector = inject(Injector);
40
+ loaded = signal(false, ...ngDevMode ? [{ debugName: "loaded" }] : []);
41
+ events = createImgEvents(() => ({}), (value) => this.loaded.set(value));
42
+ resolved = computed(() => imgAttributes({
43
+ src: this.src(),
44
+ alt: this.alt(),
45
+ width: this.width(),
46
+ height: this.height(),
47
+ sizes: this.sizes(),
48
+ densities: this.densities(),
49
+ format: this.format(),
50
+ quality: this.quality(),
51
+ fit: this.fit(),
52
+ modifiers: this.modifiers(),
53
+ provider: this.provider(),
54
+ preset: this.preset(),
55
+ loading: this.loading(),
56
+ decoding: this.decoding(),
57
+ fetchpriority: this.fetchpriority(),
58
+ preload: this.preload()
59
+ }), ...ngDevMode ? [{ debugName: "resolved" }] : []);
60
+ attrs = computed(() => strings(this.resolved()), ...ngDevMode ? [{ debugName: "attrs" }] : []);
61
+ painted = computed(() => {
62
+ const url = this.placeholder();
63
+ return this.loaded() || !url ? {} : placeholderStyle(url);
64
+ }, ...ngDevMode ? [{ debugName: "painted" }] : []);
65
+ paintedClass = computed(() => this.loaded() ? "" : this.placeholderClass() ?? "", ...ngDevMode ? [{ debugName: "paintedClass" }] : []);
66
+ constructor() {
67
+ const element = inject(ElementRef).nativeElement;
68
+ const renderer = inject(Renderer2);
69
+ effect(() => {
70
+ const attrs = this.attrs();
71
+ for (const name of ["src", "srcset", "sizes"]) {
72
+ const value = attrs[name] ?? null;
73
+ if (element.getAttribute(name) === value)
74
+ continue;
75
+ if (value === null)
76
+ renderer.removeAttribute(element, name);
77
+ else
78
+ renderer.setAttribute(element, name, value);
79
+ }
80
+ });
81
+ const finished = element.isConnected && element.complete && element.getAttribute("src") !== null;
82
+ const offLoad = renderer.listen(element, "load", (event) => this.events.load(event));
83
+ const offError = renderer.listen(element, "error", (event) => this.events.error(event));
84
+ inject(DestroyRef).onDestroy(() => {
85
+ offLoad();
86
+ offError();
87
+ });
88
+ if (finished)
89
+ afterNextRender(() => this.loaded.set(element.naturalWidth > 0));
90
+ }
91
+ ngOnInit() {
92
+ if (this.preload())
93
+ runInInjectionContext(this.injector, () => injectHead(() => ({ link: [imagePreloadLink(this.resolved())] })));
94
+ }
95
+ static \u{275}fac = i0.\u{275}\u{275}ngDeclareFactory({ minVersion: "12.0.0", version: "22.3.2", ngImport: i0, type: Img, deps: [], target: i0.\u{275}\u{275}FactoryTarget.Directive });
96
+ static \u{275}dir = i0.\u{275}\u{275}ngDeclareDirective({ minVersion: "17.1.0", version: "22.3.2", type: Img, isStandalone: true, selector: "img[hamurImg]", inputs: { src: { classPropertyName: "src", publicName: "src", isSignal: true, isRequired: true, transformFunction: null }, alt: { classPropertyName: "alt", publicName: "alt", isSignal: true, isRequired: false, transformFunction: null }, width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, sizes: { classPropertyName: "sizes", publicName: "sizes", isSignal: true, isRequired: false, transformFunction: null }, densities: { classPropertyName: "densities", publicName: "densities", isSignal: true, isRequired: false, transformFunction: null }, format: { classPropertyName: "format", publicName: "format", isSignal: true, isRequired: false, transformFunction: null }, quality: { classPropertyName: "quality", publicName: "quality", isSignal: true, isRequired: false, transformFunction: null }, fit: { classPropertyName: "fit", publicName: "fit", isSignal: true, isRequired: false, transformFunction: null }, modifiers: { classPropertyName: "modifiers", publicName: "modifiers", isSignal: true, isRequired: false, transformFunction: null }, provider: { classPropertyName: "provider", publicName: "provider", isSignal: true, isRequired: false, transformFunction: null }, preset: { classPropertyName: "preset", publicName: "preset", isSignal: true, isRequired: false, transformFunction: null }, loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, decoding: { classPropertyName: "decoding", publicName: "decoding", isSignal: true, isRequired: false, transformFunction: null }, fetchpriority: { classPropertyName: "fetchpriority", publicName: "fetchpriority", isSignal: true, isRequired: false, transformFunction: null }, preload: { classPropertyName: "preload", publicName: "preload", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, placeholderClass: { classPropertyName: "placeholderClass", publicName: "placeholderClass", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.hamurImg": "null", "attr.densities": "null", "attr.format": "null", "attr.quality": "null", "attr.fit": "null", "attr.modifiers": "null", "attr.provider": "null", "attr.preset": "null", "attr.preload": "null", "attr.placeholder": "null", "attr.placeholderClass": "null", "attr.width": "attrs()['width']", "attr.height": "attrs()['height']", "attr.alt": "attrs()['alt']", "attr.loading": "attrs()['loading']", "attr.decoding": "attrs()['decoding']", "attr.fetchpriority": "attrs()['fetchpriority']", style: "painted()", class: "paintedClass()" } }, ngImport: i0 });
97
+ }
98
+ i0.\u{275}\u{275}ngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.2", ngImport: i0, type: Img, decorators: [{
99
+ type: Directive,
100
+ args: [{
101
+ selector: "img[hamurImg]",
102
+ host: {
103
+ "[attr.hamurImg]": "null",
104
+ "[attr.densities]": "null",
105
+ "[attr.format]": "null",
106
+ "[attr.quality]": "null",
107
+ "[attr.fit]": "null",
108
+ "[attr.modifiers]": "null",
109
+ "[attr.provider]": "null",
110
+ "[attr.preset]": "null",
111
+ "[attr.preload]": "null",
112
+ "[attr.placeholder]": "null",
113
+ "[attr.placeholderClass]": "null",
114
+ "[attr.width]": "attrs()['width']",
115
+ "[attr.height]": "attrs()['height']",
116
+ "[attr.alt]": "attrs()['alt']",
117
+ "[attr.loading]": "attrs()['loading']",
118
+ "[attr.decoding]": "attrs()['decoding']",
119
+ "[attr.fetchpriority]": "attrs()['fetchpriority']",
120
+ "[style]": "painted()",
121
+ "[class]": "paintedClass()"
122
+ }
123
+ }]
124
+ }], ctorParameters: () => [], propDecorators: { src: [{ type: i0.Input, args: [{ isSignal: true, alias: "src", required: true }] }], alt: [{ type: i0.Input, args: [{ isSignal: true, alias: "alt", required: false }] }], width: [{ type: i0.Input, args: [{ isSignal: true, alias: "width", required: false }] }], height: [{ type: i0.Input, args: [{ isSignal: true, alias: "height", required: false }] }], sizes: [{ type: i0.Input, args: [{ isSignal: true, alias: "sizes", required: false }] }], densities: [{ type: i0.Input, args: [{ isSignal: true, alias: "densities", required: false }] }], format: [{ type: i0.Input, args: [{ isSignal: true, alias: "format", required: false }] }], quality: [{ type: i0.Input, args: [{ isSignal: true, alias: "quality", required: false }] }], fit: [{ type: i0.Input, args: [{ isSignal: true, alias: "fit", required: false }] }], modifiers: [{ type: i0.Input, args: [{ isSignal: true, alias: "modifiers", required: false }] }], provider: [{ type: i0.Input, args: [{ isSignal: true, alias: "provider", required: false }] }], preset: [{ type: i0.Input, args: [{ isSignal: true, alias: "preset", required: false }] }], loading: [{ type: i0.Input, args: [{ isSignal: true, alias: "loading", required: false }] }], decoding: [{ type: i0.Input, args: [{ isSignal: true, alias: "decoding", required: false }] }], fetchpriority: [{ type: i0.Input, args: [{ isSignal: true, alias: "fetchpriority", required: false }] }], preload: [{ type: i0.Input, args: [{ isSignal: true, alias: "preload", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], placeholderClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholderClass", required: false }] }] } });
125
+ // packages/image/src/adapters/angular-picture.ts
126
+ import { Component, Injector as Injector2, Renderer2 as Renderer22, afterRenderEffect, booleanAttribute as booleanAttribute2, computed as computed2, inject as inject2, input as input2, numberAttribute as numberAttribute2, runInInjectionContext as runInInjectionContext2, signal as signal2, viewChild } from "@angular/core";
127
+ import { injectHead as injectHead2 } from "@hamur/adapter-angular";
128
+ import * as i02 from "@angular/core";
129
+ var optionalNumber2 = (value) => value === undefined ? undefined : numberAttribute2(value);
130
+
131
+ class Picture {
132
+ src = input2.required(...ngDevMode ? [{ debugName: "src" }] : []);
133
+ alt = input2(...ngDevMode ? [undefined, { debugName: "alt" }] : []);
134
+ width = input2(...ngDevMode ? [undefined, { debugName: "width" }] : []);
135
+ height = input2(...ngDevMode ? [undefined, { debugName: "height" }] : []);
136
+ sizes = input2(...ngDevMode ? [undefined, { debugName: "sizes" }] : []);
137
+ densities = input2(...ngDevMode ? [undefined, { debugName: "densities" }] : []);
138
+ format = input2(...ngDevMode ? [undefined, { debugName: "format" }] : []);
139
+ legacyFormat = input2(...ngDevMode ? [undefined, { debugName: "legacyFormat" }] : []);
140
+ quality = input2(undefined, { ...ngDevMode ? { debugName: "quality" } : {}, transform: optionalNumber2 });
141
+ fit = input2(...ngDevMode ? [undefined, { debugName: "fit" }] : []);
142
+ modifiers = input2(...ngDevMode ? [undefined, { debugName: "modifiers" }] : []);
143
+ provider = input2(...ngDevMode ? [undefined, { debugName: "provider" }] : []);
144
+ preset = input2(...ngDevMode ? [undefined, { debugName: "preset" }] : []);
145
+ loading = input2(...ngDevMode ? [undefined, { debugName: "loading" }] : []);
146
+ decoding = input2(...ngDevMode ? [undefined, { debugName: "decoding" }] : []);
147
+ fetchpriority = input2(...ngDevMode ? [undefined, { debugName: "fetchpriority" }] : []);
148
+ preload = input2(false, { ...ngDevMode ? { debugName: "preload" } : {}, transform: booleanAttribute2 });
149
+ placeholder = input2(...ngDevMode ? [undefined, { debugName: "placeholder" }] : []);
150
+ placeholderClass = input2(...ngDevMode ? [undefined, { debugName: "placeholderClass" }] : []);
151
+ injector = inject2(Injector2);
152
+ loaded = signal2(false, ...ngDevMode ? [{ debugName: "loaded" }] : []);
153
+ element = viewChild("img", ...ngDevMode ? [{ debugName: "element" }] : []);
154
+ events = createImgEvents(() => ({}), (value) => this.loaded.set(value));
155
+ parts = computed2(() => pictureAttributes({
156
+ src: this.src(),
157
+ alt: this.alt(),
158
+ width: this.width(),
159
+ height: this.height(),
160
+ sizes: this.sizes(),
161
+ densities: this.densities(),
162
+ format: this.format(),
163
+ legacyFormat: this.legacyFormat(),
164
+ quality: this.quality(),
165
+ fit: this.fit(),
166
+ modifiers: this.modifiers(),
167
+ provider: this.provider(),
168
+ preset: this.preset(),
169
+ loading: this.loading(),
170
+ decoding: this.decoding(),
171
+ fetchpriority: this.fetchpriority(),
172
+ preload: this.preload()
173
+ }), ...ngDevMode ? [{ debugName: "parts" }] : []);
174
+ shown = computed2(() => strings(applyPlaceholder(this.parts().img, { placeholder: this.placeholder(), placeholderClass: this.placeholderClass() }, this.loaded())), ...ngDevMode ? [{ debugName: "shown" }] : []);
175
+ constructor() {
176
+ const renderer = inject2(Renderer22);
177
+ afterRenderEffect((onCleanup) => {
178
+ const image = this.element()?.nativeElement;
179
+ if (!image)
180
+ return;
181
+ onCleanup(renderer.listen(image, "load", (event) => this.events.load(event)));
182
+ onCleanup(renderer.listen(image, "error", (event) => this.events.error(event)));
183
+ this.events.replay(image);
184
+ });
185
+ }
186
+ ngOnInit() {
187
+ if (this.preload())
188
+ runInInjectionContext2(this.injector, () => injectHead2(() => ({ link: [picturePreloadLink(this.parts())] })));
189
+ }
190
+ static \u{275}fac = i02.\u{275}\u{275}ngDeclareFactory({ minVersion: "12.0.0", version: "22.3.2", ngImport: i02, type: Picture, deps: [], target: i02.\u{275}\u{275}FactoryTarget.Component });
191
+ static \u{275}cmp = i02.\u{275}\u{275}ngDeclareComponent({ minVersion: "17.0.0", version: "22.3.2", type: Picture, isStandalone: true, selector: "hamur-picture", inputs: { src: { classPropertyName: "src", publicName: "src", isSignal: true, isRequired: true, transformFunction: null }, alt: { classPropertyName: "alt", publicName: "alt", isSignal: true, isRequired: false, transformFunction: null }, width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, sizes: { classPropertyName: "sizes", publicName: "sizes", isSignal: true, isRequired: false, transformFunction: null }, densities: { classPropertyName: "densities", publicName: "densities", isSignal: true, isRequired: false, transformFunction: null }, format: { classPropertyName: "format", publicName: "format", isSignal: true, isRequired: false, transformFunction: null }, legacyFormat: { classPropertyName: "legacyFormat", publicName: "legacyFormat", isSignal: true, isRequired: false, transformFunction: null }, quality: { classPropertyName: "quality", publicName: "quality", isSignal: true, isRequired: false, transformFunction: null }, fit: { classPropertyName: "fit", publicName: "fit", isSignal: true, isRequired: false, transformFunction: null }, modifiers: { classPropertyName: "modifiers", publicName: "modifiers", isSignal: true, isRequired: false, transformFunction: null }, provider: { classPropertyName: "provider", publicName: "provider", isSignal: true, isRequired: false, transformFunction: null }, preset: { classPropertyName: "preset", publicName: "preset", isSignal: true, isRequired: false, transformFunction: null }, loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, decoding: { classPropertyName: "decoding", publicName: "decoding", isSignal: true, isRequired: false, transformFunction: null }, fetchpriority: { classPropertyName: "fetchpriority", publicName: "fetchpriority", isSignal: true, isRequired: false, transformFunction: null }, preload: { classPropertyName: "preload", publicName: "preload", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, placeholderClass: { classPropertyName: "placeholderClass", publicName: "placeholderClass", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "element", first: true, predicate: ["img"], descendants: true, isSignal: true }], ngImport: i02, template: `@if (parts().sources.length > 0) {
192
+ <picture>
193
+ @for (source of parts().sources; track source.type) {
194
+ <source [attr.type]="source.type" [attr.srcset]="source.srcset" [attr.sizes]="source.sizes" />
195
+ }
196
+ <img
197
+ #img
198
+ [attr.src]="shown()['src']"
199
+ [attr.srcset]="shown()['srcset']"
200
+ [attr.sizes]="shown()['sizes']"
201
+ [attr.width]="shown()['width']"
202
+ [attr.height]="shown()['height']"
203
+ [attr.alt]="shown()['alt']"
204
+ [attr.loading]="shown()['loading']"
205
+ [attr.decoding]="shown()['decoding']"
206
+ [attr.fetchpriority]="shown()['fetchpriority']"
207
+ [attr.style]="shown()['style']"
208
+ [attr.class]="shown()['class']"
209
+ />
210
+ </picture>
211
+ } @else {
212
+ <img
213
+ #img
214
+ [attr.src]="shown()['src']"
215
+ [attr.srcset]="shown()['srcset']"
216
+ [attr.sizes]="shown()['sizes']"
217
+ [attr.width]="shown()['width']"
218
+ [attr.height]="shown()['height']"
219
+ [attr.alt]="shown()['alt']"
220
+ [attr.loading]="shown()['loading']"
221
+ [attr.decoding]="shown()['decoding']"
222
+ [attr.fetchpriority]="shown()['fetchpriority']"
223
+ [attr.style]="shown()['style']"
224
+ [attr.class]="shown()['class']"
225
+ />
226
+ }`, isInline: true });
227
+ }
228
+ i02.\u{275}\u{275}ngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.2", ngImport: i02, type: Picture, decorators: [{
229
+ type: Component,
230
+ args: [{
231
+ selector: "hamur-picture",
232
+ template: `@if (parts().sources.length > 0) {
233
+ <picture>
234
+ @for (source of parts().sources; track source.type) {
235
+ <source [attr.type]="source.type" [attr.srcset]="source.srcset" [attr.sizes]="source.sizes" />
236
+ }
237
+ <img
238
+ #img
239
+ [attr.src]="shown()['src']"
240
+ [attr.srcset]="shown()['srcset']"
241
+ [attr.sizes]="shown()['sizes']"
242
+ [attr.width]="shown()['width']"
243
+ [attr.height]="shown()['height']"
244
+ [attr.alt]="shown()['alt']"
245
+ [attr.loading]="shown()['loading']"
246
+ [attr.decoding]="shown()['decoding']"
247
+ [attr.fetchpriority]="shown()['fetchpriority']"
248
+ [attr.style]="shown()['style']"
249
+ [attr.class]="shown()['class']"
250
+ />
251
+ </picture>
252
+ } @else {
253
+ <img
254
+ #img
255
+ [attr.src]="shown()['src']"
256
+ [attr.srcset]="shown()['srcset']"
257
+ [attr.sizes]="shown()['sizes']"
258
+ [attr.width]="shown()['width']"
259
+ [attr.height]="shown()['height']"
260
+ [attr.alt]="shown()['alt']"
261
+ [attr.loading]="shown()['loading']"
262
+ [attr.decoding]="shown()['decoding']"
263
+ [attr.fetchpriority]="shown()['fetchpriority']"
264
+ [attr.style]="shown()['style']"
265
+ [attr.class]="shown()['class']"
266
+ />
267
+ }`
268
+ }]
269
+ }], ctorParameters: () => [], propDecorators: { src: [{ type: i02.Input, args: [{ isSignal: true, alias: "src", required: true }] }], alt: [{ type: i02.Input, args: [{ isSignal: true, alias: "alt", required: false }] }], width: [{ type: i02.Input, args: [{ isSignal: true, alias: "width", required: false }] }], height: [{ type: i02.Input, args: [{ isSignal: true, alias: "height", required: false }] }], sizes: [{ type: i02.Input, args: [{ isSignal: true, alias: "sizes", required: false }] }], densities: [{ type: i02.Input, args: [{ isSignal: true, alias: "densities", required: false }] }], format: [{ type: i02.Input, args: [{ isSignal: true, alias: "format", required: false }] }], legacyFormat: [{ type: i02.Input, args: [{ isSignal: true, alias: "legacyFormat", required: false }] }], quality: [{ type: i02.Input, args: [{ isSignal: true, alias: "quality", required: false }] }], fit: [{ type: i02.Input, args: [{ isSignal: true, alias: "fit", required: false }] }], modifiers: [{ type: i02.Input, args: [{ isSignal: true, alias: "modifiers", required: false }] }], provider: [{ type: i02.Input, args: [{ isSignal: true, alias: "provider", required: false }] }], preset: [{ type: i02.Input, args: [{ isSignal: true, alias: "preset", required: false }] }], loading: [{ type: i02.Input, args: [{ isSignal: true, alias: "loading", required: false }] }], decoding: [{ type: i02.Input, args: [{ isSignal: true, alias: "decoding", required: false }] }], fetchpriority: [{ type: i02.Input, args: [{ isSignal: true, alias: "fetchpriority", required: false }] }], preload: [{ type: i02.Input, args: [{ isSignal: true, alias: "preload", required: false }] }], placeholder: [{ type: i02.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], placeholderClass: [{ type: i02.Input, args: [{ isSignal: true, alias: "placeholderClass", required: false }] }], element: [{ type: i02.ViewChild, args: ["img", { isSignal: true }] }] } });
270
+ export {
271
+ Img,
272
+ Picture,
273
+ getImage2 as getImage,
274
+ getSizes2 as getSizes
275
+ };
@@ -0,0 +1,70 @@
1
+ // @bun
2
+ import {
3
+ applyPlaceholder,
4
+ imagePreloadLink,
5
+ picturePreloadLink,
6
+ getImage2,
7
+ getSizes2,
8
+ imgAttributes,
9
+ pictureAttributes
10
+ } from "../../chunks/bun-index-n7xnn0a2.js";
11
+
12
+ // packages/image/src/adapters/html-img.ts
13
+ import { useHead } from "@hamur/adapter-html";
14
+ var ESCAPES = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" };
15
+ var escape = (value) => String(value).replace(/[&<>"]/g, (char) => ESCAPES[char]);
16
+ function createImg(attributes) {
17
+ return function Img({ custom, ...props }) {
18
+ const attrs = applyPlaceholder(attributes(props), props, false);
19
+ if (props.preload)
20
+ useHead({ link: [imagePreloadLink(attrs)] });
21
+ if (custom) {
22
+ const imgAttrs = {};
23
+ for (const [name, value] of Object.entries(attrs)) {
24
+ if (value === undefined || value === null || value === false)
25
+ continue;
26
+ imgAttrs[name] = value === true ? "" : String(value);
27
+ }
28
+ return custom({ imgAttrs, src: imgAttrs.src ?? "", isLoaded: false });
29
+ }
30
+ let out = "<img";
31
+ for (const [name, value] of Object.entries(attrs)) {
32
+ if (value === undefined || value === null || value === false)
33
+ continue;
34
+ out += value === true ? ` ${name}` : ` ${name}="${escape(value)}"`;
35
+ }
36
+ return `${out}>`;
37
+ };
38
+ }
39
+
40
+ // packages/image/src/adapters/html-picture.ts
41
+ import { useHead as useHead2 } from "@hamur/adapter-html";
42
+ var tag = (name, attributes) => {
43
+ let out = `<${name}`;
44
+ for (const [key, value] of Object.entries(attributes)) {
45
+ if (value === undefined || value === null || value === false)
46
+ continue;
47
+ out += value === true ? ` ${key}` : ` ${key}="${escape(value)}"`;
48
+ }
49
+ return `${out}>`;
50
+ };
51
+ function createPicture(attributes) {
52
+ return function Picture(props) {
53
+ const parts = attributes(props);
54
+ const { sources, img } = parts;
55
+ if (props.preload)
56
+ useHead2({ link: [picturePreloadLink(parts)] });
57
+ const image = tag("img", applyPlaceholder(img, props, false));
58
+ return sources.length === 0 ? image : `<picture>${sources.map((source) => tag("source", source)).join("")}${image}</picture>`;
59
+ };
60
+ }
61
+
62
+ // packages/image/src/adapters/html.ts
63
+ var Img = createImg(imgAttributes);
64
+ var Picture = createPicture(pictureAttributes);
65
+ export {
66
+ Img,
67
+ Picture,
68
+ getImage2 as getImage,
69
+ getSizes2 as getSizes
70
+ };
@@ -0,0 +1,82 @@
1
+ // @bun
2
+ import {
3
+ applyPlaceholder,
4
+ imagePreloadLink,
5
+ createImgEvents,
6
+ picturePreloadLink,
7
+ getImage2,
8
+ getSizes2,
9
+ imgAttributes,
10
+ pictureAttributes
11
+ } from "../../chunks/bun-index-n7xnn0a2.js";
12
+
13
+ // packages/image/src/adapters/preact-img.ts
14
+ import { h } from "preact";
15
+ import { useHead } from "@hamur/adapter-preact";
16
+ import { useEffect, useMemo, useRef, useState } from "preact/hooks";
17
+ function createImg(attributes) {
18
+ return function Img({ children, onLoad, onError, ...props }) {
19
+ const [isLoaded, setLoaded] = useState(false);
20
+ const handlers = useRef({ onLoad, onError });
21
+ handlers.current = { onLoad, onError };
22
+ const events = useMemo(() => createImgEvents(() => ({ load: handlers.current.onLoad, error: handlers.current.onError }), setLoaded), []);
23
+ const image = useRef(null);
24
+ useEffect(() => {
25
+ if (image.current)
26
+ events.replay(image.current);
27
+ }, [events]);
28
+ const attrs = attributes(props);
29
+ if (props.preload)
30
+ useHead({ link: [imagePreloadLink(attrs)] });
31
+ const imgAttrs = {
32
+ ...applyPlaceholder(attrs, props, isLoaded),
33
+ onLoad: events.load,
34
+ onError: events.error,
35
+ ref: image
36
+ };
37
+ if (typeof children === "function")
38
+ return children({ imgAttrs, src: String(attrs.src), isLoaded });
39
+ return h("img", imgAttrs);
40
+ };
41
+ }
42
+
43
+ // packages/image/src/adapters/preact-picture.ts
44
+ import { h as h2 } from "preact";
45
+ import { useHead as useHead2 } from "@hamur/adapter-preact";
46
+ import { useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2, useState as useState2 } from "preact/hooks";
47
+ function createPicture(attributes) {
48
+ return function Picture({ onLoad, onError, ...props }) {
49
+ const [isLoaded, setLoaded] = useState2(false);
50
+ const handlers = useRef2({ onLoad, onError });
51
+ handlers.current = { onLoad, onError };
52
+ const events = useMemo2(() => createImgEvents(() => ({ load: handlers.current.onLoad, error: handlers.current.onError }), setLoaded), []);
53
+ const node = useRef2(null);
54
+ useEffect2(() => {
55
+ if (node.current)
56
+ events.replay(node.current);
57
+ }, [events]);
58
+ const parts = attributes(props);
59
+ const { sources, img } = parts;
60
+ if (props.preload)
61
+ useHead2({ link: [picturePreloadLink(parts)] });
62
+ const image = h2("img", {
63
+ ...applyPlaceholder(img, props, isLoaded),
64
+ onLoad: events.load,
65
+ onError: events.error,
66
+ ref: node
67
+ });
68
+ if (sources.length === 0)
69
+ return image;
70
+ return h2("picture", null, ...sources.map((source) => h2("source", { key: source.type, ...source })), image);
71
+ };
72
+ }
73
+
74
+ // packages/image/src/adapters/preact.ts
75
+ var Img = createImg(imgAttributes);
76
+ var Picture = createPicture(pictureAttributes);
77
+ export {
78
+ Img,
79
+ Picture,
80
+ getImage2 as getImage,
81
+ getSizes2 as getSizes
82
+ };
@@ -0,0 +1,84 @@
1
+ // @bun
2
+ import {
3
+ applyPlaceholder,
4
+ imagePreloadLink,
5
+ createImgEvents,
6
+ picturePreloadLink,
7
+ getImage2,
8
+ getSizes2,
9
+ imgAttributes,
10
+ pictureAttributes
11
+ } from "../../chunks/bun-index-n7xnn0a2.js";
12
+
13
+ // packages/image/src/adapters/react-img.ts
14
+ import { createElement, useEffect, useMemo, useRef, useState } from "react";
15
+ import { useHead } from "@hamur/adapter-react";
16
+ var NAMES = { srcset: "srcSet", fetchpriority: "fetchPriority" };
17
+ function createImg(attributes) {
18
+ return function Img({ fetchPriority, children, onLoad, onError, ...props }) {
19
+ const [isLoaded, setLoaded] = useState(false);
20
+ const handlers = useRef({ onLoad, onError });
21
+ handlers.current = { onLoad, onError };
22
+ const events = useMemo(() => createImgEvents(() => ({ load: handlers.current.onLoad, error: handlers.current.onError }), setLoaded), []);
23
+ const image = useRef(null);
24
+ useEffect(() => {
25
+ if (image.current)
26
+ events.replay(image.current);
27
+ }, [events]);
28
+ const attrs = attributes({ ...props, fetchpriority: fetchPriority });
29
+ if (props.preload)
30
+ useHead({ link: [imagePreloadLink(attrs)] });
31
+ const imgAttrs = applyPlaceholder(Object.fromEntries(Object.entries(attrs).map(([name, value]) => [NAMES[name] ?? name, value])), props, isLoaded, { react: true });
32
+ imgAttrs.onLoad = events.load;
33
+ imgAttrs.onError = events.error;
34
+ imgAttrs.ref = image;
35
+ if (props.preload)
36
+ imgAttrs.src = new String(imgAttrs.src);
37
+ if (children)
38
+ return children({ imgAttrs, src: String(attrs.src), isLoaded });
39
+ return createElement("img", imgAttrs);
40
+ };
41
+ }
42
+
43
+ // packages/image/src/adapters/react-picture.ts
44
+ import { createElement as createElement2, useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2, useState as useState2 } from "react";
45
+ import { useHead as useHead2 } from "@hamur/adapter-react";
46
+ var NAMES2 = { srcset: "srcSet", fetchpriority: "fetchPriority" };
47
+ var named = (attributes) => Object.fromEntries(Object.entries(attributes).map(([name, value]) => [NAMES2[name] ?? name, value]));
48
+ function createPicture(attributes) {
49
+ return function Picture({ fetchPriority, onLoad, onError, ...props }) {
50
+ const [isLoaded, setLoaded] = useState2(false);
51
+ const handlers = useRef2({ onLoad, onError });
52
+ handlers.current = { onLoad, onError };
53
+ const events = useMemo2(() => createImgEvents(() => ({ load: handlers.current.onLoad, error: handlers.current.onError }), setLoaded), []);
54
+ const node = useRef2(null);
55
+ useEffect2(() => {
56
+ if (node.current)
57
+ events.replay(node.current);
58
+ }, [events]);
59
+ const parts = attributes({ ...props, fetchpriority: fetchPriority });
60
+ const { sources, img } = parts;
61
+ if (props.preload)
62
+ useHead2({ link: [picturePreloadLink(parts)] });
63
+ const imgAttrs = applyPlaceholder(named(img), props, isLoaded, { react: true });
64
+ imgAttrs.onLoad = events.load;
65
+ imgAttrs.onError = events.error;
66
+ imgAttrs.ref = node;
67
+ if (props.preload)
68
+ imgAttrs.src = new String(img.src);
69
+ const image = createElement2("img", imgAttrs);
70
+ if (sources.length === 0)
71
+ return image;
72
+ return createElement2("picture", null, ...sources.map((source) => createElement2("source", { key: source.type, ...named(source) })), image);
73
+ };
74
+ }
75
+
76
+ // packages/image/src/adapters/react.ts
77
+ var Img = createImg(imgAttributes);
78
+ var Picture = createPicture(pictureAttributes);
79
+ export {
80
+ Img,
81
+ Picture,
82
+ getImage2 as getImage,
83
+ getSizes2 as getSizes
84
+ };
@@ -0,0 +1,93 @@
1
+ // @bun
2
+ import {
3
+ applyPlaceholder,
4
+ imagePreloadLink,
5
+ createImgEvents,
6
+ picturePreloadLink,
7
+ getImage2,
8
+ getSizes2,
9
+ imgAttributes,
10
+ pictureAttributes
11
+ } from "../../chunks/bun-index-n7xnn0a2.js";
12
+
13
+ // packages/image/src/adapters/solid-img.ts
14
+ import { createComponent, createSignal, omit, onSettled } from "solid-js";
15
+ import { dynamic } from "@solidjs/web";
16
+ import { useHead } from "@hamur/adapter-solid";
17
+ var Image = dynamic(() => "img", { static: true });
18
+ function createImg(attributes) {
19
+ return function Img(props) {
20
+ const own = props;
21
+ const rest = omit(props, "children", "onLoad", "onError");
22
+ const [isLoaded, setLoaded] = createSignal(false);
23
+ const events = createImgEvents(() => ({ load: own.onLoad, error: own.onError }), setLoaded);
24
+ let image;
25
+ onSettled(() => {
26
+ if (image)
27
+ events.replay(image);
28
+ });
29
+ if (props.preload)
30
+ useHead(() => ({ link: [imagePreloadLink(attributes(rest))] }));
31
+ return () => {
32
+ const attrs = attributes(rest);
33
+ const imgAttrs = {
34
+ onLoad: events.load,
35
+ onError: events.error,
36
+ ref: (node) => image = node,
37
+ ...applyPlaceholder(attrs, rest, isLoaded())
38
+ };
39
+ const child = own.children;
40
+ if (typeof child === "function")
41
+ return child({ imgAttrs, src: String(attrs.src), isLoaded: isLoaded() });
42
+ return createComponent(Image, imgAttrs);
43
+ };
44
+ };
45
+ }
46
+
47
+ // packages/image/src/adapters/solid-picture.ts
48
+ import { createComponent as createComponent2, createSignal as createSignal2, omit as omit2, onSettled as onSettled2 } from "solid-js";
49
+ import { dynamic as dynamic2 } from "@solidjs/web";
50
+ import { useHead as useHead2 } from "@hamur/adapter-solid";
51
+ var tags = {
52
+ img: dynamic2(() => "img", { static: true }),
53
+ picture: dynamic2(() => "picture", { static: true }),
54
+ source: dynamic2(() => "source", { static: true })
55
+ };
56
+ var element = (tag, attributes) => createComponent2(tags[tag], attributes);
57
+ function createPicture(attributes) {
58
+ return function Picture(props) {
59
+ const own = props;
60
+ const rest = omit2(props, "onLoad", "onError");
61
+ const [isLoaded, setLoaded] = createSignal2(false);
62
+ const events = createImgEvents(() => ({ load: own.onLoad, error: own.onError }), setLoaded);
63
+ let node;
64
+ onSettled2(() => {
65
+ if (node)
66
+ events.replay(node);
67
+ });
68
+ if (props.preload)
69
+ useHead2(() => ({ link: [picturePreloadLink(attributes(rest))] }));
70
+ return () => {
71
+ const { sources, img } = attributes(rest);
72
+ const image = element("img", {
73
+ onLoad: events.load,
74
+ onError: events.error,
75
+ ref: (value) => node = value,
76
+ ...applyPlaceholder(img, rest, isLoaded())
77
+ });
78
+ if (sources.length === 0)
79
+ return image;
80
+ return element("picture", { children: [...sources.map((source) => element("source", source)), image] });
81
+ };
82
+ };
83
+ }
84
+
85
+ // packages/image/src/adapters/solid.ts
86
+ var Img = createImg(imgAttributes);
87
+ var Picture = createPicture(pictureAttributes);
88
+ export {
89
+ Img,
90
+ Picture,
91
+ getImage2 as getImage,
92
+ getSizes2 as getSizes
93
+ };
@@ -0,0 +1,15 @@
1
+ // @bun
2
+ import {
3
+ getImage2,
4
+ getSizes2
5
+ } from "../../chunks/bun-index-n7xnn0a2.js";
6
+
7
+ // packages/image/src/adapters/svelte.ts
8
+ import { default as default2 } from "../../../src/adapters/Img.svelte";
9
+ import { default as default3 } from "../../../src/adapters/Picture.svelte";
10
+ export {
11
+ default2 as Img,
12
+ default3 as Picture,
13
+ getImage2 as getImage,
14
+ getSizes2 as getSizes
15
+ };