@alizarin/clm 2.0.0-alpha.98 → 2.0.0-beta.3

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 (2) hide show
  1. package/dist/clm.js +19 -10
  2. package/package.json +15 -5
package/dist/clm.js CHANGED
@@ -157,7 +157,7 @@ var ReferenceValueViewModel = class c extends String {
157
157
  let c = this._pendingLookup, l = await RDM.retrieveCollection(c.collectionId), u = null;
158
158
  if (c.type === "uuid" ? (u = getReferenceValueFromCollection(l, c.uuid), u || console.error("Could not find reference for UUID", c.uuid, "in collection", c.collectionId)) : c.type === "label" && (u = getReferenceValueByLabelFromCollection(l, c.label), u || console.error("Could not find reference for label", c.label, "in collection", c.collectionId)), u && (this._resolvedRef = new StaticReference(u), this._tile && this._nodeid)) {
159
159
  let e = this._tile.data.get(this._nodeid);
160
- Array.isArray(e) || this._tile.data.set(this._nodeid, this._resolvedRef.toJSON());
160
+ Array.isArray(e) && e.length <= 1 ? this._tile.data.set(this._nodeid, [this._resolvedRef.toJSON()]) : Array.isArray(e) || this._tile.data.set(this._nodeid, [this._resolvedRef.toJSON()]);
161
161
  }
162
162
  return this._resolvedRef;
163
163
  })(), this._resolutionPromise) : null;
@@ -184,13 +184,17 @@ var ReferenceValueViewModel = class c extends String {
184
184
  } : null;
185
185
  }
186
186
  async __asTileData() {
187
- let e = await this._resolvePending();
188
- return e && typeof e.toJSON == "function" ? e.toJSON() : e;
187
+ let e = await this._resolvePending(), c = e && typeof e.toJSON == "function" ? e.toJSON() : e;
188
+ return c ? [c] : null;
189
189
  }
190
190
  static async __create(e, l, u, d) {
191
191
  let f = l.nodeid, p = l.config?.controlledList || l.config?.rdmCollection;
192
192
  if (!p) throw Error(`Node ${l.alias} (${l.nodeid}) missing controlledList or rdmCollection in config`);
193
193
  if (e && (e.data.has(f) || e.data.set(f, null), u !== null)) {
194
+ if (Array.isArray(u)) {
195
+ if (u.length === 1) u = u[0];
196
+ else if (u.length === 0) return null;
197
+ }
194
198
  if (u instanceof Promise) return u.then((u) => c.__create(e, l, u, d));
195
199
  if (typeof u == "string") if (/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.exec(u)) {
196
200
  let l = {
@@ -198,10 +202,10 @@ var ReferenceValueViewModel = class c extends String {
198
202
  uuid: u,
199
203
  collectionId: p
200
204
  };
201
- return e.data.set(f, {
205
+ return e.data.set(f, [{
202
206
  __needs_rdm_lookup: !0,
203
207
  uuid: u
204
- }), new c(null, l, e, f, p);
208
+ }]), new c(null, l, e, f, p);
205
209
  } else throw Error(`Set references using values from collections, not strings: ${u}`);
206
210
  else if (typeof u == "object" && u && u.__needs_rdm_lookup && u.uuid) {
207
211
  let l = {
@@ -209,20 +213,20 @@ var ReferenceValueViewModel = class c extends String {
209
213
  uuid: u.uuid,
210
214
  collectionId: p
211
215
  };
212
- return e.data.set(f, u), new c(null, l, e, f, p);
216
+ return e.data.set(f, [u]), new c(null, l, e, f, p);
213
217
  } else if (typeof u == "object" && u && u.__needs_rdm_label_lookup && u.label) {
214
218
  let l = u.controlledList || p, d = {
215
219
  type: "label",
216
220
  label: u.label,
217
221
  collectionId: l
218
222
  };
219
- return e.data.set(f, u), new c(null, d, e, f, l);
223
+ return e.data.set(f, [u]), new c(null, d, e, f, l);
220
224
  } else if (Array.isArray(u) && u.length > 0 && "labels" in u[0]) {
221
225
  let l = new StaticReference(u[0]);
222
- return e.data.set(f, l.toJSON()), new c(l, void 0, void 0, void 0, p);
226
+ return e.data.set(f, [l.toJSON()]), new c(l, void 0, void 0, void 0, p);
223
227
  } else if (typeof u == "object" && u && "labels" in u) {
224
228
  let l = new StaticReference(u);
225
- return e.data.set(f, l.toJSON()), new c(l, void 0, void 0, void 0, p);
229
+ return e.data.set(f, [l.toJSON()]), new c(l, void 0, void 0, void 0, p);
226
230
  } else throw Error("Could not set reference from this data: " + JSON.stringify(u));
227
231
  }
228
232
  return !e || !u ? null : new c(u, void 0, void 0, void 0, p);
@@ -283,4 +287,9 @@ var ReferenceValueViewModel = class c extends String {
283
287
  return f && f.multiValue ? ReferenceListViewModel.__create(e, l, u, d) : ReferenceValueViewModel.__create(e, l, u, d);
284
288
  }
285
289
  };
286
- viewModels.CUSTOM_DATATYPES.set("reference", ReferenceMergedDataType), registerResolvableDatatype("reference");
290
+ viewModels.CUSTOM_DATATYPES.set("reference", ReferenceMergedDataType), registerResolvableDatatype("reference"), (async () => {
291
+ try {
292
+ let e = await import("@alizarin/napi"), c = await import("@alizarin/clm-napi");
293
+ e.registerExtensionHandler(c.referenceHandlerPtr());
294
+ } catch {}
295
+ })();
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@alizarin/clm",
3
- "version": "2.0.0-alpha.98",
3
+ "version": "2.0.0-beta.3",
4
4
  "description": "Alizarin display serializers for CLM reference datatypes",
5
5
  "license": "AGPL-3.0",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/flaxandteal/alizarin",
9
- "directory": "ext/js/@alizarin/clm"
9
+ "directory": "ext/clm/js"
10
10
  },
11
11
  "author": "Phil Weir <phil.weir@flaxandteal.co.uk>",
12
12
  "type": "module",
@@ -20,13 +20,23 @@
20
20
  "dev": "vite",
21
21
  "build": "vite build && tsc -p tsconfig.build.json",
22
22
  "preview": "vite preview",
23
- "test": "cd ../../../.. && npm test -- ext/js/@alizarin/clm/tests/clm.test.ts"
23
+ "test": "cd ../../.. && npm test -- ext/clm/js/tests/clm.test.ts"
24
24
  },
25
25
  "peerDependencies": {
26
- "alizarin": "2.0.0-alpha.98"
26
+ "alizarin": "2.0.0-beta.3",
27
+ "@alizarin/napi": "2.0.0-beta.1",
28
+ "@alizarin/clm-napi": "2.0.0-beta.1"
29
+ },
30
+ "peerDependenciesMeta": {
31
+ "@alizarin/napi": {
32
+ "optional": true
33
+ },
34
+ "@alizarin/clm-napi": {
35
+ "optional": true
36
+ }
27
37
  },
28
38
  "devDependencies": {
29
- "alizarin": "file:../../../..",
39
+ "alizarin": "file:../../..",
30
40
  "typescript": "~5.9.3",
31
41
  "vite": "npm:rolldown-vite@7.2.5"
32
42
  },