@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.
Files changed (161) hide show
  1. package/LICENSE.md +11 -0
  2. package/README.md +7 -0
  3. package/dist/ak/ak.cssState.transform.d.ts +2 -0
  4. package/dist/ak/ak.cssState.transform.js +60 -0
  5. package/dist/ak/ak.cssState.types.d.ts +2 -0
  6. package/dist/ak/ak.cssState.types.js +1 -0
  7. package/dist/ak/ak.responsive.types.d.ts +18 -0
  8. package/dist/ak/ak.responsive.types.js +1 -0
  9. package/dist/ak/ak.tokens.d.ts +10 -0
  10. package/dist/ak/ak.tokens.js +10 -0
  11. package/dist/ak/ak.tokens.registry.d.ts +10 -0
  12. package/dist/ak/ak.tokens.registry.js +45 -0
  13. package/dist/ak/authoring-surface.shared.d.ts +31 -0
  14. package/dist/ak/authoring-surface.shared.js +185 -0
  15. package/dist/ak/configured-core.shared.d.ts +7 -0
  16. package/dist/ak/configured-core.shared.js +16 -0
  17. package/dist/ak/configured-surfaces.shared.d.ts +67 -0
  18. package/dist/ak/configured-surfaces.shared.js +144 -0
  19. package/dist/ak/index.d.ts +16 -0
  20. package/dist/ak/index.js +16 -0
  21. package/dist/ak/project-entry.d.ts +57 -0
  22. package/dist/ak/project-entry.js +260 -0
  23. package/dist/ak/project-surface-adapters.shared.d.ts +33 -0
  24. package/dist/ak/project-surface-adapters.shared.js +83 -0
  25. package/dist/ak/public-entry.shared.d.ts +16 -0
  26. package/dist/ak/public-entry.shared.js +18 -0
  27. package/dist/ak/resolved-layout-marker.shared.d.ts +3 -0
  28. package/dist/ak/resolved-layout-marker.shared.js +19 -0
  29. package/dist/ak/runtime-surface.shared.d.ts +31 -0
  30. package/dist/ak/runtime-surface.shared.js +221 -0
  31. package/dist/ak/style-execution.d.ts +13 -0
  32. package/dist/ak/style-execution.js +91 -0
  33. package/dist/ak/style-schema.d.ts +16 -0
  34. package/dist/ak/style-schema.js +6 -0
  35. package/dist/ak/useAk.shared.d.ts +3 -0
  36. package/dist/ak/useAk.shared.js +36 -0
  37. package/dist/authoring/authoringEffectKinds.d.ts +2 -0
  38. package/dist/authoring/authoringEffectKinds.js +48 -0
  39. package/dist/authoring/index.d.ts +1 -0
  40. package/dist/authoring/index.js +1 -0
  41. package/dist/cms/CMSPresenterSchemaTypes.d.ts +108 -0
  42. package/dist/cms/CMSPresenterSchemaTypes.js +6 -0
  43. package/dist/cms/CMSSchema.d.ts +27 -0
  44. package/dist/cms/CMSSchema.js +89 -0
  45. package/dist/cms/CMSSchemaTypes.d.ts +141 -0
  46. package/dist/cms/CMSSchemaTypes.js +1 -0
  47. package/dist/cms/index.d.ts +3 -0
  48. package/dist/cms/index.js +1 -0
  49. package/dist/design-system/DesignSystemSnapshotFactory.d.ts +34 -0
  50. package/dist/design-system/DesignSystemSnapshotFactory.js +38 -0
  51. package/dist/design-system/ProjectDesignSystemFactory.d.ts +39 -0
  52. package/dist/design-system/ProjectDesignSystemFactory.js +32 -0
  53. package/dist/design-system/index.d.ts +8 -0
  54. package/dist/design-system/index.js +7 -0
  55. package/dist/design-system/ops/ops.types.d.ts +22 -0
  56. package/dist/design-system/ops/ops.types.js +1 -0
  57. package/dist/design-system/resolvers/ds.resolvers.d.ts +3 -0
  58. package/dist/design-system/resolvers/ds.resolvers.js +24 -0
  59. package/dist/design-system/resolvers/ds.responsive.d.ts +12 -0
  60. package/dist/design-system/resolvers/ds.responsive.js +28 -0
  61. package/dist/design-system/tokens/TokenSchemas.types.d.ts +48 -0
  62. package/dist/design-system/tokens/TokenSchemas.types.js +3 -0
  63. package/dist/design-system/tokens/coreTokenFamilies.types.d.ts +2 -0
  64. package/dist/design-system/tokens/coreTokenFamilies.types.js +1 -0
  65. package/dist/index.d.ts +1 -0
  66. package/dist/index.js +1 -0
  67. package/dist/layout/index.d.ts +1 -0
  68. package/dist/layout/index.js +1 -0
  69. package/dist/layout/layoutRuntime.d.ts +12 -0
  70. package/dist/layout/layoutRuntime.js +88 -0
  71. package/dist/schema/LayoutBindingEditorPolicyMetadata.d.ts +7 -0
  72. package/dist/schema/LayoutBindingEditorPolicyMetadata.js +19 -0
  73. package/dist/schema/LayoutBindingEditorSectionMetadata.d.ts +7 -0
  74. package/dist/schema/LayoutBindingEditorSectionMetadata.js +19 -0
  75. package/dist/schema/LayoutDefinitionMeta.d.ts +54 -0
  76. package/dist/schema/LayoutDefinitionMeta.js +1 -0
  77. package/dist/schema/LayoutFieldIntentMetadata.d.ts +22 -0
  78. package/dist/schema/LayoutFieldIntentMetadata.js +38 -0
  79. package/dist/schema/LayoutFieldUiMetadata.d.ts +30 -0
  80. package/dist/schema/LayoutFieldUiMetadata.js +19 -0
  81. package/dist/schema/LayoutSchema.d.ts +39 -0
  82. package/dist/schema/LayoutSchema.js +53 -0
  83. package/dist/schema/LayoutVariantBindings.d.ts +55 -0
  84. package/dist/schema/LayoutVariantBindings.js +107 -0
  85. package/dist/schema/SlotSchema.d.ts +10 -0
  86. package/dist/schema/SlotSchema.js +3 -0
  87. package/dist/schema/StyleSchema.d.ts +16 -0
  88. package/dist/schema/StyleSchema.js +6 -0
  89. package/dist/schema/index.d.ts +9 -0
  90. package/dist/schema/index.js +9 -0
  91. package/dist/theme-contract/CompositeFieldOpByFamily.d.ts +126 -0
  92. package/dist/theme-contract/CompositeFieldOpByFamily.js +126 -0
  93. package/dist/theme-contract/index.d.ts +7 -0
  94. package/dist/theme-contract/index.js +7 -0
  95. package/dist/theme-contract/ops/coreOps.d.ts +697 -0
  96. package/dist/theme-contract/ops/coreOps.js +748 -0
  97. package/dist/theme-contract/ops/delegateValidation.types.d.ts +46 -0
  98. package/dist/theme-contract/ops/delegateValidation.types.js +4 -0
  99. package/dist/theme-contract/ops/emitters.d.ts +24 -0
  100. package/dist/theme-contract/ops/emitters.js +151 -0
  101. package/dist/theme-contract/ops/op.config.d.ts +711 -0
  102. package/dist/theme-contract/ops/op.config.js +15 -0
  103. package/dist/theme-contract/tokens/coreTokenFamilies.d.ts +9 -0
  104. package/dist/theme-contract/tokens/coreTokenFamilies.js +6 -0
  105. package/dist/theme-contract/tokens/cssLengthConversion.d.ts +2 -0
  106. package/dist/theme-contract/tokens/cssLengthConversion.js +39 -0
  107. package/dist/theme-contract/tokens/defineProjectTokenFamilySchema.d.ts +1 -0
  108. package/dist/theme-contract/tokens/defineProjectTokenFamilySchema.js +1 -0
  109. package/dist/theme-contract/tokens/defineTokenFamilySchema.d.ts +3 -0
  110. package/dist/theme-contract/tokens/defineTokenFamilySchema.js +5 -0
  111. package/dist/theme-contract/tokens/runtimeTokenFamilies.types.d.ts +5 -0
  112. package/dist/theme-contract/tokens/runtimeTokenFamilies.types.js +1 -0
  113. package/dist/theme-contract/tokens/schemas/aspect.token.schema.d.ts +20 -0
  114. package/dist/theme-contract/tokens/schemas/aspect.token.schema.js +19 -0
  115. package/dist/theme-contract/tokens/schemas/blur.token.schema.d.ts +21 -0
  116. package/dist/theme-contract/tokens/schemas/blur.token.schema.js +19 -0
  117. package/dist/theme-contract/tokens/schemas/border.token.schema.d.ts +54 -0
  118. package/dist/theme-contract/tokens/schemas/border.token.schema.js +43 -0
  119. package/dist/theme-contract/tokens/schemas/breakpoint.token.schema.d.ts +19 -0
  120. package/dist/theme-contract/tokens/schemas/breakpoint.token.schema.js +18 -0
  121. package/dist/theme-contract/tokens/schemas/color.token.schema.d.ts +24 -0
  122. package/dist/theme-contract/tokens/schemas/color.token.schema.js +23 -0
  123. package/dist/theme-contract/tokens/schemas/container.token.schema.d.ts +26 -0
  124. package/dist/theme-contract/tokens/schemas/container.token.schema.js +30 -0
  125. package/dist/theme-contract/tokens/schemas/font.token.schema.d.ts +17 -0
  126. package/dist/theme-contract/tokens/schemas/font.token.schema.js +15 -0
  127. package/dist/theme-contract/tokens/schemas/fontWeight.token.schema.d.ts +24 -0
  128. package/dist/theme-contract/tokens/schemas/fontWeight.token.schema.js +22 -0
  129. package/dist/theme-contract/tokens/schemas/leading.token.schema.d.ts +20 -0
  130. package/dist/theme-contract/tokens/schemas/leading.token.schema.js +18 -0
  131. package/dist/theme-contract/tokens/schemas/radius.token.schema.d.ts +23 -0
  132. package/dist/theme-contract/tokens/schemas/radius.token.schema.js +22 -0
  133. package/dist/theme-contract/tokens/schemas/shadow.token.schema.d.ts +108 -0
  134. package/dist/theme-contract/tokens/schemas/shadow.token.schema.js +73 -0
  135. package/dist/theme-contract/tokens/schemas/size.token.schema.d.ts +20 -0
  136. package/dist/theme-contract/tokens/schemas/size.token.schema.js +19 -0
  137. package/dist/theme-contract/tokens/schemas/spacing.token.schema.d.ts +21 -0
  138. package/dist/theme-contract/tokens/schemas/spacing.token.schema.js +20 -0
  139. package/dist/theme-contract/tokens/schemas/text.token.schema.d.ts +87 -0
  140. package/dist/theme-contract/tokens/schemas/text.token.schema.js +30 -0
  141. package/dist/theme-contract/tokens/schemas/textSize.token.schema.d.ts +28 -0
  142. package/dist/theme-contract/tokens/schemas/textSize.token.schema.js +27 -0
  143. package/dist/theme-contract/tokens/schemas/title.token.schema.d.ts +85 -0
  144. package/dist/theme-contract/tokens/schemas/title.token.schema.js +30 -0
  145. package/dist/theme-contract/tokens/schemas/tracking.token.schema.d.ts +20 -0
  146. package/dist/theme-contract/tokens/schemas/tracking.token.schema.js +18 -0
  147. package/dist/theme-contract/tokens/schemas/zIndex.token.schema.d.ts +18 -0
  148. package/dist/theme-contract/tokens/schemas/zIndex.token.schema.js +17 -0
  149. package/dist/theme-contract/tokens/tokens.schema.d.ts +531 -0
  150. package/dist/theme-contract/tokens/tokens.schema.js +32 -0
  151. package/dist/types/LayoutResolvedTs.types.d.ts +18 -0
  152. package/dist/types/LayoutResolvedTs.types.js +1 -0
  153. package/dist/types/authoredTree.types.d.ts +112 -0
  154. package/dist/types/authoredTree.types.js +1 -0
  155. package/dist/types/blockRegistry.types.d.ts +37 -0
  156. package/dist/types/blockRegistry.types.js +1 -0
  157. package/dist/types/index.d.ts +4 -0
  158. package/dist/types/index.js +1 -0
  159. package/dist/types/layout.types.d.ts +30 -0
  160. package/dist/types/layout.types.js +1 -0
  161. package/package.json +65 -0
