@weasel-js/guides 1.9.4 → 1.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/insert.d.ts CHANGED
@@ -27,4 +27,4 @@ interface SnapToGuidesInsertArgs {
27
27
  */
28
28
  declare function snapToGuides<TPose>(args: SnapToGuidesInsertArgs): InsertBehavior<TPose>;
29
29
 
30
- export { snapToGrid, snapToGuides };
30
+ export { type SnapToGuidesInsertArgs, snapToGrid, snapToGuides };
package/dist/insert.js CHANGED
@@ -1,4 +1,4 @@
1
- import { DEFAULT_GUIDE_TOLERANCE_PX, roundToGridOn, nearestGuideDelta } from './chunk-NIEZTECL.js';
1
+ import { DEFAULT_GUIDE_TOLERANCE_PX, roundToGridOn, nearestGuideDelta } from './chunk-LOFNN7EQ.js';
2
2
  import { screenTolerance } from '@weasel-js/core';
3
3
 
4
4
  // src/behaviors/insert/snapToGrid.ts
package/dist/move.d.ts CHANGED
@@ -39,4 +39,4 @@ declare function snapToGuides<TPose>(args: SnapToGuidesMoveArgs<TPose> & {
39
39
  origin: OriginProjection<TPose>;
40
40
  }): MoveBehavior<TPose>;
41
41
 
42
- export { snapToGrid, snapToGuides };
42
+ export { type SnapToGuidesMoveArgs, snapToGrid, snapToGuides };
package/dist/move.js CHANGED
@@ -1,5 +1,5 @@
1
- import { gridSnapStrategy } from './chunk-JETW4ZA3.js';
2
- import { guideSnapStrategy } from './chunk-NIEZTECL.js';
1
+ import { gridSnapStrategy } from './chunk-TLFMAZ6M.js';
2
+ import { guideSnapStrategy } from './chunk-LOFNN7EQ.js';
3
3
  import { snap } from '@weasel-js/core';
4
4
 
5
5
  function snapToGrid(args) {
package/dist/resize.d.ts CHANGED
@@ -35,4 +35,4 @@ interface SnapToGuidesResizeArgs {
35
35
  */
36
36
  declare function snapToGuides<TPose extends Bounds>(args: SnapToGuidesResizeArgs): BoundsConstraint<TPose>;
37
37
 
38
- export { snapToGrid, snapToGuides };
38
+ export { type SnapToGuidesResizeArgs, snapToGrid, snapToGuides };
package/dist/resize.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export { pointSnapToGrid } from './chunk-B25KFI3I.js';
2
- import { DEFAULT_GUIDE_TOLERANCE_PX, nearestGuideDelta, roundToGridOn } from './chunk-NIEZTECL.js';
2
+ import { DEFAULT_GUIDE_TOLERANCE_PX, nearestGuideDelta, roundToGridOn } from './chunk-LOFNN7EQ.js';
3
3
  import { screenTolerance } from '@weasel-js/core';
4
4
 
5
5
  // src/behaviors/resize/snapToGrid.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weasel-js/guides",
3
- "version": "1.9.4",
3
+ "version": "1.10.1",
4
4
  "description": "Placement aids for weasel: grids, alignment guides, snapping to them, and container layout strategies, built on core's snap and behavior seams.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -29,8 +29,8 @@
29
29
  },
30
30
  "peerDependencies": {
31
31
  "react": ">=18",
32
- "@weasel-js/core": "1.9.4",
33
- "@weasel-js/geom": "1.9.4"
32
+ "@weasel-js/core": "1.10.1",
33
+ "@weasel-js/geom": "1.10.1"
34
34
  },
35
35
  "author": "orochi235",
36
36
  "homepage": "https://orochi235.github.io/weasel/",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/strategies/grid.ts"],"names":[],"mappings":";;;AAgCO,SAAS,gBAAA,CACd,SACA,GAAA,EACqB;AACrB,EAAA,MAAM,MAAA,GACJ,OAAO,GAAA,KAAQ,QAAA,IACf,GAAA,KAAQ,IAAA,KACP,QAAA,IAAY,GAAA,IAAO,OAAA,IAAW,GAAA,IAAO,YAAA,IAAgB,GAAA,CAAA,IACtD,EAAE,MAAA,IAAU,GAAA,CAAA;AACd,EAAA,MAAM,OAAA,GAAU,SACX,GAAA,GACD,IAAA;AACJ,EAAA,MAAM,UAAA,GAAa,OAAA,GAAU,OAAA,CAAQ,UAAA,GAAc,GAAA;AACnD,EAAA,MAAM,IAAA,GAAgC,OAAA,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,\n type DebugSink,\n type OriginProjection,\n type SnapStrategy,\n type UnitSystem,\n type UnitValue,\n} from '@weasel-js/core';\nimport { roundToGridOn } from './onPlane';\n\n/** Snap-strategy that rounds the pose's origin to the nearest multiple of\n * `spacing` (resolved through `unitSystem`). For non-rect TPose pass an\n * `OriginProjection` so the strategy knows how to read/write the origin. */\nexport function gridSnapStrategy<TPose>(\n spacing: UnitValue,\n unitSystem?: UnitSystem,\n): SnapStrategy<TPose>;\n/** As above, additionally reporting each candidate to a debug sink. */\nexport function gridSnapStrategy<TPose>(\n spacing: UnitValue,\n opts: { unitSystem?: UnitSystem; debug?: DebugSink },\n): SnapStrategy<TPose>;\n/** As above, for a `TPose` that is not a rect: `origin` tells the strategy how\n * to read and write the pose's origin. */\nexport function gridSnapStrategy<TPose>(\n spacing: UnitValue,\n opts: { unitSystem?: UnitSystem; origin: OriginProjection<TPose>; debug?: DebugSink },\n): SnapStrategy<TPose>;\n/** Snap-strategy that rounds the pose's origin to the nearest multiple of\n * `spacing` (resolved through `unitSystem`). For non-rect TPose pass an\n * `OriginProjection` so the strategy knows how to read/write the origin. */\nexport function gridSnapStrategy<TPose>(\n spacing: UnitValue,\n arg?: UnitSystem | { unitSystem?: UnitSystem; origin?: OriginProjection<TPose>; debug?: DebugSink },\n): SnapStrategy<TPose> {\n const isOpts =\n typeof arg === 'object' &&\n arg !== null &&\n ('origin' in arg || 'debug' in arg || 'unitSystem' in arg) &&\n !('base' in arg);\n const optsArg = isOpts\n ? (arg as { unitSystem?: UnitSystem; origin?: OriginProjection<TPose>; debug?: DebugSink })\n : null;\n const unitSystem = optsArg ? optsArg.unitSystem : (arg as UnitSystem | undefined);\n const proj: OriginProjection<TPose> = optsArg && optsArg.origin\n ? optsArg.origin\n : (AUTO_ORIGIN_PROJECTION as unknown as OriginProjection<TPose>);\n const debug: DebugSink | undefined = optsArg ? optsArg.debug : undefined;\n const c = resolveUnit(spacing, unitSystem);\n return {\n snap(pose, ctx) {\n const o = proj.getOrigin(pose);\n const sx = roundToGridOn(o.x, 'x', c, ctx?.plane);\n const sy = roundToGridOn(o.y, 'y', c, ctx?.plane);\n debug?.recordSnapCandidate({ x: sx, y: sy }, true);\n return proj.translate(pose, sx - o.x, sy - o.y);\n },\n };\n}\n\n/**\n * Compute the integer cell `{col, row}` that contains `point`, given a grid\n * `spacing` and optional `origin` and `unitSystem`. Pair with\n * `createCellHighlightLayer` (its `getCell` callback) to draw a snap-target\n * preview that uses the same spacing as `gridSnapStrategy` — so the visual\n * and behavioral grids stay in lockstep:\n *\n * const SPACING = 20;\n * const snap = gridSnapStrategy(SPACING);\n * // visual grid:\n * createGridLayer({ spacing: SPACING, bounds: () => ... });\n * // hover-preview overlay:\n * createCellHighlightLayer({\n * spacing: SPACING,\n * getCell: () => hoverPoint && pointToGridCell(hoverPoint, SPACING),\n * });\n */\nexport function pointToGridCell(\n point: { x: number; y: number },\n spacing: UnitValue,\n unitSystem?: UnitSystem,\n origin: { x: number; y: number } = { x: 0, y: 0 },\n): { col: number; row: number } {\n const s = resolveUnit(spacing, unitSystem);\n return {\n col: Math.floor((point.x - origin.x) / s),\n row: Math.floor((point.y - origin.y) / s),\n };\n}\n"]}