@markless/serializer 0.2.0 → 0.2.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/dist/index.d.ts
CHANGED
|
@@ -70,10 +70,12 @@ declare function createProtocolStatePayload(input: ProtocolStatePayloadInput): P
|
|
|
70
70
|
declare function serializeRuntimeStateCells(cells: ProtocolStatePayload['cells']): ProtocolStatePayload['cells'];
|
|
71
71
|
declare function serializeRuntimeAsyncSnapshots(computed: ProtocolStatePayload['computed']): ProtocolStatePayload['computed'];
|
|
72
72
|
//#endregion
|
|
73
|
+
//#region src/storage-key.d.ts
|
|
74
|
+
declare function isValidStorageKey(value: string): boolean;
|
|
75
|
+
//#endregion
|
|
73
76
|
//#region src/storage-slot.d.ts
|
|
74
77
|
declare const STORAGE_SLOT_SYMBOL_KEY = "tsrx.storage/1";
|
|
75
78
|
declare function storageAttributeName(driverKey: string): string;
|
|
76
|
-
declare function isValidStorageKey(value: string): boolean;
|
|
77
79
|
type StorageSeedMetadata = {
|
|
78
80
|
readonly slotKey: string;
|
|
79
81
|
readonly driverKey: string;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ASYNC_PROTOCOL_VERSION, STORAGE_PROTOCOL_VERSION } from "./protocol.js";
|
|
2
2
|
import { deserializeGraphValue } from "./decode.js";
|
|
3
|
-
import { a as decodePayloadScripts, c as
|
|
3
|
+
import { a as decodePayloadScripts, c as isValidStorageKey, i as assertProtocolViewPayload, n as assertProtocolStateCellPayload, o as payloadInvalidError, r as assertProtocolStatePayload, s as payloadScriptSelector, t as RuntimePayloadError } from "./protocol-validation-BzwtRg-T.js";
|
|
4
4
|
//#region src/payload-scripts.ts
|
|
5
5
|
function renderPayloadScripts(input) {
|
|
6
6
|
return {
|
|
@@ -401,4 +401,30 @@ function protocolStateSerializationError(cell, diagnostic) {
|
|
|
401
401
|
});
|
|
402
402
|
}
|
|
403
403
|
//#endregion
|
|
404
|
+
//#region src/storage-slot.ts
|
|
405
|
+
const STORAGE_SLOT_SYMBOL_KEY = "tsrx.storage/1";
|
|
406
|
+
function storageAttributeName(driverKey) {
|
|
407
|
+
return `data-${driverKey.replace(/[^A-Za-z0-9-]+/g, "-")}`;
|
|
408
|
+
}
|
|
409
|
+
function storageSlotEntryKey(moduleId, key) {
|
|
410
|
+
return `${moduleId}#${key}`;
|
|
411
|
+
}
|
|
412
|
+
function storageSlotEntryKeyFromGraphNodeId(graphNodeId) {
|
|
413
|
+
return graphNodeId.startsWith("storage:") ? graphNodeId.slice(8) : graphNodeId;
|
|
414
|
+
}
|
|
415
|
+
function createStorageSeedMetadata(moduleId, driverKey, fallback) {
|
|
416
|
+
return {
|
|
417
|
+
slotKey: storageSlotEntryKey(moduleId, driverKey),
|
|
418
|
+
driverKey,
|
|
419
|
+
fallback
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
function createStorageSeedMetadataFromGraphNodeId(graphNodeId, driverKey, fallback) {
|
|
423
|
+
return {
|
|
424
|
+
slotKey: storageSlotEntryKeyFromGraphNodeId(graphNodeId),
|
|
425
|
+
driverKey,
|
|
426
|
+
fallback
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
//#endregion
|
|
404
430
|
export { ASYNC_PROTOCOL_VERSION, ProtocolStateSerializationError, RuntimePayloadError, STORAGE_PROTOCOL_VERSION, STORAGE_SLOT_SYMBOL_KEY, assertProtocolStateCellPayload, assertProtocolStatePayload, assertProtocolViewPayload, createProtocolStatePayload, createStorageSeedMetadata, createStorageSeedMetadataFromGraphNodeId, decodePayloadScripts, deserializeGraphValue, isValidStorageKey, payloadInvalidError, payloadScriptSelector, renderPayloadScripts, serializeGraphValue, serializeRuntimeAsyncSnapshots, serializeRuntimeStateCells, storageAttributeName, storageSlotEntryKey, storageSlotEntryKeyFromGraphNodeId };
|
|
@@ -1,33 +1,9 @@
|
|
|
1
1
|
import "./protocol.js";
|
|
2
|
-
//#region src/storage-
|
|
3
|
-
const STORAGE_SLOT_SYMBOL_KEY = "tsrx.storage/1";
|
|
4
|
-
function storageAttributeName(driverKey) {
|
|
5
|
-
return `data-${driverKey.replace(/[^A-Za-z0-9-]+/g, "-")}`;
|
|
6
|
-
}
|
|
2
|
+
//#region src/storage-key.ts
|
|
7
3
|
const STORAGE_KEY_PATTERN = /^[A-Za-z0-9$_:.-]+$/;
|
|
8
4
|
function isValidStorageKey(value) {
|
|
9
5
|
return STORAGE_KEY_PATTERN.test(value);
|
|
10
6
|
}
|
|
11
|
-
function storageSlotEntryKey(moduleId, key) {
|
|
12
|
-
return `${moduleId}#${key}`;
|
|
13
|
-
}
|
|
14
|
-
function storageSlotEntryKeyFromGraphNodeId(graphNodeId) {
|
|
15
|
-
return graphNodeId.startsWith("storage:") ? graphNodeId.slice(8) : graphNodeId;
|
|
16
|
-
}
|
|
17
|
-
function createStorageSeedMetadata(moduleId, driverKey, fallback) {
|
|
18
|
-
return {
|
|
19
|
-
slotKey: storageSlotEntryKey(moduleId, driverKey),
|
|
20
|
-
driverKey,
|
|
21
|
-
fallback
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
function createStorageSeedMetadataFromGraphNodeId(graphNodeId, driverKey, fallback) {
|
|
25
|
-
return {
|
|
26
|
-
slotKey: storageSlotEntryKeyFromGraphNodeId(graphNodeId),
|
|
27
|
-
driverKey,
|
|
28
|
-
fallback
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
7
|
//#endregion
|
|
32
8
|
//#region src/protocol-validation.ts
|
|
33
9
|
var RuntimePayloadError = class extends Error {
|
|
@@ -696,4 +672,4 @@ function payloadScriptSelector(type) {
|
|
|
696
672
|
return `script[type="${type}"]`;
|
|
697
673
|
}
|
|
698
674
|
//#endregion
|
|
699
|
-
export { decodePayloadScripts as a,
|
|
675
|
+
export { decodePayloadScripts as a, isValidStorageKey as c, assertProtocolViewPayload as i, assertProtocolStateCellPayload as n, payloadInvalidError as o, assertProtocolStatePayload as r, payloadScriptSelector as s, RuntimePayloadError as t };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import "./protocol.js";
|
|
2
|
-
import { a as decodePayloadScripts, i as assertProtocolViewPayload, n as assertProtocolStateCellPayload, o as payloadInvalidError, r as assertProtocolStatePayload, s as payloadScriptSelector, t as RuntimePayloadError } from "./protocol-validation-
|
|
2
|
+
import { a as decodePayloadScripts, i as assertProtocolViewPayload, n as assertProtocolStateCellPayload, o as payloadInvalidError, r as assertProtocolStatePayload, s as payloadScriptSelector, t as RuntimePayloadError } from "./protocol-validation-BzwtRg-T.js";
|
|
3
3
|
export { RuntimePayloadError, assertProtocolStateCellPayload, assertProtocolStatePayload, assertProtocolViewPayload, decodePayloadScripts, payloadInvalidError, payloadScriptSelector };
|