@scalar/blocks 0.7.4 → 0.8.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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @scalar/blocks
2
2
 
3
+ ## 0.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#11103](https://github.com/scalar/scalar/pull/11103): Support `x-scalar-token-prefix` on header API keys. Generated code examples and outgoing requests add the configured prefix while stored credentials remain unchanged.
8
+
9
+ ### Patch Changes
10
+
11
+ - [#11123](https://github.com/scalar/scalar/pull/11123): Fix the API reference freezing on schemas with several recursive or cross-referencing `$ref`s. Generated examples that are too large to render at full depth are now rendered at the deepest depth that fits.
12
+
3
13
  ## 0.7.4
4
14
 
5
15
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"process-security-schemes.d.ts","sourceRoot":"","sources":["../../../../src/code-example/helpers/operation-to-har/process-security-schemes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAA;AACzF,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AAGvD,KAAK,8BAA8B,GAAG;IACpC,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;IAC9B,WAAW,EAAE,UAAU,CAAC,aAAa,CAAC,CAAA;IACtC,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;CAC/B,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GACjC,iBAAiB,0BAA0B,EAAE,KAC5C,8BA2EF,CAAA"}
1
+ {"version":3,"file":"process-security-schemes.d.ts","sourceRoot":"","sources":["../../../../src/code-example/helpers/operation-to-har/process-security-schemes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAA;AACzF,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AAGvD,KAAK,8BAA8B,GAAG;IACpC,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;IAC9B,WAAW,EAAE,UAAU,CAAC,aAAa,CAAC,CAAA;IACtC,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;CAC/B,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GACjC,iBAAiB,0BAA0B,EAAE,KAC5C,8BA2EF,CAAA"}
@@ -1,50 +1,54 @@
1
- import { encode as e } from "js-base64";
1
+ import { formatTokenPrefix as e } from "@scalar/helpers/http/format-token-prefix";
2
+ import { encode as t } from "js-base64";
2
3
  // src/code-example/helpers/operation-to-har/process-security-schemes.ts
3
- var t = (t) => {
4
- let n = {
4
+ var n = (n) => {
5
+ let r = {
5
6
  headers: [],
6
7
  queryString: [],
7
8
  cookies: []
8
9
  };
9
- for (let r of t) if (r.type === "apiKey") {
10
- let e = r["x-scalar-secret-token"] || "YOUR_SECRET_TOKEN";
11
- if (!r.name) continue;
12
- let t = {
13
- name: r.name,
14
- value: e
10
+ for (let i of n) if (i.type === "apiKey") {
11
+ let t = i["x-scalar-secret-token"] || "YOUR_SECRET_TOKEN";
12
+ if (!i.name) continue;
13
+ let n = {
14
+ name: i.name,
15
+ value: t
15
16
  };
16
- switch (r.in) {
17
+ switch (i.in) {
17
18
  case "header":
18
- n.headers.push(t);
19
+ r.headers.push({
20
+ ...n,
21
+ value: e(t, i["x-scalar-token-prefix"])
22
+ });
19
23
  break;
20
24
  case "query":
21
- n.queryString.push(t);
25
+ r.queryString.push(n);
22
26
  break;
23
- case "cookie": n.cookies.push(t);
27
+ case "cookie": r.cookies.push(n);
24
28
  }
25
- } else if (r.type === "http") {
26
- if (r.scheme === "basic") {
27
- let t = `${r["x-scalar-secret-username"] || ""}:${r["x-scalar-secret-password"] || ""}`, i = t === ":" ? "username:password" : e(t);
28
- n.headers.push({
29
+ } else if (i.type === "http") {
30
+ if (i.scheme === "basic") {
31
+ let e = `${i["x-scalar-secret-username"] || ""}:${i["x-scalar-secret-password"] || ""}`, n = e === ":" ? "username:password" : t(e);
32
+ r.headers.push({
29
33
  name: "Authorization",
30
- value: `Basic ${i}`
34
+ value: `Basic ${n}`
31
35
  });
32
- } else if (r.scheme === "bearer") {
33
- let e = r["x-scalar-secret-token"] || "YOUR_SECRET_TOKEN";
34
- n.headers.push({
36
+ } else if (i.scheme === "bearer") {
37
+ let e = i["x-scalar-secret-token"] || "YOUR_SECRET_TOKEN";
38
+ r.headers.push({
35
39
  name: "Authorization",
36
40
  value: `Bearer ${e}`
37
41
  });
38
42
  }
39
- } else if (r.type === "oauth2" && r.flows) {
40
- let e = Object.values(r.flows).find((e) => e["x-scalar-secret-token"])?.["x-scalar-secret-token"] || "YOUR_SECRET_TOKEN";
41
- n.headers.push({
43
+ } else if (i.type === "oauth2" && i.flows) {
44
+ let e = Object.values(i.flows).find((e) => e["x-scalar-secret-token"])?.["x-scalar-secret-token"] || "YOUR_SECRET_TOKEN";
45
+ r.headers.push({
42
46
  name: "Authorization",
43
47
  value: `Bearer ${e}`
44
48
  });
45
49
  }
46
- return n;
50
+ return r;
47
51
  };
48
- export { t as processSecuritySchemes };
52
+ export { n as processSecuritySchemes };
49
53
 
50
54
  //# sourceMappingURL=process-security-schemes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"process-security-schemes.js","names":["processSecuritySchemes","result","scheme","securitySchemes","value","param","auth","encode","token","f"],"sources":["../../../../src/code-example/helpers/operation-to-har/process-security-schemes.ts"],"sourcesContent":["import type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example'\nimport type { Request as HarRequest } from 'har-format'\nimport { encode } from 'js-base64'\n\ntype ProcessedSecuritySchemesReturn = {\n headers: HarRequest['headers']\n queryString: HarRequest['queryString']\n cookies: HarRequest['cookies']\n}\n\n/**\n * Process security schemes into whichever parameters they are applicable to\n *\n * TODO: we probably want to be able to disable YOUR_SECRET_TOKEN placeholder text + or allow it to be customzied\n */\nexport const processSecuritySchemes = (\n securitySchemes: SecuritySchemeObjectSecret[],\n): ProcessedSecuritySchemesReturn => {\n const result: ProcessedSecuritySchemesReturn = {\n headers: [],\n queryString: [],\n cookies: [],\n }\n\n for (const scheme of securitySchemes) {\n // Handle apiKey type\n if (scheme.type === 'apiKey') {\n const value = scheme['x-scalar-secret-token'] || 'YOUR_SECRET_TOKEN'\n if (!scheme.name) {\n continue\n }\n\n const param = { name: scheme.name, value }\n\n switch (scheme.in) {\n case 'header':\n result.headers.push(param)\n break\n case 'query':\n result.queryString.push(param)\n break\n case 'cookie':\n result.cookies.push(param)\n break\n }\n continue\n }\n\n // Handle http type\n if (scheme.type === 'http') {\n if (scheme.scheme === 'basic') {\n const username = scheme['x-scalar-secret-username'] || ''\n const password = scheme['x-scalar-secret-password'] || ''\n\n // The snippet is documentation, so we always show an Authorization header. When both\n // fields are empty we render a readable `username:password` placeholder, mirroring the\n // `YOUR_SECRET_TOKEN` placeholder used by the other schemes. (The real request omits the\n // header entirely in that case — see buildRequestSecurity.)\n const value = `${username}:${password}`\n const auth = value === ':' ? 'username:password' : encode(value)\n\n result.headers.push({\n name: 'Authorization',\n value: `Basic ${auth}`,\n })\n } else if (scheme.scheme === 'bearer') {\n const token = scheme['x-scalar-secret-token'] || 'YOUR_SECRET_TOKEN'\n\n result.headers.push({\n name: 'Authorization',\n value: `Bearer ${token}`,\n })\n }\n continue\n }\n\n // Handle oauth2 type\n if (scheme.type === 'oauth2' && scheme.flows) {\n const flows = Object.values(scheme.flows)\n\n // Find the first flow with a token\n const flow = flows.find((f) => f['x-scalar-secret-token'])\n const token = flow?.['x-scalar-secret-token'] || 'YOUR_SECRET_TOKEN'\n\n result.headers.push({\n name: 'Authorization',\n value: `Bearer ${token}`,\n })\n }\n }\n\n return result\n}\n"],"mappings":";;AAeA,IAAaA,KACX,MACmC;CACnC,IAAMC,IAAyC;EAC7C,SAAS,CAAC;EACV,aAAa,CAAC;EACd,SAAS,CAAC;CACZ;CAEA,KAAK,IAAMC,KAAUC,GAEnB,IAAID,EAAO,SAAS,UAAU;EAC5B,IAAME,IAAQF,EAAO,4BAA4B;EACjD,IAAI,CAACA,EAAO,MACV;EAGF,IAAMG,IAAQ;GAAE,MAAMH,EAAO;GAAM;EAAM;EAEzC,QAAQA,EAAO,IAAf;GACE,KAAK;IACH,EAAO,QAAQ,KAAKG,CAAK;IACzB;GACF,KAAK;IACH,EAAO,YAAY,KAAKA,CAAK;IAC7B;GACF,KAAK,UACH,EAAO,QAAQ,KAAKA,CAAK;EAE7B;CAEF,OAGA,IAAIH,EAAO,SAAS,QAAQ;EAC1B,IAAIA,EAAO,WAAW,SAAS;GAQ7B,IAAME,IAAQ,GAPGF,EAAO,+BAA+B,GAO7B,GANTA,EAAO,+BAA+B,MAOjDI,IAAOF,MAAU,MAAM,sBAAsBG,EAAOH,CAAK;GAE/D,EAAO,QAAQ,KAAK;IAClB,MAAM;IACN,OAAO,SAASE;GAClB,CAAC;EACH,OAAO,IAAIJ,EAAO,WAAW,UAAU;GACrC,IAAMM,IAAQN,EAAO,4BAA4B;GAEjD,EAAO,QAAQ,KAAK;IAClB,MAAM;IACN,OAAO,UAAUM;GACnB,CAAC;EACH;CAEF,OAGA,IAAIN,EAAO,SAAS,YAAYA,EAAO,OAAO;EAK5C,IAAMM,IAJQ,OAAO,OAAON,EAAO,KAGtB,CAAA,CAAM,MAAM,MAAMO,EAAE,wBACnB,CAAA,GAAO,4BAA4B;EAEjD,EAAO,QAAQ,KAAK;GAClB,MAAM;GACN,OAAO,UAAUD;EACnB,CAAC;CACH;CAGF,OAAOP;AACT"}
1
+ {"version":3,"file":"process-security-schemes.js","names":["processSecuritySchemes","result","scheme","securitySchemes","value","param","formatTokenPrefix","auth","encode","token","f"],"sources":["../../../../src/code-example/helpers/operation-to-har/process-security-schemes.ts"],"sourcesContent":["import { formatTokenPrefix } from '@scalar/helpers/http/format-token-prefix'\nimport type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example'\nimport type { Request as HarRequest } from 'har-format'\nimport { encode } from 'js-base64'\n\ntype ProcessedSecuritySchemesReturn = {\n headers: HarRequest['headers']\n queryString: HarRequest['queryString']\n cookies: HarRequest['cookies']\n}\n\n/**\n * Process security schemes into whichever parameters they are applicable to\n *\n * TODO: we probably want to be able to disable YOUR_SECRET_TOKEN placeholder text + or allow it to be customzied\n */\nexport const processSecuritySchemes = (\n securitySchemes: SecuritySchemeObjectSecret[],\n): ProcessedSecuritySchemesReturn => {\n const result: ProcessedSecuritySchemesReturn = {\n headers: [],\n queryString: [],\n cookies: [],\n }\n\n for (const scheme of securitySchemes) {\n // Handle apiKey type\n if (scheme.type === 'apiKey') {\n const value = scheme['x-scalar-secret-token'] || 'YOUR_SECRET_TOKEN'\n if (!scheme.name) {\n continue\n }\n\n const param = { name: scheme.name, value }\n\n switch (scheme.in) {\n case 'header':\n result.headers.push({ ...param, value: formatTokenPrefix(value, scheme['x-scalar-token-prefix']) })\n break\n case 'query':\n result.queryString.push(param)\n break\n case 'cookie':\n result.cookies.push(param)\n break\n }\n continue\n }\n\n // Handle http type\n if (scheme.type === 'http') {\n if (scheme.scheme === 'basic') {\n const username = scheme['x-scalar-secret-username'] || ''\n const password = scheme['x-scalar-secret-password'] || ''\n\n // The snippet is documentation, so we always show an Authorization header. When both\n // fields are empty we render a readable `username:password` placeholder, mirroring the\n // `YOUR_SECRET_TOKEN` placeholder used by the other schemes. (The real request omits the\n // header entirely in that case — see buildRequestSecurity.)\n const value = `${username}:${password}`\n const auth = value === ':' ? 'username:password' : encode(value)\n\n result.headers.push({\n name: 'Authorization',\n value: `Basic ${auth}`,\n })\n } else if (scheme.scheme === 'bearer') {\n const token = scheme['x-scalar-secret-token'] || 'YOUR_SECRET_TOKEN'\n\n result.headers.push({\n name: 'Authorization',\n value: `Bearer ${token}`,\n })\n }\n continue\n }\n\n // Handle oauth2 type\n if (scheme.type === 'oauth2' && scheme.flows) {\n const flows = Object.values(scheme.flows)\n\n // Find the first flow with a token\n const flow = flows.find((f) => f['x-scalar-secret-token'])\n const token = flow?.['x-scalar-secret-token'] || 'YOUR_SECRET_TOKEN'\n\n result.headers.push({\n name: 'Authorization',\n value: `Bearer ${token}`,\n })\n }\n }\n\n return result\n}\n"],"mappings":";;;AAgBA,IAAaA,KACX,MACmC;CACnC,IAAMC,IAAyC;EAC7C,SAAS,CAAC;EACV,aAAa,CAAC;EACd,SAAS,CAAC;CACZ;CAEA,KAAK,IAAMC,KAAUC,GAEnB,IAAID,EAAO,SAAS,UAAU;EAC5B,IAAME,IAAQF,EAAO,4BAA4B;EACjD,IAAI,CAACA,EAAO,MACV;EAGF,IAAMG,IAAQ;GAAE,MAAMH,EAAO;GAAM;EAAM;EAEzC,QAAQA,EAAO,IAAf;GACE,KAAK;IACH,EAAO,QAAQ,KAAK;KAAE,GAAGG;KAAO,OAAOC,EAAkBF,GAAOF,EAAO,wBAAwB;IAAE,CAAC;IAClG;GACF,KAAK;IACH,EAAO,YAAY,KAAKG,CAAK;IAC7B;GACF,KAAK,UACH,EAAO,QAAQ,KAAKA,CAAK;EAE7B;CAEF,OAGA,IAAIH,EAAO,SAAS,QAAQ;EAC1B,IAAIA,EAAO,WAAW,SAAS;GAQ7B,IAAME,IAAQ,GAPGF,EAAO,+BAA+B,GAO7B,GANTA,EAAO,+BAA+B,MAOjDK,IAAOH,MAAU,MAAM,sBAAsBI,EAAOJ,CAAK;GAE/D,EAAO,QAAQ,KAAK;IAClB,MAAM;IACN,OAAO,SAASG;GAClB,CAAC;EACH,OAAO,IAAIL,EAAO,WAAW,UAAU;GACrC,IAAMO,IAAQP,EAAO,4BAA4B;GAEjD,EAAO,QAAQ,KAAK;IAClB,MAAM;IACN,OAAO,UAAUO;GACnB,CAAC;EACH;CAEF,OAGA,IAAIP,EAAO,SAAS,YAAYA,EAAO,OAAO;EAK5C,IAAMO,IAJQ,OAAO,OAAOP,EAAO,KAGtB,CAAA,CAAM,MAAM,MAAMQ,EAAE,wBACnB,CAAA,GAAO,4BAA4B;EAEjD,EAAO,QAAQ,KAAK;GAClB,MAAM;GACN,OAAO,UAAUD;EACnB,CAAC;CACH;CAGF,OAAOR;AACT"}
package/dist/constants.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/constants.ts
2
- var e = typeof OVERRIDE_PACKAGE_VERSION < "u" ? OVERRIDE_PACKAGE_VERSION : "0.7.4";
2
+ var e = typeof OVERRIDE_PACKAGE_VERSION < "u" ? OVERRIDE_PACKAGE_VERSION : "0.8.0";
3
3
  export { e as APP_VERSION };
4
4
 
5
5
  //# sourceMappingURL=constants.js.map
package/dist/style.css CHANGED
@@ -847,8 +847,8 @@
847
847
  filter: brightness(1.1);
848
848
  }
849
849
 
850
- .scalar-icon[data-v-b651bb23], .scalar-icon[data-v-b651bb23] * {
851
- stroke-width: var(--c07589c2);
850
+ .scalar-icon[data-v-6150d8b1], .scalar-icon[data-v-6150d8b1] * {
851
+ stroke-width: var(--scalar-icon-stroke-width);
852
852
  }
853
853
 
854
854
  :where(pre:has( > code.hljs)) {
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "blocks",
18
18
  "docs"
19
19
  ],
20
- "version": "0.7.4",
20
+ "version": "0.8.0",
21
21
  "engines": {
22
22
  "node": ">=22"
23
23
  },
@@ -62,15 +62,15 @@
62
62
  "CHANGELOG.md"
63
63
  ],
64
64
  "dependencies": {
65
- "@scalar/components": "0.35.2",
66
- "@scalar/helpers": "0.18.1",
65
+ "@scalar/components": "0.35.3",
66
+ "@scalar/helpers": "0.19.0",
67
67
  "@scalar/icons": "0.7.11",
68
- "@scalar/localization": "0.2.14",
69
- "@scalar/snippetz": "0.10.20",
68
+ "@scalar/localization": "0.2.15",
69
+ "@scalar/snippetz": "0.10.21",
70
70
  "@scalar/themes": "0.20.3",
71
- "@scalar/types": "0.30.0",
72
- "@scalar/use-hooks": "0.4.28",
73
- "@scalar/workspace-store": "0.74.0",
71
+ "@scalar/types": "0.31.0",
72
+ "@scalar/use-hooks": "0.4.29",
73
+ "@scalar/workspace-store": "0.75.0",
74
74
  "@types/har-format": "^1.2.16",
75
75
  "@vueuse/core": "15.0.0",
76
76
  "js-base64": "^3.9.6",