@govtechsg/sgds-web-component 3.30.1-rc.2 → 3.30.1-rc.3

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.
@@ -32036,7 +32036,7 @@
32036
32036
  "package": {
32037
32037
  "name": "@govtechsg/sgds-web-component",
32038
32038
  "description": "",
32039
- "version": "3.30.1-rc.2",
32039
+ "version": "3.30.1-rc.3",
32040
32040
  "author": "GovTechSG",
32041
32041
  "license": "MIT"
32042
32042
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@govtechsg/sgds-web-component",
3
- "version": "3.30.1-rc.2",
3
+ "version": "3.30.1-rc.3",
4
4
  "description": "",
5
5
  "main": "./index.umd.js",
6
6
  "module": "./index.js",
@@ -1,3 +1,2 @@
1
1
  "use client";
2
- require("./utils/ssr-nonce-patch.cjs.js");
3
2
  require("@lit-labs/ssr-react/enable-lit-ssr.js");
@@ -1,3 +1,2 @@
1
1
  "use client";
2
- import "./utils/ssr-nonce-patch.js";
3
2
  import "@lit-labs/ssr-react/enable-lit-ssr.js";
@@ -1,32 +1,39 @@
1
- "use client";
2
- //#region src/utils/ssr-nonce-patch.ts
3
1
  /**
4
- * Patches @lit-labs/ssr's LitElementRenderer.renderShadow() to respect
5
- * globalThis.litNonce for CSP nonce injection.
6
- *
7
- * Uses new Function("return require")() to get a synchronous require
8
- * that is invisible to both Rolldown and webpack. Bundlers cannot
9
- * statically analyze new Function(), so they leave it alone.
10
- * At runtime in Node.js, it returns the real require function.
11
- */
12
- if (typeof window === "undefined") try {
13
- const mod = new Function("return require")()("@lit-labs/ssr/lib/lit-element-renderer.js");
14
- const LitElementRenderer = mod.LitElementRenderer || mod.default?.LitElementRenderer;
15
- if (LitElementRenderer && !LitElementRenderer._sgdsNoncePatched) {
16
- LitElementRenderer._sgdsNoncePatched = true;
17
- const originalRenderShadow = LitElementRenderer.prototype.renderShadow;
18
- LitElementRenderer.prototype.renderShadow = function(renderInfo) {
19
- const result = originalRenderShadow.call(this, renderInfo);
20
- if (!result) return result;
21
- const nonce = globalThis.litNonce;
22
- if (!nonce) return result;
23
- return result.map((item) => {
24
- if (typeof item === "string" && item === "<style>") return `<style nonce="${nonce}">`;
25
- return item;
26
- });
27
- };
28
- }
29
- } catch {}
30
- //#endregion
2
+ * Patches @lit-labs/ssr's LitElementRenderer.renderShadow() to respect
3
+ * globalThis.litNonce for CSP nonce injection.
4
+ *
5
+ * This file is NOT processed by Rolldown — it's copied as-is to lib/.
6
+ * The bare require() is preserved so webpack resolves it within its own
7
+ * module system, ensuring we patch the SAME LitElementRenderer instance
8
+ * that @lit-labs/ssr-react uses during rendering.
9
+ */
10
+ if (typeof window === "undefined") {
11
+ try {
12
+ var mod = require("@lit-labs/ssr/lib/lit-element-renderer.js");
13
+ var LitElementRenderer =
14
+ mod.LitElementRenderer || (mod.default && mod.default.LitElementRenderer);
31
15
 
32
- //# sourceMappingURL=ssr-nonce-patch.js.map
16
+ if (LitElementRenderer && !LitElementRenderer._sgdsNoncePatched) {
17
+ LitElementRenderer._sgdsNoncePatched = true;
18
+
19
+ var originalRenderShadow = LitElementRenderer.prototype.renderShadow;
20
+
21
+ LitElementRenderer.prototype.renderShadow = function (renderInfo) {
22
+ var result = originalRenderShadow.call(this, renderInfo);
23
+ if (!result) return result;
24
+
25
+ var nonce = globalThis.litNonce;
26
+ if (!nonce) return result;
27
+
28
+ return result.map(function (item) {
29
+ if (typeof item === "string" && item === "<style>") {
30
+ return '<style nonce="' + nonce + '">';
31
+ }
32
+ return item;
33
+ });
34
+ };
35
+ }
36
+ } catch (e) {
37
+ // @lit-labs/ssr not available — nonce injection disabled
38
+ }
39
+ }
@@ -1,9 +1,5 @@
1
1
  /**
2
- * Patches @lit-labs/ssr's LitElementRenderer.renderShadow() to respect
3
- * globalThis.litNonce for CSP nonce injection.
4
- *
5
- * Uses new Function("return require")() to get a synchronous require
6
- * that is invisible to both Rolldown and webpack. Bundlers cannot
7
- * statically analyze new Function(), so they leave it alone.
8
- * At runtime in Node.js, it returns the real require function.
2
+ * Placeholder — the actual ssr-nonce-patch is in ssr-nonce-patch.raw.js
3
+ * which is copied to lib/ by frankBuild.js, bypassing Rolldown.
4
+ * This preserves bare require() for webpack's module system.
9
5
  */
@@ -1,32 +0,0 @@
1
- "use client";
2
- //#region src/utils/ssr-nonce-patch.ts
3
- /**
4
- * Patches @lit-labs/ssr's LitElementRenderer.renderShadow() to respect
5
- * globalThis.litNonce for CSP nonce injection.
6
- *
7
- * Uses new Function("return require")() to get a synchronous require
8
- * that is invisible to both Rolldown and webpack. Bundlers cannot
9
- * statically analyze new Function(), so they leave it alone.
10
- * At runtime in Node.js, it returns the real require function.
11
- */
12
- if (typeof window === "undefined") try {
13
- const mod = new Function("return require")()("@lit-labs/ssr/lib/lit-element-renderer.js");
14
- const LitElementRenderer = mod.LitElementRenderer || mod.default?.LitElementRenderer;
15
- if (LitElementRenderer && !LitElementRenderer._sgdsNoncePatched) {
16
- LitElementRenderer._sgdsNoncePatched = true;
17
- const originalRenderShadow = LitElementRenderer.prototype.renderShadow;
18
- LitElementRenderer.prototype.renderShadow = function(renderInfo) {
19
- const result = originalRenderShadow.call(this, renderInfo);
20
- if (!result) return result;
21
- const nonce = globalThis.litNonce;
22
- if (!nonce) return result;
23
- return result.map((item) => {
24
- if (typeof item === "string" && item === "<style>") return `<style nonce="${nonce}">`;
25
- return item;
26
- });
27
- };
28
- }
29
- } catch {}
30
- //#endregion
31
-
32
- //# sourceMappingURL=ssr-nonce-patch.cjs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ssr-nonce-patch.cjs.js","names":[],"sources":["../../../src/utils/ssr-nonce-patch.ts"],"sourcesContent":["/**\n * Patches @lit-labs/ssr's LitElementRenderer.renderShadow() to respect\n * globalThis.litNonce for CSP nonce injection.\n *\n * Uses new Function(\"return require\")() to get a synchronous require\n * that is invisible to both Rolldown and webpack. Bundlers cannot\n * statically analyze new Function(), so they leave it alone.\n * At runtime in Node.js, it returns the real require function.\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\nif (typeof window === \"undefined\") {\n try {\n // new Function hides require from all bundlers — synchronous at runtime\n const _require = new Function(\"return require\")() as (\n id: string\n ) => any;\n const mod = _require(\"@lit-labs/ssr/lib/lit-element-renderer.js\");\n const LitElementRenderer =\n mod.LitElementRenderer || mod.default?.LitElementRenderer;\n\n if (LitElementRenderer && !LitElementRenderer._sgdsNoncePatched) {\n LitElementRenderer._sgdsNoncePatched = true;\n\n const originalRenderShadow =\n LitElementRenderer.prototype.renderShadow;\n\n LitElementRenderer.prototype.renderShadow = function (\n renderInfo: unknown\n ) {\n const result = originalRenderShadow.call(this, renderInfo);\n if (!result) return result;\n\n const nonce = (globalThis as any).litNonce;\n if (!nonce) return result;\n\n return result.map((item: unknown) => {\n if (typeof item === \"string\" && item === \"<style>\") {\n return `<style nonce=\"${nonce}\">`;\n }\n return item;\n });\n };\n }\n } catch {\n // @lit-labs/ssr not available — nonce injection disabled\n }\n}\n"],"mappings":";;;;;;;;;;;AAYA,IAAI,OAAO,WAAW,aACpB,IAAI;CAKF,MAAM,MAHW,IAAI,SAAS,gBAAgB,CAAC,CAG5B,CAAC,CAAC,2CAA2C;CAChE,MAAM,qBACJ,IAAI,sBAAsB,IAAI,SAAS;CAEzC,IAAI,sBAAsB,CAAC,mBAAmB,mBAAmB;EAC/D,mBAAmB,oBAAoB;EAEvC,MAAM,uBACJ,mBAAmB,UAAU;EAE/B,mBAAmB,UAAU,eAAe,SAC1C,YACA;GACA,MAAM,SAAS,qBAAqB,KAAK,MAAM,UAAU;GACzD,IAAI,CAAC,QAAQ,OAAO;GAEpB,MAAM,QAAS,WAAmB;GAClC,IAAI,CAAC,OAAO,OAAO;GAEnB,OAAO,OAAO,KAAK,SAAkB;IACnC,IAAI,OAAO,SAAS,YAAY,SAAS,WACvC,OAAO,iBAAiB,MAAM;IAEhC,OAAO;GACT,CAAC;EACH;CACF;AACF,QAAQ,CAER"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ssr-nonce-patch.js","names":[],"sources":["../../../src/utils/ssr-nonce-patch.ts"],"sourcesContent":["/**\n * Patches @lit-labs/ssr's LitElementRenderer.renderShadow() to respect\n * globalThis.litNonce for CSP nonce injection.\n *\n * Uses new Function(\"return require\")() to get a synchronous require\n * that is invisible to both Rolldown and webpack. Bundlers cannot\n * statically analyze new Function(), so they leave it alone.\n * At runtime in Node.js, it returns the real require function.\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\nif (typeof window === \"undefined\") {\n try {\n // new Function hides require from all bundlers — synchronous at runtime\n const _require = new Function(\"return require\")() as (\n id: string\n ) => any;\n const mod = _require(\"@lit-labs/ssr/lib/lit-element-renderer.js\");\n const LitElementRenderer =\n mod.LitElementRenderer || mod.default?.LitElementRenderer;\n\n if (LitElementRenderer && !LitElementRenderer._sgdsNoncePatched) {\n LitElementRenderer._sgdsNoncePatched = true;\n\n const originalRenderShadow =\n LitElementRenderer.prototype.renderShadow;\n\n LitElementRenderer.prototype.renderShadow = function (\n renderInfo: unknown\n ) {\n const result = originalRenderShadow.call(this, renderInfo);\n if (!result) return result;\n\n const nonce = (globalThis as any).litNonce;\n if (!nonce) return result;\n\n return result.map((item: unknown) => {\n if (typeof item === \"string\" && item === \"<style>\") {\n return `<style nonce=\"${nonce}\">`;\n }\n return item;\n });\n };\n }\n } catch {\n // @lit-labs/ssr not available — nonce injection disabled\n }\n}\n"],"mappings":";;;;;;;;;;;AAYA,IAAI,OAAO,WAAW,aACpB,IAAI;CAKF,MAAM,MAHW,IAAI,SAAS,gBAAgB,CAAC,CAG5B,CAAC,CAAC,2CAA2C;CAChE,MAAM,qBACJ,IAAI,sBAAsB,IAAI,SAAS;CAEzC,IAAI,sBAAsB,CAAC,mBAAmB,mBAAmB;EAC/D,mBAAmB,oBAAoB;EAEvC,MAAM,uBACJ,mBAAmB,UAAU;EAE/B,mBAAmB,UAAU,eAAe,SAC1C,YACA;GACA,MAAM,SAAS,qBAAqB,KAAK,MAAM,UAAU;GACzD,IAAI,CAAC,QAAQ,OAAO;GAEpB,MAAM,QAAS,WAAmB;GAClC,IAAI,CAAC,OAAO,OAAO;GAEnB,OAAO,OAAO,KAAK,SAAkB;IACnC,IAAI,OAAO,SAAS,YAAY,SAAS,WACvC,OAAO,iBAAiB,MAAM;IAEhC,OAAO;GACT,CAAC;EACH;CACF;AACF,QAAQ,CAER"}