package/LICENSE.md ADDED
@@ -0,0 +1,11 @@
1
+ Proprietary Alpha License
2
+
3
+ Copyright (c) 2026 Rob Lawn. All rights reserved.
4
+
5
+ Permission is granted to install and use this package as a runtime dependency of generated visual site authoring projects.
6
+
7
+ This package is proprietary. No ownership or copyright interest is transferred. You may not redistribute, resell, sublicense, or repackage this package as a competing runtime, framework, scaffold, starter, or component product without prior written permission.
8
+
9
+ This software is provided "as is", without warranty of any kind, express or implied, including but not limited to warranties of merchantability, fitness for a particular purpose, non-infringement, availability, security, or correctness. Use is at your own risk.
10
+
11
+ In no event shall the copyright holder or contributors be liable for any claim, damages, data loss, business interruption, or other liability arising from use of this software.
package/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # @roblawn/devtool-runtime
2
+
3
+ Alpha runtime primitives for generated visual site authoring projects.
4
+
5
+ This package is intended to be installed by a compatible starter creator and consumed by generated sites.
6
+
7
+ This package is proprietary alpha software, supplied as-is. See `LICENSE.md`.
@@ -0,0 +1,2 @@
1
+ import type { AkCssStateInput } from './ak.cssState.types.js';
2
+ export declare function applyCssStateToClassString(classString: string, state: AkCssStateInput): string;
@@ -0,0 +1,60 @@
1
+ function normalizeCssStateInput(state) {
2
+ const list = Array.isArray(state) ? state : [state];
3
+ return list.map((entry) => String(entry).trim()).filter((entry) => entry.length > 0);
4
+ }
5
+ function splitVariants(token) {
6
+ let bracketDepth = 0;
7
+ let parenDepth = 0;
8
+ let braceDepth = 0;
9
+ let current = '';
10
+ const segments = [];
11
+ for (const ch of token) {
12
+ if (ch === '[')
13
+ bracketDepth += 1;
14
+ else if (ch === ']')
15
+ bracketDepth = Math.max(0, bracketDepth - 1);
16
+ else if (ch === '(')
17
+ parenDepth += 1;
18
+ else if (ch === ')')
19
+ parenDepth = Math.max(0, parenDepth - 1);
20
+ else if (ch === '{')
21
+ braceDepth += 1;
22
+ else if (ch === '}')
23
+ braceDepth = Math.max(0, braceDepth - 1);
24
+ if (ch === ':' && bracketDepth === 0 && parenDepth === 0 && braceDepth === 0) {
25
+ segments.push(current);
26
+ current = '';
27
+ continue;
28
+ }
29
+ current += ch;
30
+ }
31
+ segments.push(current);
32
+ if (segments.length === 0) {
33
+ return { variants: [], utility: '' };
34
+ }
35
+ if (segments.length === 1) {
36
+ return { variants: [], utility: segments[0] };
37
+ }
38
+ const utility = segments.pop() ?? '';
39
+ return {
40
+ variants: segments.filter((segment) => segment.length > 0),
41
+ utility,
42
+ };
43
+ }
44
+ export function applyCssStateToClassString(classString, state) {
45
+ const states = normalizeCssStateInput(state);
46
+ const trimmed = classString.trim();
47
+ if (trimmed.length === 0 || states.length === 0) {
48
+ return trimmed;
49
+ }
50
+ const tokens = trimmed.split(/\s+/).filter((token) => token.length > 0);
51
+ return tokens
52
+ .map((token) => {
53
+ const { variants, utility } = splitVariants(token);
54
+ if (utility.length === 0)
55
+ return '';
56
+ return [...variants, ...states, utility].join(':');
57
+ })
58
+ .filter((token) => token.length > 0)
59
+ .join(' ');
60
+ }
@@ -0,0 +1,2 @@
1
+ export type AkCssStatePrefix = 'hover' | 'focus' | 'focus-visible' | 'active' | 'disabled' | 'checked' | 'invalid' | 'required' | 'first' | 'last' | 'odd' | 'even' | 'open' | 'dark' | 'motion-reduce' | 'print' | 'group-hover' | 'group-focus' | 'peer-focus' | 'peer-checked' | `data-[${string}]` | `aria-[${string}]`;
2
+ export type AkCssStateInput = AkCssStatePrefix | readonly AkCssStatePrefix[];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,18 @@
1
+ export type ResponsiveMode = 'compute' | 'lookup' | 'hybrid';
2
+ export type ResponsiveOverridesForToken<TokenKey extends string = string> = Readonly<Record<string, TokenKey | undefined>>;
3
+ export type AuthorKitResponsiveWiring<TOp extends string = string, TToken extends string = string> = {
4
+ readonly mode: 'lookup';
5
+ readonly enabledOps: readonly TOp[];
6
+ } | {
7
+ readonly mode: 'compute' | 'hybrid';
8
+ readonly enabledOps: readonly TOp[];
9
+ readonly breakpointOrder: readonly string[];
10
+ getOverrides(op: TOp, baseToken: TToken): ResponsiveOverridesForToken<TToken>;
11
+ buildClassString(args: {
12
+ readonly op: TOp;
13
+ readonly baseToken: TToken;
14
+ readonly overrides: ResponsiveOverridesForToken<TToken>;
15
+ readonly breakpointOrder: readonly string[];
16
+ readonly resolveTokenToClasses: (op: string, token: string) => string;
17
+ }): string;
18
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ export interface SnapshotTokenSource {
2
+ getTokensForFamily(family: string): readonly string[];
3
+ getTokensForOp(op: string): readonly string[];
4
+ }
5
+ interface SnapshotTokensLike {
6
+ family(familyName: string): readonly string[];
7
+ op(opKey: string): readonly string[];
8
+ }
9
+ export declare function createAkTokensFromSnapshot(snapshot: SnapshotTokenSource): SnapshotTokensLike;
10
+ export {};
@@ -0,0 +1,10 @@
1
+ export function createAkTokensFromSnapshot(snapshot) {
2
+ return {
3
+ family(family) {
4
+ return snapshot.getTokensForFamily(String(family));
5
+ },
6
+ op(op) {
7
+ return snapshot.getTokensForOp(String(op));
8
+ },
9
+ };
10
+ }
@@ -0,0 +1,10 @@
1
+ export interface AuthorKitTokensLike {
2
+ family(familyName: string): readonly string[];
3
+ op(opKey: string): readonly string[];
4
+ }
5
+ export declare function createAkTokensFromRegistry(args: {
6
+ registryFamilies: Record<string, unknown>;
7
+ registryTokens: Record<string, Record<string, unknown>>;
8
+ coreFamilies: Record<string, readonly string[]>;
9
+ opToFamily: Readonly<Record<string, string>>;
10
+ }): AuthorKitTokensLike;
@@ -0,0 +1,45 @@
1
+ export function createAkTokensFromRegistry(args) {
2
+ const familyCache = new Map();
3
+ const opCache = new Map();
4
+ const family = (familyName) => {
5
+ const cached = familyCache.get(familyName);
6
+ if (cached) {
7
+ return cached;
8
+ }
9
+ const core = args.coreFamilies[familyName];
10
+ if (Array.isArray(core)) {
11
+ familyCache.set(familyName, core);
12
+ return core;
13
+ }
14
+ const reg = args.registryTokens[familyName];
15
+ if (reg && typeof reg === 'object') {
16
+ const keys = Object.keys(reg);
17
+ familyCache.set(familyName, keys);
18
+ return keys;
19
+ }
20
+ familyCache.set(familyName, []);
21
+ return [];
22
+ };
23
+ const op = (opKey) => {
24
+ const cached = opCache.get(opKey);
25
+ if (cached) {
26
+ return cached;
27
+ }
28
+ const familyName = args.opToFamily[opKey];
29
+ if (!familyName) {
30
+ opCache.set(opKey, []);
31
+ return [];
32
+ }
33
+ const keys = family(familyName);
34
+ opCache.set(opKey, keys);
35
+ return keys;
36
+ };
37
+ return {
38
+ family(familyName) {
39
+ return family(String(familyName));
40
+ },
41
+ op(opKey) {
42
+ return op(String(opKey));
43
+ },
44
+ };
45
+ }
@@ -0,0 +1,31 @@
1
+ import type { AkCssStateInput } from './ak.cssState.types.js';
2
+ import type { AuthorKitResponsiveWiring } from './ak.responsive.types.js';
3
+ import type { RuntimeAkClass, RuntimeAkMode, RuntimeDeclareApi, RuntimeLayoutGetter } from './runtime-surface.shared.js';
4
+ export type BoundCssResolver = (field: string, value?: string | number) => string;
5
+ export type BoundCssFactory = <Field extends string>(field: Field, def?: string | number, meta?: unknown) => RuntimeAkClass;
6
+ export type BoundCssApi = Record<string, BoundCssFactory>;
7
+ export type BoundCssStateApi = (state: AkCssStateInput) => BoundCssApi;
8
+ export type ResolveBoundCssValue<TOp extends string = string, TValue extends string | number = string> = (args: {
9
+ readonly op: TOp;
10
+ readonly field: string;
11
+ readonly def?: TValue;
12
+ readonly raw: unknown;
13
+ readonly resolver: BoundCssResolver;
14
+ }) => string;
15
+ export interface DeclareBoundOptions {
16
+ enumPassthroughUnknownString?: boolean | (() => boolean);
17
+ parseBooleanStrings?: boolean;
18
+ }
19
+ export declare function makeDeclareBound(getValue: RuntimeLayoutGetter, tokenFamilies: readonly string[], mode: RuntimeAkMode, options?: DeclareBoundOptions): RuntimeDeclareApi;
20
+ export declare function createCssApiBound<TOp extends string = string, TValue extends string | number = string>(core: Record<TOp, BoundCssResolver>, getValue: RuntimeLayoutGetter, mode: RuntimeAkMode, resolveValue: ResolveBoundCssValue<TOp, TValue>): Record<TOp, BoundCssFactory>;
21
+ export declare function createCssStateApiBound<TOp extends string = string>(css: Record<TOp, BoundCssFactory>, mode: RuntimeAkMode, enabledOps?: readonly TOp[]): (state: AkCssStateInput) => Record<TOp, BoundCssFactory>;
22
+ export type ResolveResponsiveCssValue<TOp extends string = string, TToken extends string = string> = (args: {
23
+ readonly op: TOp;
24
+ readonly field: string;
25
+ readonly def?: TToken;
26
+ readonly raw: unknown;
27
+ readonly computeResolver: BoundCssResolver;
28
+ readonly wiring: AuthorKitResponsiveWiring<TOp, TToken>;
29
+ }) => string;
30
+ export declare function createResponsiveCssApiBound<TOp extends string = string, TToken extends string = string>(computeCore: Record<TOp, BoundCssResolver>, getValue: RuntimeLayoutGetter, wiring: AuthorKitResponsiveWiring<TOp, TToken>, mode: RuntimeAkMode, resolveValue: ResolveResponsiveCssValue<TOp, TToken>): Partial<Record<TOp, BoundCssFactory>>;
31
+ export declare function mergeCssApiWithResponsive<TOp extends string = string>(cssBase: Record<TOp, BoundCssFactory>, responsiveCss: Partial<Record<TOp, BoundCssFactory>>, enabledOps: readonly string[]): Record<TOp, BoundCssFactory>;
@@ -0,0 +1,185 @@
1
+ import { unref } from 'vue';
2
+ import { applyCssStateToClassString } from './ak.cssState.transform.js';
3
+ import { makeRuntimeAkValue } from './runtime-surface.shared.js';
4
+ function pickEnumValue(raw, values, fallback) {
5
+ if (typeof raw === 'string' && values.includes(raw)) {
6
+ return raw;
7
+ }
8
+ return fallback;
9
+ }
10
+ function pickBoolean(raw, fallback) {
11
+ if (typeof raw === 'boolean')
12
+ return raw;
13
+ if (typeof raw === 'string') {
14
+ if (raw === 'true')
15
+ return true;
16
+ if (raw === 'false')
17
+ return false;
18
+ }
19
+ return fallback;
20
+ }
21
+ function readDynamicBoolean(value, fallback) {
22
+ if (typeof value === 'function') {
23
+ return value();
24
+ }
25
+ return value ?? fallback;
26
+ }
27
+ export function makeDeclareBound(getValue, tokenFamilies, mode, options) {
28
+ const parseBooleanStrings = options?.parseBooleanStrings ?? true;
29
+ const baseFor = (kind, field, defaultKey, resolver) => {
30
+ void kind;
31
+ return makeRuntimeAkValue(mode, () => {
32
+ const raw = getValue(field);
33
+ const rawString = typeof raw === 'string' ? raw : undefined;
34
+ const value = rawString ?? defaultKey;
35
+ return resolver(value);
36
+ });
37
+ };
38
+ const apiBase = {
39
+ for: baseFor,
40
+ enum(field, values, defaultValue, resolver) {
41
+ return makeRuntimeAkValue(mode, () => {
42
+ const raw = getValue(field);
43
+ const enumPassthroughUnknownString = readDynamicBoolean(options?.enumPassthroughUnknownString, false);
44
+ if (enumPassthroughUnknownString && typeof raw === 'string' && !values.includes(raw)) {
45
+ return raw;
46
+ }
47
+ const value = pickEnumValue(raw, values, defaultValue);
48
+ return resolver(value);
49
+ });
50
+ },
51
+ boolean(field, defaultValue, resolver) {
52
+ return makeRuntimeAkValue(mode, () => {
53
+ const raw = getValue(field);
54
+ const enumPassthroughUnknownString = readDynamicBoolean(options?.enumPassthroughUnknownString, false);
55
+ if (enumPassthroughUnknownString && typeof raw === 'string' && raw !== 'true' && raw !== 'false') {
56
+ return raw;
57
+ }
58
+ const value = parseBooleanStrings ? pickBoolean(raw, defaultValue) : typeof raw === 'boolean' ? raw : defaultValue;
59
+ return resolver(value);
60
+ });
61
+ },
62
+ };
63
+ const api = apiBase;
64
+ const record = api;
65
+ for (const kind of tokenFamilies) {
66
+ record[kind] = (field, defaultKey, resolver) => baseFor(kind, field, defaultKey, resolver);
67
+ }
68
+ return api;
69
+ }
70
+ export function createCssApiBound(core, getValue, mode, resolveValue) {
71
+ const api = {};
72
+ const opKeys = Object.keys(core);
73
+ for (const opKey of opKeys) {
74
+ const resolver = core[opKey];
75
+ api[opKey] = ((field, def) => {
76
+ return makeRuntimeAkValue(mode, () => {
77
+ const raw = getValue(field);
78
+ return resolveValue({
79
+ op: opKey,
80
+ field,
81
+ def: def,
82
+ raw,
83
+ resolver,
84
+ });
85
+ });
86
+ });
87
+ }
88
+ return api;
89
+ }
90
+ function normalizeCssStateInput(state) {
91
+ const list = Array.isArray(state) ? state : [state];
92
+ return list.map((entry) => String(entry).trim()).filter((entry) => entry.length > 0);
93
+ }
94
+ const didWarnUnsupportedCssStateOp = new Set();
95
+ function warnUnsupportedCssStateOpOnce(op) {
96
+ const isDev = Boolean(import.meta.env?.DEV);
97
+ if (!isDev)
98
+ return;
99
+ if (didWarnUnsupportedCssStateOp.has(op))
100
+ return;
101
+ didWarnUnsupportedCssStateOp.add(op);
102
+ console.warn('[ak.cssState] unsupported op in cssState chain; falling back to empty class', { op });
103
+ }
104
+ export function createCssStateApiBound(css, mode, enabledOps) {
105
+ const cache = new Map();
106
+ const opKeys = (enabledOps ?? Object.keys(css)).filter((op) => typeof css[op] === 'function');
107
+ return (state) => {
108
+ const states = normalizeCssStateInput(state);
109
+ const cacheKey = states.join('\u001f');
110
+ const existing = cache.get(cacheKey);
111
+ if (existing) {
112
+ return existing;
113
+ }
114
+ const api = {};
115
+ for (const opKey of opKeys) {
116
+ const resolver = css[opKey];
117
+ api[opKey] = ((field, def) => {
118
+ const baseValue = resolver(field, def);
119
+ return makeRuntimeAkValue(mode, () => applyCssStateToClassString(String(unref(baseValue) ?? ''), states));
120
+ });
121
+ }
122
+ const noOpFactoryCache = new Map();
123
+ const typed = new Proxy(api, {
124
+ get(target, prop) {
125
+ if (typeof prop !== 'string') {
126
+ return Reflect.get(target, prop);
127
+ }
128
+ const existingValue = target[prop];
129
+ if (typeof existingValue === 'function') {
130
+ return existingValue;
131
+ }
132
+ let fallback = noOpFactoryCache.get(prop);
133
+ if (!fallback) {
134
+ fallback = ((_field) => {
135
+ warnUnsupportedCssStateOpOnce(prop);
136
+ return makeRuntimeAkValue(mode, () => '');
137
+ });
138
+ noOpFactoryCache.set(prop, fallback);
139
+ }
140
+ return fallback;
141
+ },
142
+ });
143
+ cache.set(cacheKey, typed);
144
+ return typed;
145
+ };
146
+ }
147
+ export function createResponsiveCssApiBound(computeCore, getValue, wiring, mode, resolveValue) {
148
+ const api = {};
149
+ const enabled = wiring.enabledOps;
150
+ for (const opKey of enabled) {
151
+ const computeResolver = computeCore[opKey];
152
+ api[opKey] = ((field, def) => {
153
+ return makeRuntimeAkValue(mode, () => {
154
+ const raw = getValue(field);
155
+ return resolveValue({
156
+ op: opKey,
157
+ field,
158
+ def: def,
159
+ raw,
160
+ computeResolver,
161
+ wiring,
162
+ });
163
+ });
164
+ });
165
+ }
166
+ return api;
167
+ }
168
+ export function mergeCssApiWithResponsive(cssBase, responsiveCss, enabledOps) {
169
+ const enabled = new Set(enabledOps);
170
+ const responsiveRecord = responsiveCss;
171
+ return new Proxy(cssBase, {
172
+ get(target, prop, receiver) {
173
+ if (typeof prop !== 'string') {
174
+ return Reflect.get(target, prop, receiver);
175
+ }
176
+ if (enabled.has(prop)) {
177
+ const responsiveFactory = responsiveRecord[prop];
178
+ if (typeof responsiveFactory === 'function') {
179
+ return responsiveFactory;
180
+ }
181
+ }
182
+ return Reflect.get(target, prop, receiver);
183
+ },
184
+ });
185
+ }
@@ -0,0 +1,7 @@
1
+ import type { Ref } from 'vue';
2
+ import type { BoundCssResolver } from './authoring-surface.shared.js';
3
+ export declare function createConfiguredAkCore(args: {
4
+ readonly layoutRef: Ref<unknown>;
5
+ readonly ops: readonly string[];
6
+ readonly resolve: (op: string, value: string | number) => string;
7
+ }): Record<string, BoundCssResolver>;
@@ -0,0 +1,16 @@
1
+ export function createConfiguredAkCore(args) {
2
+ const core = {};
3
+ for (const op of args.ops) {
4
+ core[op] = (field, tokenKey) => {
5
+ const record = args.layoutRef.value;
6
+ const explicit = typeof tokenKey === 'string' || typeof tokenKey === 'number' ? tokenKey : undefined;
7
+ const raw = record?.[field];
8
+ const fromLayout = typeof raw === 'string' || typeof raw === 'number' ? raw : typeof raw === 'boolean' ? String(raw) : undefined;
9
+ const value = explicit ?? fromLayout;
10
+ if (value === undefined || value === '')
11
+ return '';
12
+ return args.resolve(op, value);
13
+ };
14
+ }
15
+ return core;
16
+ }
@@ -0,0 +1,67 @@
1
+ import type { Ref } from 'vue';
2
+ import type { AuthorKitResponsiveWiring } from './ak.responsive.types.js';
3
+ import type { AuthorKitTokensLike } from './ak.tokens.registry.js';
4
+ import { type BoundCssApi, type BoundCssResolver, type DeclareBoundOptions, type ResolveBoundCssValue, type ResolveResponsiveCssValue } from './authoring-surface.shared.js';
5
+ import { type RuntimeAkMode, type RuntimeLayoutGetter, type RuntimeCssApi } from './runtime-surface.shared.js';
6
+ export interface RuntimeSurfaceFactoryArgs {
7
+ readonly layoutRef: Ref<unknown>;
8
+ readonly mode: RuntimeAkMode;
9
+ readonly acceptPlainResolvedObject: boolean;
10
+ }
11
+ export type RuntimeSurfaceFactory<TSurface> = (args: RuntimeSurfaceFactoryArgs) => TSurface;
12
+ export interface RuntimeEditorApi {
13
+ binding(policy: unknown): void;
14
+ section(section: unknown): void;
15
+ }
16
+ export interface RuntimeAuthorKitShape {
17
+ readonly css: BoundCssApi | RuntimeCssApi;
18
+ readonly cssBase: BoundCssApi | RuntimeCssApi;
19
+ readonly cssState: ((state: unknown) => BoundCssApi | RuntimeCssApi) | ((state: unknown) => RuntimeCssApi);
20
+ cx(...parts: Array<unknown>): string;
21
+ readonly declare: unknown;
22
+ readonly value: unknown;
23
+ readonly wrapper: unknown;
24
+ readonly style: unknown;
25
+ readonly editor: RuntimeEditorApi;
26
+ readonly tokens: AuthorKitTokensLike;
27
+ write?: 'destructive' | 'additive';
28
+ }
29
+ export declare function createConfiguredAuthorKitSurface(args: {
30
+ readonly layoutRef: Ref<unknown>;
31
+ readonly tokenFamilies: readonly string[];
32
+ readonly tokens: AuthorKitTokensLike;
33
+ readonly getValue: RuntimeLayoutGetter;
34
+ readonly cssBase: BoundCssApi;
35
+ readonly cssStateSource: BoundCssApi;
36
+ readonly cssStateEnabledOps?: readonly string[];
37
+ readonly mode?: RuntimeAkMode;
38
+ readonly createStyleApi: RuntimeSurfaceFactory<unknown>;
39
+ readonly createWrapperApi: RuntimeSurfaceFactory<unknown>;
40
+ readonly createDeclareOptions?: DeclareBoundOptions;
41
+ }): RuntimeAuthorKitShape;
42
+ export declare function createConfiguredResponsiveAuthorKitSurface(args: {
43
+ readonly core: Record<string, BoundCssResolver>;
44
+ readonly computeCanonical?: Record<string, BoundCssResolver>;
45
+ readonly layoutRef: Ref<unknown>;
46
+ readonly getValue: RuntimeLayoutGetter;
47
+ readonly tokenFamilies: readonly string[];
48
+ readonly tokens: AuthorKitTokensLike;
49
+ readonly responsiveWiring: AuthorKitResponsiveWiring<string, string>;
50
+ readonly resolveCssValue: ResolveBoundCssValue<string, string>;
51
+ readonly resolveResponsiveCssValue: ResolveResponsiveCssValue<string, string>;
52
+ readonly cssStateEnabledOps?: readonly string[];
53
+ readonly mode?: RuntimeAkMode;
54
+ readonly createStyleApi: RuntimeSurfaceFactory<unknown>;
55
+ readonly createWrapperApi: RuntimeSurfaceFactory<unknown>;
56
+ readonly createDeclareOptions?: DeclareBoundOptions;
57
+ readonly acceptPlainResolvedObject?: boolean;
58
+ }): RuntimeAuthorKitShape;
59
+ export declare function createConfiguredRuntimeAuthorKitSurface(args: {
60
+ readonly layoutRef: Ref<unknown>;
61
+ readonly tokenFamilies: readonly string[];
62
+ readonly tokens: AuthorKitTokensLike;
63
+ readonly cssStateEnabledOps?: readonly string[];
64
+ readonly mode?: RuntimeAkMode;
65
+ readonly createStyleApi: RuntimeSurfaceFactory<unknown>;
66
+ readonly createWrapperApi: RuntimeSurfaceFactory<unknown>;
67
+ }): RuntimeAuthorKitShape;
@@ -0,0 +1,144 @@
1
+ import { createCssApiBound, createCssStateApiBound, createResponsiveCssApiBound, makeDeclareBound, mergeCssApiWithResponsive, } from './authoring-surface.shared.js';
2
+ import { createCssApiRuntime, createCssStateApiRuntime, cx, makeDeclare, makeRuntimeLayoutGetter, makeValue as makeRuntimeValue, } from './runtime-surface.shared.js';
3
+ function createEditorApi() {
4
+ return {
5
+ binding() {
6
+ },
7
+ section() {
8
+ },
9
+ };
10
+ }
11
+ function createAuthorKitShape(args) {
12
+ let cachedDeclare = null;
13
+ let cachedStyle = null;
14
+ let cachedWrapper = null;
15
+ let cachedValue = null;
16
+ return {
17
+ css: args.css,
18
+ cssBase: args.cssBase,
19
+ cssState: args.cssState,
20
+ cx,
21
+ get declare() {
22
+ if (!cachedDeclare) {
23
+ cachedDeclare = args.createDeclareApi({
24
+ getValue: args.getValue,
25
+ tokenFamilies: args.tokenFamilies,
26
+ mode: args.mode,
27
+ });
28
+ }
29
+ return cachedDeclare;
30
+ },
31
+ get value() {
32
+ if (!cachedValue) {
33
+ cachedValue = args.createValueApi({
34
+ getValue: args.getValue,
35
+ mode: args.mode,
36
+ });
37
+ }
38
+ return cachedValue;
39
+ },
40
+ get wrapper() {
41
+ if (!cachedWrapper) {
42
+ cachedWrapper = args.createWrapperApi({
43
+ layoutRef: args.layoutRef,
44
+ mode: args.mode,
45
+ acceptPlainResolvedObject: false,
46
+ });
47
+ }
48
+ return cachedWrapper;
49
+ },
50
+ get style() {
51
+ if (!cachedStyle) {
52
+ cachedStyle = args.createStyleApi({
53
+ layoutRef: args.layoutRef,
54
+ mode: args.mode,
55
+ acceptPlainResolvedObject: false,
56
+ });
57
+ }
58
+ return cachedStyle;
59
+ },
60
+ editor: createEditorApi(),
61
+ tokens: args.tokens,
62
+ write: 'destructive',
63
+ };
64
+ }
65
+ export function createConfiguredAuthorKitSurface(args) {
66
+ const mode = args.mode ?? 'reactive';
67
+ const cssState = createCssStateApiBound(args.cssStateSource, mode, args.cssStateEnabledOps);
68
+ return createAuthorKitShape({
69
+ layoutRef: args.layoutRef,
70
+ mode,
71
+ tokenFamilies: args.tokenFamilies,
72
+ tokens: args.tokens,
73
+ getValue: args.getValue,
74
+ css: args.cssBase,
75
+ cssBase: args.cssBase,
76
+ cssState: cssState,
77
+ createStyleApi: args.createStyleApi,
78
+ createWrapperApi: args.createWrapperApi,
79
+ createDeclareApi: ({ getValue, tokenFamilies, mode }) => makeDeclareBound(getValue, tokenFamilies, mode, args.createDeclareOptions),
80
+ createValueApi: ({ getValue, mode }) => makeRuntimeValue(getValue, mode),
81
+ });
82
+ }
83
+ export function createConfiguredResponsiveAuthorKitSurface(args) {
84
+ const mode = args.mode ?? 'reactive';
85
+ const canonicalCore = args.computeCanonical ?? args.core;
86
+ const cssBase = createCssApiBound(args.core, args.getValue, mode, args.resolveCssValue);
87
+ const cssResponsive = createResponsiveCssApiBound(args.core, args.getValue, args.responsiveWiring, mode, args.resolveResponsiveCssValue);
88
+ const css = mergeCssApiWithResponsive(cssBase, cssResponsive, args.responsiveWiring.enabledOps);
89
+ const cssStateBase = createCssApiBound(canonicalCore, args.getValue, mode, args.resolveCssValue);
90
+ const cssStateResponsive = createResponsiveCssApiBound(canonicalCore, args.getValue, args.responsiveWiring, mode, args.resolveResponsiveCssValue);
91
+ const cssStateSource = mergeCssApiWithResponsive(cssStateBase, cssStateResponsive, args.responsiveWiring.enabledOps);
92
+ const cssState = createCssStateApiBound(cssStateSource, mode, args.cssStateEnabledOps);
93
+ return createAuthorKitShape({
94
+ layoutRef: args.layoutRef,
95
+ mode,
96
+ tokenFamilies: args.tokenFamilies,
97
+ tokens: args.tokens,
98
+ getValue: args.getValue,
99
+ css,
100
+ cssBase,
101
+ cssState: cssState,
102
+ createStyleApi: ({ layoutRef, mode }) => args.createStyleApi({
103
+ layoutRef,
104
+ mode,
105
+ acceptPlainResolvedObject: args.acceptPlainResolvedObject ?? false,
106
+ }),
107
+ createWrapperApi: ({ layoutRef, mode }) => args.createWrapperApi({
108
+ layoutRef,
109
+ mode,
110
+ acceptPlainResolvedObject: args.acceptPlainResolvedObject ?? false,
111
+ }),
112
+ createDeclareApi: ({ getValue, tokenFamilies, mode }) => makeDeclareBound(getValue, tokenFamilies, mode, args.createDeclareOptions),
113
+ createValueApi: ({ getValue, mode }) => makeRuntimeValue(getValue, mode),
114
+ });
115
+ }
116
+ export function createConfiguredRuntimeAuthorKitSurface(args) {
117
+ const mode = args.mode ?? 'static';
118
+ const getValue = makeRuntimeLayoutGetter(args.layoutRef);
119
+ const css = createCssApiRuntime(getValue, mode);
120
+ const cssBase = createCssApiRuntime(getValue, mode);
121
+ const cssState = createCssStateApiRuntime(css, mode, args.cssStateEnabledOps);
122
+ return createAuthorKitShape({
123
+ layoutRef: args.layoutRef,
124
+ mode,
125
+ tokenFamilies: args.tokenFamilies,
126
+ tokens: args.tokens,
127
+ getValue,
128
+ css,
129
+ cssBase,
130
+ cssState: cssState,
131
+ createStyleApi: ({ layoutRef, mode }) => args.createStyleApi({
132
+ layoutRef,
133
+ mode,
134
+ acceptPlainResolvedObject: true,
135
+ }),
136
+ createWrapperApi: ({ layoutRef, mode }) => args.createWrapperApi({
137
+ layoutRef,
138
+ mode,
139
+ acceptPlainResolvedObject: false,
140
+ }),
141
+ createDeclareApi: ({ getValue, tokenFamilies, mode }) => makeDeclare(getValue, tokenFamilies, mode),
142
+ createValueApi: ({ getValue, mode }) => makeRuntimeValue(getValue, mode),
143
+ });
144
+ }
@@ -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';