@roblawn/devtool-runtime 0.1.0-alpha.0
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/LICENSE.md +11 -0
- package/README.md +7 -0
- package/dist/ak/ak.cssState.transform.d.ts +2 -0
- package/dist/ak/ak.cssState.transform.js +60 -0
- package/dist/ak/ak.cssState.types.d.ts +2 -0
- package/dist/ak/ak.cssState.types.js +1 -0
- package/dist/ak/ak.responsive.types.d.ts +18 -0
- package/dist/ak/ak.responsive.types.js +1 -0
- package/dist/ak/ak.tokens.d.ts +10 -0
- package/dist/ak/ak.tokens.js +10 -0
- package/dist/ak/ak.tokens.registry.d.ts +10 -0
- package/dist/ak/ak.tokens.registry.js +45 -0
- package/dist/ak/authoring-surface.shared.d.ts +31 -0
- package/dist/ak/authoring-surface.shared.js +185 -0
- package/dist/ak/configured-core.shared.d.ts +7 -0
- package/dist/ak/configured-core.shared.js +16 -0
- package/dist/ak/configured-surfaces.shared.d.ts +67 -0
- package/dist/ak/configured-surfaces.shared.js +144 -0
- package/dist/ak/index.d.ts +16 -0
- package/dist/ak/index.js +16 -0
- package/dist/ak/project-entry.d.ts +57 -0
- package/dist/ak/project-entry.js +260 -0
- package/dist/ak/project-surface-adapters.shared.d.ts +33 -0
- package/dist/ak/project-surface-adapters.shared.js +83 -0
- package/dist/ak/public-entry.shared.d.ts +16 -0
- package/dist/ak/public-entry.shared.js +18 -0
- package/dist/ak/resolved-layout-marker.shared.d.ts +3 -0
- package/dist/ak/resolved-layout-marker.shared.js +19 -0
- package/dist/ak/runtime-surface.shared.d.ts +31 -0
- package/dist/ak/runtime-surface.shared.js +221 -0
- package/dist/ak/style-execution.d.ts +13 -0
- package/dist/ak/style-execution.js +91 -0
- package/dist/ak/style-schema.d.ts +16 -0
- package/dist/ak/style-schema.js +6 -0
- package/dist/ak/useAk.shared.d.ts +3 -0
- package/dist/ak/useAk.shared.js +36 -0
- package/dist/authoring/authoringEffectKinds.d.ts +2 -0
- package/dist/authoring/authoringEffectKinds.js +48 -0
- package/dist/authoring/index.d.ts +1 -0
- package/dist/authoring/index.js +1 -0
- package/dist/cms/CMSPresenterSchemaTypes.d.ts +108 -0
- package/dist/cms/CMSPresenterSchemaTypes.js +6 -0
- package/dist/cms/CMSSchema.d.ts +27 -0
- package/dist/cms/CMSSchema.js +89 -0
- package/dist/cms/CMSSchemaTypes.d.ts +141 -0
- package/dist/cms/CMSSchemaTypes.js +1 -0
- package/dist/cms/index.d.ts +3 -0
- package/dist/cms/index.js +1 -0
- package/dist/design-system/DesignSystemSnapshotFactory.d.ts +34 -0
- package/dist/design-system/DesignSystemSnapshotFactory.js +38 -0
- package/dist/design-system/ProjectDesignSystemFactory.d.ts +39 -0
- package/dist/design-system/ProjectDesignSystemFactory.js +32 -0
- package/dist/design-system/index.d.ts +8 -0
- package/dist/design-system/index.js +7 -0
- package/dist/design-system/ops/ops.types.d.ts +22 -0
- package/dist/design-system/ops/ops.types.js +1 -0
- package/dist/design-system/resolvers/ds.resolvers.d.ts +3 -0
- package/dist/design-system/resolvers/ds.resolvers.js +24 -0
- package/dist/design-system/resolvers/ds.responsive.d.ts +12 -0
- package/dist/design-system/resolvers/ds.responsive.js +28 -0
- package/dist/design-system/tokens/TokenSchemas.types.d.ts +48 -0
- package/dist/design-system/tokens/TokenSchemas.types.js +3 -0
- package/dist/design-system/tokens/coreTokenFamilies.types.d.ts +2 -0
- package/dist/design-system/tokens/coreTokenFamilies.types.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/layout/index.d.ts +1 -0
- package/dist/layout/index.js +1 -0
- package/dist/layout/layoutRuntime.d.ts +12 -0
- package/dist/layout/layoutRuntime.js +88 -0
- package/dist/schema/LayoutBindingEditorPolicyMetadata.d.ts +7 -0
- package/dist/schema/LayoutBindingEditorPolicyMetadata.js +19 -0
- package/dist/schema/LayoutBindingEditorSectionMetadata.d.ts +7 -0
- package/dist/schema/LayoutBindingEditorSectionMetadata.js +19 -0
- package/dist/schema/LayoutDefinitionMeta.d.ts +54 -0
- package/dist/schema/LayoutDefinitionMeta.js +1 -0
- package/dist/schema/LayoutFieldIntentMetadata.d.ts +22 -0
- package/dist/schema/LayoutFieldIntentMetadata.js +38 -0
- package/dist/schema/LayoutFieldUiMetadata.d.ts +30 -0
- package/dist/schema/LayoutFieldUiMetadata.js +19 -0
- package/dist/schema/LayoutSchema.d.ts +39 -0
- package/dist/schema/LayoutSchema.js +53 -0
- package/dist/schema/LayoutVariantBindings.d.ts +55 -0
- package/dist/schema/LayoutVariantBindings.js +107 -0
- package/dist/schema/SlotSchema.d.ts +10 -0
- package/dist/schema/SlotSchema.js +3 -0
- package/dist/schema/StyleSchema.d.ts +16 -0
- package/dist/schema/StyleSchema.js +6 -0
- package/dist/schema/index.d.ts +9 -0
- package/dist/schema/index.js +9 -0
- package/dist/theme-contract/CompositeFieldOpByFamily.d.ts +126 -0
- package/dist/theme-contract/CompositeFieldOpByFamily.js +126 -0
- package/dist/theme-contract/index.d.ts +7 -0
- package/dist/theme-contract/index.js +7 -0
- package/dist/theme-contract/ops/coreOps.d.ts +697 -0
- package/dist/theme-contract/ops/coreOps.js +748 -0
- package/dist/theme-contract/ops/delegateValidation.types.d.ts +46 -0
- package/dist/theme-contract/ops/delegateValidation.types.js +4 -0
- package/dist/theme-contract/ops/emitters.d.ts +24 -0
- package/dist/theme-contract/ops/emitters.js +151 -0
- package/dist/theme-contract/ops/op.config.d.ts +711 -0
- package/dist/theme-contract/ops/op.config.js +15 -0
- package/dist/theme-contract/tokens/coreTokenFamilies.d.ts +9 -0
- package/dist/theme-contract/tokens/coreTokenFamilies.js +6 -0
- package/dist/theme-contract/tokens/cssLengthConversion.d.ts +2 -0
- package/dist/theme-contract/tokens/cssLengthConversion.js +39 -0
- package/dist/theme-contract/tokens/defineProjectTokenFamilySchema.d.ts +1 -0
- package/dist/theme-contract/tokens/defineProjectTokenFamilySchema.js +1 -0
- package/dist/theme-contract/tokens/defineTokenFamilySchema.d.ts +3 -0
- package/dist/theme-contract/tokens/defineTokenFamilySchema.js +5 -0
- package/dist/theme-contract/tokens/runtimeTokenFamilies.types.d.ts +5 -0
- package/dist/theme-contract/tokens/runtimeTokenFamilies.types.js +1 -0
- package/dist/theme-contract/tokens/schemas/aspect.token.schema.d.ts +20 -0
- package/dist/theme-contract/tokens/schemas/aspect.token.schema.js +19 -0
- package/dist/theme-contract/tokens/schemas/blur.token.schema.d.ts +21 -0
- package/dist/theme-contract/tokens/schemas/blur.token.schema.js +19 -0
- package/dist/theme-contract/tokens/schemas/border.token.schema.d.ts +54 -0
- package/dist/theme-contract/tokens/schemas/border.token.schema.js +43 -0
- package/dist/theme-contract/tokens/schemas/breakpoint.token.schema.d.ts +19 -0
- package/dist/theme-contract/tokens/schemas/breakpoint.token.schema.js +18 -0
- package/dist/theme-contract/tokens/schemas/color.token.schema.d.ts +24 -0
- package/dist/theme-contract/tokens/schemas/color.token.schema.js +23 -0
- package/dist/theme-contract/tokens/schemas/container.token.schema.d.ts +26 -0
- package/dist/theme-contract/tokens/schemas/container.token.schema.js +30 -0
- package/dist/theme-contract/tokens/schemas/font.token.schema.d.ts +17 -0
- package/dist/theme-contract/tokens/schemas/font.token.schema.js +15 -0
- package/dist/theme-contract/tokens/schemas/fontWeight.token.schema.d.ts +24 -0
- package/dist/theme-contract/tokens/schemas/fontWeight.token.schema.js +22 -0
- package/dist/theme-contract/tokens/schemas/leading.token.schema.d.ts +20 -0
- package/dist/theme-contract/tokens/schemas/leading.token.schema.js +18 -0
- package/dist/theme-contract/tokens/schemas/radius.token.schema.d.ts +23 -0
- package/dist/theme-contract/tokens/schemas/radius.token.schema.js +22 -0
- package/dist/theme-contract/tokens/schemas/shadow.token.schema.d.ts +108 -0
- package/dist/theme-contract/tokens/schemas/shadow.token.schema.js +73 -0
- package/dist/theme-contract/tokens/schemas/size.token.schema.d.ts +20 -0
- package/dist/theme-contract/tokens/schemas/size.token.schema.js +19 -0
- package/dist/theme-contract/tokens/schemas/spacing.token.schema.d.ts +21 -0
- package/dist/theme-contract/tokens/schemas/spacing.token.schema.js +20 -0
- package/dist/theme-contract/tokens/schemas/text.token.schema.d.ts +87 -0
- package/dist/theme-contract/tokens/schemas/text.token.schema.js +30 -0
- package/dist/theme-contract/tokens/schemas/textSize.token.schema.d.ts +28 -0
- package/dist/theme-contract/tokens/schemas/textSize.token.schema.js +27 -0
- package/dist/theme-contract/tokens/schemas/title.token.schema.d.ts +85 -0
- package/dist/theme-contract/tokens/schemas/title.token.schema.js +30 -0
- package/dist/theme-contract/tokens/schemas/tracking.token.schema.d.ts +20 -0
- package/dist/theme-contract/tokens/schemas/tracking.token.schema.js +18 -0
- package/dist/theme-contract/tokens/schemas/zIndex.token.schema.d.ts +18 -0
- package/dist/theme-contract/tokens/schemas/zIndex.token.schema.js +17 -0
- package/dist/theme-contract/tokens/tokens.schema.d.ts +531 -0
- package/dist/theme-contract/tokens/tokens.schema.js +32 -0
- package/dist/types/LayoutResolvedTs.types.d.ts +18 -0
- package/dist/types/LayoutResolvedTs.types.js +1 -0
- package/dist/types/authoredTree.types.d.ts +112 -0
- package/dist/types/authoredTree.types.js +1 -0
- package/dist/types/blockRegistry.types.d.ts +37 -0
- package/dist/types/blockRegistry.types.js +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.js +1 -0
- package/dist/types/layout.types.d.ts +30 -0
- package/dist/types/layout.types.js +1 -0
- package/package.json +65 -0
package/dist/ak/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export * from './ak.cssState.types.js';
|
|
2
|
+
export * from './ak.cssState.transform.js';
|
|
3
|
+
export * from './ak.responsive.types.js';
|
|
4
|
+
export * from './ak.tokens.registry.js';
|
|
5
|
+
export * from './ak.tokens.js';
|
|
6
|
+
export * from './authoring-surface.shared.js';
|
|
7
|
+
export * from './configured-core.shared.js';
|
|
8
|
+
export * from './configured-surfaces.shared.js';
|
|
9
|
+
export * from './project-entry.js';
|
|
10
|
+
export * from './project-surface-adapters.shared.js';
|
|
11
|
+
export * from './public-entry.shared.js';
|
|
12
|
+
export * from './resolved-layout-marker.shared.js';
|
|
13
|
+
export * from './style-schema.js';
|
|
14
|
+
export * from './runtime-surface.shared.js';
|
|
15
|
+
export * from './style-execution.js';
|
|
16
|
+
export * from './useAk.shared.js';
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { Ref } from 'vue';
|
|
2
|
+
import { type SnapshotTokenSource } from './ak.tokens.js';
|
|
3
|
+
import { type RuntimeSurfaceFactory } from './configured-surfaces.shared.js';
|
|
4
|
+
import { type AuthorKitMode, type PublicAkEntry } from './public-entry.shared.js';
|
|
5
|
+
type ResponsiveTokenOverrides = Partial<Record<string, Record<string, Record<string, string>>>>;
|
|
6
|
+
export interface ProjectAkOpConfigEntry {
|
|
7
|
+
readonly tokenFamily?: string;
|
|
8
|
+
readonly responsive?: boolean;
|
|
9
|
+
readonly addNoneasOmit?: boolean;
|
|
10
|
+
readonly authoringValue?: {
|
|
11
|
+
readonly kind: 'number';
|
|
12
|
+
readonly min?: number;
|
|
13
|
+
readonly max?: number;
|
|
14
|
+
readonly step?: number;
|
|
15
|
+
};
|
|
16
|
+
readonly useAlias?: (value: string) => string;
|
|
17
|
+
}
|
|
18
|
+
export interface ProjectAkDesignSystemBridge {
|
|
19
|
+
readonly ops: readonly string[];
|
|
20
|
+
readonly opConfig: Readonly<Record<string, ProjectAkOpConfigEntry | undefined>>;
|
|
21
|
+
readonly tokenFamilies: readonly string[];
|
|
22
|
+
readonly nonCompositeOps: readonly string[];
|
|
23
|
+
readonly responsiveOps: readonly string[];
|
|
24
|
+
readonly breakpointOrder: readonly string[];
|
|
25
|
+
readonly responsiveTokenOverrides: ResponsiveTokenOverrides;
|
|
26
|
+
readonly snapshot: SnapshotTokenSource;
|
|
27
|
+
resolve(op: string, value: string | number): string;
|
|
28
|
+
resolveForCompute(op: string, value: string | number): string;
|
|
29
|
+
}
|
|
30
|
+
export interface ProjectAkRuntimeTokensBridge {
|
|
31
|
+
readonly registryFamilies: Record<string, unknown>;
|
|
32
|
+
readonly registryTokens: Record<string, Record<string, unknown>>;
|
|
33
|
+
readonly coreFamilies: Record<string, readonly string[]>;
|
|
34
|
+
readonly opToFamily: Readonly<Record<string, string>>;
|
|
35
|
+
readonly tokenFamilies: readonly string[];
|
|
36
|
+
}
|
|
37
|
+
export interface ProjectAkAdapterBridge {
|
|
38
|
+
readonly getBoundValue: (layoutRef: Ref<unknown>) => (field: string) => unknown;
|
|
39
|
+
readonly createBoundStyleApi: RuntimeSurfaceFactory<unknown>;
|
|
40
|
+
readonly createBoundWrapperApi: RuntimeSurfaceFactory<unknown>;
|
|
41
|
+
readonly createRuntimeStyleApi: RuntimeSurfaceFactory<unknown>;
|
|
42
|
+
readonly createRuntimeWrapperApi: RuntimeSurfaceFactory<unknown>;
|
|
43
|
+
}
|
|
44
|
+
export interface ProjectAkBridge {
|
|
45
|
+
readonly mode: AuthorKitMode;
|
|
46
|
+
readonly designSystem: ProjectAkDesignSystemBridge;
|
|
47
|
+
readonly runtimeTokens: ProjectAkRuntimeTokensBridge;
|
|
48
|
+
readonly adapters: ProjectAkAdapterBridge;
|
|
49
|
+
}
|
|
50
|
+
export declare function createProjectAkImplementation<TReturn>(bridge: ProjectAkBridge, layoutInput?: unknown): TReturn;
|
|
51
|
+
export declare function defineProjectAk<TReturn>(bridge: ProjectAkBridge): PublicAkEntry<TReturn>;
|
|
52
|
+
export declare function resolveProjectAkMode(env?: {
|
|
53
|
+
readonly MODE?: string;
|
|
54
|
+
readonly DEV?: boolean;
|
|
55
|
+
readonly VITE_DEVTOOL_MODE?: string;
|
|
56
|
+
}): AuthorKitMode;
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { buildResponsiveClassString } from '../design-system/index.js';
|
|
2
|
+
import { createAkTokensFromRegistry } from './ak.tokens.registry.js';
|
|
3
|
+
import { createAkTokensFromSnapshot } from './ak.tokens.js';
|
|
4
|
+
import { createConfiguredAkCore } from './configured-core.shared.js';
|
|
5
|
+
import { createConfiguredResponsiveAuthorKitSurface, createConfiguredRuntimeAuthorKitSurface, } from './configured-surfaces.shared.js';
|
|
6
|
+
import { isMarkedResolvedLayout } from './resolved-layout-marker.shared.js';
|
|
7
|
+
import { createAkPublicEntry } from './public-entry.shared.js';
|
|
8
|
+
import { resolveLayoutRef } from './useAk.shared.js';
|
|
9
|
+
function sanitizeClassToken(input) {
|
|
10
|
+
return input
|
|
11
|
+
.toLowerCase()
|
|
12
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
13
|
+
.replace(/^-+|-+$/g, '')
|
|
14
|
+
.slice(0, 48);
|
|
15
|
+
}
|
|
16
|
+
function makeBuilderFailureClass(args) {
|
|
17
|
+
const base = 'outline outline-2 outline-dashed outline-red-500 bg-red-50 text-red-900';
|
|
18
|
+
const sig = ['ak-builder-fail', `ak-op-${sanitizeClassToken(args.op)}`, `ak-field-${sanitizeClassToken(args.field)}`, `ak-reason-${sanitizeClassToken(args.reason)}`]
|
|
19
|
+
.filter(Boolean)
|
|
20
|
+
.join(' ');
|
|
21
|
+
return `${base} ${sig}`.trim();
|
|
22
|
+
}
|
|
23
|
+
const didWarnMissing = new Set();
|
|
24
|
+
function warnMissingOnce(args) {
|
|
25
|
+
const isDev = Boolean(import.meta.env?.DEV);
|
|
26
|
+
if (!isDev)
|
|
27
|
+
return;
|
|
28
|
+
const key = `${args.op}:${args.field}`;
|
|
29
|
+
if (didWarnMissing.has(key))
|
|
30
|
+
return;
|
|
31
|
+
didWarnMissing.add(key);
|
|
32
|
+
console.warn(`[ak.builder] missing layout value`, { op: args.op, field: args.field });
|
|
33
|
+
}
|
|
34
|
+
function createResponsiveWiring(source, mode) {
|
|
35
|
+
if (mode === 'lookup') {
|
|
36
|
+
return {
|
|
37
|
+
mode: 'lookup',
|
|
38
|
+
enabledOps: source.responsiveOps,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
mode,
|
|
43
|
+
enabledOps: source.responsiveOps,
|
|
44
|
+
breakpointOrder: source.breakpointOrder,
|
|
45
|
+
getOverrides(op, baseToken) {
|
|
46
|
+
const family = source.opConfig[op]?.tokenFamily;
|
|
47
|
+
if (!family)
|
|
48
|
+
return {};
|
|
49
|
+
const familyOverrides = source.responsiveTokenOverrides[family];
|
|
50
|
+
if (!familyOverrides)
|
|
51
|
+
return {};
|
|
52
|
+
return familyOverrides[baseToken] ?? {};
|
|
53
|
+
},
|
|
54
|
+
buildClassString(args) {
|
|
55
|
+
return buildResponsiveClassString({
|
|
56
|
+
op: args.op,
|
|
57
|
+
baseToken: args.baseToken,
|
|
58
|
+
breakpointOrder: args.breakpointOrder,
|
|
59
|
+
overrides: args.overrides,
|
|
60
|
+
resolveTokenToClasses: args.resolveTokenToClasses,
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function createBuilderSurface(layoutRef, bridge) {
|
|
66
|
+
const getValue = bridge.adapters.getBoundValue(layoutRef);
|
|
67
|
+
const responsiveWiring = createResponsiveWiring(bridge.designSystem, 'compute');
|
|
68
|
+
const computeCore = createConfiguredAkCore({
|
|
69
|
+
layoutRef,
|
|
70
|
+
ops: bridge.designSystem.ops,
|
|
71
|
+
resolve: (op, value) => bridge.designSystem.resolveForCompute(op, value),
|
|
72
|
+
});
|
|
73
|
+
const canonicalCore = createConfiguredAkCore({
|
|
74
|
+
layoutRef,
|
|
75
|
+
ops: bridge.designSystem.ops,
|
|
76
|
+
resolve: (op, value) => bridge.designSystem.resolve(op, value),
|
|
77
|
+
});
|
|
78
|
+
return createConfiguredResponsiveAuthorKitSurface({
|
|
79
|
+
core: computeCore,
|
|
80
|
+
computeCanonical: canonicalCore,
|
|
81
|
+
layoutRef,
|
|
82
|
+
getValue,
|
|
83
|
+
tokenFamilies: bridge.designSystem.tokenFamilies,
|
|
84
|
+
tokens: createAkTokensFromSnapshot(bridge.designSystem.snapshot),
|
|
85
|
+
responsiveWiring,
|
|
86
|
+
resolveCssValue: ({ op, field, def, raw, resolver }) => {
|
|
87
|
+
if (isMarkedResolvedLayout(layoutRef.value) && typeof raw === 'string') {
|
|
88
|
+
return raw.trim();
|
|
89
|
+
}
|
|
90
|
+
if (raw === null || raw === undefined) {
|
|
91
|
+
warnMissingOnce({ op: String(op), field });
|
|
92
|
+
}
|
|
93
|
+
const rawValue = typeof raw === 'string' ? raw.trim() : typeof raw === 'number' ? raw : undefined;
|
|
94
|
+
const tokenKey = rawValue === '' || rawValue === undefined ? def : rawValue;
|
|
95
|
+
if (tokenKey === undefined || tokenKey === '') {
|
|
96
|
+
return makeBuilderFailureClass({
|
|
97
|
+
op: String(op),
|
|
98
|
+
field,
|
|
99
|
+
reason: 'missing-value-and-default',
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
return resolver(field, tokenKey) ?? '';
|
|
103
|
+
},
|
|
104
|
+
resolveResponsiveCssValue: ({ op, field, def, raw, computeResolver, wiring }) => {
|
|
105
|
+
if (isMarkedResolvedLayout(layoutRef.value) && typeof raw === 'string') {
|
|
106
|
+
return raw.trim();
|
|
107
|
+
}
|
|
108
|
+
if (wiring.mode === 'lookup') {
|
|
109
|
+
return typeof raw === 'string' ? raw.trim() : '';
|
|
110
|
+
}
|
|
111
|
+
if (raw === null || raw === undefined) {
|
|
112
|
+
warnMissingOnce({ op: String(op), field });
|
|
113
|
+
}
|
|
114
|
+
const rawString = typeof raw === 'string' ? raw.trim() : '';
|
|
115
|
+
const baseToken = rawString.length > 0 ? rawString : def;
|
|
116
|
+
if (!baseToken) {
|
|
117
|
+
return makeBuilderFailureClass({
|
|
118
|
+
op: String(op),
|
|
119
|
+
field,
|
|
120
|
+
reason: 'missing-value-and-default',
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
const overrides = wiring.getOverrides(op, baseToken);
|
|
124
|
+
return wiring.buildClassString({
|
|
125
|
+
op,
|
|
126
|
+
baseToken,
|
|
127
|
+
overrides,
|
|
128
|
+
breakpointOrder: wiring.breakpointOrder,
|
|
129
|
+
resolveTokenToClasses: (_op, token) => computeResolver(field, token),
|
|
130
|
+
});
|
|
131
|
+
},
|
|
132
|
+
cssStateEnabledOps: bridge.designSystem.nonCompositeOps,
|
|
133
|
+
mode: 'reactive',
|
|
134
|
+
createStyleApi: bridge.adapters.createBoundStyleApi,
|
|
135
|
+
createWrapperApi: bridge.adapters.createBoundWrapperApi,
|
|
136
|
+
createDeclareOptions: {
|
|
137
|
+
enumPassthroughUnknownString: () => isMarkedResolvedLayout(layoutRef.value),
|
|
138
|
+
parseBooleanStrings: false,
|
|
139
|
+
},
|
|
140
|
+
acceptPlainResolvedObject: false,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
function createDevSurface(layoutRef, bridge) {
|
|
144
|
+
const getValue = bridge.adapters.getBoundValue(layoutRef);
|
|
145
|
+
const responsiveWiring = createResponsiveWiring(bridge.designSystem, 'hybrid');
|
|
146
|
+
const computeCore = createConfiguredAkCore({
|
|
147
|
+
layoutRef,
|
|
148
|
+
ops: bridge.designSystem.ops,
|
|
149
|
+
resolve: (op, value) => bridge.designSystem.resolveForCompute(op, value),
|
|
150
|
+
});
|
|
151
|
+
const canonicalCore = createConfiguredAkCore({
|
|
152
|
+
layoutRef,
|
|
153
|
+
ops: bridge.designSystem.ops,
|
|
154
|
+
resolve: (op, value) => bridge.designSystem.resolve(op, value),
|
|
155
|
+
});
|
|
156
|
+
return createConfiguredResponsiveAuthorKitSurface({
|
|
157
|
+
core: computeCore,
|
|
158
|
+
computeCanonical: canonicalCore,
|
|
159
|
+
layoutRef,
|
|
160
|
+
getValue,
|
|
161
|
+
tokenFamilies: bridge.designSystem.tokenFamilies,
|
|
162
|
+
tokens: createAkTokensFromSnapshot(bridge.designSystem.snapshot),
|
|
163
|
+
responsiveWiring,
|
|
164
|
+
resolveCssValue: ({ field, def, raw, resolver }) => {
|
|
165
|
+
if (isMarkedResolvedLayout(layoutRef.value) && typeof raw === 'string') {
|
|
166
|
+
return raw.trim();
|
|
167
|
+
}
|
|
168
|
+
if (typeof raw === 'string' || typeof raw === 'number') {
|
|
169
|
+
return String(raw);
|
|
170
|
+
}
|
|
171
|
+
if (raw !== null && raw !== undefined) {
|
|
172
|
+
return '';
|
|
173
|
+
}
|
|
174
|
+
if (def === undefined || def === '') {
|
|
175
|
+
return '';
|
|
176
|
+
}
|
|
177
|
+
return resolver(field, def) ?? '';
|
|
178
|
+
},
|
|
179
|
+
resolveResponsiveCssValue: ({ op, field, def, raw, computeResolver, wiring }) => {
|
|
180
|
+
if (isMarkedResolvedLayout(layoutRef.value) && typeof raw === 'string') {
|
|
181
|
+
return raw.trim();
|
|
182
|
+
}
|
|
183
|
+
if (typeof raw === 'string') {
|
|
184
|
+
return raw;
|
|
185
|
+
}
|
|
186
|
+
if (raw !== null && raw !== undefined) {
|
|
187
|
+
return '';
|
|
188
|
+
}
|
|
189
|
+
if (!def) {
|
|
190
|
+
return '';
|
|
191
|
+
}
|
|
192
|
+
if (wiring.mode === 'lookup') {
|
|
193
|
+
return '';
|
|
194
|
+
}
|
|
195
|
+
const overrides = wiring.getOverrides(op, def);
|
|
196
|
+
return wiring.buildClassString({
|
|
197
|
+
op,
|
|
198
|
+
baseToken: def,
|
|
199
|
+
overrides,
|
|
200
|
+
breakpointOrder: wiring.breakpointOrder,
|
|
201
|
+
resolveTokenToClasses: (_op, token) => computeResolver(field, token),
|
|
202
|
+
});
|
|
203
|
+
},
|
|
204
|
+
cssStateEnabledOps: bridge.designSystem.nonCompositeOps,
|
|
205
|
+
mode: 'reactive',
|
|
206
|
+
createStyleApi: bridge.adapters.createBoundStyleApi,
|
|
207
|
+
createWrapperApi: bridge.adapters.createBoundWrapperApi,
|
|
208
|
+
createDeclareOptions: {
|
|
209
|
+
enumPassthroughUnknownString: true,
|
|
210
|
+
parseBooleanStrings: true,
|
|
211
|
+
},
|
|
212
|
+
acceptPlainResolvedObject: true,
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
function createRuntimeSurface(layoutRef, bridge) {
|
|
216
|
+
return createConfiguredRuntimeAuthorKitSurface({
|
|
217
|
+
layoutRef,
|
|
218
|
+
tokenFamilies: bridge.runtimeTokens.tokenFamilies,
|
|
219
|
+
tokens: createAkTokensFromRegistry({
|
|
220
|
+
registryFamilies: bridge.runtimeTokens.registryFamilies,
|
|
221
|
+
registryTokens: bridge.runtimeTokens.registryTokens,
|
|
222
|
+
coreFamilies: bridge.runtimeTokens.coreFamilies,
|
|
223
|
+
opToFamily: bridge.runtimeTokens.opToFamily,
|
|
224
|
+
}),
|
|
225
|
+
cssStateEnabledOps: bridge.designSystem.nonCompositeOps,
|
|
226
|
+
mode: 'static',
|
|
227
|
+
createStyleApi: bridge.adapters.createRuntimeStyleApi,
|
|
228
|
+
createWrapperApi: bridge.adapters.createRuntimeWrapperApi,
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
export function createProjectAkImplementation(bridge, layoutInput) {
|
|
232
|
+
const layoutRef = resolveLayoutRef(layoutInput);
|
|
233
|
+
switch (bridge.mode) {
|
|
234
|
+
case 'builder':
|
|
235
|
+
return createBuilderSurface(layoutRef, bridge);
|
|
236
|
+
case 'dev':
|
|
237
|
+
return createDevSurface(layoutRef, bridge);
|
|
238
|
+
case 'prod':
|
|
239
|
+
return createRuntimeSurface(layoutRef, bridge);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
export function defineProjectAk(bridge) {
|
|
243
|
+
return createAkPublicEntry({
|
|
244
|
+
mode: bridge.mode,
|
|
245
|
+
useAkImpl: (layoutInput) => createProjectAkImplementation(bridge, layoutInput),
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
export function resolveProjectAkMode(env) {
|
|
249
|
+
const explicitMode = env?.VITE_DEVTOOL_MODE;
|
|
250
|
+
if (explicitMode === 'builder' || explicitMode === 'dev' || explicitMode === 'prod') {
|
|
251
|
+
return explicitMode;
|
|
252
|
+
}
|
|
253
|
+
if (env?.MODE === 'builder') {
|
|
254
|
+
return 'builder';
|
|
255
|
+
}
|
|
256
|
+
if (env?.MODE === 'development' || env?.DEV === true) {
|
|
257
|
+
return 'dev';
|
|
258
|
+
}
|
|
259
|
+
return 'prod';
|
|
260
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Ref } from 'vue';
|
|
2
|
+
import type { RuntimeAkMode, RuntimeAkValue } from './runtime-surface.shared.js';
|
|
3
|
+
export interface ProjectWrapperSurfaceAdapter<TName extends string = string, TResolved extends Record<string, unknown> = Record<string, unknown>> {
|
|
4
|
+
readonly names: readonly TName[];
|
|
5
|
+
resolve(args: {
|
|
6
|
+
readonly wrapperName: TName;
|
|
7
|
+
readonly raw: unknown;
|
|
8
|
+
readonly acceptPlainResolvedObject: boolean;
|
|
9
|
+
}): TResolved | null;
|
|
10
|
+
}
|
|
11
|
+
export interface ProjectStyleSurfaceAdapter<TName extends string = string> {
|
|
12
|
+
readonly names: readonly TName[];
|
|
13
|
+
resolve(args: {
|
|
14
|
+
readonly styleName: TName;
|
|
15
|
+
readonly raw: unknown;
|
|
16
|
+
readonly acceptPlainResolvedObject: boolean;
|
|
17
|
+
}): Record<string, unknown> | null;
|
|
18
|
+
}
|
|
19
|
+
export type ProjectWrapperSurfaceApi<TName extends string, TResolved extends Record<string, unknown>> = Record<TName, (key?: string) => Ref<TResolved>>;
|
|
20
|
+
export type ProjectStyleSurfaceSeed = Record<string, RuntimeAkValue<string>>;
|
|
21
|
+
export type ProjectStyleSurfaceApi<TName extends string> = Record<TName, (key?: string) => ProjectStyleSurfaceSeed>;
|
|
22
|
+
export declare function createProjectWrapperApi<TName extends string, TResolved extends Record<string, unknown>>(args: {
|
|
23
|
+
readonly mode: RuntimeAkMode;
|
|
24
|
+
readonly getRoot: () => Record<string, unknown>;
|
|
25
|
+
readonly acceptPlainResolvedObject: () => boolean;
|
|
26
|
+
readonly adapter: ProjectWrapperSurfaceAdapter<TName, TResolved>;
|
|
27
|
+
}): ProjectWrapperSurfaceApi<TName, TResolved>;
|
|
28
|
+
export declare function createProjectStyleApi<TName extends string>(args: {
|
|
29
|
+
readonly mode: RuntimeAkMode;
|
|
30
|
+
readonly getRoot: () => Record<string, unknown>;
|
|
31
|
+
readonly acceptPlainResolvedObject: () => boolean;
|
|
32
|
+
readonly adapter: ProjectStyleSurfaceAdapter<TName>;
|
|
33
|
+
}): ProjectStyleSurfaceApi<TName>;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { makeRuntimeAkRef, makeRuntimeAkValue } from './runtime-surface.shared.js';
|
|
2
|
+
function normalizeStyleClassValue(value) {
|
|
3
|
+
if (Array.isArray(value)) {
|
|
4
|
+
return value
|
|
5
|
+
.map((entry) => String(entry ?? '').trim())
|
|
6
|
+
.filter((entry) => entry.length > 0)
|
|
7
|
+
.join(' ');
|
|
8
|
+
}
|
|
9
|
+
if (typeof value === 'string') {
|
|
10
|
+
return value.trim();
|
|
11
|
+
}
|
|
12
|
+
return '';
|
|
13
|
+
}
|
|
14
|
+
export function createProjectWrapperApi(args) {
|
|
15
|
+
const factoryCache = new Map();
|
|
16
|
+
return new Proxy({}, {
|
|
17
|
+
get(_target, prop) {
|
|
18
|
+
if (typeof prop !== 'string') {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
let factory = factoryCache.get(prop);
|
|
22
|
+
if (!factory) {
|
|
23
|
+
const wrapperName = prop;
|
|
24
|
+
factory = (key) => {
|
|
25
|
+
const sliceKey = key ?? wrapperName;
|
|
26
|
+
return makeRuntimeAkRef(args.mode, () => {
|
|
27
|
+
const root = args.getRoot();
|
|
28
|
+
const raw = root[sliceKey];
|
|
29
|
+
return args.adapter.resolve({
|
|
30
|
+
wrapperName,
|
|
31
|
+
raw,
|
|
32
|
+
acceptPlainResolvedObject: args.acceptPlainResolvedObject(),
|
|
33
|
+
}) ?? {};
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
factoryCache.set(prop, factory);
|
|
37
|
+
}
|
|
38
|
+
return factory;
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
export function createProjectStyleApi(args) {
|
|
43
|
+
const factoryCache = new Map();
|
|
44
|
+
return new Proxy({}, {
|
|
45
|
+
get(_target, prop) {
|
|
46
|
+
if (typeof prop !== 'string') {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
let factory = factoryCache.get(prop);
|
|
50
|
+
if (!factory) {
|
|
51
|
+
const styleName = prop;
|
|
52
|
+
factory = (key) => {
|
|
53
|
+
const sliceKey = key ?? styleName;
|
|
54
|
+
const slotCache = new Map();
|
|
55
|
+
return new Proxy({}, {
|
|
56
|
+
get(_target, prop) {
|
|
57
|
+
if (typeof prop !== 'string') {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
let slot = slotCache.get(prop);
|
|
61
|
+
if (!slot) {
|
|
62
|
+
slot = makeRuntimeAkValue(args.mode, () => {
|
|
63
|
+
const root = args.getRoot();
|
|
64
|
+
const raw = root[sliceKey];
|
|
65
|
+
const resolved = args.adapter.resolve({
|
|
66
|
+
styleName,
|
|
67
|
+
raw,
|
|
68
|
+
acceptPlainResolvedObject: args.acceptPlainResolvedObject(),
|
|
69
|
+
});
|
|
70
|
+
return normalizeStyleClassValue(resolved?.[prop]);
|
|
71
|
+
});
|
|
72
|
+
slotCache.set(prop, slot);
|
|
73
|
+
}
|
|
74
|
+
return slot;
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
factoryCache.set(prop, factory);
|
|
79
|
+
}
|
|
80
|
+
return factory;
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Ref } from 'vue';
|
|
2
|
+
export type AuthorKitMode = 'builder' | 'dev' | 'prod';
|
|
3
|
+
export type PublicAkUseAk<TReturn> = {
|
|
4
|
+
(): TReturn;
|
|
5
|
+
(_layout: never): never;
|
|
6
|
+
};
|
|
7
|
+
export type PublicAkUseAkForLayout<TReturn> = (layoutRef: Ref<unknown>) => TReturn;
|
|
8
|
+
export type PublicAkEntry<TReturn> = {
|
|
9
|
+
readonly AK_MODE: AuthorKitMode;
|
|
10
|
+
readonly useAk: PublicAkUseAk<TReturn>;
|
|
11
|
+
readonly useAkForLayout: PublicAkUseAkForLayout<TReturn>;
|
|
12
|
+
};
|
|
13
|
+
export declare function createAkPublicEntry<TReturn>(args: {
|
|
14
|
+
readonly mode: AuthorKitMode;
|
|
15
|
+
readonly useAkImpl: (layoutInput?: unknown) => TReturn;
|
|
16
|
+
}): PublicAkEntry<TReturn>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export function createAkPublicEntry(args) {
|
|
2
|
+
const useAk = ((arg) => {
|
|
3
|
+
if (arg !== undefined) {
|
|
4
|
+
throw new Error(`useAk() does not accept arguments.\n` +
|
|
5
|
+
`You likely passed a layout prop snapshot.\n` +
|
|
6
|
+
`Fix: call useAk() with no args (preferred), or use useAkForLayout(toRef(props, 'layout')).`);
|
|
7
|
+
}
|
|
8
|
+
return args.useAkImpl(undefined);
|
|
9
|
+
});
|
|
10
|
+
const useAkForLayout = (layoutRef) => {
|
|
11
|
+
return args.useAkImpl(layoutRef);
|
|
12
|
+
};
|
|
13
|
+
return {
|
|
14
|
+
AK_MODE: args.mode,
|
|
15
|
+
useAk,
|
|
16
|
+
useAkForLayout,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function isMarkedResolvedLayout(value: unknown): value is Record<string, unknown>;
|
|
2
|
+
export declare function markResolvedLayout<T extends Record<string, unknown>>(value: T): T;
|
|
3
|
+
export declare function cloneMarkedResolvedLayout<T extends Record<string, unknown>>(value: T): T;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const RESOLVED_LAYOUT_MARKER = Symbol.for('devtool-runtime:resolved-layout');
|
|
2
|
+
export function isMarkedResolvedLayout(value) {
|
|
3
|
+
return typeof value === 'object' && value !== null && value[RESOLVED_LAYOUT_MARKER] === true;
|
|
4
|
+
}
|
|
5
|
+
export function markResolvedLayout(value) {
|
|
6
|
+
if (isMarkedResolvedLayout(value)) {
|
|
7
|
+
return value;
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(value, RESOLVED_LAYOUT_MARKER, {
|
|
10
|
+
value: true,
|
|
11
|
+
enumerable: false,
|
|
12
|
+
configurable: false,
|
|
13
|
+
writable: false,
|
|
14
|
+
});
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
export function cloneMarkedResolvedLayout(value) {
|
|
18
|
+
return markResolvedLayout({ ...value });
|
|
19
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
import type { AkCssStateInput } from './ak.cssState.types.js';
|
|
3
|
+
export type RuntimeAkMode = 'static' | 'reactive';
|
|
4
|
+
export type RuntimeAkValue<T> = T | Ref<T>;
|
|
5
|
+
export type RuntimeAkClass = RuntimeAkValue<string>;
|
|
6
|
+
export type RuntimeLayoutGetter = (field: string) => unknown;
|
|
7
|
+
export type RuntimeCssOpFn = <Field extends string>(field: Field, def?: string, meta?: unknown) => RuntimeAkClass;
|
|
8
|
+
export type RuntimeCssApi = Record<string, RuntimeCssOpFn>;
|
|
9
|
+
export interface RuntimeDeclareFor {
|
|
10
|
+
for<F extends string>(kind: F, field: string, defaultKey: string, resolver: (value: string) => string, meta?: unknown): RuntimeAkValue<string>;
|
|
11
|
+
}
|
|
12
|
+
export type RuntimeDeclareFamilies = Record<string, (field: string, defaultKey: string, resolver: (value: string) => string, meta?: unknown) => RuntimeAkValue<string>>;
|
|
13
|
+
export interface RuntimeDeclareEnumBoolean {
|
|
14
|
+
enum<const Values extends readonly string[]>(field: string, values: Values, defaultValue: Values[number], resolver: (value: Values[number]) => string, meta?: unknown): RuntimeAkValue<string>;
|
|
15
|
+
boolean(field: string, defaultValue: boolean, resolver: (value: boolean) => string, meta?: unknown): RuntimeAkValue<string>;
|
|
16
|
+
}
|
|
17
|
+
export type RuntimeDeclareApi = RuntimeDeclareFor & RuntimeDeclareFamilies & RuntimeDeclareEnumBoolean;
|
|
18
|
+
export interface RuntimeValueApi {
|
|
19
|
+
boolean(field: string, defaultValue: boolean, meta?: unknown): Ref<boolean>;
|
|
20
|
+
string(field: string, defaultValue: string, meta?: unknown): Ref<string>;
|
|
21
|
+
number(field: string, defaultValue: number, meta?: unknown): Ref<number>;
|
|
22
|
+
enum<const Values extends readonly string[]>(field: string, values: Values, defaultValue: Values[number], meta?: unknown): Ref<Values[number]>;
|
|
23
|
+
}
|
|
24
|
+
export declare function makeRuntimeLayoutGetter(layoutRef: Ref<unknown>): RuntimeLayoutGetter;
|
|
25
|
+
export declare function makeRuntimeAkValue<T>(mode: RuntimeAkMode, getter: () => T): RuntimeAkValue<T>;
|
|
26
|
+
export declare function makeRuntimeAkRef<T>(mode: RuntimeAkMode, getter: () => T): Ref<T>;
|
|
27
|
+
export declare function cx(...parts: Array<RuntimeAkClass | false | null | undefined>): string;
|
|
28
|
+
export declare function createCssApiRuntime(getValue: RuntimeLayoutGetter, mode: RuntimeAkMode): RuntimeCssApi;
|
|
29
|
+
export declare function createCssStateApiRuntime(css: RuntimeCssApi, mode: RuntimeAkMode, enabledOps?: readonly string[]): (state: AkCssStateInput) => RuntimeCssApi;
|
|
30
|
+
export declare function makeDeclare(getValue: RuntimeLayoutGetter, tokenFamilies: readonly string[], mode: RuntimeAkMode): RuntimeDeclareApi;
|
|
31
|
+
export declare function makeValue(getValue: RuntimeLayoutGetter, mode: RuntimeAkMode): RuntimeValueApi;
|