@ultrst-armada/floks 1.1.1 → 1.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultrst-armada/floks",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -44,11 +44,18 @@
44
44
  "default": "./packages/contracts/dist/index.js"
45
45
  }
46
46
  },
47
+ "scripts": {
48
+ "build": "pnpm -r run build",
49
+ "postbuild": "node -e \"import('fs').then(fs => { for (const pkg of fs.readdirSync('packages')) { const d = 'packages/' + pkg + '/dist'; if (!fs.existsSync(d)) continue; for (const f of fs.readdirSync(d, { recursive: true })) { const p = d + '/' + f; if (fs.statSync(p).isFile() && (p.endsWith('.js') || p.endsWith('.d.ts'))) { const c = fs.readFileSync(p, 'utf8'); const n = c.replaceAll('@kloks/', '@ultrst-armada/kloks/').replaceAll('@floks/', '@ultrst-armada/floks/').replaceAll('@ultrst/kloks/', '@ultrst-armada/kloks/').replaceAll('@ultrst/floks/', '@ultrst-armada/floks/').replaceAll('\\\"kloks/', '\\\"@ultrst-armada/kloks/').replaceAll('\\'kloks/', '\\'@ultrst-armada/kloks/').replaceAll('\\\"floks/', '\\\"@ultrst-armada/floks/').replaceAll('\\'floks/', '\\'@ultrst-armada/floks/'); if (c !== n) fs.writeFileSync(p, n); } } } })\"",
50
+ "test": "vitest run",
51
+ "typecheck": "pnpm -r run typecheck",
52
+ "clean": "pnpm -r run clean"
53
+ },
47
54
  "dependencies": {
48
55
  "zod": "^3.24.1"
49
56
  },
50
57
  "peerDependencies": {
51
- "@ultrst-armada/kloks": "^1.0.2",
58
+ "@ultrst-armada/kloks": "^1.0.2 || ^1.4.0",
52
59
  "lucide-react": ">=0.300.0",
53
60
  "react": "^18.0.0 || ^19.0.0",
54
61
  "react-dom": "^18.0.0 || ^19.0.0"
@@ -57,7 +64,7 @@
57
64
  "@types/node": "^22.0.0",
58
65
  "@types/react": "^19.0.0",
59
66
  "@types/react-dom": "^19.0.0",
60
- "@ultrst-armada/kloks": "^1.0.2",
67
+ "@ultrst-armada/kloks": "^1.4.0",
61
68
  "lucide-react": "^1.55.0",
62
69
  "react": "^19.0.1",
63
70
  "react-dom": "^19.0.1",
@@ -65,11 +72,10 @@
65
72
  "typescript": "^5.7.3",
66
73
  "vitest": "^3.1.0"
67
74
  },
68
- "scripts": {
69
- "build": "pnpm -r run build",
70
- "postbuild": "node -e \"import('fs').then(fs => { for (const pkg of fs.readdirSync('packages')) { const d = 'packages/' + pkg + '/dist'; if (!fs.existsSync(d)) continue; for (const f of fs.readdirSync(d, { recursive: true })) { const p = d + '/' + f; if (fs.statSync(p).isFile() && (p.endsWith('.js') || p.endsWith('.d.ts'))) { const c = fs.readFileSync(p, 'utf8'); const n = c.replaceAll('@kloks/', '@ultrst-armada/kloks/').replaceAll('@floks/', '@ultrst-armada/floks/').replaceAll('@ultrst/kloks/', '@ultrst-armada/kloks/').replaceAll('@ultrst/floks/', '@ultrst-armada/floks/').replaceAll('\\\"kloks/', '\\\"@ultrst-armada/kloks/').replaceAll('\\'kloks/', '\\'@ultrst-armada/kloks/').replaceAll('\\\"floks/', '\\\"@ultrst-armada/floks/').replaceAll('\\'floks/', '\\'@ultrst-armada/floks/'); if (c !== n) fs.writeFileSync(p, n); } } } })\"",
71
- "test": "vitest run",
72
- "typecheck": "pnpm -r run typecheck",
73
- "clean": "pnpm -r run clean"
74
- }
75
- }
75
+ "pnpm": {
76
+ "overrides": {
77
+ "@ultrst-armada/kloks": "file:../Kloks"
78
+ }
79
+ },
80
+ "packageManager": "pnpm@9.15.0"
81
+ }
@@ -14,12 +14,6 @@ import {
14
14
  skipoDarkTheme,
15
15
  useMonaco
16
16
  } from "./chunk-QTTWWBNN.js";
