@plitzi/sdk-shared 0.33.2 → 0.34.1
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 +64 -0
- package/dist/actions/cron.d.ts +34 -0
- package/dist/actions/cron.mjs +72 -0
- package/dist/actions/index.d.ts +6 -0
- package/dist/actions/index.mjs +5 -0
- package/dist/actions/triggerParams.d.ts +41 -0
- package/dist/actions/triggerParams.mjs +40 -0
- package/dist/actions/triggers.d.ts +29 -0
- package/dist/actions/triggers.mjs +4 -0
- package/dist/actions/validateDocument.d.ts +23 -0
- package/dist/actions/validateDocument.mjs +267 -0
- package/dist/auth/failureChannel.d.ts +9 -4
- package/dist/auth/failureChannel.mjs +3 -2
- package/dist/authoring/builder.d.ts +51 -0
- package/dist/authoring/builder.mjs +29 -0
- package/dist/authoring/declare.d.ts +64 -0
- package/dist/authoring/declare.mjs +4 -0
- package/dist/authoring/elementCallbacks.d.ts +13 -0
- package/dist/authoring/elementCallbacks.mjs +71 -0
- package/dist/authoring/index.d.ts +21 -0
- package/dist/authoring/index.mjs +6 -0
- package/dist/authoring/paramSpec.d.ts +51 -0
- package/dist/authoring/paramSpec.mjs +40 -0
- package/dist/authoring/spaceCallbacks.d.ts +10 -0
- package/dist/authoring/spaceCallbacks.mjs +51 -0
- package/dist/builder/contexts/BuilderContext.d.ts +2 -4
- package/dist/dataSource/getBindingsDetails.mjs +1 -1
- package/dist/dataSource/helpers/getSourceName.d.ts +1 -3
- package/dist/dataSource/helpers/getSourceName.mjs +1 -1
- package/dist/dataSource/index.d.ts +2 -0
- package/dist/dataSource/index.mjs +6 -5
- package/dist/dataSource/resolveVariables.d.ts +22 -0
- package/dist/dataSource/resolveVariables.mjs +16 -0
- package/dist/dataSource/utility/index.mjs +15 -13
- package/dist/dataSource/utility/not.d.ts +11 -0
- package/dist/dataSource/utility/not.mjs +15 -0
- package/dist/devTools/debugCookie.d.ts +16 -0
- package/dist/devTools/debugCookie.mjs +7 -0
- package/dist/devTools/index.d.ts +6 -2
- package/dist/devTools/index.mjs +4 -2
- package/dist/devTools/interactionLog.d.ts +14 -0
- package/dist/devTools/interactionLog.mjs +4 -0
- package/dist/helpers/index.d.ts +2 -0
- package/dist/helpers/index.mjs +11 -9
- package/dist/helpers/reducerOrigin.d.ts +15 -0
- package/dist/helpers/reducerOrigin.mjs +4 -0
- package/dist/helpers/ruleEvaluator.d.ts +14 -0
- package/dist/helpers/ruleEvaluator.mjs +5 -0
- package/dist/helpers/twigWrapper/AST.d.ts +12 -1
- package/dist/helpers/twigWrapper/AST.mjs +0 -0
- package/dist/helpers/twigWrapper/Evaluator/Evaluator.mjs +7 -0
- package/dist/helpers/twigWrapper/Parser/Cursor.d.ts +7 -0
- package/dist/helpers/twigWrapper/Parser/Cursor.mjs +5 -0
- package/dist/helpers/twigWrapper/Parser/ExpressionParser.mjs +46 -8
- package/dist/helpers/twigWrapper/Parser/types.mjs +0 -0
- package/dist/helpers/twigWrapper/charClass.d.ts +7 -0
- package/dist/helpers/twigWrapper/charClass.mjs +16 -12
- package/dist/helpers/twigWrapper/tokens/tokenPatterns.mjs +2 -2
- package/dist/helpers/utils.d.ts +0 -2
- package/dist/helpers/utils.mjs +16 -19
- package/dist/hooks/index.d.ts +2 -1
- package/dist/hooks/index.mjs +4 -3
- package/dist/hooks/useFontHead.d.ts +3 -0
- package/dist/hooks/useFontHead.mjs +23 -0
- package/dist/hooks/usePlitziServiceContext.d.ts +3 -2
- package/dist/index.mjs +61 -45
- package/dist/navigation/index.d.ts +1 -1
- package/dist/navigation/index.mjs +2 -2
- package/dist/navigation/routes.d.ts +8 -0
- package/dist/navigation/routes.mjs +39 -39
- package/dist/network/graphql/builder/Mutations/Segment/SegmentAddMutation.mjs +0 -1
- package/dist/network/graphql/builder/Mutations/Segment/SegmentAddTemplateMutation.mjs +0 -1
- package/dist/network/graphql/builder/Mutations/Segment/SegmentUpdateMutation.mjs +0 -1
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentAddElementMutation.mjs +0 -1
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentCloneElementMutation.mjs +0 -1
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentMoveElementMutation.mjs +0 -1
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentRemoveElementMutation.mjs +0 -1
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentRenameElementMutation.d.ts +3 -0
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentRenameElementMutation.mjs +9 -0
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentUpdateElementMutation.mjs +0 -1
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentUpdateElementsMutation.mjs +0 -1
- package/dist/network/graphql/builder/Mutations/Space/SpaceAddElementMutation.mjs +0 -1
- package/dist/network/graphql/builder/Mutations/Space/SpaceAddTemplateMutation.mjs +0 -1
- package/dist/network/graphql/builder/Mutations/Space/SpaceCloneElementMutation.mjs +0 -1
- package/dist/network/graphql/builder/Mutations/Space/SpaceMoveElementMutation.mjs +0 -1
- package/dist/network/graphql/builder/Mutations/Space/SpaceRemoveElementMutation.mjs +0 -1
- package/dist/network/graphql/builder/Mutations/Space/SpaceRenameElementMutation.d.ts +5 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceRenameElementMutation.mjs +9 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceUpdateElementMutation.mjs +0 -1
- package/dist/network/graphql/builder/Mutations/Space/SpaceUpdateElementsMutation.mjs +0 -1
- package/dist/network/graphql/builder/Mutations/Space/SpaceUpdateMutation.mjs +0 -1
- package/dist/network/graphql/builder/Mutations/Space/SpaceUpdateSchemaMutation.mjs +0 -1
- package/dist/network/graphql/builder/Mutations/Space/actions/SpaceAddActionMutation.d.ts +8 -0
- package/dist/network/graphql/builder/Mutations/Space/actions/SpaceAddActionMutation.mjs +16 -0
- package/dist/network/graphql/builder/Mutations/Space/actions/SpaceRemoveActionMutation.d.ts +4 -0
- package/dist/network/graphql/builder/Mutations/Space/actions/SpaceRemoveActionMutation.mjs +16 -0
- package/dist/network/graphql/builder/Mutations/Space/actions/SpaceRunActionMutation.d.ts +4 -0
- package/dist/network/graphql/builder/Mutations/Space/actions/SpaceRunActionMutation.mjs +14 -0
- package/dist/network/graphql/builder/Mutations/Space/actions/SpaceUpdateActionMutation.d.ts +4 -0
- package/dist/network/graphql/builder/Mutations/Space/actions/SpaceUpdateActionMutation.mjs +16 -0
- package/dist/network/graphql/builder/Mutations/Space/pages/SpaceAddPageMutation.mjs +2 -3
- package/dist/network/graphql/builder/Mutations/Space/pages/SpaceUpdatePageMutation.mjs +0 -1
- package/dist/network/graphql/builder/Mutations/Style/fonts/StyleAddFontMutation.d.ts +2 -0
- package/dist/network/graphql/builder/Mutations/Style/fonts/StyleAddFontMutation.mjs +11 -0
- package/dist/network/graphql/builder/Mutations/Style/fonts/StyleRemoveFontMutation.d.ts +2 -0
- package/dist/network/graphql/builder/Mutations/Style/fonts/StyleRemoveFontMutation.mjs +11 -0
- package/dist/network/graphql/builder/Mutations/Style/fonts/StyleUpdateFontMutation.d.ts +2 -0
- package/dist/network/graphql/builder/Mutations/Style/fonts/StyleUpdateFontMutation.mjs +11 -0
- package/dist/network/graphql/builder/Mutations/index.d.ts +24 -0
- package/dist/network/graphql/builder/Mutations/index.mjs +150 -132
- package/dist/network/graphql/builder/Queries/InitQuery.mjs +1 -2
- package/dist/network/graphql/builder/Queries/Segment/SegmentQuery.mjs +0 -1
- package/dist/network/graphql/builder/Queries/Segment/SegmentsQuery.mjs +0 -1
- package/dist/network/graphql/builder/Queries/Space/SpaceActionEventsQuery.d.ts +9 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceActionEventsQuery.mjs +30 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceActionTasksQuery.d.ts +6 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceActionTasksQuery.mjs +16 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceActionsQuery.d.ts +9 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceActionsQuery.mjs +25 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceCheckActionQuery.d.ts +6 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceCheckActionQuery.mjs +17 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceQuotaQuery.d.ts +30 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceQuotaQuery.mjs +40 -0
- package/dist/network/graphql/builder/Queries/index.d.ts +16 -0
- package/dist/network/graphql/builder/Queries/index.mjs +24 -14
- package/dist/network/graphql/sdk/Queries/InitQuery.d.ts +4 -0
- package/dist/network/graphql/sdk/Queries/InitQuery.mjs +5 -2
- package/dist/network/graphql/sdk/Queries/Segment/SegmentQuery.mjs +0 -1
- package/dist/network/graphql/sdk/Queries/Segment/SegmentsQuery.mjs +0 -1
- package/dist/network/spaceEvents.d.ts +20 -1
- package/dist/network/spaceEvents.mjs +89 -74
- package/dist/schema/index.d.ts +1 -0
- package/dist/schema/index.mjs +2 -1
- package/dist/schema/serverElements.d.ts +16 -0
- package/dist/schema/serverElements.mjs +18 -0
- package/dist/server/actions/useActionsSync.d.ts +10 -0
- package/dist/server/actions/useActionsSync.mjs +7 -0
- package/dist/server/index.d.ts +2 -1
- package/dist/server/index.mjs +5 -4
- package/dist/server/rsc/refreshRsc.d.ts +11 -1
- package/dist/server/rsc/refreshRsc.mjs +30 -12
- package/dist/server/rsc/useRscSync.mjs +20 -13
- package/dist/state/runtimeStatePersist.mjs +4 -3
- package/dist/store/actionRuns/actionRunsRecorder.d.ts +36 -0
- package/dist/store/actionRuns/actionRunsRecorder.mjs +39 -0
- package/dist/store/actionRuns/actionRunsStore.d.ts +16 -0
- package/dist/store/actionRuns/actionRunsStore.mjs +5 -0
- package/dist/store/actionRuns/index.d.ts +6 -0
- package/dist/store/actionRuns/index.mjs +4 -0
- package/dist/store/actionRuns/useActionRuns.d.ts +13 -0
- package/dist/store/actionRuns/useActionRuns.mjs +10 -0
- package/dist/store/index.d.ts +46 -45
- package/dist/store/index.mjs +6 -3
- package/dist/store/renderSettings.d.ts +3 -0
- package/dist/store/renderSettings.mjs +17 -5
- package/dist/store/tracing/tracingCollector.d.ts +1 -1
- package/dist/store/tracing/tracingCollector.mjs +37 -35
- package/dist/store/tracing/tracingStore.d.ts +13 -0
- package/dist/store/tracing/tracingStore.mjs +3 -3
- package/dist/style/fontAssets.d.ts +12 -0
- package/dist/style/fontAssets.mjs +18 -0
- package/dist/style/fontValidation.d.ts +8 -0
- package/dist/style/fontValidation.mjs +107 -0
- package/dist/style/fonts.d.ts +74 -0
- package/dist/style/fonts.mjs +198 -0
- package/dist/style/fontsFromCss.d.ts +27 -0
- package/dist/style/fontsFromCss.mjs +43 -0
- package/dist/style/index.d.ts +4 -0
- package/dist/style/index.mjs +5 -1
- package/dist/style/styleConstants.d.ts +2 -2
- package/dist/style/styleConstants.mjs +1 -0
- package/dist/theme/ThemeProvider.d.ts +36 -6
- package/dist/theme/ThemeProvider.mjs +49 -35
- package/dist/theme/ThemeScope.d.ts +16 -0
- package/dist/theme/ThemeScope.mjs +6 -0
- package/dist/theme/index.d.ts +7 -1
- package/dist/theme/index.mjs +6 -2
- package/dist/theme/themeCookie.d.ts +30 -0
- package/dist/theme/themeCookie.mjs +24 -0
- package/dist/theme/themeStore.d.ts +40 -0
- package/dist/theme/themeStore.mjs +17 -0
- package/dist/theme/useTheme.d.ts +29 -0
- package/dist/theme/useTheme.mjs +20 -0
- package/dist/types/ActionTypes.d.ts +396 -0
- package/dist/types/ActionTypes.mjs +0 -0
- package/dist/types/AuthTypes.d.ts +23 -2
- package/dist/types/BuilderTypes.d.ts +0 -12
- package/dist/types/CommonTypes.d.ts +13 -0
- package/dist/types/DevToolsTypes.d.ts +57 -14
- package/dist/types/EventBridgeTypes.d.ts +1 -1
- package/dist/types/InteractionTypes.d.ts +23 -3
- package/dist/types/PluginTypes.d.ts +0 -3
- package/dist/types/SchemaTypes.d.ts +29 -4
- package/dist/types/ServerTypes.d.ts +390 -46
- package/dist/types/SpaceTypes.d.ts +16 -0
- package/dist/types/StoreTypes.d.ts +181 -3
- package/dist/types/StyleTypes.d.ts +83 -4
- package/dist/types/TemplateTypes.d.ts +20 -0
- package/dist/types/TemplateTypes.mjs +0 -0
- package/dist/types/ThemeTypes.d.ts +28 -1
- package/dist/types/index.d.ts +2 -0
- package/eslint.config.mjs +2 -0
- package/package.json +244 -29
- package/vite.config.ts +27 -7
package/dist/store/index.mjs
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import e, { DEFAULT_RENDER_SETTINGS as t, useRenderOverride as n } from "./renderSettings.mjs";
|
|
2
|
-
import
|
|
2
|
+
import r from "./actionRuns/actionRunsStore.mjs";
|
|
3
|
+
import { cancelActionRun as i, clearActionRuns as a, recordActionProgress as o, recordActionRun as s, registerActionCanceller as c, releaseActionCanceller as l, updateActionRun as u } from "./actionRuns/actionRunsRecorder.mjs";
|
|
4
|
+
import d from "./actionRuns/useActionRuns.mjs";
|
|
5
|
+
import { createStoreHook as f } from "@plitzi/nexus/react";
|
|
3
6
|
//#region src/store/index.ts
|
|
4
|
-
var { useStore:
|
|
7
|
+
var { useStore: p, useStoreSync: m, useStoreGetter: h, useStoreSetter: g } = f(), { useStore: _, useStoreSync: v, useStoreGetter: y, useStoreSetter: b } = f(), { useStore: x, useStoreSync: S, useStoreGetter: C, useStoreSetter: w } = f();
|
|
5
8
|
//#endregion
|
|
6
|
-
export { t as DEFAULT_RENDER_SETTINGS,
|
|
9
|
+
export { t as DEFAULT_RENDER_SETTINGS, r as actionRunsStore, i as cancelActionRun, a as clearActionRuns, o as recordActionProgress, s as recordActionRun, c as registerActionCanceller, l as releaseActionCanceller, u as updateActionRun, d as useActionRuns, x as useBuilderStore, C as useBuilderStoreGetter, w as useBuilderStoreSetter, S as useBuilderStoreSync, p as useCommonStore, h as useCommonStoreGetter, g as useCommonStoreSetter, m as useCommonStoreSync, n as useRenderOverride, e as useRenderSettings, _ as useSdkStore, y as useSdkStoreGetter, b as useSdkStoreSetter, v as useSdkStoreSync };
|
|
@@ -21,6 +21,9 @@ export declare const useRenderOverride: (overrides: RenderSettings) => {
|
|
|
21
21
|
renderMode: import('..').RenderMode;
|
|
22
22
|
environment: import('..').Environment;
|
|
23
23
|
isHydrating: boolean;
|
|
24
|
+
hydrated: boolean;
|
|
25
|
+
overQuota: boolean;
|
|
26
|
+
testAttributes: boolean;
|
|
24
27
|
};
|
|
25
28
|
};
|
|
26
29
|
export default useRenderSettings;
|
|
@@ -6,27 +6,39 @@ var n = {
|
|
|
6
6
|
debugMode: !1,
|
|
7
7
|
renderMode: "raw",
|
|
8
8
|
environment: "main",
|
|
9
|
-
isHydrating: !1
|
|
9
|
+
isHydrating: !1,
|
|
10
|
+
hydrated: !1,
|
|
11
|
+
overQuota: !1,
|
|
12
|
+
testAttributes: !0
|
|
10
13
|
}, r = () => {
|
|
11
|
-
let [[r, i, a, o, s]] = e([
|
|
14
|
+
let [[r, i, a, o, s, c, l, u]] = e([
|
|
12
15
|
"render.previewMode",
|
|
13
16
|
"render.debugMode",
|
|
14
17
|
"render.renderMode",
|
|
15
18
|
"render.environment",
|
|
16
|
-
"render.isHydrating"
|
|
19
|
+
"render.isHydrating",
|
|
20
|
+
"render.hydrated",
|
|
21
|
+
"render.overQuota",
|
|
22
|
+
"render.testAttributes"
|
|
17
23
|
]);
|
|
18
24
|
return t(() => ({
|
|
19
25
|
previewMode: r ?? n.previewMode,
|
|
20
26
|
debugMode: i ?? n.debugMode,
|
|
21
27
|
renderMode: a ?? n.renderMode,
|
|
22
28
|
environment: o ?? n.environment,
|
|
23
|
-
isHydrating: s ?? n.isHydrating
|
|
29
|
+
isHydrating: s ?? n.isHydrating,
|
|
30
|
+
hydrated: c ?? n.hydrated,
|
|
31
|
+
overQuota: l ?? n.overQuota,
|
|
32
|
+
testAttributes: u ?? n.testAttributes
|
|
24
33
|
}), [
|
|
25
34
|
r,
|
|
26
35
|
i,
|
|
27
36
|
a,
|
|
28
37
|
o,
|
|
29
|
-
s
|
|
38
|
+
s,
|
|
39
|
+
c,
|
|
40
|
+
l,
|
|
41
|
+
u
|
|
30
42
|
]);
|
|
31
43
|
}, i = (e) => {
|
|
32
44
|
let n = r();
|
|
@@ -2,7 +2,7 @@ import { PropChange } from '../../types';
|
|
|
2
2
|
import { ProfilerOnRenderCallback } from 'react';
|
|
3
3
|
declare const tracingCollector: {
|
|
4
4
|
onRender: ProfilerOnRenderCallback;
|
|
5
|
-
linkParent: (id: string, parentId: string | undefined) => void;
|
|
5
|
+
linkParent: (id: string, parentId: string | undefined, elementId: string) => void;
|
|
6
6
|
recordProps: (id: string, changes: PropChange[]) => void;
|
|
7
7
|
recordStoreChange: (change: {
|
|
8
8
|
path: string | undefined;
|
|
@@ -2,32 +2,33 @@ import { previewValue as e } from "./preview.mjs";
|
|
|
2
2
|
import t from "./tracingStore.mjs";
|
|
3
3
|
import { createRecorder as n } from "@plitzi/nexus";
|
|
4
4
|
//#region src/store/tracing/tracingCollector.ts
|
|
5
|
-
var r = n({ max: 30 }), i = [], a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), c =
|
|
5
|
+
var r = n({ max: 30 }), i = [], a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), l = !0, u = 0, d = /* @__PURE__ */ new Map(), f = !1, p = !1, m = 0, h = !1, g = !1, _ = typeof requestAnimationFrame == "function" ? (e) => {
|
|
6
6
|
requestAnimationFrame(e);
|
|
7
7
|
} : (e) => {
|
|
8
8
|
setTimeout(e, 16);
|
|
9
|
-
},
|
|
9
|
+
}, v = () => {
|
|
10
10
|
let e = {};
|
|
11
|
-
for (let [t, n] of
|
|
11
|
+
for (let [t, n] of c) e[t] = {
|
|
12
12
|
parentId: o.get(t),
|
|
13
|
-
baseDuration: n
|
|
13
|
+
baseDuration: n,
|
|
14
|
+
elementId: s.get(t) ?? t
|
|
14
15
|
};
|
|
15
16
|
return e;
|
|
16
|
-
}, v = () => {
|
|
17
|
-
c && (c = !1, t.setState("tree", _())), t.setState("hydrated", h), t.setState("commits", i);
|
|
18
17
|
}, y = () => {
|
|
19
|
-
|
|
18
|
+
l && (l = !1, t.setState("tree", v())), t.setState("hydrated", g), t.setState("commits", i);
|
|
20
19
|
}, b = () => {
|
|
21
|
-
|
|
20
|
+
g || (g = !0, p && t.setState("hydrated", !0));
|
|
21
|
+
}, x = () => {
|
|
22
|
+
if (h = !1, a.size > 0) {
|
|
22
23
|
let e = [...a.values()].sort((e, t) => e.timestamp - t.timestamp);
|
|
23
24
|
a.clear(), i = [...i, ...e], i.length > 200 && (i = i.slice(i.length - 200));
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
-
},
|
|
27
|
-
(!o.has(e) || o.get(e) !== t) && (c = !0), o.set(e, t);
|
|
28
|
-
},
|
|
29
|
-
let t = r.entriesSince(
|
|
30
|
-
|
|
26
|
+
p && y();
|
|
27
|
+
}, S = (e, t, n) => {
|
|
28
|
+
(!o.has(e) || o.get(e) !== t) && (l = !0), o.size >= 2e4 && !o.has(e) && (o.clear(), s.clear(), c.clear(), l = !0), o.set(e, t), s.set(e, n);
|
|
29
|
+
}, C = () => {
|
|
30
|
+
let t = r.entriesSince(u);
|
|
31
|
+
u = r.lastSeq();
|
|
31
32
|
let n = /* @__PURE__ */ new Map();
|
|
32
33
|
for (let e of t) {
|
|
33
34
|
if (e.path === void 0) continue;
|
|
@@ -41,45 +42,46 @@ var r = n({ max: 30 }), i = [], a = /* @__PURE__ */ new Map(), o = /* @__PURE__
|
|
|
41
42
|
path: t,
|
|
42
43
|
preview: `${e(n.prev)} → ${e(n.next)}`
|
|
43
44
|
}));
|
|
44
|
-
},
|
|
45
|
-
onRender: (e, n, r, i,
|
|
46
|
-
|
|
47
|
-
let
|
|
48
|
-
|
|
49
|
-
let
|
|
45
|
+
}, w = {
|
|
46
|
+
onRender: (e, n, r, i, u, p) => {
|
|
47
|
+
f || (f = !0, t.setState("enabled", !0)), c.has(e) || (l = !0), c.set(e, i);
|
|
48
|
+
let g = d.get(e);
|
|
49
|
+
d.delete(e);
|
|
50
|
+
let v = {
|
|
50
51
|
id: e,
|
|
52
|
+
elementId: s.get(e) ?? e,
|
|
51
53
|
parentId: o.get(e),
|
|
52
54
|
phase: n,
|
|
53
55
|
actualDuration: r,
|
|
54
56
|
baseDuration: i,
|
|
55
|
-
changedProps:
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
commitId:
|
|
59
|
-
timestamp:
|
|
57
|
+
changedProps: g
|
|
58
|
+
}, y = a.get(p);
|
|
59
|
+
y ? (y.elements.push(v), y.elementCount += 1, y.duration = Math.max(y.duration, r)) : (m += 1, a.set(p, {
|
|
60
|
+
commitId: m,
|
|
61
|
+
timestamp: p,
|
|
60
62
|
duration: r,
|
|
61
63
|
elementCount: 1,
|
|
62
|
-
elements: [
|
|
63
|
-
causes:
|
|
64
|
-
})),
|
|
64
|
+
elements: [v],
|
|
65
|
+
causes: C()
|
|
66
|
+
})), h || (h = !0, _(x));
|
|
65
67
|
},
|
|
66
|
-
linkParent:
|
|
68
|
+
linkParent: S,
|
|
67
69
|
recordProps: (e, t) => {
|
|
68
|
-
|
|
70
|
+
d.set(e, t);
|
|
69
71
|
},
|
|
70
72
|
recordStoreChange: (e) => {
|
|
71
73
|
r.record(e);
|
|
72
74
|
},
|
|
73
|
-
setHydrated:
|
|
75
|
+
setHydrated: b,
|
|
74
76
|
start: () => {
|
|
75
|
-
|
|
77
|
+
p = !0, x(), y();
|
|
76
78
|
},
|
|
77
79
|
stop: () => {
|
|
78
|
-
|
|
80
|
+
p = !1;
|
|
79
81
|
},
|
|
80
82
|
clear: () => {
|
|
81
|
-
i = [], a.clear(),
|
|
83
|
+
i = [], a.clear(), u = r.lastSeq(), d.clear(), m = 0, l = !0, y();
|
|
82
84
|
}
|
|
83
85
|
};
|
|
84
86
|
//#endregion
|
|
85
|
-
export {
|
|
87
|
+
export { w as default };
|
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import { TracingState } from '../../types';
|
|
2
2
|
export declare const MAX_COMMITS = 200;
|
|
3
|
+
/**
|
|
4
|
+
* How many element INSTANCES the accumulated tree may hold before it is started over.
|
|
5
|
+
*
|
|
6
|
+
* The tree is keyed per instance — a list of ninety rows is ninety nodes — and nothing ever removes one: an element
|
|
7
|
+
* that unmounts leaves its entry behind, because the collector hears about renders and never about teardowns. Across
|
|
8
|
+
* a long session of navigating between dense pages that grows without bound, which on the page it is most worth
|
|
9
|
+
* profiling is the thing that eventually takes the tab down.
|
|
10
|
+
*
|
|
11
|
+
* Cleared wholesale rather than pruned, because there is no cheap way to know which entry is stale: the tree is
|
|
12
|
+
* written on the hot path, once per element per render, and an LRU touch there costs more than the leak. Losing it
|
|
13
|
+
* costs one commit's worth of hatched ancestors and then rebuilds from the next render.
|
|
14
|
+
*/
|
|
15
|
+
export declare const MAX_TREE_NODES = 20000;
|
|
3
16
|
export declare const MAX_CAUSES = 30;
|
|
4
17
|
export declare const createTracingState: () => TracingState;
|
|
5
18
|
declare const tracingStore: import('@plitzi/nexus').StoreApi<TracingState>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createStore as e } from "@plitzi/nexus";
|
|
2
2
|
//#region src/store/tracing/tracingStore.ts
|
|
3
|
-
var t = 200, n = () => ({
|
|
3
|
+
var t = 200, n = 2e4, r = 30, i = () => ({
|
|
4
4
|
enabled: !1,
|
|
5
5
|
hydrated: !1,
|
|
6
6
|
commits: [],
|
|
7
7
|
tree: {}
|
|
8
|
-
}),
|
|
8
|
+
}), a = e(i(), { id: "tracing" });
|
|
9
9
|
//#endregion
|
|
10
|
-
export { t as MAX_COMMITS, n as createTracingState,
|
|
10
|
+
export { r as MAX_CAUSES, t as MAX_COMMITS, n as MAX_TREE_NODES, i as createTracingState, a as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Asset } from '../types/PluginTypes';
|
|
2
|
+
import { FontHead } from '../types/StyleTypes';
|
|
3
|
+
/**
|
|
4
|
+
* The manifest's stylesheets as the asset rail describes them, for the one surface that renders into a document of
|
|
5
|
+
* its own: the builder canvas, and the SDK's own iframe render mode. Its `<head>` is reachable only through the rail, so what the SSR template writes and
|
|
6
|
+
* what a client-only render appends to `document.head` has to arrive there as assets instead.
|
|
7
|
+
*
|
|
8
|
+
* Only the stylesheets. The preconnects and preloads are there to save a visitor a round trip on a cold cache, and
|
|
9
|
+
* the canvas has neither — while `@font-face` blocks cannot ride a `<link>` at all, so they travel with the style
|
|
10
|
+
* the frame already writes into a `<style>` of its own.
|
|
11
|
+
*/
|
|
12
|
+
export declare const fontLinkAssets: (head: FontHead) => Record<string, Asset>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/style/fontAssets.ts
|
|
2
|
+
var e = (e) => e.links.filter((e) => e.rel === "stylesheet").reduce((e, t, n) => {
|
|
3
|
+
let r = `font-${n}`;
|
|
4
|
+
return {
|
|
5
|
+
...e,
|
|
6
|
+
[r]: {
|
|
7
|
+
type: "link",
|
|
8
|
+
id: r,
|
|
9
|
+
params: {
|
|
10
|
+
href: t.href,
|
|
11
|
+
type: "text/css",
|
|
12
|
+
rel: "stylesheet"
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
}, {});
|
|
17
|
+
//#endregion
|
|
18
|
+
export { e as fontLinkAssets };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SpaceFont } from '../types/StyleTypes';
|
|
2
|
+
export declare class FontValidationError extends Error {
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Parses and normalizes a manifest entry. Throws {@link FontValidationError} with a message meant to be read by
|
|
6
|
+
* whoever sent the value — a person in the Fonts panel, or an agent that will try again.
|
|
7
|
+
*/
|
|
8
|
+
export declare const parseSpaceFont: (value: unknown) => SpaceFont;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { isSafeFontUrl as e } from "./fonts.mjs";
|
|
2
|
+
//#region src/style/fontValidation.ts
|
|
3
|
+
var t = /* @__PURE__ */ new Set([
|
|
4
|
+
"system",
|
|
5
|
+
"google",
|
|
6
|
+
"remote",
|
|
7
|
+
"hosted"
|
|
8
|
+
]), n = /* @__PURE__ */ new Set([
|
|
9
|
+
"auto",
|
|
10
|
+
"block",
|
|
11
|
+
"swap",
|
|
12
|
+
"fallback",
|
|
13
|
+
"optional"
|
|
14
|
+
]), r = /* @__PURE__ */ new Set(["woff2", "woff"]), i = 100, a = (e) => {
|
|
15
|
+
for (let t = 0; t < e.length; t += 1) {
|
|
16
|
+
let n = e.charCodeAt(t);
|
|
17
|
+
if (n < 32 || n === 127) return !0;
|
|
18
|
+
}
|
|
19
|
+
return !1;
|
|
20
|
+
}, o = class extends Error {}, s = (e) => {
|
|
21
|
+
throw new o(e);
|
|
22
|
+
}, c = (e) => typeof e == "object" && !!e && !Array.isArray(e), l = (e) => {
|
|
23
|
+
if (typeof e != "string") return s("font.family must be a string");
|
|
24
|
+
let t = e.trim();
|
|
25
|
+
return t ? t.length > i ? s(`font.family cannot be longer than ${i} characters`) : a(t) ? s("font.family cannot contain control characters") : t : s("font.family cannot be empty");
|
|
26
|
+
}, u = (e) => {
|
|
27
|
+
if (e === void 0) return [400];
|
|
28
|
+
if (!Array.isArray(e) || e.length === 0) return s("font.weights must be a non-empty list of numbers");
|
|
29
|
+
let t = e.map((e) => typeof e != "number" || !Number.isInteger(e) || e < 1 || e > 1e3 ? s("font.weights must hold whole numbers between 1 and 1000") : e);
|
|
30
|
+
return [...new Set(t)].sort((e, t) => e - t);
|
|
31
|
+
}, d = (e) => {
|
|
32
|
+
if (e === void 0) return ["normal"];
|
|
33
|
+
if (!Array.isArray(e) || e.length === 0) return s("font.styles must be a non-empty list");
|
|
34
|
+
let t = e.map((e) => e !== "normal" && e !== "italic" ? s("font.styles may only hold \"normal\" or \"italic\"") : e);
|
|
35
|
+
return [...new Set(t)];
|
|
36
|
+
}, f = (e, t) => {
|
|
37
|
+
if (!c(e)) return s(`font.files[${t}] must be an object`);
|
|
38
|
+
let { weight: n, style: i, format: a, unicodeRange: o } = e;
|
|
39
|
+
if (typeof n != "number" || !Number.isInteger(n) || n < 1 || n > 1e3) return s(`font.files[${t}].weight must be a whole number between 1 and 1000`);
|
|
40
|
+
if (i !== "normal" && i !== "italic") return s(`font.files[${t}].style must be "normal" or "italic"`);
|
|
41
|
+
if (typeof a != "string" || !r.has(a)) return s(`font.files[${t}].format must be "woff2" or "woff"`);
|
|
42
|
+
let l = {
|
|
43
|
+
weight: n,
|
|
44
|
+
style: i,
|
|
45
|
+
format: a
|
|
46
|
+
};
|
|
47
|
+
if (o !== void 0) {
|
|
48
|
+
if (typeof o != "string") return s(`font.files[${t}].unicodeRange must be a string`);
|
|
49
|
+
l.unicodeRange = o;
|
|
50
|
+
}
|
|
51
|
+
return l;
|
|
52
|
+
}, p = (e, t) => typeof e != "string" || !e ? s(`font.files[${t}].path must be a non-empty string`) : e.includes("://") || e.startsWith("/") ? s(`font.files[${t}].path must be relative to the font store, not a URL`) : e.split("/").includes("..") ? s(`font.files[${t}].path cannot climb out of the font store`) : e, m = (e) => !Array.isArray(e) || e.length === 0 ? s("font.files must be a non-empty list") : e, h = (r) => {
|
|
53
|
+
if (!c(r)) return s("a font must be an object");
|
|
54
|
+
let { source: i, fallback: a, display: o, preload: h } = r;
|
|
55
|
+
if (typeof i != "string" || !t.has(i)) return s("font.source must be one of: system, google, remote, hosted");
|
|
56
|
+
if (typeof a != "string" || !a.trim()) return s("font.fallback is required: it is what renders until the face arrives");
|
|
57
|
+
if (o !== void 0 && (typeof o != "string" || !n.has(o))) return s("font.display must be one of: auto, block, swap, fallback, optional");
|
|
58
|
+
if (h !== void 0 && typeof h != "boolean") return s("font.preload must be a boolean");
|
|
59
|
+
let g = {
|
|
60
|
+
family: l(r.family),
|
|
61
|
+
fallback: a.trim(),
|
|
62
|
+
weights: u(r.weights),
|
|
63
|
+
styles: d(r.styles),
|
|
64
|
+
...o === void 0 ? {} : { display: o },
|
|
65
|
+
...h === void 0 ? {} : { preload: h }
|
|
66
|
+
};
|
|
67
|
+
if (i === "system") return {
|
|
68
|
+
...g,
|
|
69
|
+
source: "system"
|
|
70
|
+
};
|
|
71
|
+
if (i === "google") {
|
|
72
|
+
let { subsets: e } = r;
|
|
73
|
+
return e !== void 0 && (!Array.isArray(e) || e.some((e) => typeof e != "string")) ? s("font.subsets must be a list of strings") : {
|
|
74
|
+
...g,
|
|
75
|
+
source: "google",
|
|
76
|
+
...e === void 0 ? {} : { subsets: e }
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
if (i === "remote") {
|
|
80
|
+
let { stylesheet: t, files: n } = r;
|
|
81
|
+
return t === void 0 && n === void 0 ? s("a remote font needs either a stylesheet URL or the font files themselves") : t === void 0 ? {
|
|
82
|
+
...g,
|
|
83
|
+
source: "remote",
|
|
84
|
+
files: m(n).map((t, n) => {
|
|
85
|
+
let r = f(t, n), { url: i } = t;
|
|
86
|
+
return typeof i != "string" || !e(i) ? s(`font.files[${n}].url must be an https URL with no credentials in it`) : {
|
|
87
|
+
...r,
|
|
88
|
+
url: i
|
|
89
|
+
};
|
|
90
|
+
})
|
|
91
|
+
} : typeof t != "string" || !e(t) ? s("font.stylesheet must be an https URL with no credentials in it") : {
|
|
92
|
+
...g,
|
|
93
|
+
source: "remote",
|
|
94
|
+
stylesheet: t
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
...g,
|
|
99
|
+
source: "hosted",
|
|
100
|
+
files: m(r.files).map((e, t) => ({
|
|
101
|
+
...f(e, t),
|
|
102
|
+
path: p(e.path, t)
|
|
103
|
+
}))
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
//#endregion
|
|
107
|
+
export { o as FontValidationError, h as parseSpaceFont };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { FontHead, GoogleFont, SpaceFont, SystemFont } from '../types/StyleTypes';
|
|
2
|
+
/**
|
|
3
|
+
* The stacks every visitor already has, which is why they are a constant and not rows in each
|
|
4
|
+
* space document: they cost no bytes, they cannot be uploaded or removed, and a picker that did
|
|
5
|
+
* not offer them would make "no web font at all" an option nobody could choose.
|
|
6
|
+
*
|
|
7
|
+
* The weights are what a system face can be relied on for; anything else is synthesized by the
|
|
8
|
+
* browser, which is the effect this whole manifest exists to make visible rather than accidental.
|
|
9
|
+
*/
|
|
10
|
+
export declare const SYSTEM_FONTS: SystemFont[];
|
|
11
|
+
/** What a space can actually name: what it declared, over the stacks that are always there. A
|
|
12
|
+
* family declared by the space wins, so a space may upload its own "Arial" and mean it. */
|
|
13
|
+
export declare const availableFonts: (fonts: SpaceFont[]) => SpaceFont[];
|
|
14
|
+
/**
|
|
15
|
+
* A URL out of a space document is a URL a person typed, and it is about to become a `href` or a
|
|
16
|
+
* `@font-face` src. Nothing but plain https gets through: `javascript:` and `data:` are script in
|
|
17
|
+
* a link's clothing, and credentials in the authority are a password published to every visitor.
|
|
18
|
+
*/
|
|
19
|
+
export declare const isSafeFontUrl: (value: string) => boolean;
|
|
20
|
+
/** What a `font-family` declaration should say for this font: the family, then what renders until
|
|
21
|
+
* it arrives. Quoted unless the name is a single bare identifier, which is what CSS asks for. */
|
|
22
|
+
export declare const fontFamilyStack: (font: SpaceFont) => string;
|
|
23
|
+
/** The family a `font-family` value leads with — the one the manifest is keyed by. The rest of the value is the
|
|
24
|
+
* fallback chain, which names nothing this space has to load. */
|
|
25
|
+
export declare const primaryFamily: (value: string) => string;
|
|
26
|
+
/**
|
|
27
|
+
* One `css2` request for every Google family in the manifest.
|
|
28
|
+
*
|
|
29
|
+
* The axis tuples have to be listed in ascending order or the API answers 400, and the families
|
|
30
|
+
* are sorted for a reason of our own: the URL is a cache key, and two spaces with the same fonts
|
|
31
|
+
* in a different order should not be two entries in every CDN between here and the visitor.
|
|
32
|
+
*
|
|
33
|
+
* `subsets` is deliberately NOT sent. The v1 API took `subset=`; css2 answers with the full set of
|
|
34
|
+
* unicode-range-split faces and lets the browser fetch only the ranges a page actually uses, which
|
|
35
|
+
* is strictly better. The field stays on the manifest because mirroring (which downloads files
|
|
36
|
+
* rather than linking them) does have to know which ranges to keep.
|
|
37
|
+
*/
|
|
38
|
+
export declare const googleCss2Url: (fonts: GoogleFont[]) => string;
|
|
39
|
+
/**
|
|
40
|
+
* The stylesheet that draws family NAMES in their own typeface — the font picker, and nothing else.
|
|
41
|
+
*
|
|
42
|
+
* `text` is what makes it cheap: Google returns faces covering only those glyphs, a few hundred
|
|
43
|
+
* bytes for a whole list. It is also what makes it useless for a page, so this never renders one.
|
|
44
|
+
*/
|
|
45
|
+
export declare const googleTextSubsetUrl: (families: string[], text: string) => string;
|
|
46
|
+
/**
|
|
47
|
+
* The `resolveUrl` every surface passes to {@link fontsToHead}: a store-relative path, joined to wherever THIS
|
|
48
|
+
* deployment serves font files from. `/fonts` by default, which is a self-hosted server serving its own; a cloud
|
|
49
|
+
* deployment passes its CDN prefix. One joining rule, because the SSR document, the client and the static export
|
|
50
|
+
* have to agree on the URL down to the slash or they fetch the same face twice.
|
|
51
|
+
*/
|
|
52
|
+
export declare const fontUrlResolver: (baseUrl?: string) => (path: string) => string;
|
|
53
|
+
/**
|
|
54
|
+
* The families a stylesheet CHOOSES, which is not the same as every family it mentions and not the same as the
|
|
55
|
+
* ones it loads — that second gap is the whole reason the manifest exists.
|
|
56
|
+
*
|
|
57
|
+
* One family per declaration: the rest of a stack is the fallback chain, and a chain is not a choice. Declaring
|
|
58
|
+
* `SFMono-Regular` because it appears third in a monospace stack would fill a space's manifest with families
|
|
59
|
+
* nobody picked and nothing should fetch.
|
|
60
|
+
*
|
|
61
|
+
* A declaration whose lead is a generic (`sans-serif`, `ui-monospace`) contributes nothing: the browser already
|
|
62
|
+
* has it. So does one built from a variable — what `var(--font-heading)` resolves to is a fact about the
|
|
63
|
+
* variables, and the variable's own value is scanned in its place.
|
|
64
|
+
*/
|
|
65
|
+
export declare const familiesInCss: (css: string) => string[];
|
|
66
|
+
/**
|
|
67
|
+
* Everything a document has to carry so the manifest's families actually render.
|
|
68
|
+
*
|
|
69
|
+
* Pure on purpose: SSR writes it into a template, the client writes it into `document.head`, the
|
|
70
|
+
* builder canvas writes it into its iframe and the static export bakes it in. They disagree about
|
|
71
|
+
* where a hosted file lives and about nothing else, which is what `resolveUrl` is for — a
|
|
72
|
+
* store-relative path becomes a CDN URL, a local `/fonts/*` URL, or whatever the export needs.
|
|
73
|
+
*/
|
|
74
|
+
export declare const fontsToHead: (fonts: SpaceFont[], resolveUrl: (path: string) => string) => FontHead;
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
//#region src/style/fonts.ts
|
|
2
|
+
var e = "https://fonts.googleapis.com", t = {
|
|
3
|
+
woff2: "font/woff2",
|
|
4
|
+
woff: "font/woff"
|
|
5
|
+
}, n = [
|
|
6
|
+
{
|
|
7
|
+
source: "system",
|
|
8
|
+
family: "system-ui",
|
|
9
|
+
fallback: "-apple-system, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif",
|
|
10
|
+
weights: [400, 700],
|
|
11
|
+
styles: ["normal", "italic"]
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
source: "system",
|
|
15
|
+
family: "Arial",
|
|
16
|
+
fallback: "Helvetica, sans-serif",
|
|
17
|
+
weights: [400, 700],
|
|
18
|
+
styles: ["normal", "italic"]
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
source: "system",
|
|
22
|
+
family: "Verdana",
|
|
23
|
+
fallback: "Geneva, sans-serif",
|
|
24
|
+
weights: [400, 700],
|
|
25
|
+
styles: ["normal", "italic"]
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
source: "system",
|
|
29
|
+
family: "Trebuchet MS",
|
|
30
|
+
fallback: "Helvetica, sans-serif",
|
|
31
|
+
weights: [400, 700],
|
|
32
|
+
styles: ["normal", "italic"]
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
source: "system",
|
|
36
|
+
family: "Georgia",
|
|
37
|
+
fallback: "\"Times New Roman\", serif",
|
|
38
|
+
weights: [400, 700],
|
|
39
|
+
styles: ["normal", "italic"]
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
source: "system",
|
|
43
|
+
family: "Times New Roman",
|
|
44
|
+
fallback: "Times, serif",
|
|
45
|
+
weights: [400, 700],
|
|
46
|
+
styles: ["normal", "italic"]
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
source: "system",
|
|
50
|
+
family: "Courier New",
|
|
51
|
+
fallback: "ui-monospace, monospace",
|
|
52
|
+
weights: [400, 700],
|
|
53
|
+
styles: ["normal", "italic"]
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
source: "system",
|
|
57
|
+
family: "ui-monospace",
|
|
58
|
+
fallback: "SFMono-Regular, Menlo, Consolas, monospace",
|
|
59
|
+
weights: [400, 700],
|
|
60
|
+
styles: ["normal", "italic"]
|
|
61
|
+
}
|
|
62
|
+
], r = (e) => {
|
|
63
|
+
let t = new Set(e.map((e) => e.family));
|
|
64
|
+
return [...e, ...n.filter((e) => !t.has(e.family))];
|
|
65
|
+
}, i = (e) => {
|
|
66
|
+
try {
|
|
67
|
+
let t = new URL(e);
|
|
68
|
+
return t.protocol === "https:" && !t.username && !t.password;
|
|
69
|
+
} catch {
|
|
70
|
+
return !1;
|
|
71
|
+
}
|
|
72
|
+
}, a = (e) => {
|
|
73
|
+
try {
|
|
74
|
+
return new URL(e).origin;
|
|
75
|
+
} catch {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
}, o = {
|
|
79
|
+
"<": "\\3c ",
|
|
80
|
+
">": "\\3e "
|
|
81
|
+
}, s = (e) => `"${e.replace(/[\\"<>]/g, (e) => o[e] ?? `\\${e}`)}"`, c = /^U\+[0-9A-Fa-f?]{1,6}(-[0-9A-Fa-f]{1,6})?(\s*,\s*U\+[0-9A-Fa-f?]{1,6}(-[0-9A-Fa-f]{1,6})?)*$/, l = (e) => /^[a-zA-Z][a-zA-Z0-9-]*$/.test(e), u = (e) => {
|
|
82
|
+
let t = l(e.family) ? e.family : s(e.family);
|
|
83
|
+
return e.fallback ? `${t}, ${e.fallback}` : t;
|
|
84
|
+
}, d = (e) => (e.split(",")[0] ?? "").trim().replace(/^['"]|['"]$/g, "").trim(), f = (e) => {
|
|
85
|
+
let t = [...new Set(e.weights)].filter((e) => Number.isFinite(e)).sort((e, t) => e - t);
|
|
86
|
+
return t.length > 0 ? t : [400];
|
|
87
|
+
}, p = (e) => encodeURIComponent(e).replace(/%20/g, "+"), m = (t) => {
|
|
88
|
+
let n = [...t].sort((e, t) => e.family.localeCompare(t.family)).map((e) => {
|
|
89
|
+
let t = f(e);
|
|
90
|
+
if (!e.styles.includes("italic")) return `family=${p(e.family)}:wght@${t.join(";")}`;
|
|
91
|
+
let n = [0, 1].flatMap((e) => t.map((t) => `${e},${t}`));
|
|
92
|
+
return `family=${p(e.family)}:ital,wght@${n.join(";")}`;
|
|
93
|
+
}), r = [...new Set(t.map((e) => e.display ?? "swap"))], i = r.length === 1 ? r[0] : "swap";
|
|
94
|
+
return `${e}/css2?${n.join("&")}&display=${i}`;
|
|
95
|
+
}, h = (t, n) => `${e}/css2?${[...t].sort((e, t) => e.localeCompare(t)).map((e) => `family=${p(e)}`).join("&")}&text=${encodeURIComponent(n)}&display=swap`, g = "/fonts", _ = (e = g) => (t) => `${e.replace(/\/+$/, "")}/${t.replace(/^\/+/, "")}`, v = /* @__PURE__ */ new Set([
|
|
96
|
+
"serif",
|
|
97
|
+
"sans-serif",
|
|
98
|
+
"monospace",
|
|
99
|
+
"cursive",
|
|
100
|
+
"fantasy",
|
|
101
|
+
"system-ui",
|
|
102
|
+
"ui-serif",
|
|
103
|
+
"ui-sans-serif",
|
|
104
|
+
"ui-monospace",
|
|
105
|
+
"ui-rounded",
|
|
106
|
+
"math",
|
|
107
|
+
"emoji",
|
|
108
|
+
"fangsong",
|
|
109
|
+
"inherit",
|
|
110
|
+
"initial",
|
|
111
|
+
"revert",
|
|
112
|
+
"revert-layer",
|
|
113
|
+
"unset"
|
|
114
|
+
]), y = (e) => {
|
|
115
|
+
let t = /* @__PURE__ */ new Set();
|
|
116
|
+
for (let n of e.matchAll(/font-family\s*:\s*([^;}]+)/g)) {
|
|
117
|
+
let e = n[1];
|
|
118
|
+
if (e.includes("var(")) continue;
|
|
119
|
+
let r = d(e);
|
|
120
|
+
r && !v.has(r.toLowerCase()) && t.add(r);
|
|
121
|
+
}
|
|
122
|
+
return [...t];
|
|
123
|
+
}, b = (e, t) => [
|
|
124
|
+
"@font-face{",
|
|
125
|
+
`font-family:${s(e.family)};`,
|
|
126
|
+
`font-style:${t.style === "italic" ? "italic" : "normal"};`,
|
|
127
|
+
`font-weight:${Number.parseInt(String(t.weight), 10) || 400};`,
|
|
128
|
+
`font-display:${e.display ?? "swap"};`,
|
|
129
|
+
`src:url(${s(t.url)}) format(${s(t.format)});`,
|
|
130
|
+
t.unicodeRange && c.test(t.unicodeRange) ? `unicode-range:${t.unicodeRange};` : "",
|
|
131
|
+
"}"
|
|
132
|
+
].join(""), x = (n, r) => {
|
|
133
|
+
let o = [], s = [], c = [], l = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Set(), d = (e, t) => {
|
|
134
|
+
e && (u.add(e), l.set(e, (l.get(e) ?? !1) || t));
|
|
135
|
+
}, f = n.filter((e) => e.source === "google");
|
|
136
|
+
if (f.length > 0) {
|
|
137
|
+
let t = m(f);
|
|
138
|
+
d(e, !1), d("https://fonts.gstatic.com", !0), f.some((e) => e.preload) && s.push({
|
|
139
|
+
href: t,
|
|
140
|
+
rel: "preload",
|
|
141
|
+
as: "style"
|
|
142
|
+
}), o.push({
|
|
143
|
+
href: t,
|
|
144
|
+
rel: "stylesheet"
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
return n.forEach((e) => {
|
|
148
|
+
if (e.source === "remote" && e.stylesheet && i(e.stylesheet)) {
|
|
149
|
+
d(a(e.stylesheet), !1), e.preload && s.push({
|
|
150
|
+
href: e.stylesheet,
|
|
151
|
+
rel: "preload",
|
|
152
|
+
as: "style"
|
|
153
|
+
}), o.push({
|
|
154
|
+
href: e.stylesheet,
|
|
155
|
+
rel: "stylesheet"
|
|
156
|
+
});
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
if (e.source === "remote" && e.files) {
|
|
160
|
+
e.files.filter((e) => i(e.url)).forEach((n) => {
|
|
161
|
+
d(a(n.url), !0), c.push(b(e, {
|
|
162
|
+
...n,
|
|
163
|
+
url: n.url
|
|
164
|
+
})), e.preload && s.push({
|
|
165
|
+
href: n.url,
|
|
166
|
+
rel: "preload",
|
|
167
|
+
as: "font",
|
|
168
|
+
type: t[n.format],
|
|
169
|
+
crossorigin: !0
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
e.source === "hosted" && e.files.forEach((n) => {
|
|
175
|
+
let i = r(n.path);
|
|
176
|
+
d(a(i), !0), c.push(b(e, {
|
|
177
|
+
...n,
|
|
178
|
+
url: i
|
|
179
|
+
})), e.preload && s.push({
|
|
180
|
+
href: i,
|
|
181
|
+
rel: "preload",
|
|
182
|
+
as: "font",
|
|
183
|
+
type: t[n.format],
|
|
184
|
+
crossorigin: !0
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
}), {
|
|
188
|
+
preconnect: [...l].map(([e, t]) => t ? {
|
|
189
|
+
href: e,
|
|
190
|
+
crossorigin: t
|
|
191
|
+
} : { href: e }),
|
|
192
|
+
links: [...s, ...o],
|
|
193
|
+
faces: c.join(""),
|
|
194
|
+
origins: [...u]
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
//#endregion
|
|
198
|
+
export { n as SYSTEM_FONTS, r as availableFonts, y as familiesInCss, u as fontFamilyStack, _ as fontUrlResolver, x as fontsToHead, m as googleCss2Url, h as googleTextSubsetUrl, i as isSafeFontUrl, d as primaryFamily };
|