stickyflow 0.5.0 → 0.7.0
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/CHANGELOG.md +43 -0
- package/dist/binding/index.cjs +9 -9
- package/dist/binding/index.d.cts +4 -4
- package/dist/binding/index.d.ts +4 -4
- package/dist/binding/index.js +3 -3
- package/dist/{chunk-ZMLQIMJK.cjs → chunk-A73UJ5AQ.cjs} +1537 -738
- package/dist/chunk-A73UJ5AQ.cjs.map +1 -0
- package/dist/{chunk-VK3T6O5Z.cjs → chunk-BUOWM3LC.cjs} +745 -62
- package/dist/chunk-BUOWM3LC.cjs.map +1 -0
- package/dist/{chunk-L3VJXZFD.cjs → chunk-EKAWJFJQ.cjs} +15 -15
- package/dist/{chunk-L3VJXZFD.cjs.map → chunk-EKAWJFJQ.cjs.map} +1 -1
- package/dist/{chunk-BODZN3ZI.js → chunk-JCRPLPKV.js} +156 -23
- package/dist/chunk-JCRPLPKV.js.map +1 -0
- package/dist/{chunk-IEHE6WVN.js → chunk-JQK4IGXJ.js} +489 -51
- package/dist/chunk-JQK4IGXJ.js.map +1 -0
- package/dist/{chunk-XY2GZUHC.cjs → chunk-KXYSO6GC.cjs} +498 -50
- package/dist/chunk-KXYSO6GC.cjs.map +1 -0
- package/dist/{chunk-G7NRK5AG.js → chunk-MUKIGLR5.js} +717 -34
- package/dist/chunk-MUKIGLR5.js.map +1 -0
- package/dist/{chunk-TWDLOXRM.cjs → chunk-OWNVXKXN.cjs} +170 -37
- package/dist/chunk-OWNVXKXN.cjs.map +1 -0
- package/dist/{chunk-LTGF5OHP.js → chunk-SDMQRSRW.js} +941 -143
- package/dist/chunk-SDMQRSRW.js.map +1 -0
- package/dist/{chunk-7VW2XKVB.js → chunk-ZNHYW47T.js} +3 -3
- package/dist/{chunk-7VW2XKVB.js.map → chunk-ZNHYW47T.js.map} +1 -1
- package/dist/index.cjs +57 -29
- package/dist/index.d.cts +80 -7
- package/dist/index.d.ts +80 -7
- package/dist/index.js +5 -5
- package/dist/interaction/index.cjs +245 -235
- package/dist/interaction/index.cjs.map +1 -1
- package/dist/interaction/index.d.cts +3 -2
- package/dist/interaction/index.d.ts +3 -2
- package/dist/interaction/index.js +17 -7
- package/dist/interaction/index.js.map +1 -1
- package/dist/{render-CgX_y15a.d.ts → render-BU2uYzjG.d.cts} +40 -16
- package/dist/{render-CgX_y15a.d.cts → render-BU2uYzjG.d.ts} +40 -16
- package/dist/{runtime-reWgr7MP.d.cts → runtime-B7KiTmn8.d.cts} +2 -2
- package/dist/{runtime-DnUxca3Y.d.ts → runtime-BPzyD-Nd.d.ts} +2 -2
- package/dist/{runtimeTypes-D60w6nyF.d.cts → runtimeTypes-BIP70z72.d.cts} +3 -2
- package/dist/{runtimeTypes-CEBGueYM.d.ts → runtimeTypes-DalvhScn.d.ts} +3 -2
- package/dist/stickyflow-diagram.global.js +387 -36
- package/dist/stickyflow-diagram.global.js.map +1 -1
- package/dist/{types-DYLC_lsk.d.ts → types-DMWs27Hn.d.ts} +1 -1
- package/dist/{types-DvhMpqrL.d.cts → types-D_2NZ6lL.d.cts} +1 -1
- package/dist/viewer/index.cjs +9 -9
- package/dist/viewer/index.d.cts +5 -4
- package/dist/viewer/index.d.ts +5 -4
- package/dist/viewer/index.js +4 -4
- package/dist/web-component/index.cjs +6 -6
- package/dist/web-component/index.d.cts +2 -2
- package/dist/web-component/index.d.ts +2 -2
- package/dist/web-component/index.js +4 -4
- package/package.json +1 -1
- package/dist/chunk-BODZN3ZI.js.map +0 -1
- package/dist/chunk-G7NRK5AG.js.map +0 -1
- package/dist/chunk-IEHE6WVN.js.map +0 -1
- package/dist/chunk-LTGF5OHP.js.map +0 -1
- package/dist/chunk-TWDLOXRM.cjs.map +0 -1
- package/dist/chunk-VK3T6O5Z.cjs.map +0 -1
- package/dist/chunk-XY2GZUHC.cjs.map +0 -1
- package/dist/chunk-ZMLQIMJK.cjs.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkA73UJ5AQ_cjs = require('./chunk-A73UJ5AQ.cjs');
|
|
4
|
+
var chunkKXYSO6GC_cjs = require('./chunk-KXYSO6GC.cjs');
|
|
5
5
|
|
|
6
6
|
// src/binding/types.ts
|
|
7
7
|
var DECLARED = {
|
|
@@ -100,12 +100,12 @@ function createDataSource(initial) {
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
// src/binding/componentBinding.ts
|
|
103
|
-
var BINDABLE_COMPONENT_PROPERTIES = ["value", "disabled"];
|
|
103
|
+
var BINDABLE_COMPONENT_PROPERTIES = ["value", "valueEnd", "disabled"];
|
|
104
104
|
function acceptsUserChange(componentType) {
|
|
105
|
-
return
|
|
105
|
+
return chunkKXYSO6GC_cjs.getComponentDescriptor(componentType)?.value?.writable === true;
|
|
106
106
|
}
|
|
107
107
|
function componentStateType(componentType, state) {
|
|
108
|
-
const descriptor =
|
|
108
|
+
const descriptor = chunkKXYSO6GC_cjs.getComponentDescriptor(componentType);
|
|
109
109
|
if (state === "focused") {
|
|
110
110
|
return "boolean";
|
|
111
111
|
}
|
|
@@ -118,7 +118,10 @@ function componentPropertyType(componentType, property) {
|
|
|
118
118
|
if (property === "disabled") {
|
|
119
119
|
return "boolean";
|
|
120
120
|
}
|
|
121
|
-
|
|
121
|
+
if (property === "valueEnd") {
|
|
122
|
+
return chunkKXYSO6GC_cjs.getComponentDescriptor(componentType)?.properties.valueEnd?.type === "number" ? "number" : void 0;
|
|
123
|
+
}
|
|
124
|
+
return property === "value" ? chunkKXYSO6GC_cjs.getComponentDescriptor(componentType)?.value?.type : void 0;
|
|
122
125
|
}
|
|
123
126
|
function twoWayTargetProblem(key, expr, contracts) {
|
|
124
127
|
const target = expr.kind === "ref" ? expr.path : void 0;
|
|
@@ -262,7 +265,7 @@ function inferType(expr, scope, report) {
|
|
|
262
265
|
const name = expr.path.join(".");
|
|
263
266
|
report(
|
|
264
267
|
"unknown-reference",
|
|
265
|
-
name === "time.delta" ? "'time.delta' is only available in an onTick handler." : `Unknown reference '${name}'. Use <DataSource>.<field>, or <element>.pressed / hovered / pointer.`
|
|
268
|
+
name === "time.delta" ? "'time.delta' is only available in an onTick handler." : `Unknown reference '${name}'. Use <DataSource>.<field>, self.id, or <element>.pressed / hovered / pointer.`
|
|
266
269
|
);
|
|
267
270
|
}
|
|
268
271
|
return type;
|
|
@@ -431,12 +434,15 @@ function elementStateType(element, state) {
|
|
|
431
434
|
}
|
|
432
435
|
return element.kind === "Component" ? componentStateType(element.componentType, state) : void 0;
|
|
433
436
|
}
|
|
434
|
-
function createScope(contracts, elements, ticking = false) {
|
|
437
|
+
function createScope(contracts, elements, ticking = false, selfAvailable = false) {
|
|
435
438
|
return {
|
|
436
439
|
resolve(path) {
|
|
437
440
|
if (path.length !== 2) {
|
|
438
441
|
return void 0;
|
|
439
442
|
}
|
|
443
|
+
if (selfAvailable && path[0] === "self" && path[1] === "id") {
|
|
444
|
+
return "string";
|
|
445
|
+
}
|
|
440
446
|
const contract = contracts.get(path[0]);
|
|
441
447
|
if (contract) {
|
|
442
448
|
return fieldType(contract, path[1]);
|
|
@@ -544,7 +550,7 @@ function bindHandler(site, contracts, elements, diagnostics) {
|
|
|
544
550
|
report("tick-needs-record", `DataSource '${name}' has to be a record source to change its fields on every tick.`);
|
|
545
551
|
return void 0;
|
|
546
552
|
}
|
|
547
|
-
const scope = createScope(contracts, elements, ticking);
|
|
553
|
+
const scope = createScope(contracts, elements, ticking, !ticking);
|
|
548
554
|
const assignments = handler.assignments.flatMap(
|
|
549
555
|
(assignment) => bindAssignment(assignment, name, own, contracts, scope, report) ?? []
|
|
550
556
|
);
|
|
@@ -583,7 +589,7 @@ function expectedType(site, elements) {
|
|
|
583
589
|
}
|
|
584
590
|
function canBindTwoWay(site, elements) {
|
|
585
591
|
const { kind, path, binding } = site;
|
|
586
|
-
return kind === "Component" && binding.key === "value" && acceptsUserChange(elements.get(path[0])?.componentType);
|
|
592
|
+
return kind === "Component" && (binding.key === "value" || binding.key === "valueEnd") && acceptsUserChange(elements.get(path[0])?.componentType);
|
|
587
593
|
}
|
|
588
594
|
function rejectedOperator(site, elements, contracts) {
|
|
589
595
|
const { binding } = site;
|
|
@@ -650,7 +656,7 @@ function buildBindingGraph(sflDocument) {
|
|
|
650
656
|
const { contracts, diagnostics } = collectContracts(sflDocument);
|
|
651
657
|
const elements = collectElements(sflDocument);
|
|
652
658
|
warnNameCollisions(contracts, elements, diagnostics);
|
|
653
|
-
const scope = createScope(contracts, elements);
|
|
659
|
+
const scope = createScope(contracts, elements, false, true);
|
|
654
660
|
const sites = [];
|
|
655
661
|
collectSites(sflDocument.blocks, [], sites);
|
|
656
662
|
const bindings = sites.flatMap((site) => bindProperty(site, scope, elements, contracts, diagnostics) ?? []);
|
|
@@ -661,7 +667,7 @@ function buildBindingGraph(sflDocument) {
|
|
|
661
667
|
}
|
|
662
668
|
|
|
663
669
|
// src/binding/interactive.ts
|
|
664
|
-
var OPERATED = /* @__PURE__ */ new Set(["toggle", "press"]);
|
|
670
|
+
var OPERATED = /* @__PURE__ */ new Set(["toggle", "press", "slide", "pick", "turn", "range"]);
|
|
665
671
|
function interactiveElements(graph) {
|
|
666
672
|
const pressable = /* @__PURE__ */ new Set();
|
|
667
673
|
const scales = /* @__PURE__ */ new Set();
|
|
@@ -683,7 +689,7 @@ function interactiveElements(graph) {
|
|
|
683
689
|
collectRefs(binding.expr).forEach(note);
|
|
684
690
|
}
|
|
685
691
|
for (const [name, info] of graph.elements) {
|
|
686
|
-
const interaction =
|
|
692
|
+
const interaction = chunkKXYSO6GC_cjs.getComponentDescriptor(info.componentType)?.interaction;
|
|
687
693
|
if (info.kind === "Component" && interaction && OPERATED.has(interaction) && !graph.contracts.has(name)) {
|
|
688
694
|
pressable.add(name);
|
|
689
695
|
}
|
|
@@ -733,17 +739,23 @@ function writeComponentValue(input, id, value) {
|
|
|
733
739
|
if (!component) {
|
|
734
740
|
return;
|
|
735
741
|
}
|
|
736
|
-
component.value =
|
|
742
|
+
component.value = chunkKXYSO6GC_cjs.isGenericComponent(component) ? value : String(value);
|
|
743
|
+
}
|
|
744
|
+
function writeComponentValueEnd(input, id, value) {
|
|
745
|
+
const component = findComponent(input, id);
|
|
746
|
+
if (component && chunkKXYSO6GC_cjs.isGenericComponent(component)) {
|
|
747
|
+
component.properties.valueEnd = value;
|
|
748
|
+
}
|
|
737
749
|
}
|
|
738
750
|
function writeComponentDisabled(input, id, disabled) {
|
|
739
751
|
const component = findComponent(input, id);
|
|
740
|
-
if (component &&
|
|
752
|
+
if (component && chunkKXYSO6GC_cjs.isGenericComponent(component)) {
|
|
741
753
|
component.disabled = disabled;
|
|
742
754
|
}
|
|
743
755
|
}
|
|
744
756
|
function isComponentDisabled(input, id) {
|
|
745
757
|
const component = findComponent(input, id);
|
|
746
|
-
return component !== void 0 &&
|
|
758
|
+
return component !== void 0 && chunkKXYSO6GC_cjs.isGenericComponent(component) && component.disabled;
|
|
747
759
|
}
|
|
748
760
|
function setShape(input, path, change) {
|
|
749
761
|
const shape = input.shapes.find((candidate) => candidate.id === path[0]);
|
|
@@ -777,13 +789,17 @@ var APPLY = {
|
|
|
777
789
|
"Shape.textColor": (input, path, value) => setShape(input, path, (shape) => shape.textColor = value),
|
|
778
790
|
"Shape.opacity": (input, path, value) => setShape(input, path, (shape) => shape.opacity = value),
|
|
779
791
|
"Component.value": (input, path, value) => writeComponentValue(input, path[0], value),
|
|
792
|
+
"Component.valueEnd": (input, path, value) => writeComponentValueEnd(input, path[0], value),
|
|
780
793
|
"Component.disabled": (input, path, value) => writeComponentDisabled(input, path[0], value === true)
|
|
781
794
|
};
|
|
782
|
-
function applyShader(input, binding, value) {
|
|
795
|
+
function applyShader(input, binding, value, ownerId) {
|
|
783
796
|
const owners = [];
|
|
784
797
|
for (const shape of input.shapes) {
|
|
785
|
-
if (shape.shader?.name === binding.ownerPath[0]) {
|
|
786
|
-
shape.shader
|
|
798
|
+
if (shape.shader?.name === binding.ownerPath[0] && (ownerId === void 0 || shape.id === ownerId)) {
|
|
799
|
+
shape.shader = {
|
|
800
|
+
...shape.shader,
|
|
801
|
+
parameters: { ...shape.shader.parameters, [binding.property]: value }
|
|
802
|
+
};
|
|
787
803
|
owners.push(shape.id);
|
|
788
804
|
}
|
|
789
805
|
}
|
|
@@ -792,7 +808,7 @@ function applyShader(input, binding, value) {
|
|
|
792
808
|
|
|
793
809
|
// src/binding/runtimeState.ts
|
|
794
810
|
function initialValue(input, id, componentType) {
|
|
795
|
-
const descriptor =
|
|
811
|
+
const descriptor = chunkKXYSO6GC_cjs.getComponentDescriptor(componentType);
|
|
796
812
|
const current = findComponent(input, id)?.value;
|
|
797
813
|
if (current === void 0) {
|
|
798
814
|
return descriptor?.value?.default ?? 0;
|
|
@@ -804,8 +820,8 @@ function initialValue(input, id, componentType) {
|
|
|
804
820
|
return current;
|
|
805
821
|
}
|
|
806
822
|
function createRuntimeState(sfl, options) {
|
|
807
|
-
const graph = buildBindingGraph(
|
|
808
|
-
const input = structuredClone(
|
|
823
|
+
const graph = buildBindingGraph(chunkKXYSO6GC_cjs.parseSource(sfl));
|
|
824
|
+
const input = structuredClone(chunkA73UJ5AQ_cjs.sflToRenderInput(sfl));
|
|
809
825
|
const elementState = /* @__PURE__ */ new Map();
|
|
810
826
|
for (const [name, info] of graph.elements) {
|
|
811
827
|
if (!graph.contracts.has(name)) {
|
|
@@ -848,7 +864,7 @@ function readValue(state, path) {
|
|
|
848
864
|
return Array.isArray(data) ? data.map((row) => row[field]) : data[field];
|
|
849
865
|
}
|
|
850
866
|
function missingSource(state, binding) {
|
|
851
|
-
return binding.dependencies.map((dependency) => dependency.split(".")[0]).find((name) => !state.sources.has(name) && !state.elementState.has(name));
|
|
867
|
+
return binding.dependencies.map((dependency) => dependency.split(".")[0]).find((name) => name !== "self" && !state.sources.has(name) && !state.elementState.has(name));
|
|
852
868
|
}
|
|
853
869
|
|
|
854
870
|
// src/binding/evaluation.ts
|
|
@@ -865,7 +881,7 @@ function applyComponentValue(state, binding, value) {
|
|
|
865
881
|
element.value = value;
|
|
866
882
|
markDirty(state, id);
|
|
867
883
|
}
|
|
868
|
-
if (!
|
|
884
|
+
if (!chunkKXYSO6GC_cjs.isBuiltInComponentType(state.graph.elements.get(id)?.componentType)) {
|
|
869
885
|
return true;
|
|
870
886
|
}
|
|
871
887
|
announce(state, binding.id, { kind: "component", id, value });
|
|
@@ -890,7 +906,32 @@ function evaluateBinding(state, binding) {
|
|
|
890
906
|
warnMissingSource(state, binding, missing);
|
|
891
907
|
return false;
|
|
892
908
|
}
|
|
893
|
-
const
|
|
909
|
+
const readsSelf = binding.dependencies.includes("self.id");
|
|
910
|
+
if (binding.ownerKind === "Shader" && readsSelf) {
|
|
911
|
+
const owners = state.input.shapes.filter((shape) => shape.shader?.name === binding.ownerPath[0]);
|
|
912
|
+
for (const owner of owners) {
|
|
913
|
+
const value2 = evaluate(binding.expr, {
|
|
914
|
+
read: (path) => path[0] === "self" && path[1] === "id" ? owner.id : readValue(state, path)
|
|
915
|
+
});
|
|
916
|
+
const appliedId = `${binding.id}.${owner.id}`;
|
|
917
|
+
const key2 = JSON.stringify(value2);
|
|
918
|
+
if (state.applied.get(appliedId) === key2) {
|
|
919
|
+
continue;
|
|
920
|
+
}
|
|
921
|
+
state.applied.set(appliedId, key2);
|
|
922
|
+
applyShader(state.input, binding, value2, owner.id);
|
|
923
|
+
announce(state, appliedId, {
|
|
924
|
+
kind: "shader",
|
|
925
|
+
owners: [owner.id],
|
|
926
|
+
parameters: { [binding.property]: value2 }
|
|
927
|
+
});
|
|
928
|
+
}
|
|
929
|
+
return false;
|
|
930
|
+
}
|
|
931
|
+
const selfId = binding.ownerKind === "Shader" ? void 0 : binding.ownerPath[0];
|
|
932
|
+
const value = evaluate(binding.expr, {
|
|
933
|
+
read: (path) => path[0] === "self" && path[1] === "id" && selfId ? selfId : readValue(state, path)
|
|
934
|
+
});
|
|
894
935
|
const key = JSON.stringify(value);
|
|
895
936
|
if (state.applied.get(binding.id) === key) {
|
|
896
937
|
return false;
|
|
@@ -925,7 +966,7 @@ function flush(state) {
|
|
|
925
966
|
if (!changed) {
|
|
926
967
|
return null;
|
|
927
968
|
}
|
|
928
|
-
const result =
|
|
969
|
+
const result = chunkA73UJ5AQ_cjs.renderCanvas(state.input, { ...state.options.renderOptions, linkHitAreas: true });
|
|
929
970
|
for (const listener of [...state.listeners]) {
|
|
930
971
|
listener(result);
|
|
931
972
|
}
|
|
@@ -948,14 +989,22 @@ function markDirty(state, name) {
|
|
|
948
989
|
}
|
|
949
990
|
|
|
950
991
|
// src/binding/handlers.ts
|
|
951
|
-
function runHandler(state, handler, delta) {
|
|
992
|
+
function runHandler(state, handler, delta, selfId) {
|
|
952
993
|
const env = {
|
|
953
|
-
read: (path) =>
|
|
994
|
+
read: (path) => {
|
|
995
|
+
if (path[0] === "time" && path[1] === "delta") {
|
|
996
|
+
return delta ?? 0;
|
|
997
|
+
}
|
|
998
|
+
if (path[0] === "self" && path[1] === "id" && selfId) {
|
|
999
|
+
return selfId;
|
|
1000
|
+
}
|
|
1001
|
+
return readValue(state, path);
|
|
1002
|
+
}
|
|
954
1003
|
};
|
|
955
1004
|
for (const assignment of handler.assignments) {
|
|
956
1005
|
const target = state.sources.get(assignment.source);
|
|
957
1006
|
const readable = collectRefs(assignment.expr).every(
|
|
958
|
-
([name]) => name === "time" || state.sources.has(name) || state.elementState.has(name)
|
|
1007
|
+
([name]) => name === "time" || name === "self" && Boolean(selfId) || state.sources.has(name) || state.elementState.has(name)
|
|
959
1008
|
);
|
|
960
1009
|
if (!target || !("set" in target) || !readable) {
|
|
961
1010
|
continue;
|
|
@@ -976,7 +1025,7 @@ function runHandler(state, handler, delta) {
|
|
|
976
1025
|
function dispatch(state, id, event) {
|
|
977
1026
|
for (const handler of state.graph.handlers) {
|
|
978
1027
|
if (handler.event === event && handler.ownerKind !== "DataSource" && handler.ownerPath[0] === id) {
|
|
979
|
-
runHandler(state, handler);
|
|
1028
|
+
runHandler(state, handler, void 0, id);
|
|
980
1029
|
}
|
|
981
1030
|
}
|
|
982
1031
|
}
|
|
@@ -1000,11 +1049,11 @@ function setElementState(state, id, patch) {
|
|
|
1000
1049
|
// src/binding/userInput.ts
|
|
1001
1050
|
function descriptorOf(state, id) {
|
|
1002
1051
|
const info = state.graph.elements.get(id);
|
|
1003
|
-
return info?.kind === "Component" ?
|
|
1052
|
+
return info?.kind === "Component" ? chunkKXYSO6GC_cjs.getComponentDescriptor(info.componentType) : void 0;
|
|
1004
1053
|
}
|
|
1005
|
-
function valueBinding(state, id) {
|
|
1054
|
+
function valueBinding(state, id, property = "value") {
|
|
1006
1055
|
return state.graph.bindings.find(
|
|
1007
|
-
(binding) => binding.ownerKind === "Component" && binding.ownerPath[0] === id && binding.property ===
|
|
1056
|
+
(binding) => binding.ownerKind === "Component" && binding.ownerPath[0] === id && binding.property === property
|
|
1008
1057
|
);
|
|
1009
1058
|
}
|
|
1010
1059
|
function writeBack(state, binding, value) {
|
|
@@ -1018,7 +1067,30 @@ function writeBack(state, binding, value) {
|
|
|
1018
1067
|
source.set({ ...row, [target[1]]: value });
|
|
1019
1068
|
}
|
|
1020
1069
|
}
|
|
1021
|
-
function
|
|
1070
|
+
function changeValueEnd(state, id, next) {
|
|
1071
|
+
const component = findComponent(state.input, id);
|
|
1072
|
+
if (!component || !chunkKXYSO6GC_cjs.isGenericComponent(component) || component.properties.valueEnd === next || isComponentDisabled(state.input, id)) {
|
|
1073
|
+
return false;
|
|
1074
|
+
}
|
|
1075
|
+
const binding = valueBinding(state, id, "valueEnd");
|
|
1076
|
+
if (binding && binding.operator !== "<->") {
|
|
1077
|
+
return false;
|
|
1078
|
+
}
|
|
1079
|
+
writeComponentValueEnd(state.input, id, next);
|
|
1080
|
+
state.renderNeeded = true;
|
|
1081
|
+
if (binding) {
|
|
1082
|
+
state.applied.set(binding.id, JSON.stringify(next));
|
|
1083
|
+
writeBack(state, binding, next);
|
|
1084
|
+
}
|
|
1085
|
+
markDirty(state, id);
|
|
1086
|
+
dispatch(state, id, CHANGE_EVENT);
|
|
1087
|
+
schedule(state);
|
|
1088
|
+
return true;
|
|
1089
|
+
}
|
|
1090
|
+
function changeComponentValue(state, id, next, property = "value") {
|
|
1091
|
+
if (property === "valueEnd") {
|
|
1092
|
+
return typeof next === "number" && changeValueEnd(state, id, next);
|
|
1093
|
+
}
|
|
1022
1094
|
const spec = descriptorOf(state, id)?.value;
|
|
1023
1095
|
const element = state.elementState.get(id);
|
|
1024
1096
|
if (!spec?.writable || !element || typeof next !== spec.type || element.value === next) {
|
|
@@ -1043,6 +1115,64 @@ function changeComponentValue(state, id, next) {
|
|
|
1043
1115
|
schedule(state);
|
|
1044
1116
|
return true;
|
|
1045
1117
|
}
|
|
1118
|
+
var TAU = Math.PI * 2;
|
|
1119
|
+
var grabbed = /* @__PURE__ */ new WeakMap();
|
|
1120
|
+
var within = (value) => Math.min(1, Math.max(0, value));
|
|
1121
|
+
function slideAlong(properties, width, height, x, y) {
|
|
1122
|
+
const vertical = properties.direction === "vertical";
|
|
1123
|
+
const length = vertical ? height : width;
|
|
1124
|
+
const reach = chunkA73UJ5AQ_cjs.sliderReach(properties.variant, vertical ? width : height);
|
|
1125
|
+
const position = vertical ? 1 - y : x;
|
|
1126
|
+
return length > reach * 2 ? within((position * length - reach) / (length - reach * 2)) : position;
|
|
1127
|
+
}
|
|
1128
|
+
function turnAlong(properties, width, height, x, y) {
|
|
1129
|
+
const start = Number(properties.start ?? 225) * Math.PI / 180;
|
|
1130
|
+
const sweep = Number(properties.sweep ?? 270) * Math.PI / 180;
|
|
1131
|
+
const gap = TAU - sweep;
|
|
1132
|
+
const angle = Math.atan2(-(y - 0.5) * height, (x - 0.5) * width);
|
|
1133
|
+
const shifted = start - angle + gap / 2;
|
|
1134
|
+
return within(((shifted % TAU + TAU) % TAU - gap / 2) / sweep);
|
|
1135
|
+
}
|
|
1136
|
+
function slideElement(state, id, x, y = 0) {
|
|
1137
|
+
const component = findComponent(state.input, id);
|
|
1138
|
+
if (!component || !chunkKXYSO6GC_cjs.isGenericComponent(component)) {
|
|
1139
|
+
return;
|
|
1140
|
+
}
|
|
1141
|
+
const kind = descriptorOf(state, id)?.interaction;
|
|
1142
|
+
const { properties } = component;
|
|
1143
|
+
if (kind === "pick") {
|
|
1144
|
+
const count = String(properties.options ?? "").split(",").filter((option) => option.trim()).length;
|
|
1145
|
+
if (count > 0) {
|
|
1146
|
+
changeComponentValue(state, id, Math.min(count - 1, Math.floor(x * count)));
|
|
1147
|
+
}
|
|
1148
|
+
return;
|
|
1149
|
+
}
|
|
1150
|
+
const along = kind === "turn" ? turnAlong(properties, component.width, component.height, x, y) : slideAlong(properties, component.width, component.height, x, y);
|
|
1151
|
+
const min = Number(properties.min ?? 0);
|
|
1152
|
+
const max = Number(properties.max ?? 100);
|
|
1153
|
+
const step = Number(properties.step ?? 0);
|
|
1154
|
+
let value = min + along * (max - min);
|
|
1155
|
+
if (step > 0) {
|
|
1156
|
+
value = min + Math.round((value - min) / step) * step;
|
|
1157
|
+
}
|
|
1158
|
+
const taken = Number(Math.min(max, Math.max(min, value)).toFixed(6));
|
|
1159
|
+
if (kind !== "range") {
|
|
1160
|
+
changeComponentValue(state, id, taken);
|
|
1161
|
+
return;
|
|
1162
|
+
}
|
|
1163
|
+
const low = Number(component.value);
|
|
1164
|
+
const high = Number(properties.valueEnd ?? max);
|
|
1165
|
+
const holds = grabbed.get(state) ?? /* @__PURE__ */ new Map();
|
|
1166
|
+
grabbed.set(state, holds);
|
|
1167
|
+
if (!holds.has(id)) {
|
|
1168
|
+
holds.set(id, taken >= high || taken > low && taken - low > high - taken ? "end" : "start");
|
|
1169
|
+
}
|
|
1170
|
+
if (holds.get(id) === "start") {
|
|
1171
|
+
changeComponentValue(state, id, Math.min(taken, high));
|
|
1172
|
+
} else {
|
|
1173
|
+
changeComponentValue(state, id, Math.max(taken, low), "valueEnd");
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1046
1176
|
function reactToActivation(state, id) {
|
|
1047
1177
|
const element = state.elementState.get(id);
|
|
1048
1178
|
const descriptor = descriptorOf(state, id);
|
|
@@ -1051,6 +1181,7 @@ function reactToActivation(state, id) {
|
|
|
1051
1181
|
}
|
|
1052
1182
|
}
|
|
1053
1183
|
function pressElement(state, id) {
|
|
1184
|
+
grabbed.get(state)?.delete(id);
|
|
1054
1185
|
if (isComponentDisabled(state.input, id)) {
|
|
1055
1186
|
return;
|
|
1056
1187
|
}
|
|
@@ -1058,6 +1189,7 @@ function pressElement(state, id) {
|
|
|
1058
1189
|
dispatch(state, id, "onPress");
|
|
1059
1190
|
}
|
|
1060
1191
|
function releaseElement(state, id, tapped) {
|
|
1192
|
+
grabbed.get(state)?.delete(id);
|
|
1061
1193
|
setElementState(state, id, { pressed: false });
|
|
1062
1194
|
if (isComponentDisabled(state.input, id)) {
|
|
1063
1195
|
return;
|
|
@@ -1154,6 +1286,7 @@ function createBindingRuntime(sfl, options = {}) {
|
|
|
1154
1286
|
release: (id, tapped) => releaseElement(state, id, tapped),
|
|
1155
1287
|
activate: (id) => activateElement(state, id),
|
|
1156
1288
|
change: (id, value) => changeComponentValue(state, id, value),
|
|
1289
|
+
slide: (id, x, y) => slideElement(state, id, x, y),
|
|
1157
1290
|
drag(id, pointer) {
|
|
1158
1291
|
if (pointer !== void 0) {
|
|
1159
1292
|
setElementState(state, id, { pointer });
|
|
@@ -1176,7 +1309,7 @@ function renderBound(sfl, options = {}) {
|
|
|
1176
1309
|
runtime.registerSource(name, { get: () => rows, subscribe: () => () => void 0 });
|
|
1177
1310
|
}
|
|
1178
1311
|
runtime.flush();
|
|
1179
|
-
return
|
|
1312
|
+
return chunkA73UJ5AQ_cjs.renderCanvas(runtime.input, renderOptions);
|
|
1180
1313
|
}
|
|
1181
1314
|
|
|
1182
1315
|
exports.buildBindingGraph = buildBindingGraph;
|
|
@@ -1185,5 +1318,5 @@ exports.createBindingRuntime = createBindingRuntime;
|
|
|
1185
1318
|
exports.createDataSource = createDataSource;
|
|
1186
1319
|
exports.interactiveElements = interactiveElements;
|
|
1187
1320
|
exports.renderBound = renderBound;
|
|
1188
|
-
//# sourceMappingURL=chunk-
|
|
1189
|
-
//# sourceMappingURL=chunk-
|
|
1321
|
+
//# sourceMappingURL=chunk-OWNVXKXN.cjs.map
|
|
1322
|
+
//# sourceMappingURL=chunk-OWNVXKXN.cjs.map
|