17
- import {
18
- PredictiveGhostNodeCard,
19
- PredictiveHudToolbar,
20
- PredictiveLayer2D,
21
- usePredictiveGraph2D
22
- } from "./chunk-OOTTFWXA.js";
23
17
  import {
24
18
  BIOME_CONFIGS,
25
19
  COORD_SCALE,
@@ -36,6 +30,18 @@ import {
36
30
  useCanvas2DCoordinates,
37
31
  useCanvas2DMagnetic
38
32
  } from "./chunk-XVAHT5WE.js";
33
+ import {
34
+ Tile,
35
+ TileCreateButton,
36
+ TileGrid,
37
+ useTileMenu
38
+ } from "./chunk-SA3JADUG.js";
39
+ import {
40
+ PredictiveGhostNodeCard,
41
+ PredictiveHudToolbar,
42
+ PredictiveLayer2D,
43
+ usePredictiveGraph2D
44
+ } from "./chunk-OOTTFWXA.js";
39
45
  import {
40
46
  NODE_CARD_WIDTH,
41
47
  Node2DBase,
@@ -46,12 +52,6 @@ import {
46
52
  getSocketScreenPosition,
47
53
  renderSpriteIcon
48
54
  } from "./chunk-U2SC3RMJ.js";
49
- import {
50
- Tile,
51
- TileCreateButton,
52
- TileGrid,
53
- useTileMenu
54
- } from "./chunk-SA3JADUG.js";
55
55
 
56
56
  // src/node-graph-ui/widgets/MidpointWidgets.tsx
57
57
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -391,4 +391,117 @@ interface ThemeValidationResult {
391
391
  declare function validateThemePackAgainstContract(themePack: ThemePack, contract?: ComponentThemeContract): ThemeValidationResult;
392
392
  declare function loadThemePack(raw: unknown): ThemePack;
393
393
 
394
- export { type ComponentThemeContract, ComponentThemeContractSchema, FLOKS_COMPONENT_REGISTRY, type ThemePack, ThemePackSchema, type ThemePackSlotBinding, ThemePackSlotBindingSchema, type ThemePackStateMapping, ThemePackStateMappingSchema, type ThemeTarget, ThemeTargetSchema, type ThemeValidationResult, type VisualParameter, VisualParameterSchema, type VisualSlot, VisualSlotSchema, type VisualState, VisualStateSchema, getComponentContract, listComponentContracts, loadThemePack, validateThemePackAgainstContract };
394
+ /**
395
+ * @file snapshot.ts
396
+ * @description Floks Contract Snapshot Generator, Diff Engine & Canonical Contract Definition.
397
+ * Enforces docs/04_THETA_COMPONENT_CONTRACTS.md and IMPLEMENTATION-SPEC.md:
398
+ * implementation_only => PATCH
399
+ * additive_compatible => MINOR
400
+ * breaking_contract_change => MAJOR
401
+ */
402
+
403
+ declare const FLOKS_PUBLIC_SYMBOLS: string[];
404
+ declare const FloksContractSnapshotSchema: z.ZodObject<{
405
+ package: z.ZodLiteral<"@ultrst-armada/floks">;
406
+ version: z.ZodString;
407
+ timestamp: z.ZodNumber;
408
+ checksum: z.ZodString;
409
+ publicSymbols: z.ZodArray<z.ZodString, "many">;
410
+ components: z.ZodRecord<z.ZodString, z.ZodObject<{
411
+ componentId: z.ZodString;
412
+ componentVersion: z.ZodString;
413
+ slots: z.ZodArray<z.ZodString, "many">;
414
+ states: z.ZodArray<z.ZodString, "many">;
415
+ parameters: z.ZodArray<z.ZodString, "many">;
416
+ assets: z.ZodArray<z.ZodString, "many">;
417
+ }, "strip", z.ZodTypeAny, {
418
+ parameters?: string[];
419
+ componentId?: string;
420
+ componentVersion?: string;
421
+ slots?: string[];
422
+ states?: string[];
423
+ assets?: string[];
424
+ }, {
425
+ parameters?: string[];
426
+ componentId?: string;
427
+ componentVersion?: string;
428
+ slots?: string[];
429
+ states?: string[];
430
+ assets?: string[];
431
+ }>>;
432
+ errorCodes: z.ZodArray<z.ZodString, "many">;
433
+ }, "strip", z.ZodTypeAny, {
434
+ version?: string;
435
+ package?: "@ultrst-armada/floks";
436
+ timestamp?: number;
437
+ checksum?: string;
438
+ publicSymbols?: string[];
439
+ components?: Record<string, {
440
+ parameters?: string[];
441
+ componentId?: string;
442
+ componentVersion?: string;
443
+ slots?: string[];
444
+ states?: string[];
445
+ assets?: string[];
446
+ }>;
447
+ errorCodes?: string[];
448
+ }, {
449
+ version?: string;
450
+ package?: "@ultrst-armada/floks";
451
+ timestamp?: number;
452
+ checksum?: string;
453
+ publicSymbols?: string[];
454
+ components?: Record<string, {
455
+ parameters?: string[];
456
+ componentId?: string;
457
+ componentVersion?: string;
458
+ slots?: string[];
459
+ states?: string[];
460
+ assets?: string[];
461
+ }>;
462
+ errorCodes?: string[];
463
+ }>;
464
+ type FloksContractSnapshot = z.infer<typeof FloksContractSnapshotSchema>;
465
+ interface ContractDiffResult {
466
+ versionRecommendation: 'PATCH' | 'MINOR' | 'MAJOR';
467
+ hasBreakingChanges: boolean;
468
+ hasAdditiveChanges: boolean;
469
+ isIdentical: boolean;
470
+ removedSymbols: string[];
471
+ addedSymbols: string[];
472
+ removedComponents: string[];
473
+ addedComponents: string[];
474
+ changedComponents: string[];
475
+ summary: string;
476
+ }
477
+ /**
478
+ * Generate canonical contract snapshot for Floks.
479
+ */
480
+ declare function createFloksSnapshot(version?: string, registry?: Record<string, ComponentThemeContract>, publicSymbols?: string[]): FloksContractSnapshot;
481
+ /**
482
+ * Computes semantic diff between previous and current Floks contract snapshots.
483
+ */
484
+ declare function diffContractSnapshots(previous: FloksContractSnapshot, current: FloksContractSnapshot): ContractDiffResult;
485
+ declare const FLOKS_CANONICAL_CONTRACT: {
486
+ package: string;
487
+ version: string;
488
+ getSnapshot: () => {
489
+ version?: string;
490
+ package?: "@ultrst-armada/floks";
491
+ timestamp?: number;
492
+ checksum?: string;
493
+ publicSymbols?: string[];
494
+ components?: Record<string, {
495
+ parameters?: string[];
496
+ componentId?: string;
497
+ componentVersion?: string;
498
+ slots?: string[];
499
+ states?: string[];
500
+ assets?: string[];
501
+ }>;
502
+ errorCodes?: string[];
503
+ };
504
+ validateCompatibility: (themePack: ThemePack) => ThemeValidationResult;
505
+ };
506
+
507
+ export { type ComponentThemeContract, ComponentThemeContractSchema, type ContractDiffResult, FLOKS_CANONICAL_CONTRACT, FLOKS_COMPONENT_REGISTRY, FLOKS_PUBLIC_SYMBOLS, type FloksContractSnapshot, FloksContractSnapshotSchema, type ThemePack, ThemePackSchema, type ThemePackSlotBinding, ThemePackSlotBindingSchema, type ThemePackStateMapping, ThemePackStateMappingSchema, type ThemeTarget, ThemeTargetSchema, type ThemeValidationResult, type VisualParameter, VisualParameterSchema, type VisualSlot, VisualSlotSchema, type VisualState, VisualStateSchema, createFloksSnapshot, diffContractSnapshots, getComponentContract, listComponentContracts, loadThemePack, validateThemePackAgainstContract };
@@ -307,9 +307,171 @@ function loadThemePack(raw) {
307
307
  }
308
308
  return parsed;
309
309
  }
310
+
311
+ // src/snapshot.ts
312
+ import { z as z2 } from "zod";
313
+ var FLOKS_PUBLIC_SYMBOLS = [
314
+ // UI Layout & Containers
315
+ "AppShell",
316
+ "TopToolbar",
317
+ "BottomStrip",
318
+ "FloatingDetailsPanel",
319
+ "SettingsTab",
320
+ "WorkspaceTilesMenu",
321
+ "UIParent",
322
+ "PanelModel",
323
+ "PanelProps",
324
+ // UI Base Primitives & Forms
325
+ "BaseButton",
326
+ "BaseCard",
327
+ "BaseInput",
328
+ "BaseSelect",
329
+ "BaseToggle",
330
+ "BaseBadge",
331
+ "ButtonModel",
332
+ "ButtonProps",
333
+ "CredentialField",
334
+ "LoginModal",
335
+ "ConfirmDialog",
336
+ "StatusIndicator",
337
+ // Canvas 2D
338
+ "InfiniteCanvas",
339
+ "DockBar",
340
+ "TileGrid",
341
+ "MonacoEditor",
342
+ // Contracts & Theta
343
+ "FLOKS_CANONICAL_CONTRACT",
344
+ "FLOKS_COMPONENT_REGISTRY",
345
+ "getComponentContract",
346
+ "listComponentContracts",
347
+ "validateThemePackAgainstContract",
348
+ "loadThemePack",
349
+ "createFloksSnapshot",
350
+ "diffContractSnapshots",
351
+ "ComponentThemeContractSchema",
352
+ "VisualSlotSchema",
353
+ "VisualStateSchema",
354
+ "VisualParameterSchema",
355
+ "ThemeTargetSchema",
356
+ "ThemePackSchema"
357
+ ];
358
+ var FloksContractSnapshotSchema = z2.object({
359
+ package: z2.literal("@ultrst-armada/floks"),
360
+ version: z2.string(),
361
+ timestamp: z2.number(),
362
+ checksum: z2.string(),
363
+ publicSymbols: z2.array(z2.string()),
364
+ components: z2.record(
365
+ z2.object({
366
+ componentId: z2.string(),
367
+ componentVersion: z2.string(),
368
+ slots: z2.array(z2.string()),
369
+ states: z2.array(z2.string()),
370
+ parameters: z2.array(z2.string()),
371
+ assets: z2.array(z2.string())
372
+ })
373
+ ),
374
+ errorCodes: z2.array(z2.string())
375
+ });
376
+ function createFloksSnapshot(version = "1.1.1", registry = FLOKS_COMPONENT_REGISTRY, publicSymbols = FLOKS_PUBLIC_SYMBOLS) {
377
+ const sortedSymbols = [...publicSymbols].sort();
378
+ const components = {};
379
+ for (const [compId, contract] of Object.entries(registry)) {
380
+ components[compId] = {
381
+ componentId: contract.componentId,
382
+ componentVersion: contract.componentVersion,
383
+ slots: contract.slots.map((s) => s.id).sort(),
384
+ states: contract.states.map((s) => s.id).sort(),
385
+ parameters: contract.parameters.map((p) => p.id).sort(),
386
+ assets: [...contract.assets].sort()
387
+ };
388
+ }
389
+ const errorCodes = [
390
+ "ERR_CONTRACT_VIOLATION",
391
+ "ERR_INTERNAL_IMPORT_FORBIDDEN",
392
+ "ERR_LOCAL_SHIM_DETECTED",
393
+ "ERR_THEME_TARGET_MISMATCH",
394
+ "ERR_SLOT_REJECTED",
395
+ "ERR_UNRECOGNIZED_STATE"
396
+ ];
397
+ const rawJson = JSON.stringify({ sortedSymbols, components });
398
+ let hash = 0;
399
+ for (let i = 0; i < rawJson.length; i++) {
400
+ hash = (hash << 5) - hash + rawJson.charCodeAt(i);
401
+ hash |= 0;
402
+ }
403
+ const checksum = `sha256-${Math.abs(hash).toString(16)}`;
404
+ const snapshot = {
405
+ package: "@ultrst-armada/floks",
406
+ version,
407
+ timestamp: 176043e7,
408
+ checksum,
409
+ publicSymbols: sortedSymbols,
410
+ components,
411
+ errorCodes
412
+ };
413
+ return FloksContractSnapshotSchema.parse(snapshot);
414
+ }
415
+ function diffContractSnapshots(previous, current) {
416
+ const prevSymbols = new Set(previous.publicSymbols);
417
+ const currSymbols = new Set(current.publicSymbols);
418
+ const removedSymbols = previous.publicSymbols.filter((s) => !currSymbols.has(s));
419
+ const addedSymbols = current.publicSymbols.filter((s) => !prevSymbols.has(s));
420
+ const prevCompIds = Object.keys(previous.components);
421
+ const currCompIds = new Set(Object.keys(current.components));
422
+ const removedComponents = prevCompIds.filter((id) => !currCompIds.has(id));
423
+ const addedComponents = Object.keys(current.components).filter((id) => !previous.components[id]);
424
+ const changedComponents = [];
425
+ for (const compId of Object.keys(current.components)) {
426
+ if (previous.components[compId]) {
427
+ const prevC = previous.components[compId];
428
+ const currC = current.components[compId];
429
+ const removedSlots = prevC.slots.filter((s) => !currC.slots.includes(s));
430
+ const removedStates = prevC.states.filter((s) => !currC.states.includes(s));
431
+ if (removedSlots.length > 0 || removedStates.length > 0) {
432
+ changedComponents.push(
433
+ `${compId} breaking: removed slots [${removedSlots.join(", ")}], removed states [${removedStates.join(", ")}]`
434
+ );
435
+ } else if (prevC.slots.length !== currC.slots.length || prevC.states.length !== currC.states.length || prevC.parameters.length !== currC.parameters.length) {
436
+ changedComponents.push(`${compId} additive extension`);
437
+ }
438
+ }
439
+ }
440
+ const hasBreakingChanges = removedSymbols.length > 0 || removedComponents.length > 0 || changedComponents.some((c) => c.includes("breaking"));
441
+ const hasAdditiveChanges = addedSymbols.length > 0 || addedComponents.length > 0 || changedComponents.some((c) => c.includes("additive"));
442
+ const isIdentical = !hasBreakingChanges && !hasAdditiveChanges;
443
+ let versionRecommendation = "PATCH";
444
+ if (hasBreakingChanges) {
445
+ versionRecommendation = "MAJOR";
446
+ } else if (hasAdditiveChanges) {
447
+ versionRecommendation = "MINOR";
448
+ }
449
+ const summary = isIdentical ? "Identical public contract surface (PATCH compatible)." : hasBreakingChanges ? `Breaking contract change detected: ${removedSymbols.length} removed symbols, ${removedComponents.length} removed components (MAJOR bump required).` : `Additive compatible changes: ${addedSymbols.length} added symbols, ${addedComponents.length} added components (MINOR bump required).`;
450
+ return {
451
+ versionRecommendation,
452
+ hasBreakingChanges,
453
+ hasAdditiveChanges,
454
+ isIdentical,
455
+ removedSymbols,
456
+ addedSymbols,
457
+ removedComponents,
458
+ addedComponents,
459
+ changedComponents,
460
+ summary
461
+ };
462
+ }
463
+ var FLOKS_CANONICAL_CONTRACT = {
464
+ package: "@ultrst-armada/floks",
465
+ version: "1.1.1",
466
+ getSnapshot: () => createFloksSnapshot("1.1.1"),
467
+ validateCompatibility: (themePack) => validateThemePackAgainstContract(themePack)
468
+ };
310
469
  export {
311
470
  ComponentThemeContractSchema,
471
+ FLOKS_CANONICAL_CONTRACT,
312
472
  FLOKS_COMPONENT_REGISTRY,
473
+ FLOKS_PUBLIC_SYMBOLS,
474
+ FloksContractSnapshotSchema,
313
475
  ThemePackSchema,
314
476
  ThemePackSlotBindingSchema,
315
477
  ThemePackStateMappingSchema,
@@ -317,6 +479,8 @@ export {
317
479
  VisualParameterSchema,
318
480
  VisualSlotSchema,
319
481
  VisualStateSchema,
482
+ createFloksSnapshot,
483
+ diffContractSnapshots,
320
484
  getComponentContract,
321
485
  listComponentContracts,
322
486
  loadThemePack,
@@ -0,0 +1,14 @@
1
+ {
2
+ "$schema": "https://skipo.dev/schemas/floks-manifest.v1.json",
3
+ "package": "@floks/contracts",
4
+ "version": "1.0.0",
5
+ "components": [
6
+ {
7
+ "id": "canonical-component-contracts",
8
+ "name": "Canonical Component Contracts & Snapshot Engine",
9
+ "export": "FLOKS_CANONICAL_CONTRACT",
10
+ "subpath": "contracts",
11
+ "targetTypes": ["App.contracts", "App.governance"]
12
+ }
13
+ ]
14
+ }