@govtechsg/sgds-web-component 3.30.1-rc.1 → 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.
- package/custom-elements.json +1 -1
- package/package.json +1 -1
- package/react/_ssr-init.cjs.js +0 -1
- package/react/_ssr-init.js +0 -1
- package/react/utils/ssr-nonce-patch.js +37 -30
- package/utils/ssr-nonce-patch.d.ts +3 -7
- package/react/utils/ssr-nonce-patch.cjs.js +0 -32
- package/react/utils/ssr-nonce-patch.cjs.js.map +0 -1
- package/react/utils/ssr-nonce-patch.js.map +0 -1
package/custom-elements.json
CHANGED
|
@@ -32036,7 +32036,7 @@
|
|
|
32036
32036
|
"package": {
|
|
32037
32037
|
"name": "@govtechsg/sgds-web-component",
|
|
32038
32038
|
"description": "",
|
|
32039
|
-
"version": "3.30.1-rc.
|
|
32039
|
+
"version": "3.30.1-rc.3",
|
|
32040
32040
|
"author": "GovTechSG",
|
|
32041
32041
|
"license": "MIT"
|
|
32042
32042
|
}
|
package/package.json
CHANGED
package/react/_ssr-init.cjs.js
CHANGED
package/react/_ssr-init.js
CHANGED
|
@@ -1,32 +1,39 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { createRequire } from "node:module";
|
|
3
|
-
//#region src/utils/ssr-nonce-patch.ts
|
|
4
1
|
/**
|
|
5
|
-
* Patches @lit-labs/ssr's LitElementRenderer.renderShadow() to respect
|
|
6
|
-
* globalThis.litNonce for CSP nonce injection.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
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
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* Uses module.createRequire for SYNCHRONOUS module resolution in ESM.
|
|
6
|
-
* createRequire is a function call (not the bare `require` keyword),
|
|
7
|
-
* so Rolldown preserves it instead of transforming to __require().
|
|
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.
|
|
8
5
|
*/
|
|
9
|
-
export {};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
let node_module = require("node:module");
|
|
3
|
-
//#region src/utils/ssr-nonce-patch.ts
|
|
4
|
-
/**
|
|
5
|
-
* Patches @lit-labs/ssr's LitElementRenderer.renderShadow() to respect
|
|
6
|
-
* globalThis.litNonce for CSP nonce injection.
|
|
7
|
-
*
|
|
8
|
-
* Uses module.createRequire for SYNCHRONOUS module resolution in ESM.
|
|
9
|
-
* createRequire is a function call (not the bare `require` keyword),
|
|
10
|
-
* so Rolldown preserves it instead of transforming to __require().
|
|
11
|
-
*/
|
|
12
|
-
if (typeof window === "undefined") try {
|
|
13
|
-
const mod = (0, node_module.createRequire)({}.url)("@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":["createRequire"],"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 module.createRequire for SYNCHRONOUS module resolution in ESM.\n * createRequire is a function call (not the bare `require` keyword),\n * so Rolldown preserves it instead of transforming to __require().\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n// @ts-expect-error -- node:module types not in tsconfig (server-only, guarded by typeof window check)\nimport { createRequire } from \"node:module\";\n\nif (typeof window === \"undefined\") {\n try {\n const _require = createRequire(import.meta.url);\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":";;;;;;;;;;;AAcA,IAAI,OAAO,WAAW,aACpB,IAAI;CAEF,MAAM,OAAA,GADWA,YAAAA,cAAAA,CAAAA,CAAAA,EAA0B,GACxB,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 module.createRequire for SYNCHRONOUS module resolution in ESM.\n * createRequire is a function call (not the bare `require` keyword),\n * so Rolldown preserves it instead of transforming to __require().\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n// @ts-expect-error -- node:module types not in tsconfig (server-only, guarded by typeof window check)\nimport { createRequire } from \"node:module\";\n\nif (typeof window === \"undefined\") {\n try {\n const _require = createRequire(import.meta.url);\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":";;;;;;;;;;;AAcA,IAAI,OAAO,WAAW,aACpB,IAAI;CAEF,MAAM,MADW,cAAc,YAAY,GACxB,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"}
|