@hotosm/ui 2.1.0 → 2.1.2
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/README.md +55 -12
- package/dist/chunks/chunk.HJTJO26W.js +1 -0
- package/dist/components/tool-menu/tool-menu.d.ts +2 -0
- package/dist/components/tool-menu/tool-menu.js +1 -1
- package/dist/hotosm-ui.js +1 -1
- package/dist/vite.d.ts +34 -0
- package/dist/vite.js +71 -0
- package/package.json +5 -1
- package/dist/chunks/chunk.GQ4LISAU.js +0 -1
package/README.md
CHANGED
|
@@ -153,26 +153,69 @@ import "@hotosm/ui/dist/components/header/header.js"; // hot-* components you us
|
|
|
153
153
|
<hot-header title="My App"></hot-header>
|
|
154
154
|
```
|
|
155
155
|
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
#### Build setup
|
|
157
|
+
|
|
158
|
+
`@hotosm/ui/vite` provides build helpers for Vite 5, 7, and 8.
|
|
159
|
+
|
|
160
|
+
Add the circular chunk guard to catch chunk cycles that can cause a blank page
|
|
161
|
+
at runtime:
|
|
162
|
+
|
|
163
|
+
```js
|
|
164
|
+
// vite.config.ts
|
|
165
|
+
import { circularChunkGuard } from "@hotosm/ui/vite";
|
|
166
|
+
import { defineConfig } from "vite";
|
|
167
|
+
|
|
168
|
+
export default defineConfig({
|
|
169
|
+
plugins: [circularChunkGuard()],
|
|
170
|
+
});
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Keep the guard enabled even if you do not split chunks manually. Dependency
|
|
174
|
+
updates can also introduce cycles.
|
|
175
|
+
|
|
176
|
+
You can also place WebAwesome in its own chunk. This lets browsers keep it
|
|
177
|
+
cached when the rest of your app changes:
|
|
178
|
+
|
|
179
|
+
For Vite 8:
|
|
180
|
+
|
|
181
|
+
```js
|
|
182
|
+
// vite.config.ts
|
|
183
|
+
import { WEBAWESOME_CHUNK } from "@hotosm/ui/vite";
|
|
184
|
+
import { defineConfig } from "vite";
|
|
185
|
+
|
|
186
|
+
export default defineConfig({
|
|
187
|
+
build: {
|
|
188
|
+
rolldownOptions: {
|
|
189
|
+
output: {
|
|
190
|
+
codeSplitting: {
|
|
191
|
+
groups: [WEBAWESOME_CHUNK],
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
});
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
For Vite 5-7:
|
|
158
200
|
|
|
159
201
|
```js
|
|
160
202
|
// vite.config.ts
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
203
|
+
import { matchWebawesome } from "@hotosm/ui/vite";
|
|
204
|
+
import { defineConfig } from "vite";
|
|
205
|
+
|
|
206
|
+
export default defineConfig({
|
|
207
|
+
build: {
|
|
208
|
+
rollupOptions: {
|
|
209
|
+
output: {
|
|
210
|
+
manualChunks: (id) => matchWebawesome(id),
|
|
166
211
|
},
|
|
167
212
|
},
|
|
168
213
|
},
|
|
169
|
-
}
|
|
214
|
+
});
|
|
170
215
|
```
|
|
171
216
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
as a FOUCE backstop (pure CSS, ships in WebAwesome's `utilities.css`,
|
|
175
|
-
already included in `style.css`).
|
|
217
|
+
This cache is per origin, so it is reused across deployments of the same app,
|
|
218
|
+
not across different HOT tools.
|
|
176
219
|
|
|
177
220
|
### Via CDN / Plain HTML / HTMX
|
|
178
221
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as o}from"./chunk.LH3TTPVQ.js";var l=o;customElements.get("hot-tool-menu")||customElements.define("hot-tool-menu",o);var e=class e extends o{connectedCallback(){super.connectedCallback(),e.warned||(e.warned=!0,console.warn("<hotosm-tool-menu> is deprecated and will be removed in the next major release of @hotosm/ui. Use <hot-tool-menu> instead."))}};e.warned=!1;var t=e;customElements.get("hotosm-tool-menu")||customElements.define("hotosm-tool-menu",t);export{l as a};
|
|
@@ -2,6 +2,8 @@ import HotToolMenu from "./tool-menu.component.js";
|
|
|
2
2
|
export default HotToolMenu;
|
|
3
3
|
declare global {
|
|
4
4
|
interface HTMLElementTagNameMap {
|
|
5
|
+
"hot-tool-menu": HotToolMenu;
|
|
6
|
+
/** @deprecated Use `hot-tool-menu` - this alias is removed in the next major release. */
|
|
5
7
|
"hotosm-tool-menu": HotToolMenu;
|
|
6
8
|
}
|
|
7
9
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../../chunks/chunk.
|
|
1
|
+
import{a}from"../../chunks/chunk.HJTJO26W.js";import"../../chunks/chunk.LH3TTPVQ.js";import"../../chunks/chunk.IVW6CBE7.js";import"../../chunks/chunk.HOF672RD.js";import"../../chunks/chunk.N2W26RCT.js";export{a as default};
|
package/dist/hotosm-ui.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as p}from"./chunks/chunk.TMPPHKMO.js";import"./chunks/chunk.LJ4XIP4K.js";import"./chunks/chunk.LIASDRWH.js";import{a as y}from"./chunks/chunk.
|
|
1
|
+
import{a as p}from"./chunks/chunk.TMPPHKMO.js";import"./chunks/chunk.LJ4XIP4K.js";import"./chunks/chunk.LIASDRWH.js";import{a as y}from"./chunks/chunk.HJTJO26W.js";import"./chunks/chunk.LH3TTPVQ.js";import"./chunks/chunk.IVW6CBE7.js";import{a as u}from"./chunks/chunk.D2QPKXC3.js";import"./chunks/chunk.RPCVLKA4.js";import{a as S}from"./chunks/chunk.GP3AB7RO.js";import{a as m}from"./chunks/chunk.G7OBK7EE.js";import"./chunks/chunk.JCAWUWEO.js";import"./chunks/chunk.7X5TBZPD.js";import{a as f}from"./chunks/chunk.HY6LFZQK.js";import"./chunks/chunk.HPW4YC7W.js";import{a as d}from"./chunks/chunk.R7BKNF25.js";import"./chunks/chunk.DY7CT6FN.js";import"./chunks/chunk.KO4EOD3I.js";import"./chunks/chunk.VSRVTIBV.js";import"./chunks/chunk.45EZ2EC2.js";import"./chunks/chunk.AYSFL7J5.js";import{a as h}from"./chunks/chunk.347QGSW2.js";import"./chunks/chunk.B77WIT2F.js";import"./chunks/chunk.TJOQKPXN.js";import"./chunks/chunk.DVVFVLNQ.js";import"./chunks/chunk.HOF672RD.js";import"./chunks/chunk.N2W26RCT.js";function a(t,e=document){let o=[],r=e.querySelectorAll(t);return o.push(...Array.from(r)),e.querySelectorAll("*").forEach(i=>{i.shadowRoot&&o.push(...a(t,i.shadowRoot))}),o}function g(t){let{css:e,selector:o="wa-button",all:r=!0,styleId:s="hot-theme-injection"}=t;(r?a(o):[a(o)[0]].filter(Boolean)).forEach(n=>{if(!n)return;let c=()=>{if(!n.shadowRoot){setTimeout(c,10);return}if(n.shadowRoot.getElementById(s))return;let l=document.createElement("style");l.id=s,l.textContent=e,n.shadowRoot.appendChild(l)};c()})}export{f as Announcement,d as Consent,S as FileInputDropzone,m as Header,h as ListCard,p as Logo,y as ToolMenu,u as Tracking,g as injectCSSIntoShadowDOM};
|
package/dist/vite.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** Build helpers for apps that use `@hotosm/ui`. */
|
|
2
|
+
/** Minimal chunk type that avoids depending on a specific bundler version. */
|
|
3
|
+
export interface EmittedChunk {
|
|
4
|
+
type: "chunk";
|
|
5
|
+
name: string;
|
|
6
|
+
fileName: string;
|
|
7
|
+
imports: readonly string[];
|
|
8
|
+
dynamicImports?: readonly string[];
|
|
9
|
+
}
|
|
10
|
+
export type EmittedBundle = Record<string, {
|
|
11
|
+
type: string;
|
|
12
|
+
} | EmittedChunk>;
|
|
13
|
+
/** Find cycles in static chunk imports. Dynamic imports are ignored. */
|
|
14
|
+
export declare function findChunkCycles(bundle: EmittedBundle): string[][];
|
|
15
|
+
export interface CircularChunkGuardOptions {
|
|
16
|
+
/** Warn instead of failing the build. */
|
|
17
|
+
warnOnly?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/** Minimal plugin type that avoids depending on a specific bundler version. */
|
|
20
|
+
export interface ChunkGuardPlugin {
|
|
21
|
+
name: string;
|
|
22
|
+
apply: "build";
|
|
23
|
+
enforce: "post";
|
|
24
|
+
generateBundle(this: unknown, options: unknown, bundle: EmittedBundle): void;
|
|
25
|
+
}
|
|
26
|
+
/** Fail the build when output chunks import each other in a cycle. */
|
|
27
|
+
export declare function circularChunkGuard(options?: CircularChunkGuardOptions): ChunkGuardPlugin;
|
|
28
|
+
/** WebAwesome modules as a Rolldown code-splitting group. */
|
|
29
|
+
export declare const WEBAWESOME_CHUNK: {
|
|
30
|
+
test: RegExp;
|
|
31
|
+
name: string;
|
|
32
|
+
};
|
|
33
|
+
/** Match WebAwesome modules in a Rollup `manualChunks` callback. */
|
|
34
|
+
export declare function matchWebawesome(id: string): string | undefined;
|
package/dist/vite.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// src/vite.ts
|
|
2
|
+
function findChunkCycles(bundle) {
|
|
3
|
+
const imports = /* @__PURE__ */ new Map();
|
|
4
|
+
const name = /* @__PURE__ */ new Map();
|
|
5
|
+
for (const [file, output] of Object.entries(bundle)) {
|
|
6
|
+
if (output.type !== "chunk") continue;
|
|
7
|
+
const chunk = output;
|
|
8
|
+
name.set(file, chunk.name || file);
|
|
9
|
+
imports.set(
|
|
10
|
+
file,
|
|
11
|
+
chunk.imports.filter((id) => bundle[id]?.type === "chunk")
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
const onStack = /* @__PURE__ */ new Set();
|
|
15
|
+
const done = /* @__PURE__ */ new Set();
|
|
16
|
+
const stack = [];
|
|
17
|
+
const cycles = /* @__PURE__ */ new Map();
|
|
18
|
+
const visit = (file) => {
|
|
19
|
+
onStack.add(file);
|
|
20
|
+
stack.push(file);
|
|
21
|
+
for (const next of imports.get(file) ?? []) {
|
|
22
|
+
if (onStack.has(next)) {
|
|
23
|
+
const cycle = [...stack.slice(stack.indexOf(next)), next].map((f) => name.get(f) ?? f);
|
|
24
|
+
cycles.set(cycle.join(" -> "), cycle);
|
|
25
|
+
} else if (!done.has(next)) {
|
|
26
|
+
visit(next);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
stack.pop();
|
|
30
|
+
onStack.delete(file);
|
|
31
|
+
done.add(file);
|
|
32
|
+
};
|
|
33
|
+
for (const file of imports.keys()) if (!done.has(file)) visit(file);
|
|
34
|
+
return [...cycles.values()];
|
|
35
|
+
}
|
|
36
|
+
function circularChunkGuard(options = {}) {
|
|
37
|
+
return {
|
|
38
|
+
name: "hotosm-circular-chunk-guard",
|
|
39
|
+
apply: "build",
|
|
40
|
+
enforce: "post",
|
|
41
|
+
generateBundle(_options, bundle) {
|
|
42
|
+
const cycles = findChunkCycles(bundle);
|
|
43
|
+
if (cycles.length === 0) return;
|
|
44
|
+
const message = [
|
|
45
|
+
`Circular chunk import${cycles.length > 1 ? "s" : ""} in the build output:`,
|
|
46
|
+
...cycles.map((cycle) => ` ${cycle.join(" -> ")}`),
|
|
47
|
+
"",
|
|
48
|
+
"This can cause a blank page or an 'x is undefined' error at runtime.",
|
|
49
|
+
"Check your manual chunk rules or remove them."
|
|
50
|
+
].join("\n");
|
|
51
|
+
if (options.warnOnly) {
|
|
52
|
+
console.warn(`[hotosm-circular-chunk-guard] ${message}`);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
throw new Error(message);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
var WEBAWESOME_CHUNK = {
|
|
60
|
+
test: /[\\/]@awesome\.me[\\/]webawesome[\\/]/,
|
|
61
|
+
name: "webawesome"
|
|
62
|
+
};
|
|
63
|
+
function matchWebawesome(id) {
|
|
64
|
+
return WEBAWESOME_CHUNK.test.test(id) ? WEBAWESOME_CHUNK.name : void 0;
|
|
65
|
+
}
|
|
66
|
+
export {
|
|
67
|
+
WEBAWESOME_CHUNK,
|
|
68
|
+
circularChunkGuard,
|
|
69
|
+
findChunkCycles,
|
|
70
|
+
matchWebawesome
|
|
71
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hotosm/ui",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "Shared UI components with HOT theming.",
|
|
5
5
|
"homepage": "https://github.com/hotosm/ui#readme",
|
|
6
6
|
"license": "GPL-3.0-only",
|
|
@@ -44,6 +44,10 @@
|
|
|
44
44
|
"types": "./dist/hotosm-ui.d.ts",
|
|
45
45
|
"import": "./dist/hotosm-ui.js"
|
|
46
46
|
},
|
|
47
|
+
"./vite": {
|
|
48
|
+
"types": "./dist/vite.d.ts",
|
|
49
|
+
"import": "./dist/vite.js"
|
|
50
|
+
},
|
|
47
51
|
"./dist/hotosm-ui.js": "./dist/hotosm-ui.js",
|
|
48
52
|
"./dist/webawesome-all.js": {
|
|
49
53
|
"types": "./dist/webawesome-all.d.ts",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as o}from"./chunk.LH3TTPVQ.js";var t=o;customElements.get("hotosm-tool-menu")||customElements.define("hotosm-tool-menu",o);export{t as a};
|