@politiet/sheriff-web-components 1.0.0-rc.1 → 1.0.0-rc.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.
|
@@ -4,8 +4,11 @@ export declare const loadLocalIcons: IconPromise;
|
|
|
4
4
|
export declare class SDSIconLoader {
|
|
5
5
|
private readonly cache;
|
|
6
6
|
static defaultResolver: IconPromise;
|
|
7
|
+
static loadCdnIcons: IconPromise;
|
|
8
|
+
static loadLocalIcons: IconPromise;
|
|
7
9
|
resolver: IconPromise;
|
|
8
10
|
constructor();
|
|
9
11
|
resolve(name: string, onResolved: (svg: string) => void): void;
|
|
12
|
+
static setCustomResolver(resolver: IconPromise): void;
|
|
10
13
|
}
|
|
11
14
|
//# sourceMappingURL=sds-icon-loader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sds-icon-loader.d.ts","sourceRoot":"","sources":["../../src/sds-icon/sds-icon-loader.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAEhE,eAAO,MAAM,YAAY,EAAE,WAMxB,CAAC;AAEJ,eAAO,MAAM,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"sds-icon-loader.d.ts","sourceRoot":"","sources":["../../src/sds-icon/sds-icon-loader.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAEhE,eAAO,MAAM,YAAY,EAAE,WAMxB,CAAC;AAEJ,eAAO,MAAM,cAAc,EAAE,WAQ5B,CAAC;AAEF,qBAAa,aAAa;IACzB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA6B;IAGnD,MAAM,CAAC,eAAe,EAAE,WAAW,CAQjC;IAGF,MAAM,CAAC,YAAY,EAAE,WAAW,CAI5B;IAGJ,MAAM,CAAC,cAAc,EAAE,WAAW,CAOhC;IAGF,QAAQ,EAAE,WAAW,CAAC;;IAMtB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI;IAmB9D,MAAM,CAAC,iBAAiB,CAAC,QAAQ,EAAE,WAAW,GAAG,IAAI;CAGrD"}
|
|
@@ -1,14 +1,24 @@
|
|
|
1
|
+
var _a;
|
|
1
2
|
export const loadCdnIcons = async (name) => await fetch(`https://unpkg.com/@politiet/sheriff-icons/dist/${name}.svg`).then((response) => {
|
|
2
3
|
if (!response.ok) {
|
|
3
4
|
throw new TypeError(`Sheriff: unknown icon: '${name}'`);
|
|
4
5
|
}
|
|
5
6
|
return response.text();
|
|
6
7
|
});
|
|
7
|
-
export const loadLocalIcons = async (name) =>
|
|
8
|
+
export const loadLocalIcons = async (name) => {
|
|
9
|
+
try {
|
|
10
|
+
const { default: svg } = await import(`@politiet/sheriff-icons/dist/${name}.js`);
|
|
11
|
+
return svg;
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
console.warn(`Local icon '${name}' could not be loaded. Falling back to CDN.`);
|
|
15
|
+
return loadCdnIcons(name); // Fallback to CDN if local loading fails
|
|
16
|
+
}
|
|
17
|
+
};
|
|
8
18
|
export class SDSIconLoader {
|
|
9
19
|
constructor() {
|
|
10
20
|
this.cache = new Map();
|
|
11
|
-
this.resolver =
|
|
21
|
+
this.resolver = _a.defaultResolver;
|
|
12
22
|
}
|
|
13
23
|
resolve(name, onResolved) {
|
|
14
24
|
const cached = this.cache.get(name);
|
|
@@ -16,18 +26,47 @@ export class SDSIconLoader {
|
|
|
16
26
|
onResolved(cached);
|
|
17
27
|
return;
|
|
18
28
|
}
|
|
19
|
-
|
|
29
|
+
this.resolver(name)
|
|
20
30
|
.catch((error) => {
|
|
21
31
|
console.error(`Failed to fetch icon '${name}':`, error);
|
|
22
32
|
return '';
|
|
23
33
|
})
|
|
24
34
|
.then((svg) => {
|
|
25
35
|
this.cache.set(name, svg);
|
|
26
|
-
|
|
36
|
+
onResolved(svg);
|
|
27
37
|
});
|
|
28
|
-
|
|
38
|
+
}
|
|
39
|
+
// Allow consumers to override the resolver
|
|
40
|
+
static setCustomResolver(resolver) {
|
|
41
|
+
_a.defaultResolver = resolver;
|
|
29
42
|
}
|
|
30
43
|
}
|
|
31
|
-
|
|
32
|
-
|
|
44
|
+
_a = SDSIconLoader;
|
|
45
|
+
// Default resolver: First try CDN, then fallback to local node_modules
|
|
46
|
+
SDSIconLoader.defaultResolver = async (name) => {
|
|
47
|
+
try {
|
|
48
|
+
// Try to load from CDN
|
|
49
|
+
return await _a.loadCdnIcons(name);
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
console.warn(`CDN icon '${name}' not found, falling back to local.`);
|
|
53
|
+
return _a.loadLocalIcons(name);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
// CDN Resolver
|
|
57
|
+
SDSIconLoader.loadCdnIcons = async (name) => fetch(`https://unpkg.com/@politiet/sheriff-icons/dist/${name}.svg`).then((response) => {
|
|
58
|
+
if (!response.ok)
|
|
59
|
+
throw new Error(`Sheriff: unknown icon '${name}'`);
|
|
60
|
+
return response.text();
|
|
61
|
+
});
|
|
62
|
+
// Local Resolver (fallback)
|
|
63
|
+
SDSIconLoader.loadLocalIcons = async (name) => {
|
|
64
|
+
try {
|
|
65
|
+
const { default: svg } = await import(`@politiet/sheriff-icons/dist/${name}.js`);
|
|
66
|
+
return svg;
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
throw new Error(`Local icon '${name}' could not be loaded.`);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
33
72
|
//# sourceMappingURL=sds-icon-loader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sds-icon-loader.js","sourceRoot":"","sources":["../../src/sds-icon/sds-icon-loader.ts"],"names":[],"mappings":"A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;AACF,CAAC,AARqB,CAQpB;AAEF,eAAe;AACR,0BAAY,GAAgB,KAAK,EAAE,IAAY,EAAE,EAAE,CACzD,KAAK,CAAC,kDAAkD,IAAI,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;IACrF,IAAI,CAAC,QAAQ,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,IAAI,GAAG,CAAC,CAAC;IACrE,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;AACxB,CAAC,CAAC,AAJgB,CAIf;AAEJ,4BAA4B;AACrB,4BAAc,GAAgB,KAAK,EAAE,IAAY,EAAE,EAAE;IAC3D,IAAI,CAAC;QACJ,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,MAAM,MAAM,CAAC,gCAAgC,IAAI,KAAK,CAAC,CAAC;QACjF,OAAO,GAAG,CAAC;IACZ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,eAAe,IAAI,wBAAwB,CAAC,CAAC;IAC9D,CAAC;AACF,CAAC,AAPoB,CAOnB","sourcesContent":["export type IconPromise = (iconName: string) => Promise<string>;\n\nexport const loadCdnIcons: IconPromise = async (name: string) =>\n\tawait fetch(`https://unpkg.com/@politiet/sheriff-icons/dist/${name}.svg`).then((response) => {\n\t\tif (!response.ok) {\n\t\t\tthrow new TypeError(`Sheriff: unknown icon: '${name}'`);\n\t\t}\n\t\treturn response.text();\n\t});\n\nexport const loadLocalIcons: IconPromise = async (name: string) => {\n\ttry {\n\t\tconst { default: svg } = await import(`@politiet/sheriff-icons/dist/${name}.js`);\n\t\treturn svg;\n\t} catch (error) {\n\t\tconsole.warn(`Local icon '${name}' could not be loaded. Falling back to CDN.`);\n\t\treturn loadCdnIcons(name); // Fallback to CDN if local loading fails\n\t}\n};\n\nexport class SDSIconLoader {\n\tprivate readonly cache = new Map<string, string>();\n\n\t// Default resolver: First try CDN, then fallback to local node_modules\n\tstatic defaultResolver: IconPromise = async (name: string) => {\n\t\ttry {\n\t\t\t// Try to load from CDN\n\t\t\treturn await SDSIconLoader.loadCdnIcons(name);\n\t\t} catch (error) {\n\t\t\tconsole.warn(`CDN icon '${name}' not found, falling back to local.`);\n\t\t\treturn SDSIconLoader.loadLocalIcons(name);\n\t\t}\n\t};\n\n\t// CDN Resolver\n\tstatic loadCdnIcons: IconPromise = async (name: string) =>\n\t\tfetch(`https://unpkg.com/@politiet/sheriff-icons/dist/${name}.svg`).then((response) => {\n\t\t\tif (!response.ok) throw new Error(`Sheriff: unknown icon '${name}'`);\n\t\t\treturn response.text();\n\t\t});\n\n\t// Local Resolver (fallback)\n\tstatic loadLocalIcons: IconPromise = async (name: string) => {\n\t\ttry {\n\t\t\tconst { default: svg } = await import(`@politiet/sheriff-icons/dist/${name}.js`);\n\t\t\treturn svg;\n\t\t} catch (error) {\n\t\t\tthrow new Error(`Local icon '${name}' could not be loaded.`);\n\t\t}\n\t};\n\n\t// Instance resolver (uses the static resolver by default)\n\tresolver: IconPromise;\n\n\tconstructor() {\n\t\tthis.resolver = SDSIconLoader.defaultResolver;\n\t}\n\n\tresolve(name: string, onResolved: (svg: string) => void): void {\n\t\tconst cached = this.cache.get(name);\n\t\tif (cached != null) {\n\t\t\tonResolved(cached);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.resolver(name)\n\t\t\t.catch((error) => {\n\t\t\t\tconsole.error(`Failed to fetch icon '${name}':`, error);\n\t\t\t\treturn '';\n\t\t\t})\n\t\t\t.then((svg) => {\n\t\t\t\tthis.cache.set(name, svg);\n\t\t\t\tonResolved(svg);\n\t\t\t});\n\t}\n\n\t// Allow consumers to override the resolver\n\tstatic setCustomResolver(resolver: IconPromise): void {\n\t\tSDSIconLoader.defaultResolver = resolver;\n\t}\n}\n"]}
|
|
@@ -1209,12 +1209,6 @@ class e extends i {
|
|
|
1209
1209
|
}
|
|
1210
1210
|
e.directiveName = "unsafeHTML", e.resultType = 1;
|
|
1211
1211
|
const o = e$2(e);
|
|
1212
|
-
const loadCdnIcons = async (name) => await fetch(`https://unpkg.com/@politiet/sheriff-icons/dist/${name}.svg`).then((response) => {
|
|
1213
|
-
if (!response.ok) {
|
|
1214
|
-
throw new TypeError(`Sheriff: unknown icon: '${name}'`);
|
|
1215
|
-
}
|
|
1216
|
-
return response.text();
|
|
1217
|
-
});
|
|
1218
1212
|
const _SDSIconLoader = class _SDSIconLoader {
|
|
1219
1213
|
constructor() {
|
|
1220
1214
|
this.cache = /* @__PURE__ */ new Map();
|
|
@@ -1226,17 +1220,39 @@ const _SDSIconLoader = class _SDSIconLoader {
|
|
|
1226
1220
|
onResolved(cached);
|
|
1227
1221
|
return;
|
|
1228
1222
|
}
|
|
1229
|
-
|
|
1223
|
+
this.resolver(name).catch((error) => {
|
|
1230
1224
|
console.error(`Failed to fetch icon '${name}':`, error);
|
|
1231
1225
|
return "";
|
|
1232
1226
|
}).then((svg) => {
|
|
1233
1227
|
this.cache.set(name, svg);
|
|
1234
|
-
|
|
1228
|
+
onResolved(svg);
|
|
1235
1229
|
});
|
|
1236
|
-
|
|
1230
|
+
}
|
|
1231
|
+
// Allow consumers to override the resolver
|
|
1232
|
+
static setCustomResolver(resolver) {
|
|
1233
|
+
_SDSIconLoader.defaultResolver = resolver;
|
|
1234
|
+
}
|
|
1235
|
+
};
|
|
1236
|
+
_SDSIconLoader.defaultResolver = async (name) => {
|
|
1237
|
+
try {
|
|
1238
|
+
return await _SDSIconLoader.loadCdnIcons(name);
|
|
1239
|
+
} catch (error) {
|
|
1240
|
+
console.warn(`CDN icon '${name}' not found, falling back to local.`);
|
|
1241
|
+
return _SDSIconLoader.loadLocalIcons(name);
|
|
1242
|
+
}
|
|
1243
|
+
};
|
|
1244
|
+
_SDSIconLoader.loadCdnIcons = async (name) => fetch(`https://unpkg.com/@politiet/sheriff-icons/dist/${name}.svg`).then((response) => {
|
|
1245
|
+
if (!response.ok) throw new Error(`Sheriff: unknown icon '${name}'`);
|
|
1246
|
+
return response.text();
|
|
1247
|
+
});
|
|
1248
|
+
_SDSIconLoader.loadLocalIcons = async (name) => {
|
|
1249
|
+
try {
|
|
1250
|
+
const { default: svg } = await import(`@politiet/sheriff-icons/dist/${name}.js`);
|
|
1251
|
+
return svg;
|
|
1252
|
+
} catch (error) {
|
|
1253
|
+
throw new Error(`Local icon '${name}' could not be loaded.`);
|
|
1237
1254
|
}
|
|
1238
1255
|
};
|
|
1239
|
-
_SDSIconLoader.defaultResolver = loadCdnIcons;
|
|
1240
1256
|
let SDSIconLoader = _SDSIconLoader;
|
|
1241
1257
|
const styles$e = i$4`
|
|
1242
1258
|
:host {
|