@editframe/elements 0.40.2 → 0.40.4

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.
@@ -17,7 +17,7 @@ function EFSourceMixin(superClass, options) {
17
17
  } });
18
18
  }
19
19
  get apiHost() {
20
- return this.closest("ef-configuration")?.apiHost ?? this.closest("ef-workbench")?.apiHost ?? this.closest("ef-preview")?.apiHost;
20
+ return this.closest("ef-configuration")?.apiHost ?? this.closest("ef-workbench")?.apiHost ?? this.closest("ef-preview")?.apiHost ?? window.location.origin;
21
21
  }
22
22
  #md5Value = void 0;
23
23
  #md5Promise = null;
@@ -1 +1 @@
1
- {"version":3,"file":"EFSourceMixin.js","names":["#md5Value","#md5LastSrc","#md5Promise","#doLoadMd5"],"sources":["../../src/elements/EFSourceMixin.ts"],"sourcesContent":["import type { LitElement } from \"lit\";\nimport { property } from \"lit/decorators/property.js\";\n\nexport declare class EFSourceMixinInterface {\n apiHost?: string;\n productionSrc(): string;\n src: string;\n}\n\ninterface EFSourceMixinOptions {\n assetType: string;\n}\ntype Constructor<T = {}> = new (...args: any[]) => T;\nexport function EFSourceMixin<T extends Constructor<LitElement>>(\n superClass: T,\n options: EFSourceMixinOptions,\n) {\n class EFSourceElement extends superClass {\n get apiHost() {\n const apiHost =\n (this.closest(\"ef-configuration\") as any)?.apiHost ??\n (this.closest(\"ef-workbench\") as any)?.apiHost ??\n (this.closest(\"ef-preview\") as any)?.apiHost;\n\n // Return undefined instead of defaulting to external URL\n // This allows components to use current origin when apiHost is not set\n return apiHost;\n }\n\n @property({ type: String, reflect: true })\n src = \"\";\n\n #md5Value: string | undefined = undefined;\n #md5Promise: Promise<string | undefined> | null = null;\n #md5LastSrc: string | null = null;\n\n productionSrc() {\n if (!this.#md5Value) {\n throw new Error(\n `MD5 sum not available for ${this}. Cannot generate production URL`,\n );\n }\n\n if (!this.apiHost) {\n throw new Error(\n `apiHost not available for ${this}. Cannot generate production URL`,\n );\n }\n\n return `${this.apiHost}/api/v1/${options.assetType}/${this.#md5Value}`;\n }\n\n /**\n * Load MD5 sum for the current source\n */\n async loadMd5Sum(signal?: AbortSignal): Promise<string | undefined> {\n if (this.#md5LastSrc === this.src && this.#md5Value) {\n return this.#md5Value;\n }\n\n if (this.#md5Promise && this.#md5LastSrc === this.src) {\n return this.#md5Promise;\n }\n\n this.#md5LastSrc = this.src;\n this.#md5Promise = this.#doLoadMd5(this.src, signal);\n\n try {\n this.#md5Value = await this.#md5Promise;\n return this.#md5Value;\n } catch (error) {\n if (error instanceof DOMException && error.name === \"AbortError\") {\n throw error;\n }\n console.error(\"EFSourceMixin md5Sum error\", error);\n return undefined;\n } finally {\n this.#md5Promise = null;\n }\n }\n\n async #doLoadMd5(\n src: string,\n signal?: AbortSignal,\n ): Promise<string | undefined> {\n // Normalize the path: remove leading slash and any double slashes\n let normalizedSrc = src.startsWith(\"/\") ? src.slice(1) : src;\n normalizedSrc = normalizedSrc.replace(/^\\/+/, \"\");\n const md5Path = `/api/v1/files/md5?src=${encodeURIComponent(normalizedSrc)}`;\n const response = await fetch(md5Path, { signal });\n if (!response.ok) {\n return undefined;\n }\n const data = await response.json();\n return data.md5 ?? undefined;\n }\n\n /** @internal Exposes md5 state for md5SumLoader proxy without private field access in handler */\n _getMd5Value(): string | undefined {\n return this.#md5Value;\n }\n\n /** @internal Exposes md5 promise state for md5SumLoader proxy */\n _getMd5Promise(): Promise<string | undefined> | null {\n return this.#md5Promise;\n }\n\n /**\n * Compatibility wrapper for code expecting md5SumLoader.value\n */\n md5SumLoader = new Proxy(\n {\n run: () => this.loadMd5Sum(),\n host: this,\n } as unknown as {\n run: () => Promise<string | undefined>;\n host: {\n _getMd5Value: () => string | undefined;\n _getMd5Promise: () => Promise<string | undefined> | null;\n };\n value: string | undefined;\n taskComplete: Promise<string | undefined>;\n },\n {\n get(target, prop) {\n if (prop === \"value\") {\n return target.host._getMd5Value();\n }\n if (prop === \"taskComplete\") {\n const p = target.host._getMd5Promise();\n return p || Promise.resolve(target.host._getMd5Value());\n }\n return (target as any)[prop];\n },\n },\n );\n }\n\n return EFSourceElement as Constructor<EFSourceMixinInterface> & T;\n}\n"],"mappings":";;;;AAaA,SAAgB,cACd,YACA,SACA;CACA,MAAM,wBAAwB,WAAW;;;cAajC;uBAgFS,IAAI,MACjB;IACE,WAAW,KAAK,YAAY;IAC5B,MAAM;IACP,EASD,EACE,IAAI,QAAQ,MAAM;AAChB,QAAI,SAAS,QACX,QAAO,OAAO,KAAK,cAAc;AAEnC,QAAI,SAAS,eAEX,QADU,OAAO,KAAK,gBAAgB,IAC1B,QAAQ,QAAQ,OAAO,KAAK,cAAc,CAAC;AAEzD,WAAQ,OAAe;MAE1B,CACF;;EArHD,IAAI,UAAU;AAQZ,UANG,KAAK,QAAQ,mBAAmB,EAAU,WAC1C,KAAK,QAAQ,eAAe,EAAU,WACtC,KAAK,QAAQ,aAAa,EAAU;;EAUzC,YAAgC;EAChC,cAAkD;EAClD,cAA6B;EAE7B,gBAAgB;AACd,OAAI,CAAC,MAAKA,SACR,OAAM,IAAI,MACR,6BAA6B,KAAK,kCACnC;AAGH,OAAI,CAAC,KAAK,QACR,OAAM,IAAI,MACR,6BAA6B,KAAK,kCACnC;AAGH,UAAO,GAAG,KAAK,QAAQ,UAAU,QAAQ,UAAU,GAAG,MAAKA;;;;;EAM7D,MAAM,WAAW,QAAmD;AAClE,OAAI,MAAKC,eAAgB,KAAK,OAAO,MAAKD,SACxC,QAAO,MAAKA;AAGd,OAAI,MAAKE,cAAe,MAAKD,eAAgB,KAAK,IAChD,QAAO,MAAKC;AAGd,SAAKD,aAAc,KAAK;AACxB,SAAKC,aAAc,MAAKC,UAAW,KAAK,KAAK,OAAO;AAEpD,OAAI;AACF,UAAKH,WAAY,MAAM,MAAKE;AAC5B,WAAO,MAAKF;YACL,OAAO;AACd,QAAI,iBAAiB,gBAAgB,MAAM,SAAS,aAClD,OAAM;AAER,YAAQ,MAAM,8BAA8B,MAAM;AAClD;aACQ;AACR,UAAKE,aAAc;;;EAIvB,OAAMC,UACJ,KACA,QAC6B;GAE7B,IAAI,gBAAgB,IAAI,WAAW,IAAI,GAAG,IAAI,MAAM,EAAE,GAAG;AACzD,mBAAgB,cAAc,QAAQ,QAAQ,GAAG;GACjD,MAAM,UAAU,yBAAyB,mBAAmB,cAAc;GAC1E,MAAM,WAAW,MAAM,MAAM,SAAS,EAAE,QAAQ,CAAC;AACjD,OAAI,CAAC,SAAS,GACZ;AAGF,WADa,MAAM,SAAS,MAAM,EACtB,OAAO;;;EAIrB,eAAmC;AACjC,UAAO,MAAKH;;;EAId,iBAAqD;AACnD,UAAO,MAAKE;;;aA3Eb,SAAS;EAAE,MAAM;EAAQ,SAAS;EAAM,CAAC;AA6G5C,QAAO"}
1
+ {"version":3,"file":"EFSourceMixin.js","names":["#md5Value","#md5LastSrc","#md5Promise","#doLoadMd5"],"sources":["../../src/elements/EFSourceMixin.ts"],"sourcesContent":["import type { LitElement } from \"lit\";\nimport { property } from \"lit/decorators/property.js\";\n\nexport declare class EFSourceMixinInterface {\n apiHost?: string;\n productionSrc(): string;\n src: string;\n}\n\ninterface EFSourceMixinOptions {\n assetType: string;\n}\ntype Constructor<T = {}> = new (...args: any[]) => T;\nexport function EFSourceMixin<T extends Constructor<LitElement>>(\n superClass: T,\n options: EFSourceMixinOptions,\n) {\n class EFSourceElement extends superClass {\n get apiHost() {\n return (\n (this.closest(\"ef-configuration\") as any)?.apiHost ??\n (this.closest(\"ef-workbench\") as any)?.apiHost ??\n (this.closest(\"ef-preview\") as any)?.apiHost ??\n window.location.origin\n );\n }\n\n @property({ type: String, reflect: true })\n src = \"\";\n\n #md5Value: string | undefined = undefined;\n #md5Promise: Promise<string | undefined> | null = null;\n #md5LastSrc: string | null = null;\n\n productionSrc() {\n if (!this.#md5Value) {\n throw new Error(\n `MD5 sum not available for ${this}. Cannot generate production URL`,\n );\n }\n\n if (!this.apiHost) {\n throw new Error(\n `apiHost not available for ${this}. Cannot generate production URL`,\n );\n }\n\n return `${this.apiHost}/api/v1/${options.assetType}/${this.#md5Value}`;\n }\n\n /**\n * Load MD5 sum for the current source\n */\n async loadMd5Sum(signal?: AbortSignal): Promise<string | undefined> {\n if (this.#md5LastSrc === this.src && this.#md5Value) {\n return this.#md5Value;\n }\n\n if (this.#md5Promise && this.#md5LastSrc === this.src) {\n return this.#md5Promise;\n }\n\n this.#md5LastSrc = this.src;\n this.#md5Promise = this.#doLoadMd5(this.src, signal);\n\n try {\n this.#md5Value = await this.#md5Promise;\n return this.#md5Value;\n } catch (error) {\n if (error instanceof DOMException && error.name === \"AbortError\") {\n throw error;\n }\n console.error(\"EFSourceMixin md5Sum error\", error);\n return undefined;\n } finally {\n this.#md5Promise = null;\n }\n }\n\n async #doLoadMd5(\n src: string,\n signal?: AbortSignal,\n ): Promise<string | undefined> {\n // Normalize the path: remove leading slash and any double slashes\n let normalizedSrc = src.startsWith(\"/\") ? src.slice(1) : src;\n normalizedSrc = normalizedSrc.replace(/^\\/+/, \"\");\n const md5Path = `/api/v1/files/md5?src=${encodeURIComponent(normalizedSrc)}`;\n const response = await fetch(md5Path, { signal });\n if (!response.ok) {\n return undefined;\n }\n const data = await response.json();\n return data.md5 ?? undefined;\n }\n\n /** @internal Exposes md5 state for md5SumLoader proxy without private field access in handler */\n _getMd5Value(): string | undefined {\n return this.#md5Value;\n }\n\n /** @internal Exposes md5 promise state for md5SumLoader proxy */\n _getMd5Promise(): Promise<string | undefined> | null {\n return this.#md5Promise;\n }\n\n /**\n * Compatibility wrapper for code expecting md5SumLoader.value\n */\n md5SumLoader = new Proxy(\n {\n run: () => this.loadMd5Sum(),\n host: this,\n } as unknown as {\n run: () => Promise<string | undefined>;\n host: {\n _getMd5Value: () => string | undefined;\n _getMd5Promise: () => Promise<string | undefined> | null;\n };\n value: string | undefined;\n taskComplete: Promise<string | undefined>;\n },\n {\n get(target, prop) {\n if (prop === \"value\") {\n return target.host._getMd5Value();\n }\n if (prop === \"taskComplete\") {\n const p = target.host._getMd5Promise();\n return p || Promise.resolve(target.host._getMd5Value());\n }\n return (target as any)[prop];\n },\n },\n );\n }\n\n return EFSourceElement as Constructor<EFSourceMixinInterface> & T;\n}\n"],"mappings":";;;;AAaA,SAAgB,cACd,YACA,SACA;CACA,MAAM,wBAAwB,WAAW;;;cAWjC;uBAgFS,IAAI,MACjB;IACE,WAAW,KAAK,YAAY;IAC5B,MAAM;IACP,EASD,EACE,IAAI,QAAQ,MAAM;AAChB,QAAI,SAAS,QACX,QAAO,OAAO,KAAK,cAAc;AAEnC,QAAI,SAAS,eAEX,QADU,OAAO,KAAK,gBAAgB,IAC1B,QAAQ,QAAQ,OAAO,KAAK,cAAc,CAAC;AAEzD,WAAQ,OAAe;MAE1B,CACF;;EAnHD,IAAI,UAAU;AACZ,UACG,KAAK,QAAQ,mBAAmB,EAAU,WAC1C,KAAK,QAAQ,eAAe,EAAU,WACtC,KAAK,QAAQ,aAAa,EAAU,WACrC,OAAO,SAAS;;EAOpB,YAAgC;EAChC,cAAkD;EAClD,cAA6B;EAE7B,gBAAgB;AACd,OAAI,CAAC,MAAKA,SACR,OAAM,IAAI,MACR,6BAA6B,KAAK,kCACnC;AAGH,OAAI,CAAC,KAAK,QACR,OAAM,IAAI,MACR,6BAA6B,KAAK,kCACnC;AAGH,UAAO,GAAG,KAAK,QAAQ,UAAU,QAAQ,UAAU,GAAG,MAAKA;;;;;EAM7D,MAAM,WAAW,QAAmD;AAClE,OAAI,MAAKC,eAAgB,KAAK,OAAO,MAAKD,SACxC,QAAO,MAAKA;AAGd,OAAI,MAAKE,cAAe,MAAKD,eAAgB,KAAK,IAChD,QAAO,MAAKC;AAGd,SAAKD,aAAc,KAAK;AACxB,SAAKC,aAAc,MAAKC,UAAW,KAAK,KAAK,OAAO;AAEpD,OAAI;AACF,UAAKH,WAAY,MAAM,MAAKE;AAC5B,WAAO,MAAKF;YACL,OAAO;AACd,QAAI,iBAAiB,gBAAgB,MAAM,SAAS,aAClD,OAAM;AAER,YAAQ,MAAM,8BAA8B,MAAM;AAClD;aACQ;AACR,UAAKE,aAAc;;;EAIvB,OAAMC,UACJ,KACA,QAC6B;GAE7B,IAAI,gBAAgB,IAAI,WAAW,IAAI,GAAG,IAAI,MAAM,EAAE,GAAG;AACzD,mBAAgB,cAAc,QAAQ,QAAQ,GAAG;GACjD,MAAM,UAAU,yBAAyB,mBAAmB,cAAc;GAC1E,MAAM,WAAW,MAAM,MAAM,SAAS,EAAE,QAAQ,CAAC;AACjD,OAAI,CAAC,SAAS,GACZ;AAGF,WADa,MAAM,SAAS,MAAM,EACtB,OAAO;;;EAIrB,eAAmC;AACjC,UAAO,MAAKH;;;EAId,iBAAqD;AACnD,UAAO,MAAKE;;;aA3Eb,SAAS;EAAE,MAAM;EAAQ,SAAS;EAAM,CAAC;AA6G5C,QAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@editframe/elements",
3
- "version": "0.40.2",
3
+ "version": "0.40.4",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -18,7 +18,7 @@
18
18
  "license": "UNLICENSED",
19
19
  "dependencies": {
20
20
  "@bramus/style-observer": "^1.3.0",
21
- "@editframe/assets": "0.40.2",
21
+ "@editframe/assets": "0.40.4",
22
22
  "@lit/context": "^1.1.6",
23
23
  "@opentelemetry/api": "^1.9.0",
24
24
  "@opentelemetry/context-zone": "^1.26.0",