@bstage-sdk/host 0.11.0 → 0.12.0

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/dist/index.cjs CHANGED
@@ -33,11 +33,12 @@ var import_core = require("@bstage-sdk/core");
33
33
 
34
34
  // src/scriptLoader.ts
35
35
  var cache = /* @__PURE__ */ new Map();
36
- function loadScript(url, timeoutMs = 1e4) {
36
+ function loadScript(url, timeoutMs = 1e4, crossOrigin) {
37
37
  const existing = cache.get(url);
38
38
  if (existing) return existing;
39
39
  const promise = new Promise((resolve, reject) => {
40
40
  const script = document.createElement("script");
41
+ if (crossOrigin === "anonymous") script.crossOrigin = "anonymous";
41
42
  script.src = url;
42
43
  script.async = true;
43
44
  const timer = setTimeout(() => {
@@ -184,7 +185,7 @@ var TemplateHandle = class _TemplateHandle {
184
185
  // src/loadTemplate.ts
185
186
  async function loadTemplate(templateUrl, options) {
186
187
  const timeout = options?.timeout ?? 1e4;
187
- await loadScript(templateUrl, timeout);
188
+ await loadScript(templateUrl, timeout, options?.crossOrigin);
188
189
  const elementName = (0, import_core.lookupElementName)(templateUrl) ?? recoverLegacyElementName(templateUrl);
189
190
  if (!elementName) {
190
191
  throw new Error(
package/dist/index.d.cts CHANGED
@@ -17,6 +17,11 @@ interface TemplateInfo {
17
17
  interface LoadTemplateOptions {
18
18
  /** 스크립트 로드 타임아웃 (밀리초 단위, 기본값: 10,000) */
19
19
  timeout?: number;
20
+ /**
21
+ * 템플릿 번들 `<script>`의 crossorigin. `'anonymous'`면 교차 origin 번들의 에러 메시지·스택이 보인다
22
+ * (CDN이 `Access-Control-Allow-Origin`으로 응답해야 하며, 아니면 로드가 실패한다). 기본은 속성 없음.
23
+ */
24
+ crossOrigin?: 'anonymous';
20
25
  }
21
26
 
22
27
  declare class TemplateHandle {
package/dist/index.d.ts CHANGED
@@ -17,6 +17,11 @@ interface TemplateInfo {
17
17
  interface LoadTemplateOptions {
18
18
  /** 스크립트 로드 타임아웃 (밀리초 단위, 기본값: 10,000) */
19
19
  timeout?: number;
20
+ /**
21
+ * 템플릿 번들 `<script>`의 crossorigin. `'anonymous'`면 교차 origin 번들의 에러 메시지·스택이 보인다
22
+ * (CDN이 `Access-Control-Allow-Origin`으로 응답해야 하며, 아니면 로드가 실패한다). 기본은 속성 없음.
23
+ */
24
+ crossOrigin?: 'anonymous';
20
25
  }
21
26
 
22
27
  declare class TemplateHandle {
package/dist/index.js CHANGED
@@ -3,11 +3,12 @@ import { lookupElementName } from "@bstage-sdk/core";
3
3
 
4
4
  // src/scriptLoader.ts
5
5
  var cache = /* @__PURE__ */ new Map();
6
- function loadScript(url, timeoutMs = 1e4) {
6
+ function loadScript(url, timeoutMs = 1e4, crossOrigin) {
7
7
  const existing = cache.get(url);
8
8
  if (existing) return existing;
9
9
  const promise = new Promise((resolve, reject) => {
10
10
  const script = document.createElement("script");
11
+ if (crossOrigin === "anonymous") script.crossOrigin = "anonymous";
11
12
  script.src = url;
12
13
  script.async = true;
13
14
  const timer = setTimeout(() => {
@@ -154,7 +155,7 @@ var TemplateHandle = class _TemplateHandle {
154
155
  // src/loadTemplate.ts
155
156
  async function loadTemplate(templateUrl, options) {
156
157
  const timeout = options?.timeout ?? 1e4;
157
- await loadScript(templateUrl, timeout);
158
+ await loadScript(templateUrl, timeout, options?.crossOrigin);
158
159
  const elementName = lookupElementName(templateUrl) ?? recoverLegacyElementName(templateUrl);
159
160
  if (!elementName) {
160
161
  throw new Error(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bstage-sdk/host",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "bstage SDK host — load and manage template bundles on the platform side",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -30,7 +30,7 @@
30
30
  "dist"
31
31
  ],
32
32
  "dependencies": {
33
- "@bstage-sdk/core": "0.11.0"
33
+ "@bstage-sdk/core": "0.12.0"
34
34
  },
35
35
  "devDependencies": {
36
36
  "tsup": "^8.0.0",