@asyra/props-manager 0.2.5 → 0.5.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/LICENSE +21 -0
- package/README.md +13 -1
- package/dist/components/base.d.ts +12 -2
- package/dist/components/base.d.ts.map +1 -1
- package/dist/components/base.js +78 -4
- package/dist/components/base.js.map +1 -1
- package/dist/components/index.d.ts +4 -4
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +2 -3
- package/dist/components/index.js.map +1 -1
- package/dist/components/props-change-handler.d.ts +2 -1
- package/dist/components/props-change-handler.d.ts.map +1 -1
- package/dist/components/props-change-handler.js +2 -3
- package/dist/components/props-change-handler.js.map +1 -1
- package/dist/factories/create-property.d.ts +6 -0
- package/dist/factories/create-property.d.ts.map +1 -0
- package/dist/factories/create-property.js +24 -0
- package/dist/factories/create-property.js.map +1 -0
- package/dist/index.d.ts +19 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -3
- package/dist/index.js.map +1 -1
- package/dist/manager/component-accessor.d.ts +12 -0
- package/dist/manager/component-accessor.d.ts.map +1 -0
- package/dist/manager/component-accessor.js +23 -0
- package/dist/manager/component-accessor.js.map +1 -0
- package/dist/manager/props-manager.d.ts +209 -0
- package/dist/manager/props-manager.d.ts.map +1 -0
- package/dist/manager/props-manager.js +3848 -0
- package/dist/manager/props-manager.js.map +1 -0
- package/dist/manager/subscribes.d.ts.map +1 -0
- package/dist/manager/subscribes.js +76 -0
- package/dist/manager/subscribes.js.map +1 -0
- package/dist/registries/declarative-property-type.d.ts +39 -0
- package/dist/registries/declarative-property-type.d.ts.map +1 -0
- package/dist/registries/declarative-property-type.js +482 -0
- package/dist/registries/declarative-property-type.js.map +1 -0
- package/dist/registries/property-component.d.ts +50 -0
- package/dist/registries/property-component.d.ts.map +1 -0
- package/dist/registries/property-component.js +151 -0
- package/dist/registries/property-component.js.map +1 -0
- package/dist/registries/property-definition-value.d.ts +5 -0
- package/dist/registries/property-definition-value.d.ts.map +1 -0
- package/dist/registries/property-definition-value.js +19 -0
- package/dist/registries/property-definition-value.js.map +1 -0
- package/dist/registries/property-definition.d.ts +48 -0
- package/dist/registries/property-definition.d.ts.map +1 -0
- package/dist/registries/property-definition.js +107 -0
- package/dist/registries/property-definition.js.map +1 -0
- package/dist/registries/property-registration.d.ts +36 -0
- package/dist/registries/property-registration.d.ts.map +1 -0
- package/dist/registries/property-registration.js +61 -0
- package/dist/registries/property-registration.js.map +1 -0
- package/dist/registries/property-schema.d.ts +19 -0
- package/dist/registries/property-schema.d.ts.map +1 -0
- package/dist/registries/property-schema.js +75 -0
- package/dist/registries/property-schema.js.map +1 -0
- package/dist/registries/property-value-kind.d.ts +3 -0
- package/dist/registries/property-value-kind.d.ts.map +1 -0
- package/dist/registries/property-value-kind.js +18 -0
- package/dist/registries/property-value-kind.js.map +1 -0
- package/dist/registries/registration-options.d.ts +4 -0
- package/dist/registries/registration-options.d.ts.map +1 -0
- package/dist/registries/registration-options.js +2 -0
- package/dist/registries/registration-options.js.map +1 -0
- package/dist/registries/state.d.ts +14 -0
- package/dist/registries/state.d.ts.map +1 -0
- package/dist/registries/state.js +53 -0
- package/dist/registries/state.js.map +1 -0
- package/package.json +24 -4
- package/.turbo/turbo-test$colon$ci.log +0 -130
- package/.turbo/turbo-test$colon$local.log +0 -50
- package/.turbo/turbo-test.log +0 -0
- package/CHANGELOG.md +0 -46
- package/coverage/base.css +0 -224
- package/coverage/block-navigation.js +0 -87
- package/coverage/clover.xml +0 -368
- package/coverage/coverage-final.json +0 -5904
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +0 -131
- package/coverage/prettify.css +0 -1
- package/coverage/prettify.js +0 -2
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +0 -196
- package/coverage/src/components/base.ts.html +0 -262
- package/coverage/src/components/dimension.ts.html +0 -253
- package/coverage/src/components/index.html +0 -176
- package/coverage/src/components/index.ts.html +0 -106
- package/coverage/src/components/position.ts.html +0 -250
- package/coverage/src/components/props-change-handler.ts.html +0 -145
- package/coverage/src/index.html +0 -161
- package/coverage/src/index.ts.html +0 -106
- package/coverage/src/props-manager.ts.html +0 -574
- package/coverage/src/subscribes.ts.html +0 -247
- package/coverage/src/utils.ts.html +0 -226
- package/dist/__tests__/props-manager.test.d.ts +0 -2
- package/dist/__tests__/props-manager.test.d.ts.map +0 -1
- package/dist/__tests__/props-manager.test.js +0 -290
- package/dist/__tests__/props-manager.test.js.map +0 -1
- package/dist/components/dimension.d.ts +0 -12
- package/dist/components/dimension.d.ts.map +0 -1
- package/dist/components/dimension.js +0 -43
- package/dist/components/dimension.js.map +0 -1
- package/dist/components/position.d.ts +0 -12
- package/dist/components/position.d.ts.map +0 -1
- package/dist/components/position.js +0 -42
- package/dist/components/position.js.map +0 -1
- package/dist/props-manager.d.ts +0 -28
- package/dist/props-manager.d.ts.map +0 -1
- package/dist/props-manager.js +0 -120
- package/dist/props-manager.js.map +0 -1
- package/dist/subscribes.d.ts.map +0 -1
- package/dist/subscribes.js +0 -35
- package/dist/subscribes.js.map +0 -1
- package/dist/utils.d.ts +0 -3
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -31
- package/dist/utils.js.map +0 -1
- package/src/__tests__/props-manager.test.ts +0 -362
- package/src/components/base.ts +0 -59
- package/src/components/dimension.ts +0 -56
- package/src/components/index.ts +0 -7
- package/src/components/position.ts +0 -55
- package/src/components/props-change-handler.ts +0 -20
- package/src/index.ts +0 -7
- package/src/props-manager.ts +0 -163
- package/src/subscribes.ts +0 -54
- package/src/utils.ts +0 -47
- package/tsconfig.json +0 -17
- /package/dist/{subscribes.d.ts → manager/subscribes.d.ts} +0 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { MapRegistry, isRecord } from '@asyra/utils';
|
|
2
|
+
import { clonePropertyDefinitionRecord } from './property-definition-value.js';
|
|
3
|
+
export const resolvePropertyComponentConfigRoles = (config) => {
|
|
4
|
+
const defaults = isRecord(config.defaults) ? config.defaults : {};
|
|
5
|
+
const inferredPersistKeys = Object.keys(defaults);
|
|
6
|
+
if (config.children && !inferredPersistKeys.includes(config.children.key)) {
|
|
7
|
+
inferredPersistKeys.push(config.children.key);
|
|
8
|
+
}
|
|
9
|
+
const persistKeys = config.persistKeys ?? inferredPersistKeys;
|
|
10
|
+
const unitKeys = config.unitKeys ?? persistKeys.filter((key) => key.endsWith('Unit'));
|
|
11
|
+
const valueKeys = config.valueKeys ?? persistKeys.filter((key) => !unitKeys.includes(key));
|
|
12
|
+
return { defaults, persistKeys, valueKeys, unitKeys };
|
|
13
|
+
};
|
|
14
|
+
const batchRebindablePropertyComponentRelations = new WeakMap();
|
|
15
|
+
export const markPropertyComponentBatchRebindable = (component, relation) => {
|
|
16
|
+
if (relation) {
|
|
17
|
+
batchRebindablePropertyComponentRelations.set(component, { ...relation });
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
batchRebindablePropertyComponentRelations.delete(component);
|
|
21
|
+
};
|
|
22
|
+
export const getPropertyComponentBatchRebindableRelation = (component) => {
|
|
23
|
+
const relation = batchRebindablePropertyComponentRelations.get(component);
|
|
24
|
+
return relation ? { ...relation } : undefined;
|
|
25
|
+
};
|
|
26
|
+
export const arePropertyChildRelationsEqual = (left, right) => {
|
|
27
|
+
if (!left || !right) {
|
|
28
|
+
return left === right;
|
|
29
|
+
}
|
|
30
|
+
return (left.key === right.key &&
|
|
31
|
+
left.childType === right.childType &&
|
|
32
|
+
(left.mode ?? 'ids') === (right.mode ?? 'ids') &&
|
|
33
|
+
(left.collection ?? 'array') === (right.collection ?? 'array') &&
|
|
34
|
+
left.toChildData === right.toChildData &&
|
|
35
|
+
left.toValue === right.toValue);
|
|
36
|
+
};
|
|
37
|
+
export const isPropertyComponentBatchRebindable = (component, relation) => arePropertyChildRelationsEqual(batchRebindablePropertyComponentRelations.get(component), relation);
|
|
38
|
+
class PropertyComponentRegistry {
|
|
39
|
+
constructor() {
|
|
40
|
+
this.registry = new MapRegistry();
|
|
41
|
+
this.configDefinitions = new Map();
|
|
42
|
+
this.canonicalChildRelations = new Map();
|
|
43
|
+
this.registrationRevisions = new Map();
|
|
44
|
+
}
|
|
45
|
+
bumpRegistrationRevision(type) {
|
|
46
|
+
this.registrationRevisions.set(type, (this.registrationRevisions.get(type) ?? 0) + 1);
|
|
47
|
+
}
|
|
48
|
+
register(type, component, options = {}, configDefinition, canonicalChildRelation) {
|
|
49
|
+
if (!type) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const configChildRelation = configDefinition?.children;
|
|
53
|
+
if (configChildRelation &&
|
|
54
|
+
canonicalChildRelation &&
|
|
55
|
+
!arePropertyChildRelationsEqual(configChildRelation, canonicalChildRelation)) {
|
|
56
|
+
throw new Error(`Property component "${type}" has incoherent canonical child metadata`);
|
|
57
|
+
}
|
|
58
|
+
const childRelation = canonicalChildRelation ?? configChildRelation;
|
|
59
|
+
this.registry.register(type, component, {
|
|
60
|
+
duplicateErrorMessage: options.duplicateErrorMessage ??
|
|
61
|
+
`Property component "${type}" is already registered`
|
|
62
|
+
});
|
|
63
|
+
if (canonicalChildRelation) {
|
|
64
|
+
markPropertyComponentBatchRebindable(component, canonicalChildRelation);
|
|
65
|
+
}
|
|
66
|
+
if (childRelation) {
|
|
67
|
+
this.canonicalChildRelations.set(type, { ...childRelation });
|
|
68
|
+
}
|
|
69
|
+
if (configDefinition) {
|
|
70
|
+
this.configDefinitions.set(type, clonePropertyComponentConfigRegistration(configDefinition));
|
|
71
|
+
}
|
|
72
|
+
this.bumpRegistrationRevision(type);
|
|
73
|
+
}
|
|
74
|
+
get(type) {
|
|
75
|
+
return this.registry.get(type);
|
|
76
|
+
}
|
|
77
|
+
has(type) {
|
|
78
|
+
return this.registry.has(type);
|
|
79
|
+
}
|
|
80
|
+
getConfigDefinition(type) {
|
|
81
|
+
const definition = this.configDefinitions.get(type);
|
|
82
|
+
return definition
|
|
83
|
+
? clonePropertyComponentConfigRegistration(definition)
|
|
84
|
+
: undefined;
|
|
85
|
+
}
|
|
86
|
+
getCanonicalChildRelation(type) {
|
|
87
|
+
const relation = this.canonicalChildRelations.get(type);
|
|
88
|
+
return relation ? { ...relation } : undefined;
|
|
89
|
+
}
|
|
90
|
+
getRegistrationRevision(type) {
|
|
91
|
+
return this.registrationRevisions.get(type) ?? 0;
|
|
92
|
+
}
|
|
93
|
+
unregister(type) {
|
|
94
|
+
const removedConfig = this.configDefinitions.delete(type);
|
|
95
|
+
const removedCanonicalRelation = this.canonicalChildRelations.delete(type);
|
|
96
|
+
const removedComponent = this.registry.delete(type);
|
|
97
|
+
if (removedConfig || removedCanonicalRelation || removedComponent) {
|
|
98
|
+
this.bumpRegistrationRevision(type);
|
|
99
|
+
}
|
|
100
|
+
return removedComponent;
|
|
101
|
+
}
|
|
102
|
+
restoreAfterFailedDeclarativeCommit(type, component, configDefinition) {
|
|
103
|
+
this.registry.set(type, component);
|
|
104
|
+
this.configDefinitions.set(type, clonePropertyComponentConfigRegistration(configDefinition));
|
|
105
|
+
const childRelation = configDefinition.children;
|
|
106
|
+
if (childRelation) {
|
|
107
|
+
this.canonicalChildRelations.set(type, { ...childRelation });
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
this.canonicalChildRelations.delete(type);
|
|
111
|
+
}
|
|
112
|
+
this.bumpRegistrationRevision(type);
|
|
113
|
+
}
|
|
114
|
+
clear() {
|
|
115
|
+
const clearedTypes = this.registry.keys();
|
|
116
|
+
this.registry.clear();
|
|
117
|
+
this.configDefinitions.clear();
|
|
118
|
+
this.canonicalChildRelations.clear();
|
|
119
|
+
clearedTypes.forEach((type) => {
|
|
120
|
+
this.bumpRegistrationRevision(type);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
export const clonePropertyComponentConfigRegistration = (definition) => ({
|
|
125
|
+
...definition,
|
|
126
|
+
defaults: clonePropertyDefinitionRecord(definition.defaults),
|
|
127
|
+
persistKeys: definition.persistKeys ? [...definition.persistKeys] : undefined,
|
|
128
|
+
valueKeys: definition.valueKeys ? [...definition.valueKeys] : undefined,
|
|
129
|
+
unitKeys: definition.unitKeys ? [...definition.unitKeys] : undefined,
|
|
130
|
+
dynamicReservedKeys: definition.dynamicReservedKeys
|
|
131
|
+
? [...definition.dynamicReservedKeys]
|
|
132
|
+
: undefined,
|
|
133
|
+
children: definition.children ? { ...definition.children } : undefined
|
|
134
|
+
});
|
|
135
|
+
const propertyComponentRegistryOwner = new PropertyComponentRegistry();
|
|
136
|
+
export const propertyComponentRegistry = {
|
|
137
|
+
register: propertyComponentRegistryOwner.register.bind(propertyComponentRegistryOwner),
|
|
138
|
+
get: propertyComponentRegistryOwner.get.bind(propertyComponentRegistryOwner),
|
|
139
|
+
has: propertyComponentRegistryOwner.has.bind(propertyComponentRegistryOwner),
|
|
140
|
+
getConfigDefinition: propertyComponentRegistryOwner.getConfigDefinition.bind(propertyComponentRegistryOwner),
|
|
141
|
+
unregister: propertyComponentRegistryOwner.unregister.bind(propertyComponentRegistryOwner),
|
|
142
|
+
clear: propertyComponentRegistryOwner.clear.bind(propertyComponentRegistryOwner)
|
|
143
|
+
};
|
|
144
|
+
export const registerPropertyComponent = (type, component, options, configDefinition, canonicalChildRelation) => propertyComponentRegistry.register(type, component, options, configDefinition, canonicalChildRelation);
|
|
145
|
+
export const getPropertyComponent = (type) => propertyComponentRegistry.get(type);
|
|
146
|
+
export const getPropertyComponentConfigDefinition = (type) => propertyComponentRegistry.getConfigDefinition(type);
|
|
147
|
+
export const getPropertyComponentCanonicalChildRelation = (type) => propertyComponentRegistryOwner.getCanonicalChildRelation(type);
|
|
148
|
+
export const getPropertyComponentRegistrationRevision = (type) => propertyComponentRegistryOwner.getRegistrationRevision(type);
|
|
149
|
+
export const unregisterPropertyComponent = (type) => propertyComponentRegistry.unregister(type);
|
|
150
|
+
export const restorePropertyComponentAfterFailedDeclarativeCommit = (type, component, configDefinition) => propertyComponentRegistryOwner.restoreAfterFailedDeclarativeCommit(type, component, configDefinition);
|
|
151
|
+
//# sourceMappingURL=property-component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"property-component.js","sourceRoot":"","sources":["../../src/registries/property-component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAEpD,OAAO,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAA;AA6B9E,MAAM,CAAC,MAAM,mCAAmC,GAAG,CACjD,MAA2C,EAC3C,EAAE;IACF,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAA;IACjE,MAAM,mBAAmB,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IACjD,IAAI,MAAM,CAAC,QAAQ,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1E,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;IAC/C,CAAC;IACD,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,IAAI,mBAAmB,CAAA;IAC7D,MAAM,QAAQ,GACZ,MAAM,CAAC,QAAQ,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAA;IACtE,MAAM,SAAS,GACb,MAAM,CAAC,SAAS,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAA;IAC1E,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAA;AACvD,CAAC,CAAA;AAED,MAAM,yCAAyC,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MAAM,CAAC,MAAM,yBAAyB,GAAG,CACvC,IAAY,EACZ,SAAuC,EACvC,OAAqC,EACrC,gBAAsD,EACtD,sBAAwD,EACxD,EAAE,CACF,yBAAyB,CAAC,QAAQ,CAChC,IAAI,EACJ,SAAS,EACT,OAAO,EACP,gBAAgB,EAChB,sBAAsB,CACvB,CAAA;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,IAAY,EAAE,EAAE,CACnD,yBAAyB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;AAErC,MAAM,CAAC,MAAM,oCAAoC,GAAG,CAAC,IAAY,EAAE,EAAE,CACnE,yBAAyB,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAA;AAErD,MAAM,CAAC,MAAM,0CAA0C,GAAG,CAAC,IAAY,EAAE,EAAE,CACzE,8BAA8B,CAAC,yBAAyB,CAAC,IAAI,CAAC,CAAA;AAEhE,MAAM,CAAC,MAAM,wCAAwC,GAAG,CAAC,IAAY,EAAE,EAAE,CACvE,8BAA8B,CAAC,uBAAuB,CAAC,IAAI,CAAC,CAAA;AAE9D,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,IAAY,EAAW,EAAE,CACnE,yBAAyB,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;AAE5C,MAAM,CAAC,MAAM,oDAAoD,GAAG,CAClE,IAAY,EACZ,SAAuC,EACvC,gBAAqD,EAC/C,EAAE,CACR,8BAA8B,CAAC,mCAAmC,CAChE,IAAI,EACJ,SAAS,EACT,gBAAgB,CACjB,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const clonePropertyDefinitionValue: (value: unknown) => unknown;
|
|
2
|
+
export declare function clonePropertyDefinitionRecord(value: Record<string, unknown>): Record<string, unknown>;
|
|
3
|
+
export declare function clonePropertyDefinitionRecord(value: undefined): undefined;
|
|
4
|
+
export declare function clonePropertyDefinitionRecord(value: Record<string, unknown> | undefined): Record<string, unknown> | undefined;
|
|
5
|
+
//# sourceMappingURL=property-definition-value.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"property-definition-value.d.ts","sourceRoot":"","sources":["../../src/registries/property-definition-value.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,4BAA4B,GAAI,OAAO,OAAO,KAAG,OAgB7D,CAAA;AAED,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAC1B,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,CAAA;AAC1E,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GACzC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { isRecord } from '@asyra/utils';
|
|
2
|
+
export const clonePropertyDefinitionValue = (value) => {
|
|
3
|
+
if (Array.isArray(value)) {
|
|
4
|
+
return value.map((item) => clonePropertyDefinitionValue(item));
|
|
5
|
+
}
|
|
6
|
+
if (isRecord(value)) {
|
|
7
|
+
return Object.entries(value).reduce((cloned, [key, item]) => {
|
|
8
|
+
cloned[key] = clonePropertyDefinitionValue(item);
|
|
9
|
+
return cloned;
|
|
10
|
+
}, {});
|
|
11
|
+
}
|
|
12
|
+
return value;
|
|
13
|
+
};
|
|
14
|
+
export function clonePropertyDefinitionRecord(value) {
|
|
15
|
+
return value
|
|
16
|
+
? clonePropertyDefinitionValue(value)
|
|
17
|
+
: undefined;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=property-definition-value.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"property-definition-value.js","sourceRoot":"","sources":["../../src/registries/property-definition-value.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAEvC,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,KAAc,EAAW,EAAE;IACtE,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,4BAA4B,CAAC,IAAI,CAAC,CAAC,CAAA;IAChE,CAAC;IAED,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACpB,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CACjC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE;YACtB,MAAM,CAAC,GAAG,CAAC,GAAG,4BAA4B,CAAC,IAAI,CAAC,CAAA;YAChD,OAAO,MAAM,CAAA;QACf,CAAC,EACD,EAAE,CACH,CAAA;IACH,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AASD,MAAM,UAAU,6BAA6B,CAC3C,KAA0C;IAE1C,OAAO,KAAK;QACV,CAAC,CAAE,4BAA4B,CAAC,KAAK,CAA6B;QAClE,CAAC,CAAC,SAAS,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { PropertySchema } from '@asyra/utils';
|
|
2
|
+
interface PropertyDefinition {
|
|
3
|
+
name: string;
|
|
4
|
+
type: string;
|
|
5
|
+
alias?: string[];
|
|
6
|
+
defaultValue?: unknown;
|
|
7
|
+
schema?: PropertySchema;
|
|
8
|
+
}
|
|
9
|
+
declare class ElementPropertyRegistry {
|
|
10
|
+
private registry;
|
|
11
|
+
private definitionsByComponent;
|
|
12
|
+
/**
|
|
13
|
+
* Register a property type
|
|
14
|
+
* @param definition - Property definition
|
|
15
|
+
* @param componentType - Component type that uses this property
|
|
16
|
+
*/
|
|
17
|
+
register(definition: PropertyDefinition, componentType: string): void;
|
|
18
|
+
/**
|
|
19
|
+
* Get property definition by name
|
|
20
|
+
*/
|
|
21
|
+
get(name: string): PropertyDefinition | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Get the exact definition declared by one component.
|
|
24
|
+
*/
|
|
25
|
+
getForComponent(componentType: string, name: string): PropertyDefinition | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Get all properties for a component type
|
|
28
|
+
*/
|
|
29
|
+
getPropertiesForComponent(componentType: string): PropertyDefinition[];
|
|
30
|
+
/**
|
|
31
|
+
* Check if property exists
|
|
32
|
+
*/
|
|
33
|
+
has(name: string): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Get component types that currently own a property definition.
|
|
36
|
+
*/
|
|
37
|
+
getComponentTypesForProperty(name: string): string[];
|
|
38
|
+
unregisterRelation(componentType: string, name: string): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Unregister all properties for a component type
|
|
41
|
+
*/
|
|
42
|
+
unregisterComponent(componentType: string): void;
|
|
43
|
+
private removeReverseOwner;
|
|
44
|
+
}
|
|
45
|
+
export declare const elementPropertyRegistry: ElementPropertyRegistry;
|
|
46
|
+
export default elementPropertyRegistry;
|
|
47
|
+
export type { PropertyDefinition };
|
|
48
|
+
//# sourceMappingURL=property-definition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"property-definition.d.ts","sourceRoot":"","sources":["../../src/registries/property-definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAElD,UAAU,kBAAkB;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAChB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,MAAM,CAAC,EAAE,cAAc,CAAA;CACxB;AAOD,cAAM,uBAAuB;IAC3B,OAAO,CAAC,QAAQ,CAAwC;IACxD,OAAO,CAAC,sBAAsB,CAG3B;IAEH;;;;OAIG;IACH,QAAQ,CAAC,UAAU,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,GAAG,IAAI;IAsBrE;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS;IAIjD;;OAEG;IACH,eAAe,CACb,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,MAAM,GACX,kBAAkB,GAAG,SAAS;IAIjC;;OAEG;IACH,yBAAyB,CAAC,aAAa,EAAE,MAAM,GAAG,kBAAkB,EAAE;IAMtE;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B;;OAEG;IACH,4BAA4B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE;IASpD,kBAAkB,CAAC,aAAa,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO;IAahE;;OAEG;IACH,mBAAmB,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI;IAYhD,OAAO,CAAC,kBAAkB;CAgB3B;AAED,eAAO,MAAM,uBAAuB,yBAAgC,CAAA;AACpE,eAAe,uBAAuB,CAAA;AACtC,YAAY,EAAE,kBAAkB,EAAE,CAAA"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
class ElementPropertyRegistry {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.registry = new Map();
|
|
4
|
+
this.definitionsByComponent = new Map();
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Register a property type
|
|
8
|
+
* @param definition - Property definition
|
|
9
|
+
* @param componentType - Component type that uses this property
|
|
10
|
+
*/
|
|
11
|
+
register(definition, componentType) {
|
|
12
|
+
let componentDefinitions = this.definitionsByComponent.get(componentType);
|
|
13
|
+
if (!componentDefinitions) {
|
|
14
|
+
componentDefinitions = new Map();
|
|
15
|
+
this.definitionsByComponent.set(componentType, componentDefinitions);
|
|
16
|
+
}
|
|
17
|
+
componentDefinitions.set(definition.name, definition);
|
|
18
|
+
const existing = this.registry.get(definition.name);
|
|
19
|
+
if (existing) {
|
|
20
|
+
// Add component type to existing property
|
|
21
|
+
existing.componentTypes.add(componentType);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
// Create new property registration
|
|
25
|
+
this.registry.set(definition.name, {
|
|
26
|
+
definition,
|
|
27
|
+
componentTypes: new Set([componentType])
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Get property definition by name
|
|
33
|
+
*/
|
|
34
|
+
get(name) {
|
|
35
|
+
return this.registry.get(name)?.definition;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Get the exact definition declared by one component.
|
|
39
|
+
*/
|
|
40
|
+
getForComponent(componentType, name) {
|
|
41
|
+
return this.definitionsByComponent.get(componentType)?.get(name);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Get all properties for a component type
|
|
45
|
+
*/
|
|
46
|
+
getPropertiesForComponent(componentType) {
|
|
47
|
+
return Array.from(this.definitionsByComponent.get(componentType)?.values() ?? []);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Check if property exists
|
|
51
|
+
*/
|
|
52
|
+
has(name) {
|
|
53
|
+
return this.registry.has(name);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Get component types that currently own a property definition.
|
|
57
|
+
*/
|
|
58
|
+
getComponentTypesForProperty(name) {
|
|
59
|
+
const registered = this.registry.get(name);
|
|
60
|
+
if (!registered) {
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
63
|
+
return Array.from(registered.componentTypes).sort();
|
|
64
|
+
}
|
|
65
|
+
unregisterRelation(componentType, name) {
|
|
66
|
+
const componentDefinitions = this.definitionsByComponent.get(componentType);
|
|
67
|
+
if (!componentDefinitions?.delete(name)) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
if (componentDefinitions.size === 0) {
|
|
71
|
+
this.definitionsByComponent.delete(componentType);
|
|
72
|
+
}
|
|
73
|
+
this.removeReverseOwner(name, componentType);
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Unregister all properties for a component type
|
|
78
|
+
*/
|
|
79
|
+
unregisterComponent(componentType) {
|
|
80
|
+
const definitions = this.definitionsByComponent.get(componentType);
|
|
81
|
+
if (!definitions) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
for (const name of definitions.keys()) {
|
|
85
|
+
this.removeReverseOwner(name, componentType);
|
|
86
|
+
}
|
|
87
|
+
this.definitionsByComponent.delete(componentType);
|
|
88
|
+
}
|
|
89
|
+
removeReverseOwner(name, componentType) {
|
|
90
|
+
const registered = this.registry.get(name);
|
|
91
|
+
if (!registered)
|
|
92
|
+
return;
|
|
93
|
+
registered.componentTypes.delete(componentType);
|
|
94
|
+
if (registered.componentTypes.size === 0) {
|
|
95
|
+
this.registry.delete(name);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const nextOwner = Array.from(registered.componentTypes).sort()[0];
|
|
99
|
+
const nextDefinition = this.definitionsByComponent.get(nextOwner)?.get(name);
|
|
100
|
+
if (nextDefinition) {
|
|
101
|
+
registered.definition = nextDefinition;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
export const elementPropertyRegistry = new ElementPropertyRegistry();
|
|
106
|
+
export default elementPropertyRegistry;
|
|
107
|
+
//# sourceMappingURL=property-definition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"property-definition.js","sourceRoot":"","sources":["../../src/registries/property-definition.ts"],"names":[],"mappings":"AAeA,MAAM,uBAAuB;IAA7B;QACU,aAAQ,GAAG,IAAI,GAAG,EAA8B,CAAA;QAChD,2BAAsB,GAAG,IAAI,GAAG,EAGrC,CAAA;IAsHL,CAAC;IApHC;;;;OAIG;IACH,QAAQ,CAAC,UAA8B,EAAE,aAAqB;QAC5D,IAAI,oBAAoB,GAAG,IAAI,CAAC,sBAAsB,CAAC,GAAG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AG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QAC1C,IAAI,CAAC,UAAU;YAAE,OAAM;QAEvB,UAAU,CAAC,cAAc,CAAC,MAAM,CAAC,aAAa,CAAC,CAAA;QAC/C,IAAI,UAAU,CAAC,cAAc,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;YACzC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;YAC1B,OAAM;QACR,CAAC;QAED,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;QACjE,MAAM,cAAc,GAAG,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,CAAA;QAC5E,IAAI,cAAc,EAAE,CAAC;YACnB,UAAU,CAAC,UAAU,GAAG,cAAc,CAAA;QACxC,CAAC;IACH,CAAC;CACF;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,uBAAuB,EAAE,CAAA;AACpE,eAAe,uBAAuB,CAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { PropsManager } from '../manager/props-manager.js';
|
|
2
|
+
export declare const PROPERTY_REGISTRATION_ERROR_CODES: readonly ["PROPERTY_REGISTRATION_NOT_FOUND", "PROPERTY_TYPE_IN_USE"];
|
|
3
|
+
export type PropertyRegistrationErrorCode = (typeof PROPERTY_REGISTRATION_ERROR_CODES)[number];
|
|
4
|
+
export declare const PROPERTY_REGISTRATION_SCOPES: readonly ["all", "schema", "runtime"];
|
|
5
|
+
export type PropertyRegistrationScope = (typeof PROPERTY_REGISTRATION_SCOPES)[number];
|
|
6
|
+
export interface PropertyRegistrationUnregisterSuccess {
|
|
7
|
+
ok: true;
|
|
8
|
+
type: string;
|
|
9
|
+
removedSchema: boolean;
|
|
10
|
+
removedComponent: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface PropertyRegistrationUnregisterMissing {
|
|
13
|
+
ok: false;
|
|
14
|
+
code: 'PROPERTY_REGISTRATION_NOT_FOUND';
|
|
15
|
+
type: string;
|
|
16
|
+
removedSchema: false;
|
|
17
|
+
removedComponent: false;
|
|
18
|
+
}
|
|
19
|
+
export interface PropertyRegistrationInUseFailure {
|
|
20
|
+
ok: false;
|
|
21
|
+
code: 'PROPERTY_TYPE_IN_USE';
|
|
22
|
+
type: string;
|
|
23
|
+
propertyIds: readonly string[];
|
|
24
|
+
removedSchema: false;
|
|
25
|
+
removedComponent: false;
|
|
26
|
+
}
|
|
27
|
+
export type PropertyRegistrationUnregisterResult = PropertyRegistrationUnregisterSuccess | PropertyRegistrationUnregisterMissing;
|
|
28
|
+
export declare class PropertyRegistrationError extends Error {
|
|
29
|
+
readonly code: PropertyRegistrationErrorCode;
|
|
30
|
+
readonly type: string;
|
|
31
|
+
readonly propertyIds: readonly string[];
|
|
32
|
+
readonly result: PropertyRegistrationInUseFailure;
|
|
33
|
+
constructor(result: PropertyRegistrationInUseFailure);
|
|
34
|
+
}
|
|
35
|
+
export declare const unregisterPropertyRegistration: (type: string, manager?: PropsManager, scope?: PropertyRegistrationScope) => PropertyRegistrationUnregisterResult;
|
|
36
|
+
//# sourceMappingURL=property-registration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"property-registration.d.ts","sourceRoot":"","sources":["../../src/registries/property-registration.ts"],"names":[],"mappings":"AAAA,OAAqB,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAUxE,eAAO,MAAM,iCAAiC,sEAGpC,CAAA;AAEV,MAAM,MAAM,6BAA6B,GACvC,CAAC,OAAO,iCAAiC,CAAC,CAAC,MAAM,CAAC,CAAA;AAEpD,eAAO,MAAM,4BAA4B,uCAI/B,CAAA;AAEV,MAAM,MAAM,yBAAyB,GACnC,CAAC,OAAO,4BAA4B,CAAC,CAAC,MAAM,CAAC,CAAA;AAE/C,MAAM,WAAW,qCAAqC;IACpD,EAAE,EAAE,IAAI,CAAA;IACR,IAAI,EAAE,MAAM,CAAA;IACZ,aAAa,EAAE,OAAO,CAAA;IACtB,gBAAgB,EAAE,OAAO,CAAA;CAC1B;AAED,MAAM,WAAW,qCAAqC;IACpD,EAAE,EAAE,KAAK,CAAA;IACT,IAAI,EAAE,iCAAiC,CAAA;IACvC,IAAI,EAAE,MAAM,CAAA;IACZ,aAAa,EAAE,KAAK,CAAA;IACpB,gBAAgB,EAAE,KAAK,CAAA;CACxB;AAED,MAAM,WAAW,gCAAgC;IAC/C,EAAE,EAAE,KAAK,CAAA;IACT,IAAI,EAAE,sBAAsB,CAAA;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,SAAS,MAAM,EAAE,CAAA;IAC9B,aAAa,EAAE,KAAK,CAAA;IACpB,gBAAgB,EAAE,KAAK,CAAA;CACxB;AAED,MAAM,MAAM,oCAAoC,GAC5C,qCAAqC,GACrC,qCAAqC,CAAA;AAEzC,qBAAa,yBAA0B,SAAQ,KAAK;IAClD,QAAQ,CAAC,IAAI,EAAE,6BAA6B,CAAA;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAA;IACvC,QAAQ,CAAC,MAAM,EAAE,gCAAgC,CAAA;gBAErC,MAAM,EAAE,gCAAgC;CAarD;AAED,eAAO,MAAM,8BAA8B,GACzC,MAAM,MAAM,EACZ,UAAS,YAA2B,EACpC,QAAO,yBAAiC,KACvC,oCAwCF,CAAA"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import propsManager from '../manager/props-manager.js';
|
|
2
|
+
import { propertyComponentRegistry, unregisterPropertyComponent } from './property-component.js';
|
|
3
|
+
import { propertySchemaRegistry, unregisterPropertySchema } from './property-schema.js';
|
|
4
|
+
export const PROPERTY_REGISTRATION_ERROR_CODES = [
|
|
5
|
+
'PROPERTY_REGISTRATION_NOT_FOUND',
|
|
6
|
+
'PROPERTY_TYPE_IN_USE'
|
|
7
|
+
];
|
|
8
|
+
export const PROPERTY_REGISTRATION_SCOPES = [
|
|
9
|
+
'all',
|
|
10
|
+
'schema',
|
|
11
|
+
'runtime'
|
|
12
|
+
];
|
|
13
|
+
export class PropertyRegistrationError extends Error {
|
|
14
|
+
constructor(result) {
|
|
15
|
+
super(`Property registration "${result.type}" is in use by: ${result.propertyIds.join(', ')}`);
|
|
16
|
+
this.name = 'PropertyRegistrationError';
|
|
17
|
+
this.code = result.code;
|
|
18
|
+
this.type = result.type;
|
|
19
|
+
this.propertyIds = [...result.propertyIds];
|
|
20
|
+
this.result = {
|
|
21
|
+
...result,
|
|
22
|
+
propertyIds: [...result.propertyIds]
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export const unregisterPropertyRegistration = (type, manager = propsManager, scope = 'all') => {
|
|
27
|
+
const hasSchema = propertySchemaRegistry.has(type);
|
|
28
|
+
const hasComponent = propertyComponentRegistry.has(type);
|
|
29
|
+
const unregisterSchema = scope === 'all' || scope === 'schema';
|
|
30
|
+
const unregisterRuntime = scope === 'all' || scope === 'runtime';
|
|
31
|
+
const hasRequestedRegistration = (unregisterSchema && hasSchema) || (unregisterRuntime && hasComponent);
|
|
32
|
+
if (!hasRequestedRegistration) {
|
|
33
|
+
return {
|
|
34
|
+
ok: false,
|
|
35
|
+
code: 'PROPERTY_REGISTRATION_NOT_FOUND',
|
|
36
|
+
type,
|
|
37
|
+
removedSchema: false,
|
|
38
|
+
removedComponent: false
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
const propertyIds = manager.getPropertyIdsByType(type);
|
|
42
|
+
if (propertyIds.length > 0) {
|
|
43
|
+
throw new PropertyRegistrationError({
|
|
44
|
+
ok: false,
|
|
45
|
+
code: 'PROPERTY_TYPE_IN_USE',
|
|
46
|
+
type,
|
|
47
|
+
propertyIds,
|
|
48
|
+
removedSchema: false,
|
|
49
|
+
removedComponent: false
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
ok: true,
|
|
54
|
+
type,
|
|
55
|
+
removedSchema: unregisterSchema && hasSchema ? unregisterPropertySchema(type) : false,
|
|
56
|
+
removedComponent: unregisterRuntime && hasComponent
|
|
57
|
+
? unregisterPropertyComponent(type)
|
|
58
|
+
: false
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=property-registration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"property-registration.js","sourceRoot":"","sources":["../../src/registries/property-registration.ts"],"names":[],"mappings":"AAAA,OAAO,YAA8B,MAAM,6BAA6B,CAAA;AACxE,OAAO,EACL,yBAAyB,EACzB,2BAA2B,EAC5B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACzB,MAAM,sBAAsB,CAAA;AAE7B,MAAM,CAAC,MAAM,iCAAiC,GAAG;IAC/C,iCAAiC;IACjC,sBAAsB;CACd,CAAA;AAKV,MAAM,CAAC,MAAM,4BAA4B,GAAG;IAC1C,KAAK;IACL,QAAQ;IACR,SAAS;CACD,CAAA;AAiCV,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IAMlD,YAAY,MAAwC;QAClD,KAAK,CACH,0BAA0B,MAAM,CAAC,IAAI,mBAAmB,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACxF,CAAA;QACD,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAA;QACvC,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAA;QACvB,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAA;QACvB,IAAI,CAAC,WAAW,GAAG,CAAC,GAAG,MAAM,CAAC,WAAW,CAAC,CAAA;QAC1C,IAAI,CAAC,MAAM,GAAG;YACZ,GAAG,MAAM;YACT,WAAW,EAAE,CAAC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AAY;YAC/B,CAAC,CAAC,2BAA2B,CAAC,IAAI,CAAC;YACnC,CAAC,CAAC,KAAK;KACZ,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { PropertySchema } from '@asyra/utils';
|
|
2
|
+
import type { PropertyRegistrationOptions } from './registration-options.js';
|
|
3
|
+
type PropertySchemaResolver = (type: string) => PropertySchema | undefined;
|
|
4
|
+
export declare const propertySchemaRegistry: {
|
|
5
|
+
register: (schema: PropertySchema, options?: PropertyRegistrationOptions) => void;
|
|
6
|
+
get: (type: string) => PropertySchema | undefined;
|
|
7
|
+
has: (type: string) => boolean;
|
|
8
|
+
unregister: (type: string) => boolean;
|
|
9
|
+
clear: () => void;
|
|
10
|
+
};
|
|
11
|
+
export declare const registerPropertySchema: (schema: PropertySchema, options?: PropertyRegistrationOptions) => void;
|
|
12
|
+
export declare const getRegisteredPropertySchema: (type: string) => PropertySchema | undefined;
|
|
13
|
+
export declare const getPropertySchema: (type: string) => PropertySchema | undefined;
|
|
14
|
+
export declare const runWithPropertySchemaResolver: <T>(resolver: PropertySchemaResolver, callback: () => T) => T;
|
|
15
|
+
export declare const getPropertySchemaRegistrationRevision: (type: string) => number;
|
|
16
|
+
export declare const unregisterPropertySchema: (type: string) => boolean;
|
|
17
|
+
export declare const restorePropertySchemaAfterFailedDeclarativeCommit: (schema: PropertySchema) => void;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=property-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"property-schema.d.ts","sourceRoot":"","sources":["../../src/registries/property-schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAA;AAE5E,KAAK,sBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,cAAc,GAAG,SAAS,CAAA;AAgE1E,eAAO,MAAM,sBAAsB;uBAjDhB,cAAc,YAAW,2BAA2B;gBAa3D,MAAM,KAAG,cAAc,GAAG,SAAS;gBAInC,MAAM,KAAG,OAAO;uBAQT,MAAM,KAAG,OAAO;iBAaxB,IAAI;CAqBd,CAAA;AAED,eAAO,MAAM,sBAAsB,GACjC,QAAQ,cAAc,EACtB,UAAU,2BAA2B,SACc,CAAA;AAErD,eAAO,MAAM,2BAA2B,GAAI,MAAM,MAAM,+BACtB,CAAA;AAElC,eAAO,MAAM,iBAAiB,GAAI,MAAM,MAAM,+BAGP,CAAA;AAEvC,eAAO,MAAM,6BAA6B,GAAI,CAAC,EAC7C,UAAU,sBAAsB,EAChC,UAAU,MAAM,CAAC,KAChB,CAQF,CAAA;AAED,eAAO,MAAM,qCAAqC,GAAI,MAAM,MAAM,WACP,CAAA;AAE3D,eAAO,MAAM,wBAAwB,GAAI,MAAM,MAAM,KAAG,OACf,CAAA;AAEzC,eAAO,MAAM,iDAAiD,GAC5D,QAAQ,cAAc,KACrB,IACsE,CAAA"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { MapRegistry } from '@asyra/utils';
|
|
2
|
+
let scopedPropertySchemaResolver;
|
|
3
|
+
class PropertySchemaRegistry {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.registry = new MapRegistry();
|
|
6
|
+
this.registrationRevisions = new Map();
|
|
7
|
+
}
|
|
8
|
+
bumpRegistrationRevision(type) {
|
|
9
|
+
this.registrationRevisions.set(type, (this.registrationRevisions.get(type) ?? 0) + 1);
|
|
10
|
+
}
|
|
11
|
+
register(schema, options = {}) {
|
|
12
|
+
if (!schema?.type) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
this.registry.register(schema.type, schema, {
|
|
16
|
+
duplicateErrorMessage: options.duplicateErrorMessage ??
|
|
17
|
+
`Property schema "${schema.type}" is already registered`
|
|
18
|
+
});
|
|
19
|
+
this.bumpRegistrationRevision(schema.type);
|
|
20
|
+
}
|
|
21
|
+
get(type) {
|
|
22
|
+
return this.registry.get(type);
|
|
23
|
+
}
|
|
24
|
+
has(type) {
|
|
25
|
+
return this.registry.has(type);
|
|
26
|
+
}
|
|
27
|
+
getRegistrationRevision(type) {
|
|
28
|
+
return this.registrationRevisions.get(type) ?? 0;
|
|
29
|
+
}
|
|
30
|
+
unregister(type) {
|
|
31
|
+
const removed = this.registry.delete(type);
|
|
32
|
+
if (removed) {
|
|
33
|
+
this.bumpRegistrationRevision(type);
|
|
34
|
+
}
|
|
35
|
+
return removed;
|
|
36
|
+
}
|
|
37
|
+
restoreAfterFailedDeclarativeCommit(schema) {
|
|
38
|
+
this.registry.set(schema.type, schema);
|
|
39
|
+
this.bumpRegistrationRevision(schema.type);
|
|
40
|
+
}
|
|
41
|
+
clear() {
|
|
42
|
+
const clearedTypes = this.registry.keys();
|
|
43
|
+
this.registry.clear();
|
|
44
|
+
clearedTypes.forEach((type) => {
|
|
45
|
+
this.bumpRegistrationRevision(type);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const propertySchemaRegistryOwner = new PropertySchemaRegistry();
|
|
50
|
+
export const propertySchemaRegistry = {
|
|
51
|
+
register: propertySchemaRegistryOwner.register.bind(propertySchemaRegistryOwner),
|
|
52
|
+
get: propertySchemaRegistryOwner.get.bind(propertySchemaRegistryOwner),
|
|
53
|
+
has: propertySchemaRegistryOwner.has.bind(propertySchemaRegistryOwner),
|
|
54
|
+
unregister: propertySchemaRegistryOwner.unregister.bind(propertySchemaRegistryOwner),
|
|
55
|
+
clear: propertySchemaRegistryOwner.clear.bind(propertySchemaRegistryOwner)
|
|
56
|
+
};
|
|
57
|
+
export const registerPropertySchema = (schema, options) => propertySchemaRegistry.register(schema, options);
|
|
58
|
+
export const getRegisteredPropertySchema = (type) => propertySchemaRegistry.get(type);
|
|
59
|
+
export const getPropertySchema = (type) => scopedPropertySchemaResolver
|
|
60
|
+
? scopedPropertySchemaResolver(type)
|
|
61
|
+
: getRegisteredPropertySchema(type);
|
|
62
|
+
export const runWithPropertySchemaResolver = (resolver, callback) => {
|
|
63
|
+
const previousResolver = scopedPropertySchemaResolver;
|
|
64
|
+
scopedPropertySchemaResolver = resolver;
|
|
65
|
+
try {
|
|
66
|
+
return callback();
|
|
67
|
+
}
|
|
68
|
+
finally {
|
|
69
|
+
scopedPropertySchemaResolver = previousResolver;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
export const getPropertySchemaRegistrationRevision = (type) => propertySchemaRegistryOwner.getRegistrationRevision(type);
|
|
73
|
+
export const unregisterPropertySchema = (type) => propertySchemaRegistry.unregister(type);
|
|
74
|
+
export const restorePropertySchemaAfterFailedDeclarativeCommit = (schema) => propertySchemaRegistryOwner.restoreAfterFailedDeclarativeCommit(schema);
|
|
75
|
+
//# sourceMappingURL=property-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"property-schema.js","sourceRoot":"","sources":["../../src/registries/property-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAM1C,IAAI,4BAAgE,CAAA;AAEpE,MAAM,sBAAsB;IAA5B;QACU,aAAQ,GAAG,IAAI,WAAW,EAA0B,CAAA;QACpD,0BAAqB,GAAG,IAAI,GAAG,EAAkB,CAAA;IAsD3D,CAAC;IApDS,wBAAwB,CAAC,IAAY;QAC3C,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAC5B,IAAI,EACJ,CAAC,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAChD,CAAA;IACH,CAAC;IAED,QAAQ,CAAC,MAAsB,EAAE,UAAuC,EAAE;QACxE,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC;YAClB,OAAM;QACR,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE;YAC1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CAAC,CAAA;AAE3D,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,IAAY,EAAW,EAAE,CAChE,sBAAsB,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;AAEzC,MAAM,CAAC,MAAM,iDAAiD,GAAG,CAC/D,MAAsB,EAChB,EAAE,CACR,2BAA2B,CAAC,mCAAmC,CAAC,MAAM,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"property-value-kind.d.ts","sourceRoot":"","sources":["../../src/registries/property-value-kind.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAErD,eAAO,MAAM,wBAAwB,GACnC,MAAM,iBAAiB,EACvB,OAAO,OAAO,KACb,OAkBF,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const matchesPropertyValueKind = (kind, value) => {
|
|
2
|
+
switch (kind) {
|
|
3
|
+
case 'number':
|
|
4
|
+
return typeof value === 'number' && Number.isFinite(value);
|
|
5
|
+
case 'string':
|
|
6
|
+
return typeof value === 'string';
|
|
7
|
+
case 'boolean':
|
|
8
|
+
return typeof value === 'boolean';
|
|
9
|
+
case 'object':
|
|
10
|
+
return (value === null ||
|
|
11
|
+
(!!value && typeof value === 'object' && !Array.isArray(value)));
|
|
12
|
+
case 'array':
|
|
13
|
+
return Array.isArray(value);
|
|
14
|
+
case 'custom':
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=property-value-kind.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"property-value-kind.js","sourceRoot":"","sources":["../../src/registries/property-value-kind.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,IAAuB,EACvB,KAAc,EACL,EAAE;IACX,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,QAAQ;YACX,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QAC5D,KAAK,QAAQ;YACX,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAA;QAClC,KAAK,SAAS;YACZ,OAAO,OAAO,KAAK,KAAK,SAAS,CAAA;QACnC,KAAK,QAAQ;YACX,OAAO,CACL,KAAK,KAAK,IAAI;gBACd,CAAC,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAChE,CAAA;QACH,KAAK,OAAO;YACV,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QAC7B,KAAK,QAAQ;YACX,OAAO,IAAI,CAAA;IACf,CAAC;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registration-options.d.ts","sourceRoot":"","sources":["../../src/registries/registration-options.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,2BAA2B;IAC1C,qBAAqB,CAAC,EAAE,MAAM,CAAA;CAC/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registration-options.js","sourceRoot":"","sources":["../../src/registries/registration-options.ts"],"names":[],"mappings":""}
|