@jigging/jig 0.1.0-alpha.2 → 0.1.0-alpha.5

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.
@@ -95,12 +95,20 @@
95
95
  "settings": {
96
96
  "type": "object",
97
97
  "maxProperties": 65536
98
+ },
99
+ "slots": {
100
+ "type": "object",
101
+ "additionalProperties": {
102
+ "$ref": "#/$defs/projectPath"
103
+ },
104
+ "maxProperties": 256
98
105
  }
99
106
  },
100
107
  "required": [
101
108
  "kind",
102
109
  "package",
103
- "settings"
110
+ "settings",
111
+ "slots"
104
112
  ],
105
113
  "additionalProperties": false
106
114
  },
@@ -1754,6 +1754,7 @@ function compareProjectPaths(left, right) {
1754
1754
  }
1755
1755
 
1756
1756
  // src/project/author.ts
1757
+ var LOCAL_NAME = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
1757
1758
  var GLOB_CHARACTERS = /[*?\[\]{}]/;
1758
1759
  function discover(roots) {
1759
1760
  const values = typeof roots === "string" ? [roots] : snapshotStringArray(roots, "roots");
@@ -1784,7 +1785,7 @@ function defineBinding(input) {
1784
1785
  }
1785
1786
  function normalizeBinding(input, canonical) {
1786
1787
  const captured = snapshotJsonObject(input, "Binding definition");
1787
- assertClosedObject(captured, canonical ? ["kind", "package", "settings"] : ["package", "settings"], "Binding definition");
1788
+ assertClosedObject(captured, canonical ? ["kind", "package", "settings", "slots"] : ["package", "settings", "slots"], "Binding definition");
1788
1789
  if (canonical && captured.kind !== "package") {
1789
1790
  throw new TypeError("Binding kind must be package");
1790
1791
  }
@@ -1792,7 +1793,20 @@ function normalizeBinding(input, canonical) {
1792
1793
  throw new TypeError("Binding package is required");
1793
1794
  const packagePath = normalizeProjectPath(captured.package, "package");
1794
1795
  const settings = Object.hasOwn(captured, "settings") ? expectJsonObject(captured.settings, "settings") : emptyRecord();
1795
- return record({ kind: "package", package: packagePath, settings });
1796
+ const slots = Object.hasOwn(captured, "slots") ? normalizeFlowSlots(captured.slots) : emptyRecord();
1797
+ return record({ kind: "package", package: packagePath, settings, slots });
1798
+ }
1799
+ function normalizeFlowSlots(value) {
1800
+ const input = snapshotJsonObject(value, "slots");
1801
+ if (Object.keys(input).length > 256) {
1802
+ throw new TypeError("slots exceed 256 entries");
1803
+ }
1804
+ const output = Object.create(null);
1805
+ for (const name of Object.keys(input).sort(compareUtf8)) {
1806
+ validateLocalName(name, "slot name");
1807
+ output[name] = normalizeProjectPath(input[name], `slot ${name}`);
1808
+ }
1809
+ return Object.freeze(output);
1796
1810
  }
1797
1811
  function normalizeSource(value, field, canonical) {
1798
1812
  if (value === undefined)
@@ -1836,6 +1850,12 @@ function normalizeUniquePaths(values, label, rejectGlob) {
1836
1850
  assertNoProjectPathCollisions(paths, label);
1837
1851
  return Object.freeze(paths);
1838
1852
  }
1853
+ function validateLocalName(value, label) {
1854
+ if (typeof value !== "string" || value.length > 64 || !LOCAL_NAME.test(value)) {
1855
+ throw new TypeError(`${label} must be a LocalName`);
1856
+ }
1857
+ return value;
1858
+ }
1839
1859
  function snapshotJsonObject(value, label) {
1840
1860
  const snapshot = snapshotJson(value, label);
1841
1861
  validateJson1(snapshot);