@appinternalleads/ui 0.4.1 → 0.4.2
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/README.md +92 -0
- package/dist/cjs/motion/typesurface/TypeSurfaceCanvas.js +25 -2
- package/dist/cjs/motion/typesurface/TypeSurfaceCanvas.js.map +1 -1
- package/dist/cjs/motion/typesurface/config.js +21 -1
- package/dist/cjs/motion/typesurface/config.js.map +1 -1
- package/dist/cjs/motion/typesurface/construct.js +875 -0
- package/dist/cjs/motion/typesurface/construct.js.map +1 -0
- package/dist/cjs/motion/typesurface/engine.js +28 -4
- package/dist/cjs/motion/typesurface/engine.js.map +1 -1
- package/dist/cjs/motion/typesurface/index.js +9 -1
- package/dist/cjs/motion/typesurface/index.js.map +1 -1
- package/dist/cjs/motion/typesurface/presets.js +69 -2
- package/dist/cjs/motion/typesurface/presets.js.map +1 -1
- package/dist/cjs/motion/typesurface/renderer.js +81 -15
- package/dist/cjs/motion/typesurface/renderer.js.map +1 -1
- package/dist/cjs/motion/typesurface/shaders.js +23 -1
- package/dist/cjs/motion/typesurface/shaders.js.map +1 -1
- package/dist/cjs/motion/typesurface/surfaces.js +69 -0
- package/dist/cjs/motion/typesurface/surfaces.js.map +1 -1
- package/dist/esm/motion/typesurface/TypeSurfaceCanvas.d.ts +11 -1
- package/dist/esm/motion/typesurface/TypeSurfaceCanvas.d.ts.map +1 -1
- package/dist/esm/motion/typesurface/TypeSurfaceCanvas.js +25 -2
- package/dist/esm/motion/typesurface/TypeSurfaceCanvas.js.map +1 -1
- package/dist/esm/motion/typesurface/config.d.ts +13 -2
- package/dist/esm/motion/typesurface/config.d.ts.map +1 -1
- package/dist/esm/motion/typesurface/config.js +21 -1
- package/dist/esm/motion/typesurface/config.js.map +1 -1
- package/dist/esm/motion/typesurface/construct.d.ts +284 -0
- package/dist/esm/motion/typesurface/construct.d.ts.map +1 -0
- package/dist/esm/motion/typesurface/construct.js +866 -0
- package/dist/esm/motion/typesurface/construct.js.map +1 -0
- package/dist/esm/motion/typesurface/engine.d.ts +8 -0
- package/dist/esm/motion/typesurface/engine.d.ts.map +1 -1
- package/dist/esm/motion/typesurface/engine.js +28 -4
- package/dist/esm/motion/typesurface/engine.js.map +1 -1
- package/dist/esm/motion/typesurface/index.d.ts +7 -3
- package/dist/esm/motion/typesurface/index.d.ts.map +1 -1
- package/dist/esm/motion/typesurface/index.js +6 -2
- package/dist/esm/motion/typesurface/index.js.map +1 -1
- package/dist/esm/motion/typesurface/presets.d.ts +18 -0
- package/dist/esm/motion/typesurface/presets.d.ts.map +1 -1
- package/dist/esm/motion/typesurface/presets.js +68 -3
- package/dist/esm/motion/typesurface/presets.js.map +1 -1
- package/dist/esm/motion/typesurface/renderer.d.ts +10 -0
- package/dist/esm/motion/typesurface/renderer.d.ts.map +1 -1
- package/dist/esm/motion/typesurface/renderer.js +82 -16
- package/dist/esm/motion/typesurface/renderer.js.map +1 -1
- package/dist/esm/motion/typesurface/shaders.d.ts +1 -1
- package/dist/esm/motion/typesurface/shaders.d.ts.map +1 -1
- package/dist/esm/motion/typesurface/shaders.js +23 -1
- package/dist/esm/motion/typesurface/shaders.js.map +1 -1
- package/dist/esm/motion/typesurface/surfaces.d.ts +28 -1
- package/dist/esm/motion/typesurface/surfaces.d.ts.map +1 -1
- package/dist/esm/motion/typesurface/surfaces.js +67 -0
- package/dist/esm/motion/typesurface/surfaces.js.map +1 -1
- package/docs/TYPE-SURFACE.md +183 -0
- package/package.json +4 -2
- package/src/motion/typesurface/TypeSurfaceCanvas.tsx +30 -2
- package/src/motion/typesurface/config.ts +29 -3
- package/src/motion/typesurface/construct.ts +828 -0
- package/src/motion/typesurface/engine.ts +31 -5
- package/src/motion/typesurface/index.ts +7 -3
- package/src/motion/typesurface/presets.ts +75 -3
- package/src/motion/typesurface/renderer.ts +77 -17
- package/src/motion/typesurface/shaders.ts +23 -1
- package/src/motion/typesurface/surfaces.ts +78 -1
- package/tools/ask/dist/components.mjs +1138 -57
- package/tools/ask/dist/neon.js +69 -0
- package/tools/ask/mcp.mjs +90 -5
- package/tools/ask/neon-render.mjs +143 -0
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* typography how the letters look: font, weight, size, spacing, colour, gradient, blend mode
|
|
8
8
|
* placement where the text sits ON the surface (surface coordinates, 0–1), its angle and width
|
|
9
9
|
* surface which physical thing it meets (newspaper, bottle, wrapper…) and in which state
|
|
10
|
+
* object instead of a surface: something built from primitives (`construct.ts`), as JSON
|
|
10
11
|
* deformation how far each transformation has gone: wrap, morph, fold, roll, crumple…
|
|
11
12
|
* material how the letters become part of the surface: ink, print, foil, emboss
|
|
12
13
|
* view the camera: perspective comes from here, not from the text
|
|
@@ -18,6 +19,7 @@
|
|
|
18
19
|
* Angles are degrees, times are ms. `docs/TYPE-SURFACE.md`.
|
|
19
20
|
*/
|
|
20
21
|
import type { Easing } from '../types';
|
|
22
|
+
import { sanitizeObject, type TSObjectSpec } from './construct';
|
|
21
23
|
import { hasSurface } from './surfaces';
|
|
22
24
|
|
|
23
25
|
export const TS_SURFACES = ['newspaper', 'paper', 'bottle', 'wrapper', 'fabric'] as const;
|
|
@@ -73,7 +75,8 @@ export type TSPlacement = {
|
|
|
73
75
|
};
|
|
74
76
|
|
|
75
77
|
export type TSSurface = {
|
|
76
|
-
|
|
78
|
+
/** A built-in surface, or `object` when the config's `object` is what the text meets. */
|
|
79
|
+
type: TSSurfaceType | 'object';
|
|
77
80
|
/** A named state from `SURFACE_STATES[type]`; applying it sets `deformation`. Informational after. */
|
|
78
81
|
state: string;
|
|
79
82
|
/** Seeds every random choice: creases, wrinkles, the newspaper's copy and photos. */
|
|
@@ -222,6 +225,11 @@ export type TypeSurfaceConfig = {
|
|
|
222
225
|
typography: TSTypography;
|
|
223
226
|
placement: TSPlacement;
|
|
224
227
|
surface: TSSurface;
|
|
228
|
+
/**
|
|
229
|
+
* An object built from primitives (`construct.ts`). When set, it is what the text meets, and
|
|
230
|
+
* `surface.type` is ignored: the text wraps the part named in `object.text`.
|
|
231
|
+
*/
|
|
232
|
+
object: TSObjectSpec | null;
|
|
225
233
|
deformation: TSDeformation;
|
|
226
234
|
material: TSMaterial;
|
|
227
235
|
view: TSView;
|
|
@@ -229,7 +237,8 @@ export type TypeSurfaceConfig = {
|
|
|
229
237
|
};
|
|
230
238
|
|
|
231
239
|
type DeepPartial<T> = T extends (infer U)[] ? U[] : T extends object ? { [K in keyof T]?: DeepPartial<T[K]> } : T;
|
|
232
|
-
|
|
240
|
+
/** Every field optional, except an `object`, which is given whole (its parts are a list). */
|
|
241
|
+
export type TypeSurfaceConfigInput = Omit<DeepPartial<TypeSurfaceConfig>, 'object'> & { object?: TSObjectSpec | null };
|
|
233
242
|
|
|
234
243
|
const FOLD_OFF: TSFold = { amount: 0, position: 0.5, angle: 180, width: 0.035, influence: 0.7, orientation: 'vertical', direction: 'over', side: 'far' };
|
|
235
244
|
const WRAP_OFF: TSWrap = { amount: 0, position: 0.7, radius: 0.06, angle: 300, orientation: 'vertical', direction: 'under', side: 'far' };
|
|
@@ -259,6 +268,7 @@ export const DEFAULT_TYPE_SURFACE: TypeSurfaceConfig = {
|
|
|
259
268
|
},
|
|
260
269
|
placement: { x: 0.5, y: 0.34, rotation: 0, maxWidth: 900 },
|
|
261
270
|
surface: { type: 'newspaper', state: 'flat', seed: 7, color: null },
|
|
271
|
+
object: null,
|
|
262
272
|
deformation: { ...REST_DEFORMATION, wrap: 1 },
|
|
263
273
|
material: {
|
|
264
274
|
type: 'ink', blend: 0.75, inkStrength: 0.9, inkSpread: 0.35, inkRoughness: 0.4, paperInfluence: 0.75, grainInfluence: 0.5, halftone: 0,
|
|
@@ -408,7 +418,8 @@ export function setPath<T>(obj: T, path: string, value: unknown): T {
|
|
|
408
418
|
function merge<T>(base: T, over: unknown): T {
|
|
409
419
|
if (!isObj(base) || !isObj(over)) return (over === undefined ? base : over) as T;
|
|
410
420
|
const out: Record<string, unknown> = { ...base };
|
|
411
|
-
|
|
421
|
+
// An object replaces the one before it: merging two part lists means nothing.
|
|
422
|
+
for (const [k, v] of Object.entries(over)) out[k] = v === undefined ? out[k] : k === 'object' ? v : merge((base as Record<string, unknown>)[k], v);
|
|
412
423
|
return out as T;
|
|
413
424
|
}
|
|
414
425
|
|
|
@@ -458,11 +469,18 @@ function checkStages(stages: unknown): TSConfigError[] {
|
|
|
458
469
|
export function validateTypeSurface(config: unknown): TSConfigError[] {
|
|
459
470
|
if (!isObj(config)) return [{ path: '', message: 'The config must be an object.' }];
|
|
460
471
|
const errors: TSConfigError[] = [];
|
|
472
|
+
const built = config.object !== undefined && config.object !== null;
|
|
461
473
|
for (const ctl of TS_CONTROLS) {
|
|
474
|
+
// `surface.type: 'object'` says the object is the surface; it needs one.
|
|
475
|
+
if (ctl.path === 'surface.type' && config.surface && (config.surface as Record<string, unknown>).type === 'object') {
|
|
476
|
+
if (!built) errors.push({ path: ctl.path, message: 'Surface is “object” but the config has no object.' });
|
|
477
|
+
continue;
|
|
478
|
+
}
|
|
462
479
|
const msg = checkControl(ctl, getPath(config, ctl.path));
|
|
463
480
|
if (msg) errors.push({ path: ctl.path, message: msg });
|
|
464
481
|
}
|
|
465
482
|
errors.push(...checkStages(getPath(config, 'animation.stages')));
|
|
483
|
+
if (built) errors.push(...sanitizeObject(config.object).errors);
|
|
466
484
|
return errors;
|
|
467
485
|
}
|
|
468
486
|
|
|
@@ -473,6 +491,14 @@ export function validateTypeSurface(config: unknown): TSConfigError[] {
|
|
|
473
491
|
export function sanitizeTypeSurface(input: unknown): { config: TypeSurfaceConfig; invalid: string[] } {
|
|
474
492
|
let config = resolveTypeSurface(isObj(input) ? (input as TypeSurfaceConfigInput) : {});
|
|
475
493
|
const invalid: string[] = [];
|
|
494
|
+
// An object is repaired as a whole: numbers clamped, bad parts dropped, null if nothing can be drawn.
|
|
495
|
+
if (config.object !== null) {
|
|
496
|
+
const fixed = sanitizeObject(config.object);
|
|
497
|
+
if (fixed.errors.length) {
|
|
498
|
+
config = { ...config, object: fixed.object };
|
|
499
|
+
invalid.push(...fixed.errors.map((e) => e.path));
|
|
500
|
+
}
|
|
501
|
+
}
|
|
476
502
|
for (const err of validateTypeSurface(config)) {
|
|
477
503
|
if (err.path.startsWith('animation.stages')) {
|
|
478
504
|
config = { ...config, animation: { ...config.animation, stages: [] } };
|