@stackframe/stack 2.5.12 → 2.5.15
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 +28 -0
- package/dist/components/user-button.js +4 -11
- package/dist/components/user-button.js.map +1 -1
- package/dist/esm/components/user-button.js +4 -11
- package/dist/esm/components/user-button.js.map +1 -1
- package/dist/esm/generated/global-css.js +1 -1
- package/dist/esm/generated/global-css.js.map +1 -1
- package/dist/esm/lib/stack-app.js +120 -70
- package/dist/esm/lib/stack-app.js.map +1 -1
- package/dist/esm/utils/browser-script.js +41 -13
- package/dist/esm/utils/browser-script.js.map +1 -1
- package/dist/generated/global-css.d.mts +1 -1
- package/dist/generated/global-css.d.ts +1 -1
- package/dist/generated/global-css.js +1 -1
- package/dist/generated/global-css.js.map +1 -1
- package/dist/lib/stack-app.d.mts +1 -0
- package/dist/lib/stack-app.d.ts +1 -0
- package/dist/lib/stack-app.js +120 -70
- package/dist/lib/stack-app.js.map +1 -1
- package/dist/utils/browser-script.js +41 -13
- package/dist/utils/browser-script.js.map +1 -1
- package/package.json +4 -4
|
@@ -27,21 +27,46 @@ var import_ssr_layout_effect = require("../components/elements/ssr-layout-effect
|
|
|
27
27
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
28
28
|
var script = () => {
|
|
29
29
|
const attributes = ["data-joy-color-scheme", "data-mui-color-scheme", "data-theme", "data-color-scheme", "class"];
|
|
30
|
+
const getColorMode = (value) => {
|
|
31
|
+
if (value.includes("dark")) {
|
|
32
|
+
return "dark";
|
|
33
|
+
}
|
|
34
|
+
if (value.includes("light")) {
|
|
35
|
+
return "light";
|
|
36
|
+
}
|
|
37
|
+
return null;
|
|
38
|
+
};
|
|
39
|
+
const copyFromColorScheme = () => {
|
|
40
|
+
const colorScheme = getComputedStyle(document.documentElement).getPropertyValue("color-scheme");
|
|
41
|
+
if (colorScheme) {
|
|
42
|
+
const mode = getColorMode(colorScheme);
|
|
43
|
+
if (mode) {
|
|
44
|
+
document.documentElement.setAttribute("data-stack-theme", mode);
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return false;
|
|
49
|
+
};
|
|
50
|
+
const copyFromAttributes = () => {
|
|
51
|
+
for (const attributeName of attributes) {
|
|
52
|
+
const colorTheme = document.documentElement.getAttribute(attributeName);
|
|
53
|
+
if (colorTheme) {
|
|
54
|
+
const mode = getColorMode(colorTheme);
|
|
55
|
+
if (mode) {
|
|
56
|
+
document.documentElement.setAttribute("data-stack-theme", mode);
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return false;
|
|
62
|
+
};
|
|
30
63
|
const observer = new MutationObserver((mutations) => {
|
|
31
64
|
mutations.forEach((mutation) => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
const darkMode = colorTheme.includes("dark");
|
|
39
|
-
const lightMode = colorTheme.includes("light");
|
|
40
|
-
if (!darkMode && !lightMode) {
|
|
41
|
-
continue;
|
|
42
|
-
}
|
|
43
|
-
document.documentElement.setAttribute("data-stack-theme", darkMode ? "dark" : "light");
|
|
44
|
-
}
|
|
65
|
+
if (copyFromColorScheme()) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (mutation.attributeName && attributes.includes(mutation.attributeName)) {
|
|
69
|
+
copyFromAttributes();
|
|
45
70
|
}
|
|
46
71
|
});
|
|
47
72
|
});
|
|
@@ -49,6 +74,9 @@ var script = () => {
|
|
|
49
74
|
attributes: true,
|
|
50
75
|
attributeFilter: attributes
|
|
51
76
|
});
|
|
77
|
+
if (!copyFromColorScheme()) {
|
|
78
|
+
copyFromAttributes();
|
|
79
|
+
}
|
|
52
80
|
};
|
|
53
81
|
function BrowserScript(props) {
|
|
54
82
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ssr_layout_effect.SsrScript, { nonce: props.nonce, script: `(${script.toString()})()` });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/browser-script.tsx"],"sourcesContent":["// Note that this script can not import anything from outside as it will be converted to a string and executed in the browser.\n\nimport { SsrScript } from \"../components/elements/ssr-layout-effect\";\n\n// Also please note that there might be hydration issues with this script, always check the browser console for errors after changing this script.\nconst script = () => {\n const attributes = ['data-joy-color-scheme', 'data-mui-color-scheme', 'data-theme', 'data-color-scheme', 'class'];\n\n const
|
|
1
|
+
{"version":3,"sources":["../../src/utils/browser-script.tsx"],"sourcesContent":["// Note that this script can not import anything from outside as it will be converted to a string and executed in the browser.\n\nimport { SsrScript } from \"../components/elements/ssr-layout-effect\";\n\n// Also please note that there might be hydration issues with this script, always check the browser console for errors after changing this script.\nconst script = () => {\n const attributes = ['data-joy-color-scheme', 'data-mui-color-scheme', 'data-theme', 'data-color-scheme', 'class'];\n\n const getColorMode = (value: string) => {\n if (value.includes('dark')) {\n return 'dark';\n }\n if (value.includes('light')) {\n return 'light';\n }\n return null;\n };\n\n const copyFromColorScheme = () => {\n const colorScheme = getComputedStyle(document.documentElement).getPropertyValue('color-scheme');\n if (colorScheme) {\n const mode = getColorMode(colorScheme);\n if (mode) {\n document.documentElement.setAttribute('data-stack-theme', mode);\n return true;\n }\n }\n return false;\n };\n\n const copyFromAttributes = () => {\n for (const attributeName of attributes) {\n const colorTheme = document.documentElement.getAttribute(attributeName);\n if (colorTheme) {\n const mode = getColorMode(colorTheme);\n if (mode) {\n document.documentElement.setAttribute('data-stack-theme', mode);\n return true;\n }\n }\n }\n return false;\n };\n\n const observer = new MutationObserver((mutations) => {\n mutations.forEach((mutation) => {\n if (copyFromColorScheme()) {\n return;\n }\n if (mutation.attributeName && attributes.includes(mutation.attributeName)) {\n copyFromAttributes();\n }\n });\n });\n\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: attributes,\n });\n\n // Initial check on page load\n if (!copyFromColorScheme()) {\n copyFromAttributes();\n }\n};\n\nexport function BrowserScript(props : { nonce?: string }) {\n return <SsrScript nonce={props.nonce} script={`(${script.toString()})()`}/>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,+BAA0B;AAiEjB;AA9DT,IAAM,SAAS,MAAM;AACnB,QAAM,aAAa,CAAC,yBAAyB,yBAAyB,cAAc,qBAAqB,OAAO;AAEhH,QAAM,eAAe,CAAC,UAAkB;AACtC,QAAI,MAAM,SAAS,MAAM,GAAG;AAC1B,aAAO;AAAA,IACT;AACA,QAAI,MAAM,SAAS,OAAO,GAAG;AAC3B,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT;AAEA,QAAM,sBAAsB,MAAM;AAChC,UAAM,cAAc,iBAAiB,SAAS,eAAe,EAAE,iBAAiB,cAAc;AAC9F,QAAI,aAAa;AACf,YAAM,OAAO,aAAa,WAAW;AACrC,UAAI,MAAM;AACR,iBAAS,gBAAgB,aAAa,oBAAoB,IAAI;AAC9D,eAAO;AAAA,MACT;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAEA,QAAM,qBAAqB,MAAM;AAC/B,eAAW,iBAAiB,YAAY;AACtC,YAAM,aAAa,SAAS,gBAAgB,aAAa,aAAa;AACtE,UAAI,YAAY;AACd,cAAM,OAAO,aAAa,UAAU;AACpC,YAAI,MAAM;AACR,mBAAS,gBAAgB,aAAa,oBAAoB,IAAI;AAC9D,iBAAO;AAAA,QACT;AAAA,MACF;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAEA,QAAM,WAAW,IAAI,iBAAiB,CAAC,cAAc;AACnD,cAAU,QAAQ,CAAC,aAAa;AAC9B,UAAI,oBAAoB,GAAG;AACzB;AAAA,MACF;AACA,UAAI,SAAS,iBAAiB,WAAW,SAAS,SAAS,aAAa,GAAG;AACzE,2BAAmB;AAAA,MACrB;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AAED,WAAS,QAAQ,SAAS,iBAAiB;AAAA,IACzC,YAAY;AAAA,IACZ,iBAAiB;AAAA,EACnB,CAAC;AAGD,MAAI,CAAC,oBAAoB,GAAG;AAC1B,uBAAmB;AAAA,EACrB;AACF;AAEO,SAAS,cAAc,OAA4B;AACxD,SAAO,4CAAC,sCAAU,OAAO,MAAM,OAAO,QAAQ,IAAI,OAAO,SAAS,CAAC,OAAM;AAC3E;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stackframe/stack",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.15",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"tailwindcss-animate": "^1.0.7",
|
|
39
39
|
"tsx": "^4.7.2",
|
|
40
40
|
"yup": "^1.4.0",
|
|
41
|
-
"@stackframe/stack-
|
|
42
|
-
"@stackframe/stack-
|
|
43
|
-
"@stackframe/stack-
|
|
41
|
+
"@stackframe/stack-sc": "2.5.15",
|
|
42
|
+
"@stackframe/stack-shared": "2.5.15",
|
|
43
|
+
"@stackframe/stack-ui": "2.5.15"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"next": ">=14.1",
|