@puckeditor/plugin-auth 0.9.0-canary.f8c1abd5 → 0.10.0-canary.124630b6
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.css +5 -0
- package/dist/index.js +106 -3
- package/dist/index.mjs +105 -2
- package/package.json +5 -5
package/dist/index.css
CHANGED
package/dist/index.js
CHANGED
|
@@ -4743,12 +4743,114 @@ var __iconNode2 = [
|
|
|
4743
4743
|
var LogOut = createLucideIcon("log-out", __iconNode2);
|
|
4744
4744
|
|
|
4745
4745
|
// src/components/SessionMenu/index.tsx
|
|
4746
|
-
var
|
|
4746
|
+
var import_react9 = require("react");
|
|
4747
4747
|
|
|
4748
4748
|
// css-module:/home/runner/work/platform/platform/packages/plugin-auth/src/components/SessionMenu/styles.module.css#css-module
|
|
4749
4749
|
init_react_import();
|
|
4750
4750
|
var styles_module_default2 = { "SessionMenu-avatar": "_SessionMenu-avatar_j6dlr_1", "SessionMenu-placeholder": "_SessionMenu-placeholder_j6dlr_16", "SessionMenu-identity": "_SessionMenu-identity_j6dlr_30", "SessionMenu-name": "_SessionMenu-name_j6dlr_37", "SessionMenu-email": "_SessionMenu-email_j6dlr_41" };
|
|
4751
4751
|
|
|
4752
|
+
// ../platform-client/lib/use-inject-css.ts
|
|
4753
|
+
init_react_import();
|
|
4754
|
+
var import_react8 = require("react");
|
|
4755
|
+
|
|
4756
|
+
// runtime-css:runtime-css
|
|
4757
|
+
init_react_import();
|
|
4758
|
+
var runtimeStyles = "._Menu_1jr57_1{display:flex;position:relative}._Menu-content_1jr57_6{outline:none;z-index:1}._Menu-sections_1jr57_11{background-color:#fff;border:1px solid var(--puck-color-grey-09);border-radius:8px;box-sizing:border-box;box-shadow:0 2px 10px #0000001a;min-width:128px;padding-bottom:4px;padding-top:4px}._Menu-action_1jr57_22{background:none;border:none;margin-left:auto;padding:0}._Menu-action_1jr57_22:hover:not(:disabled){cursor:pointer;opacity:.8}._Menu-action_1jr57_22:disabled{cursor:not-allowed;opacity:.5}._Menu-action_1jr57_22:focus-visible{outline:2px solid var(--puck-color-azure-05);outline-offset:2px}._Menu-list_1jr57_44{list-style:none;margin:0;padding:0}._Menu-list_1jr57_44+._Menu-list_1jr57_44{border-top:1px solid var(--puck-color-grey-09);margin-top:4px}._Menu-item_1jr57_55{align-items:center;background:none;border:none;box-sizing:border-box;color:var(--puck-color-grey-02);display:flex;font-family:var(--puck-font-family);font-size:var(--puck-font-size-xxs);font-weight:500;gap:8px;padding:8px 12px;text-align:start;text-decoration:none;white-space:nowrap;width:100%}a._Menu-item_1jr57_55,button._Menu-item_1jr57_55{cursor:pointer}a._Menu-item_1jr57_55:hover,button._Menu-item_1jr57_55:hover{background-color:var(--puck-color-azure-11);color:var(--puck-color-azure-04)}._Menu-item--disabled_1jr57_84{cursor:not-allowed;opacity:.5}._SessionMenu-avatar_j6dlr_1{display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;border-radius:50%;overflow:hidden;background:var(--puck-color-azure-11);color:var(--puck-color-azure-04);font-size:var(--puck-font-size-xxs);font-weight:600;letter-spacing:.02em}._SessionMenu-placeholder_j6dlr_16{display:block;width:32px;height:32px;border-radius:50%;background:var(--puck-color-grey-11)}._SessionMenu-avatar_j6dlr_1 img{width:100%;height:100%;object-fit:cover}._SessionMenu-identity_j6dlr_30{display:flex;flex-direction:column;gap:2px;color:var(--puck-color-grey-03)}._SessionMenu-name_j6dlr_37{font-weight:600}._SessionMenu-email_j6dlr_41{font-size:var(--puck-font-size-xxxs);color:var(--puck-color-grey-05)}";
|
|
4759
|
+
|
|
4760
|
+
// ../platform-client/lib/use-inject-css.ts
|
|
4761
|
+
var STYLE_SOURCE_ATTRIBUTE = "data-puck-style-source";
|
|
4762
|
+
var STYLE_SOURCE_VALUE = "puck";
|
|
4763
|
+
var STYLE_ID_ATTRIBUTE = "data-puck-style-id";
|
|
4764
|
+
var styleRegistry = /* @__PURE__ */ new WeakMap();
|
|
4765
|
+
var staticCssDetected = /* @__PURE__ */ new Map();
|
|
4766
|
+
var warned = /* @__PURE__ */ new Set();
|
|
4767
|
+
var getStyleMap = (target) => {
|
|
4768
|
+
const existing = styleRegistry.get(target);
|
|
4769
|
+
if (existing) {
|
|
4770
|
+
return existing;
|
|
4771
|
+
}
|
|
4772
|
+
const created = /* @__PURE__ */ new Map();
|
|
4773
|
+
styleRegistry.set(target, created);
|
|
4774
|
+
return created;
|
|
4775
|
+
};
|
|
4776
|
+
var attachStyleElement = (target, el, prepend = false) => {
|
|
4777
|
+
const head = target.head;
|
|
4778
|
+
if (!head) {
|
|
4779
|
+
return;
|
|
4780
|
+
}
|
|
4781
|
+
if (el.parentElement !== head) {
|
|
4782
|
+
if (prepend) {
|
|
4783
|
+
head.prepend(el);
|
|
4784
|
+
} else {
|
|
4785
|
+
head.append(el);
|
|
4786
|
+
}
|
|
4787
|
+
return;
|
|
4788
|
+
}
|
|
4789
|
+
if (prepend && head.firstChild !== el) {
|
|
4790
|
+
head.prepend(el);
|
|
4791
|
+
}
|
|
4792
|
+
if (!prepend && head.lastChild !== el) {
|
|
4793
|
+
head.append(el);
|
|
4794
|
+
}
|
|
4795
|
+
};
|
|
4796
|
+
var useInjectStyleSheet = (options) => {
|
|
4797
|
+
(0, import_react8.useInsertionEffect)(() => {
|
|
4798
|
+
if (!options || typeof document === "undefined") {
|
|
4799
|
+
return;
|
|
4800
|
+
}
|
|
4801
|
+
const registry = getStyleMap(document);
|
|
4802
|
+
const existing = registry.get(options.id);
|
|
4803
|
+
if (existing) {
|
|
4804
|
+
existing.count = existing.count + 1;
|
|
4805
|
+
if (existing.el.textContent !== options.cssText) {
|
|
4806
|
+
existing.el.textContent = options.cssText;
|
|
4807
|
+
}
|
|
4808
|
+
attachStyleElement(document, existing.el, options.prepend);
|
|
4809
|
+
} else {
|
|
4810
|
+
const el = document.createElement("style");
|
|
4811
|
+
el.setAttribute(STYLE_SOURCE_ATTRIBUTE, STYLE_SOURCE_VALUE);
|
|
4812
|
+
el.setAttribute(STYLE_ID_ATTRIBUTE, options.id);
|
|
4813
|
+
el.textContent = options.cssText;
|
|
4814
|
+
attachStyleElement(document, el, options.prepend);
|
|
4815
|
+
registry.set(options.id, { count: 1, el });
|
|
4816
|
+
}
|
|
4817
|
+
return () => {
|
|
4818
|
+
const current = registry.get(options.id);
|
|
4819
|
+
if (!current) {
|
|
4820
|
+
return;
|
|
4821
|
+
}
|
|
4822
|
+
current.count = current.count - 1;
|
|
4823
|
+
if (current.count <= 0) {
|
|
4824
|
+
current.el.remove();
|
|
4825
|
+
registry.delete(options.id);
|
|
4826
|
+
}
|
|
4827
|
+
};
|
|
4828
|
+
}, [options?.cssText, options?.id, options?.prepend]);
|
|
4829
|
+
};
|
|
4830
|
+
var hasStaticPluginCss = (name) => {
|
|
4831
|
+
const cached = staticCssDetected.get(name);
|
|
4832
|
+
if (cached !== void 0) return cached;
|
|
4833
|
+
if (typeof document === "undefined") return false;
|
|
4834
|
+
const detected = getComputedStyle(document.documentElement).getPropertyValue(`--_puck-${name}-styles-loaded`).trim() !== "";
|
|
4835
|
+
staticCssDetected.set(name, detected);
|
|
4836
|
+
return detected;
|
|
4837
|
+
};
|
|
4838
|
+
var useInjectPluginCss = (name) => {
|
|
4839
|
+
const skip = hasStaticPluginCss(name);
|
|
4840
|
+
useInjectStyleSheet(
|
|
4841
|
+
skip || !runtimeStyles ? null : { cssText: runtimeStyles, id: name, prepend: true }
|
|
4842
|
+
);
|
|
4843
|
+
(0, import_react8.useEffect)(() => {
|
|
4844
|
+
if (!skip || process.env.NODE_ENV === "production" || warned.has(name)) {
|
|
4845
|
+
return;
|
|
4846
|
+
}
|
|
4847
|
+
warned.add(name);
|
|
4848
|
+
console.info(
|
|
4849
|
+
`Puck: Skipped runtime style injection as @puckeditor/${name} styles are already loaded. You can safely remove the "@puckeditor/${name}/styles.css" import, or ignore this message.`
|
|
4850
|
+
);
|
|
4851
|
+
}, [name, skip]);
|
|
4852
|
+
};
|
|
4853
|
+
|
|
4752
4854
|
// src/components/SessionMenu/index.tsx
|
|
4753
4855
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
4754
4856
|
var cx = getClassNameFactory2("SessionMenu", styles_module_default2);
|
|
@@ -4757,8 +4859,9 @@ var SessionMenu = ({
|
|
|
4757
4859
|
authHost,
|
|
4758
4860
|
showBranch
|
|
4759
4861
|
}) => {
|
|
4760
|
-
|
|
4761
|
-
(0,
|
|
4862
|
+
useInjectPluginCss("plugin-auth");
|
|
4863
|
+
const [session, setSession] = (0, import_react9.useState)();
|
|
4864
|
+
(0, import_react9.useEffect)(() => {
|
|
4762
4865
|
let cancelled = false;
|
|
4763
4866
|
fetch(`${authHost}/session`, { cache: "no-store" }).then((response) => response.ok ? response.json() : null).then((data) => {
|
|
4764
4867
|
if (!cancelled) setSession(data?.user ? data : null);
|
package/dist/index.mjs
CHANGED
|
@@ -4734,12 +4734,114 @@ var __iconNode2 = [
|
|
|
4734
4734
|
var LogOut = createLucideIcon("log-out", __iconNode2);
|
|
4735
4735
|
|
|
4736
4736
|
// src/components/SessionMenu/index.tsx
|
|
4737
|
-
import { useEffect as
|
|
4737
|
+
import { useEffect as useEffect16, useState as useState15 } from "react";
|
|
4738
4738
|
|
|
4739
4739
|
// css-module:/home/runner/work/platform/platform/packages/plugin-auth/src/components/SessionMenu/styles.module.css#css-module
|
|
4740
4740
|
init_react_import();
|
|
4741
4741
|
var styles_module_default2 = { "SessionMenu-avatar": "_SessionMenu-avatar_j6dlr_1", "SessionMenu-placeholder": "_SessionMenu-placeholder_j6dlr_16", "SessionMenu-identity": "_SessionMenu-identity_j6dlr_30", "SessionMenu-name": "_SessionMenu-name_j6dlr_37", "SessionMenu-email": "_SessionMenu-email_j6dlr_41" };
|
|
4742
4742
|
|
|
4743
|
+
// ../platform-client/lib/use-inject-css.ts
|
|
4744
|
+
init_react_import();
|
|
4745
|
+
import { useEffect as useEffect15, useInsertionEffect as useInsertionEffect2 } from "react";
|
|
4746
|
+
|
|
4747
|
+
// runtime-css:runtime-css
|
|
4748
|
+
init_react_import();
|
|
4749
|
+
var runtimeStyles = "._Menu_1jr57_1{display:flex;position:relative}._Menu-content_1jr57_6{outline:none;z-index:1}._Menu-sections_1jr57_11{background-color:#fff;border:1px solid var(--puck-color-grey-09);border-radius:8px;box-sizing:border-box;box-shadow:0 2px 10px #0000001a;min-width:128px;padding-bottom:4px;padding-top:4px}._Menu-action_1jr57_22{background:none;border:none;margin-left:auto;padding:0}._Menu-action_1jr57_22:hover:not(:disabled){cursor:pointer;opacity:.8}._Menu-action_1jr57_22:disabled{cursor:not-allowed;opacity:.5}._Menu-action_1jr57_22:focus-visible{outline:2px solid var(--puck-color-azure-05);outline-offset:2px}._Menu-list_1jr57_44{list-style:none;margin:0;padding:0}._Menu-list_1jr57_44+._Menu-list_1jr57_44{border-top:1px solid var(--puck-color-grey-09);margin-top:4px}._Menu-item_1jr57_55{align-items:center;background:none;border:none;box-sizing:border-box;color:var(--puck-color-grey-02);display:flex;font-family:var(--puck-font-family);font-size:var(--puck-font-size-xxs);font-weight:500;gap:8px;padding:8px 12px;text-align:start;text-decoration:none;white-space:nowrap;width:100%}a._Menu-item_1jr57_55,button._Menu-item_1jr57_55{cursor:pointer}a._Menu-item_1jr57_55:hover,button._Menu-item_1jr57_55:hover{background-color:var(--puck-color-azure-11);color:var(--puck-color-azure-04)}._Menu-item--disabled_1jr57_84{cursor:not-allowed;opacity:.5}._SessionMenu-avatar_j6dlr_1{display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;border-radius:50%;overflow:hidden;background:var(--puck-color-azure-11);color:var(--puck-color-azure-04);font-size:var(--puck-font-size-xxs);font-weight:600;letter-spacing:.02em}._SessionMenu-placeholder_j6dlr_16{display:block;width:32px;height:32px;border-radius:50%;background:var(--puck-color-grey-11)}._SessionMenu-avatar_j6dlr_1 img{width:100%;height:100%;object-fit:cover}._SessionMenu-identity_j6dlr_30{display:flex;flex-direction:column;gap:2px;color:var(--puck-color-grey-03)}._SessionMenu-name_j6dlr_37{font-weight:600}._SessionMenu-email_j6dlr_41{font-size:var(--puck-font-size-xxxs);color:var(--puck-color-grey-05)}";
|
|
4750
|
+
|
|
4751
|
+
// ../platform-client/lib/use-inject-css.ts
|
|
4752
|
+
var STYLE_SOURCE_ATTRIBUTE = "data-puck-style-source";
|
|
4753
|
+
var STYLE_SOURCE_VALUE = "puck";
|
|
4754
|
+
var STYLE_ID_ATTRIBUTE = "data-puck-style-id";
|
|
4755
|
+
var styleRegistry = /* @__PURE__ */ new WeakMap();
|
|
4756
|
+
var staticCssDetected = /* @__PURE__ */ new Map();
|
|
4757
|
+
var warned = /* @__PURE__ */ new Set();
|
|
4758
|
+
var getStyleMap = (target) => {
|
|
4759
|
+
const existing = styleRegistry.get(target);
|
|
4760
|
+
if (existing) {
|
|
4761
|
+
return existing;
|
|
4762
|
+
}
|
|
4763
|
+
const created = /* @__PURE__ */ new Map();
|
|
4764
|
+
styleRegistry.set(target, created);
|
|
4765
|
+
return created;
|
|
4766
|
+
};
|
|
4767
|
+
var attachStyleElement = (target, el, prepend = false) => {
|
|
4768
|
+
const head = target.head;
|
|
4769
|
+
if (!head) {
|
|
4770
|
+
return;
|
|
4771
|
+
}
|
|
4772
|
+
if (el.parentElement !== head) {
|
|
4773
|
+
if (prepend) {
|
|
4774
|
+
head.prepend(el);
|
|
4775
|
+
} else {
|
|
4776
|
+
head.append(el);
|
|
4777
|
+
}
|
|
4778
|
+
return;
|
|
4779
|
+
}
|
|
4780
|
+
if (prepend && head.firstChild !== el) {
|
|
4781
|
+
head.prepend(el);
|
|
4782
|
+
}
|
|
4783
|
+
if (!prepend && head.lastChild !== el) {
|
|
4784
|
+
head.append(el);
|
|
4785
|
+
}
|
|
4786
|
+
};
|
|
4787
|
+
var useInjectStyleSheet = (options) => {
|
|
4788
|
+
useInsertionEffect2(() => {
|
|
4789
|
+
if (!options || typeof document === "undefined") {
|
|
4790
|
+
return;
|
|
4791
|
+
}
|
|
4792
|
+
const registry = getStyleMap(document);
|
|
4793
|
+
const existing = registry.get(options.id);
|
|
4794
|
+
if (existing) {
|
|
4795
|
+
existing.count = existing.count + 1;
|
|
4796
|
+
if (existing.el.textContent !== options.cssText) {
|
|
4797
|
+
existing.el.textContent = options.cssText;
|
|
4798
|
+
}
|
|
4799
|
+
attachStyleElement(document, existing.el, options.prepend);
|
|
4800
|
+
} else {
|
|
4801
|
+
const el = document.createElement("style");
|
|
4802
|
+
el.setAttribute(STYLE_SOURCE_ATTRIBUTE, STYLE_SOURCE_VALUE);
|
|
4803
|
+
el.setAttribute(STYLE_ID_ATTRIBUTE, options.id);
|
|
4804
|
+
el.textContent = options.cssText;
|
|
4805
|
+
attachStyleElement(document, el, options.prepend);
|
|
4806
|
+
registry.set(options.id, { count: 1, el });
|
|
4807
|
+
}
|
|
4808
|
+
return () => {
|
|
4809
|
+
const current = registry.get(options.id);
|
|
4810
|
+
if (!current) {
|
|
4811
|
+
return;
|
|
4812
|
+
}
|
|
4813
|
+
current.count = current.count - 1;
|
|
4814
|
+
if (current.count <= 0) {
|
|
4815
|
+
current.el.remove();
|
|
4816
|
+
registry.delete(options.id);
|
|
4817
|
+
}
|
|
4818
|
+
};
|
|
4819
|
+
}, [options?.cssText, options?.id, options?.prepend]);
|
|
4820
|
+
};
|
|
4821
|
+
var hasStaticPluginCss = (name) => {
|
|
4822
|
+
const cached = staticCssDetected.get(name);
|
|
4823
|
+
if (cached !== void 0) return cached;
|
|
4824
|
+
if (typeof document === "undefined") return false;
|
|
4825
|
+
const detected = getComputedStyle(document.documentElement).getPropertyValue(`--_puck-${name}-styles-loaded`).trim() !== "";
|
|
4826
|
+
staticCssDetected.set(name, detected);
|
|
4827
|
+
return detected;
|
|
4828
|
+
};
|
|
4829
|
+
var useInjectPluginCss = (name) => {
|
|
4830
|
+
const skip = hasStaticPluginCss(name);
|
|
4831
|
+
useInjectStyleSheet(
|
|
4832
|
+
skip || !runtimeStyles ? null : { cssText: runtimeStyles, id: name, prepend: true }
|
|
4833
|
+
);
|
|
4834
|
+
useEffect15(() => {
|
|
4835
|
+
if (!skip || process.env.NODE_ENV === "production" || warned.has(name)) {
|
|
4836
|
+
return;
|
|
4837
|
+
}
|
|
4838
|
+
warned.add(name);
|
|
4839
|
+
console.info(
|
|
4840
|
+
`Puck: Skipped runtime style injection as @puckeditor/${name} styles are already loaded. You can safely remove the "@puckeditor/${name}/styles.css" import, or ignore this message.`
|
|
4841
|
+
);
|
|
4842
|
+
}, [name, skip]);
|
|
4843
|
+
};
|
|
4844
|
+
|
|
4743
4845
|
// src/components/SessionMenu/index.tsx
|
|
4744
4846
|
import { jsx as jsx11, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
4745
4847
|
var cx = getClassNameFactory2("SessionMenu", styles_module_default2);
|
|
@@ -4748,8 +4850,9 @@ var SessionMenu = ({
|
|
|
4748
4850
|
authHost,
|
|
4749
4851
|
showBranch
|
|
4750
4852
|
}) => {
|
|
4853
|
+
useInjectPluginCss("plugin-auth");
|
|
4751
4854
|
const [session, setSession] = useState15();
|
|
4752
|
-
|
|
4855
|
+
useEffect16(() => {
|
|
4753
4856
|
let cancelled = false;
|
|
4754
4857
|
fetch(`${authHost}/session`, { cache: "no-store" }).then((response) => response.ok ? response.json() : null).then((data) => {
|
|
4755
4858
|
if (!cancelled) setSession(data?.user ? data : null);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@puckeditor/plugin-auth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0-canary.124630b6",
|
|
4
4
|
"author": "Chris Villa <chris@puckeditor.com>",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"tsup": "^8.2.4",
|
|
39
39
|
"typescript": "^5.5.4",
|
|
40
40
|
"vite-tsconfig-paths": "^5.1.4",
|
|
41
|
-
"vitest": "^4.1.
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
41
|
+
"vitest": "^4.1.12",
|
|
42
|
+
"eslint-config-custom": "0.10.0-canary.124630b6",
|
|
43
|
+
"tsconfig": "0.10.0-canary.124630b6",
|
|
44
|
+
"tsup-config": "0.10.0-canary.124630b6"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"@puckeditor/core": "^0",
|