@velarscript/web 0.10.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 +201 -0
- package/README.md +89 -0
- package/dist/analyzer.d.ts +302 -0
- package/dist/analyzer.d.ts.map +1 -0
- package/dist/analyzer.js +2931 -0
- package/dist/analyzer.js.map +1 -0
- package/dist/ast.d.ts +220 -0
- package/dist/ast.d.ts.map +1 -0
- package/dist/ast.js +102 -0
- package/dist/ast.js.map +1 -0
- package/dist/browser-test.d.ts +29 -0
- package/dist/browser-test.d.ts.map +1 -0
- package/dist/browser-test.js +33 -0
- package/dist/browser-test.js.map +1 -0
- package/dist/compiler.d.ts +9 -0
- package/dist/compiler.d.ts.map +1 -0
- package/dist/compiler.js +715 -0
- package/dist/compiler.js.map +1 -0
- package/dist/css-tokens.d.ts +46 -0
- package/dist/css-tokens.d.ts.map +1 -0
- package/dist/css-tokens.js +363 -0
- package/dist/css-tokens.js.map +1 -0
- package/dist/editor.d.ts +3 -0
- package/dist/editor.d.ts.map +1 -0
- package/dist/editor.js +147 -0
- package/dist/editor.js.map +1 -0
- package/dist/elements.d.ts +11 -0
- package/dist/elements.d.ts.map +1 -0
- package/dist/elements.js +24 -0
- package/dist/elements.js.map +1 -0
- package/dist/emitter.d.ts +79 -0
- package/dist/emitter.d.ts.map +1 -0
- package/dist/emitter.js +2699 -0
- package/dist/emitter.js.map +1 -0
- package/dist/host.d.ts +7 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/host.js +224 -0
- package/dist/host.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/inspection.d.ts +3 -0
- package/dist/inspection.d.ts.map +1 -0
- package/dist/inspection.js +82 -0
- package/dist/inspection.js.map +1 -0
- package/dist/keyframes.d.ts +16 -0
- package/dist/keyframes.d.ts.map +1 -0
- package/dist/keyframes.js +29 -0
- package/dist/keyframes.js.map +1 -0
- package/dist/lexer.d.ts +85 -0
- package/dist/lexer.d.ts.map +1 -0
- package/dist/lexer.js +422 -0
- package/dist/lexer.js.map +1 -0
- package/dist/look-static.d.ts +31 -0
- package/dist/look-static.d.ts.map +1 -0
- package/dist/look-static.js +266 -0
- package/dist/look-static.js.map +1 -0
- package/dist/look.d.ts +134 -0
- package/dist/look.d.ts.map +1 -0
- package/dist/look.js +627 -0
- package/dist/look.js.map +1 -0
- package/dist/parser.d.ts +71 -0
- package/dist/parser.d.ts.map +1 -0
- package/dist/parser.js +976 -0
- package/dist/parser.js.map +1 -0
- package/dist/project-config.d.ts +33 -0
- package/dist/project-config.d.ts.map +1 -0
- package/dist/project-config.js +199 -0
- package/dist/project-config.js.map +1 -0
- package/dist/runtime-foundation.d.ts +7 -0
- package/dist/runtime-foundation.d.ts.map +1 -0
- package/dist/runtime-foundation.js +1245 -0
- package/dist/runtime-foundation.js.map +1 -0
- package/dist/runtime.d.ts +7 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +3444 -0
- package/dist/runtime.js.map +1 -0
- package/dist/semantic.d.ts +3 -0
- package/dist/semantic.d.ts.map +1 -0
- package/dist/semantic.js +150 -0
- package/dist/semantic.js.map +1 -0
- package/dist/types.d.ts +56 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +178 -0
- package/dist/types.js.map +1 -0
- package/dist/websocket-runtime.d.ts +2 -0
- package/dist/websocket-runtime.d.ts.map +1 -0
- package/dist/websocket-runtime.js +30 -0
- package/dist/websocket-runtime.js.map +1 -0
- package/dist/worker-runtime.d.ts +2 -0
- package/dist/worker-runtime.d.ts.map +1 -0
- package/dist/worker-runtime.js +72 -0
- package/dist/worker-runtime.js.map +1 -0
- package/package.json +52 -0
|
@@ -0,0 +1,1245 @@
|
|
|
1
|
+
import { VELAR_ERROR_NORMALIZATION_RUNTIME, VELAR_RUNTIME_REGISTRY_KEY, VELAR_RUNTIME_SCHEMA_VERSION, } from "@velarscript/compiler/extension";
|
|
2
|
+
export const WEB_DOM_HOST_RUNTIME = String.raw `
|
|
3
|
+
const __velarDomNativeObject = globalThis.Object;
|
|
4
|
+
const __velarDomNativeArray = globalThis.Array;
|
|
5
|
+
const __velarDomNativeSet = globalThis.Set;
|
|
6
|
+
const __velarDomNativeNumber = globalThis.Number;
|
|
7
|
+
const __velarDomNativeString = globalThis.String;
|
|
8
|
+
const __velarDomNativeSymbol = globalThis.Symbol;
|
|
9
|
+
const __velarDomReflectApply = Object.getOwnPropertyDescriptor(Reflect, "apply")?.value;
|
|
10
|
+
const __velarDomGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor(Object, "getOwnPropertyDescriptor")?.value;
|
|
11
|
+
const __velarDomGetOwnPropertyNames = Object.getOwnPropertyDescriptor(Object, "getOwnPropertyNames")?.value;
|
|
12
|
+
const __velarDomGetOwnPropertySymbols = Object.getOwnPropertyDescriptor(Object, "getOwnPropertySymbols")?.value;
|
|
13
|
+
const __velarDomGetPrototypeOf = Object.getOwnPropertyDescriptor(Object, "getPrototypeOf")?.value;
|
|
14
|
+
const __velarDomDefineProperty = Object.getOwnPropertyDescriptor(Object, "defineProperty")?.value;
|
|
15
|
+
const __velarDomArrayIsArray = Object.getOwnPropertyDescriptor(Array, "isArray")?.value;
|
|
16
|
+
const __velarDomNumberIsFinite = Object.getOwnPropertyDescriptor(Number, "isFinite")?.value;
|
|
17
|
+
const __velarDomNumberIsInteger = Object.getOwnPropertyDescriptor(Number, "isInteger")?.value;
|
|
18
|
+
const __velarDomSymbolHasInstance = typeof __velarDomNativeSymbol === "function" ? __velarDomNativeSymbol.hasInstance : null;
|
|
19
|
+
const __velarDomFunctionHasInstance = __velarDomSymbolHasInstance == null
|
|
20
|
+
? null
|
|
21
|
+
: Object.getOwnPropertyDescriptor(Function.prototype, __velarDomSymbolHasInstance)?.value;
|
|
22
|
+
const __velarDomSetPrototype = typeof __velarDomNativeSet === "function"
|
|
23
|
+
? Object.getOwnPropertyDescriptor(__velarDomNativeSet, "prototype")?.value
|
|
24
|
+
: null;
|
|
25
|
+
const __velarDomSetHas = __velarDomSetPrototype && Object.getOwnPropertyDescriptor(__velarDomSetPrototype, "has")?.value;
|
|
26
|
+
const __velarDomSetAdd = __velarDomSetPrototype && Object.getOwnPropertyDescriptor(__velarDomSetPrototype, "add")?.value;
|
|
27
|
+
const __velarDomSetDelete = __velarDomSetPrototype && Object.getOwnPropertyDescriptor(__velarDomSetPrototype, "delete")?.value;
|
|
28
|
+
const __velarDomDocument = globalThis.document ?? null;
|
|
29
|
+
const __velarDomNativeNode = typeof globalThis.Node === "function" ? globalThis.Node : null;
|
|
30
|
+
const __velarDomNativeElement = typeof globalThis.Element === "function" ? globalThis.Element : null;
|
|
31
|
+
const __velarDomNativeDocument = typeof globalThis.Document === "function" ? globalThis.Document : null;
|
|
32
|
+
const __velarDomNativeFragment = typeof globalThis.DocumentFragment === "function" ? globalThis.DocumentFragment : null;
|
|
33
|
+
const __velarDomNativeCharacterData = typeof globalThis.CharacterData === "function" ? globalThis.CharacterData : null;
|
|
34
|
+
const __velarDomNativeDocumentType = typeof globalThis.DocumentType === "function" ? globalThis.DocumentType : null;
|
|
35
|
+
const __velarDomNativeNodeList = typeof globalThis.NodeList === "function" ? globalThis.NodeList : null;
|
|
36
|
+
const __velarDomNativeEventTarget = typeof globalThis.EventTarget === "function" ? globalThis.EventTarget : null;
|
|
37
|
+
const __velarDomNativeHtmlElement = typeof globalThis.HTMLElement === "function" ? globalThis.HTMLElement : null;
|
|
38
|
+
const __velarDomNativeSvgElement = typeof globalThis.SVGElement === "function" ? globalThis.SVGElement : null;
|
|
39
|
+
const __velarDomNativeStyleDeclaration = typeof globalThis.CSSStyleDeclaration === "function" ? globalThis.CSSStyleDeclaration : null;
|
|
40
|
+
const __velarDomNativeTokenList = typeof globalThis.DOMTokenList === "function" ? globalThis.DOMTokenList : null;
|
|
41
|
+
const __velarDomNativeInputElement = typeof globalThis.HTMLInputElement === "function" ? globalThis.HTMLInputElement : null;
|
|
42
|
+
const __velarDomNativeTextAreaElement = typeof globalThis.HTMLTextAreaElement === "function" ? globalThis.HTMLTextAreaElement : null;
|
|
43
|
+
const __velarDomNativeSelectElement = typeof globalThis.HTMLSelectElement === "function" ? globalThis.HTMLSelectElement : null;
|
|
44
|
+
function __velarDomApply(operation, receiver, arguments_, label) {
|
|
45
|
+
if (typeof operation !== "function" || typeof __velarDomReflectApply !== "function") {
|
|
46
|
+
throw new TypeError("The browser " + label + " API is unavailable");
|
|
47
|
+
}
|
|
48
|
+
return __velarDomReflectApply(operation, receiver, arguments_);
|
|
49
|
+
}
|
|
50
|
+
function __velarDomOwnDescriptor(value, name) {
|
|
51
|
+
if ((typeof value !== "object" && typeof value !== "function") || value === null
|
|
52
|
+
|| typeof __velarDomGetOwnPropertyDescriptor !== "function" || typeof __velarDomReflectApply !== "function") return null;
|
|
53
|
+
return __velarDomReflectApply(__velarDomGetOwnPropertyDescriptor, __velarDomNativeObject, [value, name]) ?? null;
|
|
54
|
+
}
|
|
55
|
+
function __velarDomMember(value, name, kind = "value") {
|
|
56
|
+
if ((typeof value !== "object" && typeof value !== "function") || value === null) return null;
|
|
57
|
+
let current = value;
|
|
58
|
+
for (let depth = 0; current && depth < 32; depth += 1) {
|
|
59
|
+
const descriptor = __velarDomOwnDescriptor(current, name);
|
|
60
|
+
if (descriptor) {
|
|
61
|
+
const member = kind === "get" ? descriptor.get : kind === "set" ? descriptor.set : "value" in descriptor ? descriptor.value : null;
|
|
62
|
+
return typeof member === "function" ? member : null;
|
|
63
|
+
}
|
|
64
|
+
if (typeof __velarDomGetPrototypeOf !== "function" || typeof __velarDomReflectApply !== "function") return null;
|
|
65
|
+
current = __velarDomReflectApply(__velarDomGetPrototypeOf, __velarDomNativeObject, [current]);
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
function __velarDomPrototype(constructor) {
|
|
70
|
+
return typeof constructor === "function" ? __velarDomOwnDescriptor(constructor, "prototype")?.value ?? null : null;
|
|
71
|
+
}
|
|
72
|
+
function __velarDomPrototypeMember(constructor, name, kind = "value") {
|
|
73
|
+
return __velarDomMember(__velarDomPrototype(constructor), name, kind);
|
|
74
|
+
}
|
|
75
|
+
function __velarDomInstance(value, constructor) {
|
|
76
|
+
if (typeof constructor !== "function" || typeof __velarDomFunctionHasInstance !== "function") return false;
|
|
77
|
+
try { return __velarDomApply(__velarDomFunctionHasInstance, constructor, [value], "Node identity"); }
|
|
78
|
+
catch { return false; }
|
|
79
|
+
}
|
|
80
|
+
const __velarDomDocumentCreateElement = __velarDomMember(__velarDomDocument, "createElement");
|
|
81
|
+
const __velarDomDocumentCreateElementNS = __velarDomMember(__velarDomDocument, "createElementNS");
|
|
82
|
+
const __velarDomDocumentCreateTextNode = __velarDomMember(__velarDomDocument, "createTextNode");
|
|
83
|
+
const __velarDomDocumentCreateComment = __velarDomMember(__velarDomDocument, "createComment");
|
|
84
|
+
const __velarDomDocumentCreateFragment = __velarDomMember(__velarDomDocument, "createDocumentFragment");
|
|
85
|
+
const __velarDomDocumentQuerySelector = __velarDomMember(__velarDomDocument, "querySelector");
|
|
86
|
+
const __velarDomNodeNodeType = __velarDomPrototypeMember(__velarDomNativeNode, "nodeType", "get");
|
|
87
|
+
const __velarDomNodeChildNodes = __velarDomPrototypeMember(__velarDomNativeNode, "childNodes", "get");
|
|
88
|
+
const __velarDomNodeInsertBefore = __velarDomPrototypeMember(__velarDomNativeNode, "insertBefore");
|
|
89
|
+
const __velarDomNodeReplaceChildren = __velarDomPrototypeMember(__velarDomNativeNode, "replaceChildren");
|
|
90
|
+
const __velarDomNodeAppend = __velarDomPrototypeMember(__velarDomNativeNode, "append");
|
|
91
|
+
const __velarDomNodeTextContentSet = __velarDomPrototypeMember(__velarDomNativeNode, "textContent", "set");
|
|
92
|
+
const __velarDomElementAppend = __velarDomPrototypeMember(__velarDomNativeElement, "append");
|
|
93
|
+
const __velarDomElementReplaceChildren = __velarDomPrototypeMember(__velarDomNativeElement, "replaceChildren");
|
|
94
|
+
const __velarDomDocumentAppend = __velarDomPrototypeMember(__velarDomNativeDocument, "append");
|
|
95
|
+
const __velarDomDocumentReplaceChildren = __velarDomPrototypeMember(__velarDomNativeDocument, "replaceChildren");
|
|
96
|
+
const __velarDomFragmentAppend = __velarDomPrototypeMember(__velarDomNativeFragment, "append");
|
|
97
|
+
const __velarDomFragmentReplaceChildren = __velarDomPrototypeMember(__velarDomNativeFragment, "replaceChildren");
|
|
98
|
+
const __velarDomNodeRemove = __velarDomPrototypeMember(__velarDomNativeNode, "remove");
|
|
99
|
+
const __velarDomElementRemove = __velarDomPrototypeMember(__velarDomNativeElement, "remove");
|
|
100
|
+
const __velarDomCharacterDataRemove = __velarDomPrototypeMember(__velarDomNativeCharacterData, "remove");
|
|
101
|
+
const __velarDomDocumentTypeRemove = __velarDomPrototypeMember(__velarDomNativeDocumentType, "remove");
|
|
102
|
+
const __velarDomNodeBefore = __velarDomPrototypeMember(__velarDomNativeNode, "before");
|
|
103
|
+
const __velarDomElementBefore = __velarDomPrototypeMember(__velarDomNativeElement, "before");
|
|
104
|
+
const __velarDomCharacterDataBefore = __velarDomPrototypeMember(__velarDomNativeCharacterData, "before");
|
|
105
|
+
const __velarDomDocumentTypeBefore = __velarDomPrototypeMember(__velarDomNativeDocumentType, "before");
|
|
106
|
+
const __velarDomNodeSetAttribute = __velarDomPrototypeMember(__velarDomNativeNode, "setAttribute");
|
|
107
|
+
const __velarDomElementSetAttribute = __velarDomPrototypeMember(__velarDomNativeElement, "setAttribute");
|
|
108
|
+
const __velarDomElementSetAttributeNS = __velarDomPrototypeMember(__velarDomNativeElement, "setAttributeNS");
|
|
109
|
+
const __velarDomNodeRemoveAttribute = __velarDomPrototypeMember(__velarDomNativeNode, "removeAttribute");
|
|
110
|
+
const __velarDomElementRemoveAttribute = __velarDomPrototypeMember(__velarDomNativeElement, "removeAttribute");
|
|
111
|
+
const __velarDomElementRemoveAttributeNS = __velarDomPrototypeMember(__velarDomNativeElement, "removeAttributeNS");
|
|
112
|
+
const __velarDomNodeListLength = __velarDomPrototypeMember(__velarDomNativeNodeList, "length", "get");
|
|
113
|
+
const __velarDomNodeListItem = __velarDomPrototypeMember(__velarDomNativeNodeList, "item");
|
|
114
|
+
const __velarDomNodeNextSibling = __velarDomPrototypeMember(__velarDomNativeNode, "nextSibling", "get");
|
|
115
|
+
const __velarDomNodeAddListener = __velarDomPrototypeMember(__velarDomNativeNode, "addEventListener");
|
|
116
|
+
const __velarDomNodeRemoveListener = __velarDomPrototypeMember(__velarDomNativeNode, "removeEventListener");
|
|
117
|
+
const __velarDomNodeInnerHtml = __velarDomPrototypeMember(__velarDomNativeNode, "innerHTML", "set");
|
|
118
|
+
const __velarDomNodeQuerySelectorAll = __velarDomPrototypeMember(__velarDomNativeNode, "querySelectorAll");
|
|
119
|
+
const __velarDomNodeClassList = __velarDomPrototypeMember(__velarDomNativeNode, "classList", "get");
|
|
120
|
+
const __velarDomNodeStyle = __velarDomPrototypeMember(__velarDomNativeNode, "style", "get");
|
|
121
|
+
const __velarDomNodeFieldValue = __velarDomPrototypeMember(__velarDomNativeNode, "value", "get");
|
|
122
|
+
const __velarDomNodeSetFieldValue = __velarDomPrototypeMember(__velarDomNativeNode, "value", "set");
|
|
123
|
+
const __velarDomNodeFieldNumber = __velarDomPrototypeMember(__velarDomNativeNode, "valueAsNumber", "get");
|
|
124
|
+
const __velarDomNodeFieldChecked = __velarDomPrototypeMember(__velarDomNativeNode, "checked", "get");
|
|
125
|
+
const __velarDomNodeSetFieldChecked = __velarDomPrototypeMember(__velarDomNativeNode, "checked", "set");
|
|
126
|
+
const __velarDomEventTargetAdd = __velarDomPrototypeMember(__velarDomNativeEventTarget, "addEventListener");
|
|
127
|
+
const __velarDomEventTargetRemove = __velarDomPrototypeMember(__velarDomNativeEventTarget, "removeEventListener");
|
|
128
|
+
const __velarDomElementInnerHtml = __velarDomPrototypeMember(__velarDomNativeElement, "innerHTML", "set");
|
|
129
|
+
const __velarDomElementQuerySelectorAll = __velarDomPrototypeMember(__velarDomNativeElement, "querySelectorAll");
|
|
130
|
+
const __velarDomElementClassList = __velarDomPrototypeMember(__velarDomNativeElement, "classList", "get");
|
|
131
|
+
const __velarDomHtmlElementStyle = __velarDomPrototypeMember(__velarDomNativeHtmlElement, "style", "get");
|
|
132
|
+
const __velarDomSvgElementStyle = __velarDomPrototypeMember(__velarDomNativeSvgElement, "style", "get");
|
|
133
|
+
const __velarDomStyleSetProperty = __velarDomPrototypeMember(__velarDomNativeStyleDeclaration, "setProperty");
|
|
134
|
+
const __velarDomStyleRemoveProperty = __velarDomPrototypeMember(__velarDomNativeStyleDeclaration, "removeProperty");
|
|
135
|
+
const __velarDomStylePropertyValue = __velarDomPrototypeMember(__velarDomNativeStyleDeclaration, "getPropertyValue");
|
|
136
|
+
const __velarDomStylePropertyPriority = __velarDomPrototypeMember(__velarDomNativeStyleDeclaration, "getPropertyPriority");
|
|
137
|
+
const __velarDomTokenListAdd = __velarDomPrototypeMember(__velarDomNativeTokenList, "add");
|
|
138
|
+
const __velarDomTokenListRemove = __velarDomPrototypeMember(__velarDomNativeTokenList, "remove");
|
|
139
|
+
const __velarDomTokenListLength = __velarDomPrototypeMember(__velarDomNativeTokenList, "length", "get");
|
|
140
|
+
const __velarDomTokenListItem = __velarDomPrototypeMember(__velarDomNativeTokenList, "item");
|
|
141
|
+
const __velarDomInputValueGet = __velarDomPrototypeMember(__velarDomNativeInputElement, "value", "get");
|
|
142
|
+
const __velarDomInputValueSet = __velarDomPrototypeMember(__velarDomNativeInputElement, "value", "set");
|
|
143
|
+
const __velarDomInputNumberGet = __velarDomPrototypeMember(__velarDomNativeInputElement, "valueAsNumber", "get");
|
|
144
|
+
const __velarDomInputCheckedGet = __velarDomPrototypeMember(__velarDomNativeInputElement, "checked", "get");
|
|
145
|
+
const __velarDomInputCheckedSet = __velarDomPrototypeMember(__velarDomNativeInputElement, "checked", "set");
|
|
146
|
+
const __velarDomTextAreaValueGet = __velarDomPrototypeMember(__velarDomNativeTextAreaElement, "value", "get");
|
|
147
|
+
const __velarDomTextAreaValueSet = __velarDomPrototypeMember(__velarDomNativeTextAreaElement, "value", "set");
|
|
148
|
+
const __velarDomSelectValueGet = __velarDomPrototypeMember(__velarDomNativeSelectElement, "value", "get");
|
|
149
|
+
const __velarDomSelectValueSet = __velarDomPrototypeMember(__velarDomNativeSelectElement, "value", "set");
|
|
150
|
+
function __velarDomOwnData(value, name) {
|
|
151
|
+
const descriptor = __velarDomOwnDescriptor(value, name);
|
|
152
|
+
return descriptor?.enumerable && "value" in descriptor ? descriptor.value : undefined;
|
|
153
|
+
}
|
|
154
|
+
function __velarDomOwnMethod(value, name) {
|
|
155
|
+
const method = __velarDomOwnData(value, name);
|
|
156
|
+
return typeof method === "function" ? method : null;
|
|
157
|
+
}
|
|
158
|
+
function __velarDomNodeOperation(value, name, candidates, arguments_) {
|
|
159
|
+
for (let index = 0; index < candidates.length; index += 1) {
|
|
160
|
+
const candidate = candidates[index];
|
|
161
|
+
if (__velarDomInstance(value, candidate[0]) && typeof candidate[1] === "function") {
|
|
162
|
+
return __velarDomApply(candidate[1], value, arguments_, "DOM " + name);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
const own = __velarDomOwnMethod(value, name);
|
|
166
|
+
if (own) return __velarDomApply(own, value, arguments_, "DOM " + name);
|
|
167
|
+
throw new TypeError("The value does not expose native DOM " + name);
|
|
168
|
+
}
|
|
169
|
+
function __velarDomCreateElement(tag) { return __velarDomApply(__velarDomDocumentCreateElement, __velarDomDocument, [tag], "document.createElement"); }
|
|
170
|
+
function __velarDomCreateElementNS(namespace, tag) { return __velarDomApply(__velarDomDocumentCreateElementNS, __velarDomDocument, [namespace, tag], "document.createElementNS"); }
|
|
171
|
+
function __velarDomCreateTextNode(value) { return __velarDomApply(__velarDomDocumentCreateTextNode, __velarDomDocument, [value], "document.createTextNode"); }
|
|
172
|
+
function __velarDomCreateComment(value) { return __velarDomApply(__velarDomDocumentCreateComment, __velarDomDocument, [value], "document.createComment"); }
|
|
173
|
+
function __velarDomCreateFragment() { return __velarDomApply(__velarDomDocumentCreateFragment, __velarDomDocument, [], "document.createDocumentFragment"); }
|
|
174
|
+
function __velarDomQuerySelector(value) { return __velarDomApply(__velarDomDocumentQuerySelector, __velarDomDocument, [value], "document.querySelector"); }
|
|
175
|
+
function __velarDomAppend(value, ...children) {
|
|
176
|
+
return __velarDomNodeOperation(value, "append", [
|
|
177
|
+
[__velarDomNativeNode, __velarDomNodeAppend], [__velarDomNativeElement, __velarDomElementAppend],
|
|
178
|
+
[__velarDomNativeDocument, __velarDomDocumentAppend], [__velarDomNativeFragment, __velarDomFragmentAppend],
|
|
179
|
+
], children);
|
|
180
|
+
}
|
|
181
|
+
function __velarDomInsertBefore(value, child, before = null) {
|
|
182
|
+
return __velarDomNodeOperation(value, "insertBefore", [[__velarDomNativeNode, __velarDomNodeInsertBefore]], [child, before]);
|
|
183
|
+
}
|
|
184
|
+
function __velarDomReplaceChildren(value, ...children) {
|
|
185
|
+
return __velarDomNodeOperation(value, "replaceChildren", [
|
|
186
|
+
[__velarDomNativeNode, __velarDomNodeReplaceChildren], [__velarDomNativeElement, __velarDomElementReplaceChildren],
|
|
187
|
+
[__velarDomNativeDocument, __velarDomDocumentReplaceChildren], [__velarDomNativeFragment, __velarDomFragmentReplaceChildren],
|
|
188
|
+
], children);
|
|
189
|
+
}
|
|
190
|
+
function __velarDomRemove(value) {
|
|
191
|
+
return __velarDomNodeOperation(value, "remove", [
|
|
192
|
+
[__velarDomNativeNode, __velarDomNodeRemove], [__velarDomNativeElement, __velarDomElementRemove],
|
|
193
|
+
[__velarDomNativeCharacterData, __velarDomCharacterDataRemove], [__velarDomNativeDocumentType, __velarDomDocumentTypeRemove],
|
|
194
|
+
], []);
|
|
195
|
+
}
|
|
196
|
+
function __velarDomBefore(value, child) {
|
|
197
|
+
return __velarDomNodeOperation(value, "before", [
|
|
198
|
+
[__velarDomNativeNode, __velarDomNodeBefore], [__velarDomNativeElement, __velarDomElementBefore],
|
|
199
|
+
[__velarDomNativeCharacterData, __velarDomCharacterDataBefore], [__velarDomNativeDocumentType, __velarDomDocumentTypeBefore],
|
|
200
|
+
], [child]);
|
|
201
|
+
}
|
|
202
|
+
function __velarDomSetAttribute(value, name, next) {
|
|
203
|
+
return __velarDomNodeOperation(value, "setAttribute", [
|
|
204
|
+
[__velarDomNativeNode, __velarDomNodeSetAttribute], [__velarDomNativeElement, __velarDomElementSetAttribute],
|
|
205
|
+
], [name, next]);
|
|
206
|
+
}
|
|
207
|
+
function __velarDomSetAttributeNS(value, namespace, name, next) {
|
|
208
|
+
return __velarDomNodeOperation(value, "setAttributeNS", [[__velarDomNativeElement, __velarDomElementSetAttributeNS]], [namespace, name, next]);
|
|
209
|
+
}
|
|
210
|
+
function __velarDomRemoveAttribute(value, name) {
|
|
211
|
+
return __velarDomNodeOperation(value, "removeAttribute", [
|
|
212
|
+
[__velarDomNativeNode, __velarDomNodeRemoveAttribute], [__velarDomNativeElement, __velarDomElementRemoveAttribute],
|
|
213
|
+
], [name]);
|
|
214
|
+
}
|
|
215
|
+
function __velarDomRemoveAttributeNS(value, namespace, name) {
|
|
216
|
+
return __velarDomNodeOperation(value, "removeAttributeNS", [[__velarDomNativeElement, __velarDomElementRemoveAttributeNS]], [namespace, name]);
|
|
217
|
+
}
|
|
218
|
+
// Accessor twin of __velarDomNodeOperation: the framework reads and writes a
|
|
219
|
+
// handful of host properties (style, classList, innerHTML, field value) whose
|
|
220
|
+
// prototypes are as replaceable as the methods above, so they go through the
|
|
221
|
+
// same captured-then-own-data-descriptor path instead of ambient '.' access.
|
|
222
|
+
function __velarDomNodeAccessor(value, name, candidates, arguments_, write) {
|
|
223
|
+
for (let index = 0; index < candidates.length; index += 1) {
|
|
224
|
+
const candidate = candidates[index];
|
|
225
|
+
if (__velarDomInstance(value, candidate[0]) && typeof candidate[1] === "function") {
|
|
226
|
+
return __velarDomApply(candidate[1], value, arguments_, "DOM " + name);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
const descriptor = __velarDomOwnDescriptor(value, name);
|
|
230
|
+
if (!write) {
|
|
231
|
+
if (descriptor && "value" in descriptor) return descriptor.value;
|
|
232
|
+
throw new TypeError("The value does not expose native DOM " + name);
|
|
233
|
+
}
|
|
234
|
+
if (typeof __velarDomDefineProperty !== "function" || typeof __velarDomReflectApply !== "function"
|
|
235
|
+
|| (descriptor && (!("value" in descriptor) || descriptor.writable !== true))) {
|
|
236
|
+
throw new TypeError("The value does not expose native DOM " + name);
|
|
237
|
+
}
|
|
238
|
+
return __velarDomReflectApply(__velarDomDefineProperty, __velarDomNativeObject, [value, name, descriptor
|
|
239
|
+
? { ...descriptor, value: arguments_[0] }
|
|
240
|
+
: { value: arguments_[0], writable: true, enumerable: true, configurable: true }]);
|
|
241
|
+
}
|
|
242
|
+
function __velarDomNextSibling(value) {
|
|
243
|
+
if (__velarDomInstance(value, __velarDomNativeNode) && typeof __velarDomNodeNextSibling === "function") {
|
|
244
|
+
return __velarDomApply(__velarDomNodeNextSibling, value, [], "Node.nextSibling");
|
|
245
|
+
}
|
|
246
|
+
return null;
|
|
247
|
+
}
|
|
248
|
+
function __velarDomAddListener(value, name, listener, options) {
|
|
249
|
+
return __velarDomNodeOperation(value, "addEventListener", [
|
|
250
|
+
[__velarDomNativeNode, __velarDomNodeAddListener], [__velarDomNativeEventTarget, __velarDomEventTargetAdd],
|
|
251
|
+
], [name, listener, options]);
|
|
252
|
+
}
|
|
253
|
+
function __velarDomRemoveListener(value, name, listener, options) {
|
|
254
|
+
return __velarDomNodeOperation(value, "removeEventListener", [
|
|
255
|
+
[__velarDomNativeNode, __velarDomNodeRemoveListener], [__velarDomNativeEventTarget, __velarDomEventTargetRemove],
|
|
256
|
+
], [name, listener, options]);
|
|
257
|
+
}
|
|
258
|
+
function __velarDomSetHtml(value, next) {
|
|
259
|
+
return __velarDomNodeAccessor(value, "innerHTML", [
|
|
260
|
+
[__velarDomNativeNode, __velarDomNodeInnerHtml], [__velarDomNativeElement, __velarDomElementInnerHtml],
|
|
261
|
+
], [next], true);
|
|
262
|
+
}
|
|
263
|
+
function __velarDomQuerySelectorAll(value, selector) {
|
|
264
|
+
return __velarDomNodeOperation(value, "querySelectorAll", [
|
|
265
|
+
[__velarDomNativeNode, __velarDomNodeQuerySelectorAll], [__velarDomNativeElement, __velarDomElementQuerySelectorAll],
|
|
266
|
+
], [selector]);
|
|
267
|
+
}
|
|
268
|
+
function __velarDomStyle(value) {
|
|
269
|
+
return __velarDomNodeAccessor(value, "style", [
|
|
270
|
+
[__velarDomNativeNode, __velarDomNodeStyle], [__velarDomNativeHtmlElement, __velarDomHtmlElementStyle],
|
|
271
|
+
[__velarDomNativeSvgElement, __velarDomSvgElementStyle],
|
|
272
|
+
], [], false);
|
|
273
|
+
}
|
|
274
|
+
function __velarDomStyleValue(value, property) {
|
|
275
|
+
return __velarDomNodeOperation(__velarDomStyle(value), "getPropertyValue", [[__velarDomNativeStyleDeclaration, __velarDomStylePropertyValue]], [property]);
|
|
276
|
+
}
|
|
277
|
+
function __velarDomStylePriority(value, property) {
|
|
278
|
+
return __velarDomNodeOperation(__velarDomStyle(value), "getPropertyPriority", [[__velarDomNativeStyleDeclaration, __velarDomStylePropertyPriority]], [property]);
|
|
279
|
+
}
|
|
280
|
+
function __velarDomStyleWrite(value, property, next, priority = "") {
|
|
281
|
+
return __velarDomNodeOperation(__velarDomStyle(value), "setProperty", [[__velarDomNativeStyleDeclaration, __velarDomStyleSetProperty]], [property, next, priority]);
|
|
282
|
+
}
|
|
283
|
+
function __velarDomStyleClear(value, property) {
|
|
284
|
+
return __velarDomNodeOperation(__velarDomStyle(value), "removeProperty", [[__velarDomNativeStyleDeclaration, __velarDomStyleRemoveProperty]], [property]);
|
|
285
|
+
}
|
|
286
|
+
function __velarDomClassList(value) {
|
|
287
|
+
return __velarDomNodeAccessor(value, "classList", [
|
|
288
|
+
[__velarDomNativeNode, __velarDomNodeClassList], [__velarDomNativeElement, __velarDomElementClassList],
|
|
289
|
+
], [], false);
|
|
290
|
+
}
|
|
291
|
+
function __velarDomClassInsert(value, name) {
|
|
292
|
+
return __velarDomNodeOperation(__velarDomClassList(value), "add", [[__velarDomNativeTokenList, __velarDomTokenListAdd]], [name]);
|
|
293
|
+
}
|
|
294
|
+
function __velarDomClassRemove(value, name) {
|
|
295
|
+
return __velarDomNodeOperation(__velarDomClassList(value), "remove", [[__velarDomNativeTokenList, __velarDomTokenListRemove]], [name]);
|
|
296
|
+
}
|
|
297
|
+
function __velarDomClassNames(value) {
|
|
298
|
+
const list = __velarDomClassList(value);
|
|
299
|
+
const length = __velarDomInstance(list, __velarDomNativeTokenList) && typeof __velarDomTokenListLength === "function"
|
|
300
|
+
? __velarDomApply(__velarDomTokenListLength, list, [], "DOMTokenList.length")
|
|
301
|
+
: __velarDomOwnData(list, "length");
|
|
302
|
+
// A data-only seam that exposes no bounded token list simply owns no base
|
|
303
|
+
// classes; only a real token list can contribute names the framework must
|
|
304
|
+
// preserve while it manages the rest.
|
|
305
|
+
if (!__velarDomIsInteger(length) || length < 0 || length > 1000000) return new __velarDomNativeArray(0);
|
|
306
|
+
const output = new __velarDomNativeArray(length);
|
|
307
|
+
for (let index = 0; index < length; index += 1) {
|
|
308
|
+
output[index] = __velarDomNodeOperation(list, "item", [[__velarDomNativeTokenList, __velarDomTokenListItem]], [index]);
|
|
309
|
+
}
|
|
310
|
+
return output;
|
|
311
|
+
}
|
|
312
|
+
function __velarDomFieldValue(value) {
|
|
313
|
+
return __velarDomNodeAccessor(value, "value", [
|
|
314
|
+
[__velarDomNativeNode, __velarDomNodeFieldValue], [__velarDomNativeInputElement, __velarDomInputValueGet],
|
|
315
|
+
[__velarDomNativeTextAreaElement, __velarDomTextAreaValueGet], [__velarDomNativeSelectElement, __velarDomSelectValueGet],
|
|
316
|
+
], [], false);
|
|
317
|
+
}
|
|
318
|
+
function __velarDomSetFieldValue(value, next) {
|
|
319
|
+
return __velarDomNodeAccessor(value, "value", [
|
|
320
|
+
[__velarDomNativeNode, __velarDomNodeSetFieldValue], [__velarDomNativeInputElement, __velarDomInputValueSet],
|
|
321
|
+
[__velarDomNativeTextAreaElement, __velarDomTextAreaValueSet], [__velarDomNativeSelectElement, __velarDomSelectValueSet],
|
|
322
|
+
], [next], true);
|
|
323
|
+
}
|
|
324
|
+
function __velarDomFieldNumber(value) {
|
|
325
|
+
return __velarDomNodeAccessor(value, "valueAsNumber", [
|
|
326
|
+
[__velarDomNativeNode, __velarDomNodeFieldNumber], [__velarDomNativeInputElement, __velarDomInputNumberGet],
|
|
327
|
+
], [], false);
|
|
328
|
+
}
|
|
329
|
+
function __velarDomFieldChecked(value) {
|
|
330
|
+
return __velarDomNodeAccessor(value, "checked", [
|
|
331
|
+
[__velarDomNativeNode, __velarDomNodeFieldChecked], [__velarDomNativeInputElement, __velarDomInputCheckedGet],
|
|
332
|
+
], [], false);
|
|
333
|
+
}
|
|
334
|
+
function __velarDomSetFieldChecked(value, next) {
|
|
335
|
+
return __velarDomNodeAccessor(value, "checked", [
|
|
336
|
+
[__velarDomNativeNode, __velarDomNodeSetFieldChecked], [__velarDomNativeInputElement, __velarDomInputCheckedSet],
|
|
337
|
+
], [next], true);
|
|
338
|
+
}
|
|
339
|
+
function __velarDomNodeType(value) {
|
|
340
|
+
if (__velarDomInstance(value, __velarDomNativeNode) && typeof __velarDomNodeNodeType === "function") {
|
|
341
|
+
return __velarDomApply(__velarDomNodeNodeType, value, [], "Node.nodeType");
|
|
342
|
+
}
|
|
343
|
+
const nodeType = __velarDomOwnData(value, "nodeType");
|
|
344
|
+
return typeof nodeType === "number" ? nodeType : null;
|
|
345
|
+
}
|
|
346
|
+
function __velarDomSetText(value, next) {
|
|
347
|
+
if (__velarDomInstance(value, __velarDomNativeNode) && typeof __velarDomNodeTextContentSet === "function") {
|
|
348
|
+
return __velarDomApply(__velarDomNodeTextContentSet, value, [next], "Node.textContent");
|
|
349
|
+
}
|
|
350
|
+
const descriptor = __velarDomOwnDescriptor(value, "textContent");
|
|
351
|
+
if (!descriptor?.enumerable || !("value" in descriptor) || descriptor.writable !== true
|
|
352
|
+
|| typeof __velarDomDefineProperty !== "function" || typeof __velarDomReflectApply !== "function") {
|
|
353
|
+
throw new TypeError("The value does not expose native DOM textContent");
|
|
354
|
+
}
|
|
355
|
+
return __velarDomReflectApply(__velarDomDefineProperty, __velarDomNativeObject, [value, "textContent", { ...descriptor, value: next }]);
|
|
356
|
+
}
|
|
357
|
+
function __velarDomIsNode(value) {
|
|
358
|
+
return __velarDomInstance(value, __velarDomNativeNode) || __velarDomNodeType(value) !== null;
|
|
359
|
+
}
|
|
360
|
+
function __velarDomCollectionSnapshot(value, name) {
|
|
361
|
+
let length = null;
|
|
362
|
+
let read = null;
|
|
363
|
+
if (__velarDomInstance(value, __velarDomNativeNodeList) && typeof __velarDomNodeListLength === "function" && typeof __velarDomNodeListItem === "function") {
|
|
364
|
+
length = __velarDomApply(__velarDomNodeListLength, value, [], name + ".length");
|
|
365
|
+
read = (index) => __velarDomApply(__velarDomNodeListItem, value, [index], name + ".item");
|
|
366
|
+
} else if (__velarDomIsArray(value)) {
|
|
367
|
+
length = __velarDomOwnDescriptor(value, "length")?.value;
|
|
368
|
+
read = (index) => __velarDomOwnDescriptor(value, index)?.value;
|
|
369
|
+
}
|
|
370
|
+
if (!__velarDomIsInteger(length) || length < 0 || length > 1000000 || read === null) throw new TypeError(name + " is not a bounded native collection");
|
|
371
|
+
const output = new __velarDomNativeArray(length);
|
|
372
|
+
for (let index = 0; index < length; index += 1) output[index] = read(index);
|
|
373
|
+
return output;
|
|
374
|
+
}
|
|
375
|
+
function __velarDomChildNodes(value) {
|
|
376
|
+
let children;
|
|
377
|
+
if (__velarDomInstance(value, __velarDomNativeNode) && typeof __velarDomNodeChildNodes === "function") {
|
|
378
|
+
children = __velarDomApply(__velarDomNodeChildNodes, value, [], "Node.childNodes");
|
|
379
|
+
} else children = __velarDomOwnData(value, "childNodes");
|
|
380
|
+
return __velarDomCollectionSnapshot(children, "Node.childNodes");
|
|
381
|
+
}
|
|
382
|
+
function __velarDomIsArray(value) {
|
|
383
|
+
return typeof __velarDomArrayIsArray === "function" && typeof __velarDomReflectApply === "function"
|
|
384
|
+
&& __velarDomReflectApply(__velarDomArrayIsArray, __velarDomNativeArray, [value]);
|
|
385
|
+
}
|
|
386
|
+
function __velarDomIsFinite(value) {
|
|
387
|
+
return typeof __velarDomNumberIsFinite === "function" && typeof __velarDomReflectApply === "function"
|
|
388
|
+
&& __velarDomReflectApply(__velarDomNumberIsFinite, __velarDomNativeNumber, [value]);
|
|
389
|
+
}
|
|
390
|
+
function __velarDomIsInteger(value) {
|
|
391
|
+
return typeof __velarDomNumberIsInteger === "function" && typeof __velarDomReflectApply === "function"
|
|
392
|
+
&& __velarDomReflectApply(__velarDomNumberIsInteger, __velarDomNativeNumber, [value]);
|
|
393
|
+
}
|
|
394
|
+
function __velarDomString(value) { return __velarDomApply(__velarDomNativeString, undefined, [value], "String"); }
|
|
395
|
+
function __velarDomListSnapshot(value, name) {
|
|
396
|
+
if (!__velarDomIsArray(value)) throw new TypeError(name + " requires a List");
|
|
397
|
+
const lengthDescriptor = __velarDomOwnDescriptor(value, "length");
|
|
398
|
+
if (!lengthDescriptor || lengthDescriptor.writable !== true || lengthDescriptor.enumerable
|
|
399
|
+
|| lengthDescriptor.configurable || !("value" in lengthDescriptor)) {
|
|
400
|
+
throw new TypeError(name + " requires an ordinary mutable List length");
|
|
401
|
+
}
|
|
402
|
+
const length = lengthDescriptor.value;
|
|
403
|
+
if (!__velarDomIsInteger(length) || length < 0 || length > 1000000) throw new RangeError(name + " cannot exceed 1000000 items");
|
|
404
|
+
const names = __velarDomApply(__velarDomGetOwnPropertyNames, __velarDomNativeObject, [value]);
|
|
405
|
+
const symbols = __velarDomApply(__velarDomGetOwnPropertySymbols, __velarDomNativeObject, [value]);
|
|
406
|
+
if (symbols.length > 0 || names.length !== length + 1) throw new TypeError(name + " requires a dense List without extra fields");
|
|
407
|
+
const output = new __velarDomNativeArray(length);
|
|
408
|
+
for (let index = 0; index < length; index += 1) {
|
|
409
|
+
const descriptor = __velarDomOwnDescriptor(value, index);
|
|
410
|
+
if (!descriptor?.enumerable || !descriptor.configurable || !descriptor.writable || !("value" in descriptor)) {
|
|
411
|
+
throw new TypeError(name + " requires ordinary mutable List elements");
|
|
412
|
+
}
|
|
413
|
+
output[index] = descriptor.value;
|
|
414
|
+
}
|
|
415
|
+
return output;
|
|
416
|
+
}
|
|
417
|
+
function __velarDomCreateSet() {
|
|
418
|
+
if (typeof __velarDomNativeSet !== "function") throw new TypeError("The browser Set API is unavailable");
|
|
419
|
+
return new __velarDomNativeSet();
|
|
420
|
+
}
|
|
421
|
+
function __velarDomSetContains(value, item) { return __velarDomApply(__velarDomSetHas, value, [item], "Set.has"); }
|
|
422
|
+
function __velarDomSetInsert(value, item) { return __velarDomApply(__velarDomSetAdd, value, [item], "Set.add"); }
|
|
423
|
+
function __velarDomSetRemove(value, item) { return __velarDomApply(__velarDomSetDelete, value, [item], "Set.delete"); }
|
|
424
|
+
`.trimStart();
|
|
425
|
+
export const WEB_REACTIVITY_HOST_RUNTIME = String.raw `
|
|
426
|
+
const __velarGraphNativeObject = globalThis.Object;
|
|
427
|
+
const __velarGraphNativeArray = globalThis.Array;
|
|
428
|
+
const __velarGraphNativeSet = globalThis.Set;
|
|
429
|
+
const __velarGraphNativeMap = globalThis.Map;
|
|
430
|
+
const __velarGraphNativeWeakSet = globalThis.WeakSet;
|
|
431
|
+
const __velarGraphNativeWeakMap = globalThis.WeakMap;
|
|
432
|
+
const __velarGraphNativeProxy = globalThis.Proxy;
|
|
433
|
+
const __velarGraphReflectApply = Object.getOwnPropertyDescriptor(Reflect, "apply")?.value;
|
|
434
|
+
const __velarGraphArrayIsArray = Object.getOwnPropertyDescriptor(Array, "isArray")?.value;
|
|
435
|
+
const __velarGraphObjectIs = Object.getOwnPropertyDescriptor(Object, "is")?.value;
|
|
436
|
+
const __velarGraphObjectFreeze = Object.getOwnPropertyDescriptor(Object, "freeze")?.value;
|
|
437
|
+
const __velarGraphObjectDefineProperty = Object.getOwnPropertyDescriptor(Object, "defineProperty")?.value;
|
|
438
|
+
const __velarGraphObjectIsExtensible = Object.getOwnPropertyDescriptor(Object, "isExtensible")?.value;
|
|
439
|
+
const __velarGraphObjectGetPrototypeOf = Object.getOwnPropertyDescriptor(Object, "getPrototypeOf")?.value;
|
|
440
|
+
const __velarGraphObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor(Object, "getOwnPropertyDescriptor")?.value;
|
|
441
|
+
const __velarGraphObjectGetOwnPropertyNames = Object.getOwnPropertyDescriptor(Object, "getOwnPropertyNames")?.value;
|
|
442
|
+
const __velarGraphObjectCreate = Object.getOwnPropertyDescriptor(Object, "create")?.value;
|
|
443
|
+
const __velarGraphSetPrototype = Object.getOwnPropertyDescriptor(__velarGraphNativeSet, "prototype")?.value;
|
|
444
|
+
const __velarGraphSetHas = __velarGraphSetPrototype && Object.getOwnPropertyDescriptor(__velarGraphSetPrototype, "has")?.value;
|
|
445
|
+
const __velarGraphSetAdd = __velarGraphSetPrototype && Object.getOwnPropertyDescriptor(__velarGraphSetPrototype, "add")?.value;
|
|
446
|
+
const __velarGraphSetDelete = __velarGraphSetPrototype && Object.getOwnPropertyDescriptor(__velarGraphSetPrototype, "delete")?.value;
|
|
447
|
+
const __velarGraphSetClear = __velarGraphSetPrototype && Object.getOwnPropertyDescriptor(__velarGraphSetPrototype, "clear")?.value;
|
|
448
|
+
const __velarGraphSetValues = __velarGraphSetPrototype && Object.getOwnPropertyDescriptor(__velarGraphSetPrototype, "values")?.value;
|
|
449
|
+
const __velarGraphSetSize = __velarGraphSetPrototype && Object.getOwnPropertyDescriptor(__velarGraphSetPrototype, "size")?.get;
|
|
450
|
+
const __velarGraphMapPrototype = Object.getOwnPropertyDescriptor(__velarGraphNativeMap, "prototype")?.value;
|
|
451
|
+
const __velarGraphMapHas = __velarGraphMapPrototype && Object.getOwnPropertyDescriptor(__velarGraphMapPrototype, "has")?.value;
|
|
452
|
+
const __velarGraphMapGet = __velarGraphMapPrototype && Object.getOwnPropertyDescriptor(__velarGraphMapPrototype, "get")?.value;
|
|
453
|
+
const __velarGraphMapSet = __velarGraphMapPrototype && Object.getOwnPropertyDescriptor(__velarGraphMapPrototype, "set")?.value;
|
|
454
|
+
const __velarGraphMapDelete = __velarGraphMapPrototype && Object.getOwnPropertyDescriptor(__velarGraphMapPrototype, "delete")?.value;
|
|
455
|
+
const __velarGraphMapClear = __velarGraphMapPrototype && Object.getOwnPropertyDescriptor(__velarGraphMapPrototype, "clear")?.value;
|
|
456
|
+
const __velarGraphMapValues = __velarGraphMapPrototype && Object.getOwnPropertyDescriptor(__velarGraphMapPrototype, "values")?.value;
|
|
457
|
+
const __velarGraphMapKeys = __velarGraphMapPrototype && Object.getOwnPropertyDescriptor(__velarGraphMapPrototype, "keys")?.value;
|
|
458
|
+
const __velarGraphMapSize = __velarGraphMapPrototype && Object.getOwnPropertyDescriptor(__velarGraphMapPrototype, "size")?.get;
|
|
459
|
+
const __velarGraphWeakSetPrototype = Object.getOwnPropertyDescriptor(__velarGraphNativeWeakSet, "prototype")?.value;
|
|
460
|
+
const __velarGraphWeakSetHas = __velarGraphWeakSetPrototype && Object.getOwnPropertyDescriptor(__velarGraphWeakSetPrototype, "has")?.value;
|
|
461
|
+
const __velarGraphWeakSetAdd = __velarGraphWeakSetPrototype && Object.getOwnPropertyDescriptor(__velarGraphWeakSetPrototype, "add")?.value;
|
|
462
|
+
const __velarGraphWeakSetDelete = __velarGraphWeakSetPrototype && Object.getOwnPropertyDescriptor(__velarGraphWeakSetPrototype, "delete")?.value;
|
|
463
|
+
const __velarGraphWeakMapPrototype = Object.getOwnPropertyDescriptor(__velarGraphNativeWeakMap, "prototype")?.value;
|
|
464
|
+
const __velarGraphWeakMapHas = __velarGraphWeakMapPrototype && Object.getOwnPropertyDescriptor(__velarGraphWeakMapPrototype, "has")?.value;
|
|
465
|
+
const __velarGraphWeakMapGet = __velarGraphWeakMapPrototype && Object.getOwnPropertyDescriptor(__velarGraphWeakMapPrototype, "get")?.value;
|
|
466
|
+
const __velarGraphWeakMapSet = __velarGraphWeakMapPrototype && Object.getOwnPropertyDescriptor(__velarGraphWeakMapPrototype, "set")?.value;
|
|
467
|
+
const __velarGraphWeakMapDelete = __velarGraphWeakMapPrototype && Object.getOwnPropertyDescriptor(__velarGraphWeakMapPrototype, "delete")?.value;
|
|
468
|
+
const __velarGraphReflectGet = Object.getOwnPropertyDescriptor(Reflect, "get")?.value;
|
|
469
|
+
const __velarGraphReflectSet = Object.getOwnPropertyDescriptor(Reflect, "set")?.value;
|
|
470
|
+
const __velarGraphReflectHas = Object.getOwnPropertyDescriptor(Reflect, "has")?.value;
|
|
471
|
+
const __velarGraphReflectDeleteProperty = Object.getOwnPropertyDescriptor(Reflect, "deleteProperty")?.value;
|
|
472
|
+
function __velarGraphApply(operation, receiver, arguments_, label) {
|
|
473
|
+
if (typeof operation !== "function" || typeof __velarGraphReflectApply !== "function") {
|
|
474
|
+
throw new TypeError("The JavaScript " + label + " API is unavailable");
|
|
475
|
+
}
|
|
476
|
+
return __velarGraphReflectApply(operation, receiver, arguments_);
|
|
477
|
+
}
|
|
478
|
+
function __velarGraphCreateSet(values) {
|
|
479
|
+
const output = new __velarGraphNativeSet();
|
|
480
|
+
if (values !== undefined) for (const value of values) __velarGraphSetInsert(output, value);
|
|
481
|
+
return output;
|
|
482
|
+
}
|
|
483
|
+
function __velarGraphCreateMap(values) {
|
|
484
|
+
const output = new __velarGraphNativeMap();
|
|
485
|
+
if (values !== undefined) for (const entry of values) __velarGraphMapWrite(output, entry[0], entry[1]);
|
|
486
|
+
return output;
|
|
487
|
+
}
|
|
488
|
+
function __velarGraphCreateWeakSet() { return new __velarGraphNativeWeakSet(); }
|
|
489
|
+
function __velarGraphCreateWeakMap() { return new __velarGraphNativeWeakMap(); }
|
|
490
|
+
function __velarGraphSetContains(value, item) { return __velarGraphApply(__velarGraphSetHas, value, [item], "Set.has"); }
|
|
491
|
+
function __velarGraphSetInsert(value, item) { return __velarGraphApply(__velarGraphSetAdd, value, [item], "Set.add"); }
|
|
492
|
+
function __velarGraphSetRemove(value, item) { return __velarGraphApply(__velarGraphSetDelete, value, [item], "Set.delete"); }
|
|
493
|
+
function __velarGraphSetEmpty(value) { return __velarGraphApply(__velarGraphSetClear, value, [], "Set.clear"); }
|
|
494
|
+
function __velarGraphSetItems(value) { return __velarGraphApply(__velarGraphSetValues, value, [], "Set.values"); }
|
|
495
|
+
function __velarGraphSetCount(value) { return __velarGraphApply(__velarGraphSetSize, value, [], "Set.size"); }
|
|
496
|
+
function __velarGraphMapContains(value, key) { return __velarGraphApply(__velarGraphMapHas, value, [key], "Map.has"); }
|
|
497
|
+
function __velarGraphMapRead(value, key) { return __velarGraphApply(__velarGraphMapGet, value, [key], "Map.get"); }
|
|
498
|
+
function __velarGraphMapWrite(value, key, item) { return __velarGraphApply(__velarGraphMapSet, value, [key, item], "Map.set"); }
|
|
499
|
+
function __velarGraphMapRemove(value, key) { return __velarGraphApply(__velarGraphMapDelete, value, [key], "Map.delete"); }
|
|
500
|
+
function __velarGraphMapItems(value) { return __velarGraphApply(__velarGraphMapValues, value, [], "Map.values"); }
|
|
501
|
+
function __velarGraphMapEmpty(value) { return __velarGraphApply(__velarGraphMapClear, value, [], "Map.clear"); }
|
|
502
|
+
function __velarGraphMapKeyItems(value) { return __velarGraphApply(__velarGraphMapKeys, value, [], "Map.keys"); }
|
|
503
|
+
function __velarGraphMapCount(value) { return __velarGraphApply(__velarGraphMapSize, value, [], "Map.size"); }
|
|
504
|
+
function __velarGraphWeakSetContains(value, item) { return __velarGraphApply(__velarGraphWeakSetHas, value, [item], "WeakSet.has"); }
|
|
505
|
+
function __velarGraphWeakSetInsert(value, item) { return __velarGraphApply(__velarGraphWeakSetAdd, value, [item], "WeakSet.add"); }
|
|
506
|
+
function __velarGraphWeakSetRemove(value, item) { return __velarGraphApply(__velarGraphWeakSetDelete, value, [item], "WeakSet.delete"); }
|
|
507
|
+
function __velarGraphWeakMapContains(value, key) { return __velarGraphApply(__velarGraphWeakMapHas, value, [key], "WeakMap.has"); }
|
|
508
|
+
function __velarGraphWeakMapRead(value, key) { return __velarGraphApply(__velarGraphWeakMapGet, value, [key], "WeakMap.get"); }
|
|
509
|
+
function __velarGraphWeakMapWrite(value, key, item) { return __velarGraphApply(__velarGraphWeakMapSet, value, [key, item], "WeakMap.set"); }
|
|
510
|
+
function __velarGraphWeakMapRemove(value, key) { return __velarGraphApply(__velarGraphWeakMapDelete, value, [key], "WeakMap.delete"); }
|
|
511
|
+
function __velarGraphIsList(value) { return __velarGraphApply(__velarGraphArrayIsArray, __velarGraphNativeArray, [value], "Array.isArray"); }
|
|
512
|
+
function __velarGraphSame(left, right) { return __velarGraphApply(__velarGraphObjectIs, __velarGraphNativeObject, [left, right], "Object.is"); }
|
|
513
|
+
function __velarGraphFreeze(value) { return __velarGraphApply(__velarGraphObjectFreeze, __velarGraphNativeObject, [value], "Object.freeze"); }
|
|
514
|
+
function __velarGraphDefine(value, key, descriptor) { return __velarGraphApply(__velarGraphObjectDefineProperty, __velarGraphNativeObject, [value, key, descriptor], "Object.defineProperty"); }
|
|
515
|
+
function __velarGraphIsExtensible(value) { return __velarGraphApply(__velarGraphObjectIsExtensible, __velarGraphNativeObject, [value], "Object.isExtensible"); }
|
|
516
|
+
function __velarGraphPrototype(value) { return __velarGraphApply(__velarGraphObjectGetPrototypeOf, __velarGraphNativeObject, [value], "Object.getPrototypeOf"); }
|
|
517
|
+
function __velarGraphOwnDescriptor(value, key) { return __velarGraphApply(__velarGraphObjectGetOwnPropertyDescriptor, __velarGraphNativeObject, [value, key], "Object.getOwnPropertyDescriptor"); }
|
|
518
|
+
function __velarGraphOwnNames(value) { return __velarGraphApply(__velarGraphObjectGetOwnPropertyNames, __velarGraphNativeObject, [value], "Object.getOwnPropertyNames"); }
|
|
519
|
+
function __velarGraphCreateRecord() { return __velarGraphApply(__velarGraphObjectCreate, __velarGraphNativeObject, [null], "Object.create"); }
|
|
520
|
+
function __velarGraphGet(value, key, receiver) { return __velarGraphApply(__velarGraphReflectGet, null, [value, key, receiver], "Reflect.get"); }
|
|
521
|
+
function __velarGraphSet(value, key, item, receiver) { return __velarGraphApply(__velarGraphReflectSet, null, [value, key, item, receiver], "Reflect.set"); }
|
|
522
|
+
function __velarGraphHas(value, key) { return __velarGraphApply(__velarGraphReflectHas, null, [value, key], "Reflect.has"); }
|
|
523
|
+
function __velarGraphDelete(value, key) { return __velarGraphApply(__velarGraphReflectDeleteProperty, null, [value, key], "Reflect.deleteProperty"); }
|
|
524
|
+
`.trimStart();
|
|
525
|
+
export const WEB_ERROR_HOST_RUNTIME_BODY = String.raw `
|
|
526
|
+
const __velarWebErrorNativeObject = globalThis.Object;
|
|
527
|
+
const __velarWebErrorNativeNumber = globalThis.Number;
|
|
528
|
+
const __velarWebErrorNativePromise = globalThis.Promise;
|
|
529
|
+
const __velarWebErrorOwnSymbolsOperation = Object.getOwnPropertyDescriptor(Object, "getOwnPropertySymbols")?.value;
|
|
530
|
+
const __velarWebErrorFreezeOperation = Object.getOwnPropertyDescriptor(Object, "freeze")?.value;
|
|
531
|
+
const __velarWebErrorFiniteOperation = Object.getOwnPropertyDescriptor(Number, "isFinite")?.value;
|
|
532
|
+
const __velarWebErrorPromisePrototype = Object.getOwnPropertyDescriptor(__velarWebErrorNativePromise, "prototype")?.value;
|
|
533
|
+
const __velarWebErrorThenOperation = __velarWebErrorPromisePrototype
|
|
534
|
+
? Object.getOwnPropertyDescriptor(__velarWebErrorPromisePrototype, "then")?.value
|
|
535
|
+
: null;
|
|
536
|
+
function __velarWebErrorOwnSymbols(value) {
|
|
537
|
+
return __velarErrorApply(__velarWebErrorOwnSymbolsOperation, __velarWebErrorNativeObject, [value], "Object.getOwnPropertySymbols");
|
|
538
|
+
}
|
|
539
|
+
function __velarWebErrorFreeze(value) {
|
|
540
|
+
return __velarErrorApply(__velarWebErrorFreezeOperation, __velarWebErrorNativeObject, [value], "Object.freeze");
|
|
541
|
+
}
|
|
542
|
+
function __velarWebErrorFinite(value) {
|
|
543
|
+
return __velarErrorApply(__velarWebErrorFiniteOperation, __velarWebErrorNativeNumber, [value], "Number.isFinite");
|
|
544
|
+
}
|
|
545
|
+
function __velarObservePromise(value, onRejected) {
|
|
546
|
+
if ((typeof value !== "object" && typeof value !== "function") || value === null) return null;
|
|
547
|
+
try { return __velarErrorApply(__velarWebErrorThenOperation, value, [undefined, onRejected], "Promise.then"); }
|
|
548
|
+
catch { return null; }
|
|
549
|
+
}
|
|
550
|
+
`.trimStart();
|
|
551
|
+
export const WEB_ERROR_HOST_RUNTIME = `${VELAR_ERROR_NORMALIZATION_RUNTIME}\n${WEB_ERROR_HOST_RUNTIME_BODY}`;
|
|
552
|
+
function webRuntimeFoundation(errorHostRuntime) {
|
|
553
|
+
return String.raw `
|
|
554
|
+
${WEB_REACTIVITY_HOST_RUNTIME}
|
|
555
|
+
${WEB_DOM_HOST_RUNTIME}
|
|
556
|
+
${errorHostRuntime}
|
|
557
|
+
const __velarRuntimeKey = Symbol.for(${JSON.stringify(VELAR_RUNTIME_REGISTRY_KEY)});
|
|
558
|
+
const __velarFoundationReflectApply = Object.getOwnPropertyDescriptor(Reflect, "apply")?.value;
|
|
559
|
+
const __velarFoundationQueueMicrotask = globalThis.queueMicrotask;
|
|
560
|
+
const __velarFoundationDate = globalThis.Date;
|
|
561
|
+
const __velarFoundationDateNow = typeof __velarFoundationDate === "function"
|
|
562
|
+
? Object.getOwnPropertyDescriptor(__velarFoundationDate, "now")?.value
|
|
563
|
+
: null;
|
|
564
|
+
const __velarFoundationConsole = globalThis.console ?? null;
|
|
565
|
+
const __velarFoundationConsoleError = __velarFoundationConsole !== null
|
|
566
|
+
? Object.getOwnPropertyDescriptor(__velarFoundationConsole, "error")?.value ?? null
|
|
567
|
+
: null;
|
|
568
|
+
function __velarFoundationTrace(error) {
|
|
569
|
+
if (typeof __velarFoundationConsoleError !== "function" || typeof __velarFoundationReflectApply !== "function") return;
|
|
570
|
+
let trace = "An unhandled VelarScript failure was reported";
|
|
571
|
+
try { const stack = error.stack; if (typeof stack === "string" && stack !== "") trace = stack; } catch {}
|
|
572
|
+
if (trace === "An unhandled VelarScript failure was reported") {
|
|
573
|
+
try { const message = error.message; if (typeof message === "string" && message !== "") trace = message; } catch {}
|
|
574
|
+
}
|
|
575
|
+
try { __velarFoundationReflectApply(__velarFoundationConsoleError, __velarFoundationConsole, ["Unhandled VelarScript error report: " + trace]); } catch {}
|
|
576
|
+
}
|
|
577
|
+
function __velarEnqueue(callback) {
|
|
578
|
+
if (typeof __velarFoundationQueueMicrotask !== "function" || typeof __velarFoundationReflectApply !== "function") {
|
|
579
|
+
throw new TypeError("The browser queueMicrotask API is unavailable");
|
|
580
|
+
}
|
|
581
|
+
return __velarFoundationReflectApply(__velarFoundationQueueMicrotask, globalThis, [callback]);
|
|
582
|
+
}
|
|
583
|
+
function __velarNow() {
|
|
584
|
+
if (typeof __velarFoundationDateNow !== "function" || typeof __velarFoundationReflectApply !== "function") {
|
|
585
|
+
throw new TypeError("The browser Date.now API is unavailable");
|
|
586
|
+
}
|
|
587
|
+
return __velarFoundationReflectApply(__velarFoundationDateNow, __velarFoundationDate, []);
|
|
588
|
+
}
|
|
589
|
+
const __velarRuntimeFields = Object.freeze([
|
|
590
|
+
"version", "domQueue", "watchQueue", "flushPending", "activeObserver", "errorHandlers",
|
|
591
|
+
"actionFailures", "unhandledFailures", "lookSources", "classSources", "dependencies", "rawToProxy", "proxyToRaw",
|
|
592
|
+
"versions", "parents", "toRaw", "reactive", "track", "trackDeep", "trigger", "versionOf",
|
|
593
|
+
"collectionRead", "collectionTrigger", "collectionUnlink", "trackSubscribers", "runTracked", "cleanupObserver", "computed",
|
|
594
|
+
"schedule", "report", "applyLook", "installLook",
|
|
595
|
+
]);
|
|
596
|
+
|
|
597
|
+
function __velarRuntimeCollection(value, kind) {
|
|
598
|
+
try {
|
|
599
|
+
if (kind === "Set") __velarGraphSetContains(value, value);
|
|
600
|
+
else if (kind === "WeakSet") __velarGraphWeakSetContains(value, value);
|
|
601
|
+
else __velarGraphWeakMapContains(value, value);
|
|
602
|
+
return true;
|
|
603
|
+
} catch { return false; }
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
function __velarReportOptions(value) {
|
|
607
|
+
if (value === undefined) value = {};
|
|
608
|
+
if (!value || typeof value !== "object" || __velarGraphIsList(value)
|
|
609
|
+
|| (__velarGraphPrototype(value) !== __velarGraphNativeObject.prototype && __velarGraphPrototype(value) !== null)
|
|
610
|
+
|| __velarWebErrorOwnSymbols(value).length > 0) {
|
|
611
|
+
throw new TypeError("VelarScript error report options must be a record");
|
|
612
|
+
}
|
|
613
|
+
const allowed = __velarGraphCreateSet(["phase", "detail", "component", "unhandled"]);
|
|
614
|
+
const output = { phase: "runtime", detail: "", component: "", unhandled: false };
|
|
615
|
+
for (const name of __velarGraphOwnNames(value)) {
|
|
616
|
+
if (!__velarGraphSetContains(allowed, name)) throw new TypeError("Unknown VelarScript error report option '" + name + "'");
|
|
617
|
+
const descriptor = __velarGraphOwnDescriptor(value, name);
|
|
618
|
+
if (!descriptor || !("value" in descriptor)) throw new TypeError("VelarScript error report options cannot use accessors");
|
|
619
|
+
const next = descriptor.value;
|
|
620
|
+
if (name === "unhandled") {
|
|
621
|
+
if (typeof next !== "boolean") throw new TypeError("VelarScript error report unhandled must be bool");
|
|
622
|
+
output.unhandled = next;
|
|
623
|
+
} else {
|
|
624
|
+
if (typeof next !== "string") throw new TypeError("VelarScript error report " + name + " must be a string");
|
|
625
|
+
const maximum = name === "phase" ? 256 : name === "component" ? 1024 : 65536;
|
|
626
|
+
if (next.length > maximum) throw new RangeError("VelarScript error report " + name + " is too long");
|
|
627
|
+
output[name] = next;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
return output;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
function __velarCreateRuntime() {
|
|
634
|
+
const runtime = Object.create(null);
|
|
635
|
+
const domQueue = Object.freeze(__velarGraphCreateSet());
|
|
636
|
+
const watchQueue = Object.freeze(__velarGraphCreateSet());
|
|
637
|
+
const errorHandlers = Object.freeze(__velarGraphCreateSet());
|
|
638
|
+
const unhandledFailures = Object.freeze(__velarGraphCreateSet());
|
|
639
|
+
const actionFailures = Object.freeze(__velarGraphCreateWeakSet());
|
|
640
|
+
const lookSources = Object.freeze(__velarGraphCreateWeakMap());
|
|
641
|
+
const classSources = Object.freeze(__velarGraphCreateWeakMap());
|
|
642
|
+
const dependencies = Object.freeze(__velarGraphCreateWeakMap());
|
|
643
|
+
const rawToProxy = Object.freeze(__velarGraphCreateWeakMap());
|
|
644
|
+
const proxyToRaw = Object.freeze(__velarGraphCreateWeakMap());
|
|
645
|
+
const versions = Object.freeze(__velarGraphCreateWeakMap());
|
|
646
|
+
const parents = Object.freeze(__velarGraphCreateWeakMap());
|
|
647
|
+
const subscriptionStops = __velarGraphCreateWeakMap();
|
|
648
|
+
const collectionBrands = __velarGraphCreateWeakMap();
|
|
649
|
+
const iterateKey = Symbol.for("velar.reactive.iterate.v1");
|
|
650
|
+
const structureKey = Symbol.for("velar.reactive.structure.v1");
|
|
651
|
+
const deepKey = Symbol.for("velar.reactive.deep.v1");
|
|
652
|
+
let lookImplementation = null;
|
|
653
|
+
const toRaw = (value) => {
|
|
654
|
+
if ((typeof value !== "object" && typeof value !== "function") || value === null) return value;
|
|
655
|
+
return __velarGraphWeakMapRead(proxyToRaw, value) ?? value;
|
|
656
|
+
};
|
|
657
|
+
const trackSubscribers = (subscribers) => {
|
|
658
|
+
const observer = runtime.activeObserver;
|
|
659
|
+
if (!observer || observer.stopped) return;
|
|
660
|
+
__velarGraphSetInsert(subscribers, observer);
|
|
661
|
+
__velarGraphSetInsert(observer.dependencies, subscribers);
|
|
662
|
+
};
|
|
663
|
+
const runTracked = (observer, read) => {
|
|
664
|
+
const previousDependencies = observer.dependencies;
|
|
665
|
+
// Every run needs a second dependency set to diff against, and an observer
|
|
666
|
+
// that re-runs thousands of times per second would otherwise allocate one
|
|
667
|
+
// per run. The emptied previous set is kept as the next run's buffer.
|
|
668
|
+
const spare = observer.spareDependencies;
|
|
669
|
+
observer.spareDependencies = null;
|
|
670
|
+
observer.dependencies = spare ?? __velarGraphCreateSet();
|
|
671
|
+
const previousObserver = runtime.activeObserver;
|
|
672
|
+
runtime.activeObserver = observer;
|
|
673
|
+
try { return read(); }
|
|
674
|
+
finally {
|
|
675
|
+
runtime.activeObserver = previousObserver;
|
|
676
|
+
for (const subscribers of __velarGraphSetItems(previousDependencies)) {
|
|
677
|
+
if (__velarGraphSetContains(observer.dependencies, subscribers)) continue;
|
|
678
|
+
// A stop fires exactly when an actual removal empties the set. Firing
|
|
679
|
+
// on an already-empty set would let two detaching computeds whose
|
|
680
|
+
// cleanups have not yet emptied their dependency sets re-trigger each
|
|
681
|
+
// other without bound.
|
|
682
|
+
if (__velarGraphSetRemove(subscribers, observer) && __velarGraphSetCount(subscribers) === 0) {
|
|
683
|
+
const stop = __velarGraphWeakMapRead(subscriptionStops, subscribers);
|
|
684
|
+
if (stop) stop();
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
__velarGraphSetEmpty(previousDependencies);
|
|
688
|
+
observer.spareDependencies = previousDependencies;
|
|
689
|
+
}
|
|
690
|
+
};
|
|
691
|
+
const cleanupObserver = (observer) => {
|
|
692
|
+
for (const subscribers of __velarGraphSetItems(observer.dependencies)) {
|
|
693
|
+
if (__velarGraphSetRemove(subscribers, observer) && __velarGraphSetCount(subscribers) === 0) {
|
|
694
|
+
const stop = __velarGraphWeakMapRead(subscriptionStops, subscribers);
|
|
695
|
+
if (stop) stop();
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
__velarGraphSetEmpty(observer.dependencies);
|
|
699
|
+
};
|
|
700
|
+
const track = (target, key) => {
|
|
701
|
+
target = toRaw(target);
|
|
702
|
+
if ((typeof target !== "object" && typeof target !== "function") || target === null) return;
|
|
703
|
+
let byKey = __velarGraphWeakMapRead(dependencies, target);
|
|
704
|
+
if (!byKey) { byKey = __velarGraphCreateMap(); __velarGraphWeakMapWrite(dependencies, target, byKey); }
|
|
705
|
+
let subscribers = __velarGraphMapRead(byKey, key);
|
|
706
|
+
if (!subscribers) {
|
|
707
|
+
subscribers = __velarGraphCreateSet();
|
|
708
|
+
__velarGraphMapWrite(byKey, key, subscribers);
|
|
709
|
+
const ownedSubscribers = subscribers;
|
|
710
|
+
__velarGraphWeakMapWrite(subscriptionStops, subscribers, () => {
|
|
711
|
+
if (__velarGraphMapRead(byKey, key) !== ownedSubscribers) return;
|
|
712
|
+
__velarGraphMapRemove(byKey, key);
|
|
713
|
+
if (__velarGraphMapCount(byKey) === 0) __velarGraphWeakMapRemove(dependencies, target);
|
|
714
|
+
});
|
|
715
|
+
}
|
|
716
|
+
trackSubscribers(subscribers);
|
|
717
|
+
};
|
|
718
|
+
const notify = (target, key) => {
|
|
719
|
+
const byKey = __velarGraphWeakMapRead(dependencies, target);
|
|
720
|
+
const subscribers = byKey ? __velarGraphMapRead(byKey, key) : null;
|
|
721
|
+
if (subscribers) for (const observer of __velarGraphSetItems(subscribers)) observer.notify();
|
|
722
|
+
};
|
|
723
|
+
const bump = (target) => {
|
|
724
|
+
__velarGraphWeakMapWrite(versions, target, (__velarGraphWeakMapRead(versions, target) ?? 0) + 1);
|
|
725
|
+
};
|
|
726
|
+
const trigger = (target, key, iterate = false, structure = false, indexFrom = null, allKeys = false) => {
|
|
727
|
+
target = toRaw(target);
|
|
728
|
+
if ((typeof target !== "object" && typeof target !== "function") || target === null) return;
|
|
729
|
+
bump(target);
|
|
730
|
+
notify(target, key);
|
|
731
|
+
if (allKeys || indexFrom !== null) {
|
|
732
|
+
const byKey = __velarGraphWeakMapRead(dependencies, target);
|
|
733
|
+
if (byKey) for (const candidate of __velarGraphMapKeyItems(byKey)) {
|
|
734
|
+
if (candidate === key) continue;
|
|
735
|
+
if (allKeys || (typeof candidate === "number" && candidate >= indexFrom)) notify(target, candidate);
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
if (iterate) notify(target, iterateKey);
|
|
739
|
+
if (structure) notify(target, structureKey);
|
|
740
|
+
notify(target, deepKey);
|
|
741
|
+
const owners = __velarGraphWeakMapRead(parents, target);
|
|
742
|
+
// A mutation of an unowned value -- the overwhelmingly common case -- must
|
|
743
|
+
// not pay for the cycle bookkeeping that only an ancestor walk needs.
|
|
744
|
+
if (!owners) return;
|
|
745
|
+
const visited = __velarGraphCreateSet();
|
|
746
|
+
__velarGraphSetInsert(visited, target);
|
|
747
|
+
const bubble = (current) => {
|
|
748
|
+
if (__velarGraphSetContains(visited, current)) return;
|
|
749
|
+
__velarGraphSetInsert(visited, current);
|
|
750
|
+
bump(current);
|
|
751
|
+
notify(current, deepKey);
|
|
752
|
+
const next = __velarGraphWeakMapRead(parents, current);
|
|
753
|
+
if (next) for (const owner of __velarGraphSetItems(next)) bubble(owner);
|
|
754
|
+
};
|
|
755
|
+
for (const owner of __velarGraphSetItems(owners)) bubble(owner);
|
|
756
|
+
};
|
|
757
|
+
const link = (child, parent) => {
|
|
758
|
+
if (child === null || (typeof child !== "object" && typeof child !== "function")) return;
|
|
759
|
+
linkOwner(toRaw(child), parent);
|
|
760
|
+
};
|
|
761
|
+
const linkOwner = (child, parent) => {
|
|
762
|
+
parent = toRaw(parent);
|
|
763
|
+
if (parent === null || (typeof parent !== "object" && typeof parent !== "function") || child === parent) return;
|
|
764
|
+
let owners = __velarGraphWeakMapRead(parents, child);
|
|
765
|
+
if (!owners) { owners = __velarGraphCreateSet(); __velarGraphWeakMapWrite(parents, child, owners); }
|
|
766
|
+
__velarGraphSetInsert(owners, parent);
|
|
767
|
+
};
|
|
768
|
+
// Removing the last owner of a value detaches everything only that value
|
|
769
|
+
// owned. Without the cascade, replacing a state root leaves every surviving
|
|
770
|
+
// descendant pointing at the dead root: the root stays strongly reachable
|
|
771
|
+
// and each later deep mutation walks one more generation.
|
|
772
|
+
const release = (root) => {
|
|
773
|
+
const pending = [root];
|
|
774
|
+
let index = 0;
|
|
775
|
+
while (index < pending.length) {
|
|
776
|
+
const current = pending[index];
|
|
777
|
+
index += 1;
|
|
778
|
+
forEachOwnedValue(current, (value) => {
|
|
779
|
+
const owners = __velarGraphWeakMapRead(parents, value);
|
|
780
|
+
if (!owners || !__velarGraphSetContains(owners, current)) return;
|
|
781
|
+
__velarGraphSetRemove(owners, current);
|
|
782
|
+
if (__velarGraphSetCount(owners) > 0) return;
|
|
783
|
+
__velarGraphWeakMapRemove(parents, value);
|
|
784
|
+
pending[pending.length] = value;
|
|
785
|
+
});
|
|
786
|
+
}
|
|
787
|
+
};
|
|
788
|
+
const unlink = (child, parent) => {
|
|
789
|
+
child = toRaw(child);
|
|
790
|
+
parent = toRaw(parent);
|
|
791
|
+
const owners = child !== null && (typeof child === "object" || typeof child === "function")
|
|
792
|
+
? __velarGraphWeakMapRead(parents, child)
|
|
793
|
+
: null;
|
|
794
|
+
if (!owners) return;
|
|
795
|
+
__velarGraphSetRemove(owners, parent);
|
|
796
|
+
if (__velarGraphSetCount(owners) > 0) return;
|
|
797
|
+
__velarGraphWeakMapRemove(parents, child);
|
|
798
|
+
release(child);
|
|
799
|
+
};
|
|
800
|
+
// Map and Set membership is decided once per value and remembered: the only
|
|
801
|
+
// cross-realm test JavaScript offers is invoking a prototype accessor and
|
|
802
|
+
// catching, and a record write must not pay two thrown exceptions per field.
|
|
803
|
+
const collectionBrand = (value) => {
|
|
804
|
+
const known = __velarGraphWeakMapRead(collectionBrands, value);
|
|
805
|
+
if (known !== undefined) return known;
|
|
806
|
+
let brand = 0;
|
|
807
|
+
try { __velarGraphMapCount(value); brand = 1; }
|
|
808
|
+
catch {
|
|
809
|
+
try { __velarGraphSetCount(value); brand = 2; }
|
|
810
|
+
catch { brand = 0; }
|
|
811
|
+
}
|
|
812
|
+
__velarGraphWeakMapWrite(collectionBrands, value, brand);
|
|
813
|
+
return brand;
|
|
814
|
+
};
|
|
815
|
+
const forEachOwnedValue = (parent, visit) => {
|
|
816
|
+
if (parent === null || (typeof parent !== "object" && typeof parent !== "function")) return;
|
|
817
|
+
if (__velarGraphIsList(parent)) {
|
|
818
|
+
for (let index = 0; index < parent.length; index += 1) {
|
|
819
|
+
const value = toRaw(__velarGraphOwnDescriptor(parent, index)?.value);
|
|
820
|
+
if (value !== null && (typeof value === "object" || typeof value === "function")) visit(value);
|
|
821
|
+
}
|
|
822
|
+
return;
|
|
823
|
+
}
|
|
824
|
+
const brand = collectionBrand(parent);
|
|
825
|
+
if (brand === 1) {
|
|
826
|
+
for (const value of __velarGraphMapItems(parent)) {
|
|
827
|
+
const owned = toRaw(value);
|
|
828
|
+
if (owned !== null && (typeof owned === "object" || typeof owned === "function")) visit(owned);
|
|
829
|
+
}
|
|
830
|
+
// A Map key is linked to its Map exactly like a value, so releasing the
|
|
831
|
+
// Map has to release object keys too.
|
|
832
|
+
for (const value of __velarGraphMapKeyItems(parent)) {
|
|
833
|
+
const owned = toRaw(value);
|
|
834
|
+
if (owned !== null && (typeof owned === "object" || typeof owned === "function")) visit(owned);
|
|
835
|
+
}
|
|
836
|
+
return;
|
|
837
|
+
}
|
|
838
|
+
if (brand === 2) {
|
|
839
|
+
for (const value of __velarGraphSetItems(parent)) {
|
|
840
|
+
const owned = toRaw(value);
|
|
841
|
+
if (owned !== null && (typeof owned === "object" || typeof owned === "function")) visit(owned);
|
|
842
|
+
}
|
|
843
|
+
return;
|
|
844
|
+
}
|
|
845
|
+
if (typeof parent !== "object") return;
|
|
846
|
+
for (const name of __velarGraphOwnNames(parent)) {
|
|
847
|
+
const descriptor = __velarGraphOwnDescriptor(parent, name);
|
|
848
|
+
if (!descriptor || !("value" in descriptor)) continue;
|
|
849
|
+
const value = toRaw(descriptor.value);
|
|
850
|
+
if (value !== null && (typeof value === "object" || typeof value === "function")) visit(value);
|
|
851
|
+
}
|
|
852
|
+
};
|
|
853
|
+
const contains = (parent, child) => {
|
|
854
|
+
parent = toRaw(parent);
|
|
855
|
+
child = toRaw(child);
|
|
856
|
+
if (__velarGraphIsList(parent)) {
|
|
857
|
+
for (let index = 0; index < parent.length; index += 1) {
|
|
858
|
+
if (toRaw(__velarGraphOwnDescriptor(parent, index)?.value) === child) return true;
|
|
859
|
+
}
|
|
860
|
+
return false;
|
|
861
|
+
}
|
|
862
|
+
const brand = collectionBrand(parent);
|
|
863
|
+
if (brand === 1) {
|
|
864
|
+
for (const value of __velarGraphMapItems(parent)) if (toRaw(value) === child) return true;
|
|
865
|
+
return false;
|
|
866
|
+
}
|
|
867
|
+
if (brand === 2) {
|
|
868
|
+
for (const value of __velarGraphSetItems(parent)) if (toRaw(value) === child) return true;
|
|
869
|
+
return false;
|
|
870
|
+
}
|
|
871
|
+
if (!parent || typeof parent !== "object") return false;
|
|
872
|
+
for (const name of __velarGraphOwnNames(parent)) {
|
|
873
|
+
const descriptor = __velarGraphOwnDescriptor(parent, name);
|
|
874
|
+
if (descriptor && "value" in descriptor && toRaw(descriptor.value) === child) return true;
|
|
875
|
+
}
|
|
876
|
+
return false;
|
|
877
|
+
};
|
|
878
|
+
// The one guard every detach path shares: a primitive was never linked, and
|
|
879
|
+
// an object with no owners has nothing to release, so neither may reach the
|
|
880
|
+
// O(fields) containment scan.
|
|
881
|
+
const releaseChild = (parent, child) => {
|
|
882
|
+
if (child === null || (typeof child !== "object" && typeof child !== "function")
|
|
883
|
+
|| !__velarGraphWeakMapContains(parents, child)) return;
|
|
884
|
+
if (!contains(parent, child)) unlink(child, parent);
|
|
885
|
+
};
|
|
886
|
+
const reactive = (value, parent = null) => {
|
|
887
|
+
if (value === null || (typeof value !== "object" && typeof value !== "function")) return value;
|
|
888
|
+
value = toRaw(value);
|
|
889
|
+
if (parent !== null) linkOwner(value, parent);
|
|
890
|
+
if (typeof value !== "object" || __velarGraphIsList(value) || !__velarGraphIsExtensible(value)) return value;
|
|
891
|
+
const prototype = __velarGraphPrototype(value);
|
|
892
|
+
if (prototype !== __velarGraphNativeObject.prototype && prototype !== null) return value;
|
|
893
|
+
let proxy = __velarGraphWeakMapRead(rawToProxy, value);
|
|
894
|
+
if (proxy) return proxy;
|
|
895
|
+
proxy = new __velarGraphNativeProxy(value, {
|
|
896
|
+
get(target, key) {
|
|
897
|
+
track(target, key);
|
|
898
|
+
return reactive(__velarGraphGet(target, key, target), target);
|
|
899
|
+
},
|
|
900
|
+
set(target, key, next) {
|
|
901
|
+
next = toRaw(next);
|
|
902
|
+
const present = __velarGraphHas(target, key);
|
|
903
|
+
const previous = toRaw(__velarGraphGet(target, key, target));
|
|
904
|
+
// Creating an absent key is a structural change even when the value
|
|
905
|
+
// written equals the absent key's 'undefined' reading.
|
|
906
|
+
const changed = !present || !__velarGraphSame(previous, next);
|
|
907
|
+
const written = __velarGraphSet(target, key, next, target);
|
|
908
|
+
if (!written || !changed) return written;
|
|
909
|
+
link(next, target);
|
|
910
|
+
releaseChild(target, previous);
|
|
911
|
+
trigger(target, key, true, !present);
|
|
912
|
+
return true;
|
|
913
|
+
},
|
|
914
|
+
has(target, key) { track(target, key); return __velarGraphHas(target, key); },
|
|
915
|
+
deleteProperty(target, key) {
|
|
916
|
+
if (!__velarGraphHas(target, key)) return true;
|
|
917
|
+
const previous = toRaw(__velarGraphGet(target, key, target));
|
|
918
|
+
const deleted = __velarGraphDelete(target, key);
|
|
919
|
+
if (deleted) {
|
|
920
|
+
releaseChild(target, previous);
|
|
921
|
+
trigger(target, key, true, true);
|
|
922
|
+
}
|
|
923
|
+
return deleted;
|
|
924
|
+
},
|
|
925
|
+
});
|
|
926
|
+
__velarGraphWeakMapWrite(rawToProxy, value, proxy);
|
|
927
|
+
__velarGraphWeakMapWrite(proxyToRaw, proxy, value);
|
|
928
|
+
return proxy;
|
|
929
|
+
};
|
|
930
|
+
const trackDeep = (value) => { value = toRaw(value); track(value, deepKey); return value; };
|
|
931
|
+
const versionOf = (value) => {
|
|
932
|
+
value = toRaw(value);
|
|
933
|
+
return value && (typeof value === "object" || typeof value === "function")
|
|
934
|
+
? __velarGraphWeakMapRead(versions, value) ?? 0
|
|
935
|
+
: 0;
|
|
936
|
+
};
|
|
937
|
+
const collectionRead = (value, key, child) => {
|
|
938
|
+
value = toRaw(value);
|
|
939
|
+
track(value, key);
|
|
940
|
+
// Only containers already connected to a state graph own children read
|
|
941
|
+
// through them. Fresh derived Lists (filter/map/etc.) stay ephemeral and
|
|
942
|
+
// cannot become strongly retained parents of every item merely by being
|
|
943
|
+
// iterated during rendering.
|
|
944
|
+
return reactive(child, __velarGraphWeakMapContains(parents, value) ? value : null);
|
|
945
|
+
};
|
|
946
|
+
const collectionTrigger = (value, key, iterate = true, structure = false, indexFrom = null, allKeys = false) => trigger(toRaw(value), key, iterate, structure, indexFrom, allKeys);
|
|
947
|
+
const collectionUnlink = (value, child) => {
|
|
948
|
+
releaseChild(toRaw(value), toRaw(child));
|
|
949
|
+
};
|
|
950
|
+
const computed = (read) => {
|
|
951
|
+
if (typeof read !== "function") throw new TypeError("computed requires a function");
|
|
952
|
+
let dirty = true;
|
|
953
|
+
let evaluating = false;
|
|
954
|
+
let recursed = false;
|
|
955
|
+
let initialized = false;
|
|
956
|
+
let value;
|
|
957
|
+
let failed = false;
|
|
958
|
+
let failure;
|
|
959
|
+
const subscribers = __velarGraphCreateSet();
|
|
960
|
+
const notifyDependents = (skip = null) => {
|
|
961
|
+
for (const dependent of __velarGraphSetItems(subscribers)) if (dependent !== skip) dependent.notify();
|
|
962
|
+
};
|
|
963
|
+
const invalidateComputedDependents = () => {
|
|
964
|
+
for (const dependent of __velarGraphSetItems(subscribers)) {
|
|
965
|
+
if (dependent.mode === "computed") dependent.notify();
|
|
966
|
+
}
|
|
967
|
+
};
|
|
968
|
+
const observer = {
|
|
969
|
+
mode: "computed",
|
|
970
|
+
stopped: false,
|
|
971
|
+
running: false,
|
|
972
|
+
selfInvalidations: 0,
|
|
973
|
+
dependencies: __velarGraphCreateSet(),
|
|
974
|
+
notify() {
|
|
975
|
+
// Stopping is shared discipline with DOM and watch observers: a flush
|
|
976
|
+
// overflow marks queued computed observers stopped, and a stopped
|
|
977
|
+
// observer must go inert instead of re-entering the storm on the next
|
|
978
|
+
// write.
|
|
979
|
+
if (observer.stopped) return;
|
|
980
|
+
// The 100 self-invalidation cap covers computed observers too. A
|
|
981
|
+
// computed whose own turn (evaluation plus dependent notification)
|
|
982
|
+
// keeps invalidating it is stopped with the same owned report a
|
|
983
|
+
// render or watch observer gets, instead of running to the whole
|
|
984
|
+
// flush budget.
|
|
985
|
+
if (observer.running) {
|
|
986
|
+
observer.selfInvalidations += 1;
|
|
987
|
+
if (observer.selfInvalidations > 100) {
|
|
988
|
+
observer.stopped = true;
|
|
989
|
+
cleanupObserver(observer);
|
|
990
|
+
reportUntracked(new RangeError("A computed value cannot invalidate itself more than 100 times"));
|
|
991
|
+
return;
|
|
992
|
+
}
|
|
993
|
+
} else {
|
|
994
|
+
observer.selfInvalidations = 0;
|
|
995
|
+
}
|
|
996
|
+
if (dirty) return;
|
|
997
|
+
dirty = true;
|
|
998
|
+
if (__velarGraphSetCount(subscribers) === 0) {
|
|
999
|
+
cleanupObserver(observer);
|
|
1000
|
+
return;
|
|
1001
|
+
}
|
|
1002
|
+
schedule(observer);
|
|
1003
|
+
// A downstream computed must become dirty immediately so a same-turn
|
|
1004
|
+
// read cannot observe its cached result while an upstream dependency
|
|
1005
|
+
// is already stale. DOM and watch observers still wait for evaluation
|
|
1006
|
+
// to prove that the public result actually changed.
|
|
1007
|
+
invalidateComputedDependents();
|
|
1008
|
+
},
|
|
1009
|
+
run() {
|
|
1010
|
+
if (observer.stopped || !dirty || __velarGraphSetCount(subscribers) === 0) return;
|
|
1011
|
+
observer.running = true;
|
|
1012
|
+
try {
|
|
1013
|
+
if (evaluate(false)) notifyDependents();
|
|
1014
|
+
} finally { observer.running = false; }
|
|
1015
|
+
},
|
|
1016
|
+
};
|
|
1017
|
+
const detach = () => {
|
|
1018
|
+
cleanupObserver(observer);
|
|
1019
|
+
dirty = true;
|
|
1020
|
+
};
|
|
1021
|
+
__velarGraphWeakMapWrite(subscriptionStops, subscribers, detach);
|
|
1022
|
+
const evaluate = (throwFailure) => {
|
|
1023
|
+
if (evaluating) {
|
|
1024
|
+
recursed = true;
|
|
1025
|
+
throw new RangeError("A computed value cannot read itself recursively");
|
|
1026
|
+
}
|
|
1027
|
+
const previous = value;
|
|
1028
|
+
const previouslyFailed = failed;
|
|
1029
|
+
const previousFailure = failure;
|
|
1030
|
+
const hadValue = initialized;
|
|
1031
|
+
evaluating = true;
|
|
1032
|
+
recursed = false;
|
|
1033
|
+
failed = false;
|
|
1034
|
+
failure = undefined;
|
|
1035
|
+
try { value = runTracked(observer, read); }
|
|
1036
|
+
catch (error) { failed = true; failure = error; }
|
|
1037
|
+
finally {
|
|
1038
|
+
evaluating = false;
|
|
1039
|
+
initialized = true;
|
|
1040
|
+
dirty = false;
|
|
1041
|
+
}
|
|
1042
|
+
// A computed that failed because its own recursion guard tripped sits on
|
|
1043
|
+
// a dependency cycle. The failure is cached and served, but the cyclic
|
|
1044
|
+
// edges must not persist: two failed computeds that keep notifying each
|
|
1045
|
+
// other would otherwise ping-pong the next flush into the whole-flush
|
|
1046
|
+
// budget. Detaching unwinds the cycle (a peer whose last subscriber
|
|
1047
|
+
// leaves detaches with it) and a later read simply re-attempts.
|
|
1048
|
+
if (failed && recursed) detach();
|
|
1049
|
+
else if (__velarGraphSetCount(subscribers) === 0) detach();
|
|
1050
|
+
recursed = false;
|
|
1051
|
+
const changed = !hadValue || previouslyFailed !== failed || (failed ? previousFailure !== failure : !__velarGraphSame(previous, value));
|
|
1052
|
+
if (throwFailure && failed) throw failure;
|
|
1053
|
+
return changed;
|
|
1054
|
+
};
|
|
1055
|
+
const access = () => {
|
|
1056
|
+
const consumer = runtime.activeObserver;
|
|
1057
|
+
if (consumer !== observer) trackSubscribers(subscribers);
|
|
1058
|
+
if (dirty && !observer.stopped) {
|
|
1059
|
+
// A cyclic read re-enters access while the outer evaluation is still
|
|
1060
|
+
// running, so the running span is restored, never cleared.
|
|
1061
|
+
const wasRunning = observer.running;
|
|
1062
|
+
observer.running = true;
|
|
1063
|
+
try {
|
|
1064
|
+
const changed = evaluate(false);
|
|
1065
|
+
if (changed && initialized) notifyDependents(consumer);
|
|
1066
|
+
} finally { observer.running = wasRunning; }
|
|
1067
|
+
}
|
|
1068
|
+
if (failed) throw failure;
|
|
1069
|
+
return value;
|
|
1070
|
+
};
|
|
1071
|
+
return __velarGraphFreeze(access);
|
|
1072
|
+
};
|
|
1073
|
+
// The loud channel for a failure nothing owns. In a browser the microtask
|
|
1074
|
+
// throw reaches the host error event and the page survives it; in a
|
|
1075
|
+
// non-browser host (a headless 'velar test' process, a worker) the same
|
|
1076
|
+
// throw terminates the process, which is the program termination the
|
|
1077
|
+
// runtime boundary forbids. There the failure is traced to the console and
|
|
1078
|
+
// parked so the next tick() fails its awaiting caller instead.
|
|
1079
|
+
const escalate = (error) => {
|
|
1080
|
+
if (__velarDomDocument !== null) {
|
|
1081
|
+
__velarEnqueue(() => { throw error; });
|
|
1082
|
+
return;
|
|
1083
|
+
}
|
|
1084
|
+
if (__velarGraphSetCount(unhandledFailures) < 100) __velarGraphSetInsert(unhandledFailures, error);
|
|
1085
|
+
__velarFoundationTrace(error);
|
|
1086
|
+
};
|
|
1087
|
+
const report = (value, options) => {
|
|
1088
|
+
const error = __velarNormalizeError(value);
|
|
1089
|
+
const checked = __velarReportOptions(options);
|
|
1090
|
+
const timestamp = __velarNow();
|
|
1091
|
+
if (!__velarWebErrorFinite(timestamp)) throw new TypeError("The browser returned an invalid error timestamp");
|
|
1092
|
+
const errorReport = __velarWebErrorFreeze({
|
|
1093
|
+
error,
|
|
1094
|
+
phase: checked.phase,
|
|
1095
|
+
detail: checked.detail,
|
|
1096
|
+
component: checked.component,
|
|
1097
|
+
timestamp,
|
|
1098
|
+
});
|
|
1099
|
+
let handled = false;
|
|
1100
|
+
for (const handler of __velarGraphSetItems(errorHandlers)) {
|
|
1101
|
+
handled = true;
|
|
1102
|
+
try {
|
|
1103
|
+
const result = handler(errorReport);
|
|
1104
|
+
__velarObservePromise(result, (failure) => escalate(__velarNormalizeError(failure)));
|
|
1105
|
+
} catch (failure) { escalate(__velarNormalizeError(failure)); }
|
|
1106
|
+
}
|
|
1107
|
+
if (checked.unhandled && !handled) escalate(error);
|
|
1108
|
+
return errorReport;
|
|
1109
|
+
};
|
|
1110
|
+
// A report raised from inside a tracked evaluation (the computed cap) must
|
|
1111
|
+
// not let handler reads become dependencies of the failing observer.
|
|
1112
|
+
const reportUntracked = (error) => {
|
|
1113
|
+
const previousObserver = runtime.activeObserver;
|
|
1114
|
+
runtime.activeObserver = null;
|
|
1115
|
+
try { report(error, { phase: "update", detail: "", component: "", unhandled: true }); }
|
|
1116
|
+
finally { runtime.activeObserver = previousObserver; }
|
|
1117
|
+
};
|
|
1118
|
+
// The scheduler lives on the runtime registry itself: computed observers are
|
|
1119
|
+
// created by whichever module stamped the registry first (velar/app under
|
|
1120
|
+
// ESM import order, or the application prelude), and their notifications
|
|
1121
|
+
// must schedule correctly no matter which module that was. The emitted
|
|
1122
|
+
// application prelude keeps its own identical drain for the observers it
|
|
1123
|
+
// creates; the shared flushPending flag keeps exactly one flush microtask
|
|
1124
|
+
// enqueued whichever side scheduled first, and either drain runs every
|
|
1125
|
+
// queued observer.
|
|
1126
|
+
const scheduleFlush = () => {
|
|
1127
|
+
if (runtime.flushPending) return;
|
|
1128
|
+
runtime.flushPending = true;
|
|
1129
|
+
__velarEnqueue(flush);
|
|
1130
|
+
};
|
|
1131
|
+
const flushOverflow = () => {
|
|
1132
|
+
const stalled = [];
|
|
1133
|
+
for (const observer of __velarGraphSetItems(domQueue)) stalled[stalled.length] = observer;
|
|
1134
|
+
for (const observer of __velarGraphSetItems(watchQueue)) stalled[stalled.length] = observer;
|
|
1135
|
+
__velarGraphSetEmpty(domQueue);
|
|
1136
|
+
__velarGraphSetEmpty(watchQueue);
|
|
1137
|
+
for (let index = 0; index < stalled.length; index += 1) {
|
|
1138
|
+
const observer = stalled[index];
|
|
1139
|
+
if (typeof observer.stop === "function") observer.stop();
|
|
1140
|
+
else observer.stopped = true;
|
|
1141
|
+
}
|
|
1142
|
+
report(new RangeError("Reactive updates cannot run more than 100000 observers in one flush"), { phase: "update", detail: "", component: "", unhandled: true });
|
|
1143
|
+
};
|
|
1144
|
+
const flush = () => {
|
|
1145
|
+
runtime.flushPending = false;
|
|
1146
|
+
let budget = 100000;
|
|
1147
|
+
for (const observer of __velarGraphSetItems(domQueue)) {
|
|
1148
|
+
__velarGraphSetRemove(domQueue, observer);
|
|
1149
|
+
if ((budget -= 1) < 0) { flushOverflow(); return; }
|
|
1150
|
+
observer.run();
|
|
1151
|
+
}
|
|
1152
|
+
for (const observer of __velarGraphSetItems(watchQueue)) {
|
|
1153
|
+
__velarGraphSetRemove(watchQueue, observer);
|
|
1154
|
+
if ((budget -= 1) < 0) { flushOverflow(); return; }
|
|
1155
|
+
observer.run();
|
|
1156
|
+
}
|
|
1157
|
+
if (__velarGraphSetCount(domQueue) || __velarGraphSetCount(watchQueue)) scheduleFlush();
|
|
1158
|
+
};
|
|
1159
|
+
const schedule = (observer) => {
|
|
1160
|
+
const queue = observer.mode === "watch" ? watchQueue : domQueue;
|
|
1161
|
+
if (!__velarGraphSetContains(queue, observer) && __velarGraphSetCount(queue) >= 100000) throw new RangeError("VelarScript reactive queues cannot exceed 100000 observers");
|
|
1162
|
+
__velarGraphSetInsert(queue, observer);
|
|
1163
|
+
scheduleFlush();
|
|
1164
|
+
};
|
|
1165
|
+
const applyLook = (...arguments_) => {
|
|
1166
|
+
if (!lookImplementation) throw new TypeError("Link Look requires the VelarScript Web runtime");
|
|
1167
|
+
return lookImplementation(...arguments_);
|
|
1168
|
+
};
|
|
1169
|
+
const installLook = (implementation) => {
|
|
1170
|
+
if (typeof implementation !== "function") throw new TypeError("VelarScript Look integration requires a function");
|
|
1171
|
+
lookImplementation ??= implementation;
|
|
1172
|
+
return null;
|
|
1173
|
+
};
|
|
1174
|
+
const fields = {
|
|
1175
|
+
version: ${JSON.stringify(VELAR_RUNTIME_SCHEMA_VERSION)}, domQueue, watchQueue, flushPending: false, activeObserver: null, errorHandlers,
|
|
1176
|
+
actionFailures, unhandledFailures, lookSources, classSources, dependencies, rawToProxy, proxyToRaw, versions, parents,
|
|
1177
|
+
toRaw, reactive, track, trackDeep, trigger, versionOf, collectionRead, collectionTrigger, collectionUnlink,
|
|
1178
|
+
trackSubscribers, runTracked, cleanupObserver, computed,
|
|
1179
|
+
schedule, report, applyLook, installLook,
|
|
1180
|
+
};
|
|
1181
|
+
for (const name of __velarRuntimeFields) Object.defineProperty(runtime, name, {
|
|
1182
|
+
value: fields[name],
|
|
1183
|
+
enumerable: false,
|
|
1184
|
+
configurable: false,
|
|
1185
|
+
writable: name === "flushPending" || name === "activeObserver",
|
|
1186
|
+
});
|
|
1187
|
+
return Object.preventExtensions(runtime);
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
function __velarRequireRuntime(value) {
|
|
1191
|
+
if (!value || typeof value !== "object" || Object.getPrototypeOf(value) !== null || Object.isExtensible(value)
|
|
1192
|
+
|| Object.getOwnPropertySymbols(value).length > 0) throw new TypeError("VelarScript Web runtime ownership is invalid");
|
|
1193
|
+
const names = Object.getOwnPropertyNames(value);
|
|
1194
|
+
if (names.length !== __velarRuntimeFields.length || __velarRuntimeFields.some((name) => !names.includes(name))) {
|
|
1195
|
+
throw new TypeError("VelarScript Web runtime fields are invalid");
|
|
1196
|
+
}
|
|
1197
|
+
for (const name of __velarRuntimeFields) {
|
|
1198
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, name);
|
|
1199
|
+
const mutable = name === "flushPending" || name === "activeObserver";
|
|
1200
|
+
if (!descriptor || !("value" in descriptor) || descriptor.enumerable || descriptor.configurable || descriptor.writable !== mutable) {
|
|
1201
|
+
throw new TypeError("VelarScript Web runtime field '" + name + "' is invalid");
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
if (value.version !== ${JSON.stringify(VELAR_RUNTIME_SCHEMA_VERSION)}
|
|
1205
|
+
|| !__velarRuntimeCollection(value.domQueue, "Set") || !__velarRuntimeCollection(value.watchQueue, "Set")
|
|
1206
|
+
|| typeof value.flushPending !== "boolean" || (value.activeObserver !== null && typeof value.activeObserver !== "object")
|
|
1207
|
+
|| !__velarRuntimeCollection(value.errorHandlers, "Set") || !__velarRuntimeCollection(value.actionFailures, "WeakSet")
|
|
1208
|
+
|| !__velarRuntimeCollection(value.unhandledFailures, "Set")
|
|
1209
|
+
|| !__velarRuntimeCollection(value.lookSources, "WeakMap") || !__velarRuntimeCollection(value.classSources, "WeakMap")
|
|
1210
|
+
|| !__velarRuntimeCollection(value.dependencies, "WeakMap") || !__velarRuntimeCollection(value.rawToProxy, "WeakMap")
|
|
1211
|
+
|| !__velarRuntimeCollection(value.proxyToRaw, "WeakMap") || !__velarRuntimeCollection(value.versions, "WeakMap")
|
|
1212
|
+
|| !__velarRuntimeCollection(value.parents, "WeakMap")
|
|
1213
|
+
|| typeof value.toRaw !== "function" || typeof value.reactive !== "function" || typeof value.track !== "function"
|
|
1214
|
+
|| typeof value.trackDeep !== "function" || typeof value.trigger !== "function" || typeof value.versionOf !== "function"
|
|
1215
|
+
|| typeof value.collectionRead !== "function" || typeof value.collectionTrigger !== "function" || typeof value.collectionUnlink !== "function"
|
|
1216
|
+
|| typeof value.trackSubscribers !== "function" || typeof value.runTracked !== "function"
|
|
1217
|
+
|| typeof value.cleanupObserver !== "function" || typeof value.computed !== "function" || typeof value.schedule !== "function"
|
|
1218
|
+
|| typeof value.report !== "function" || typeof value.applyLook !== "function" || typeof value.installLook !== "function") {
|
|
1219
|
+
throw new TypeError("VelarScript Web runtime values are invalid");
|
|
1220
|
+
}
|
|
1221
|
+
return value;
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
const __velarRuntime = (() => {
|
|
1225
|
+
const descriptor = Object.getOwnPropertyDescriptor(globalThis, __velarRuntimeKey);
|
|
1226
|
+
if (descriptor) {
|
|
1227
|
+
if (!("value" in descriptor) || descriptor.enumerable || descriptor.configurable || descriptor.writable) {
|
|
1228
|
+
throw new TypeError("VelarScript Web runtime registry ownership is invalid");
|
|
1229
|
+
}
|
|
1230
|
+
return __velarRequireRuntime(descriptor.value);
|
|
1231
|
+
}
|
|
1232
|
+
const runtime = __velarCreateRuntime();
|
|
1233
|
+
Object.defineProperty(globalThis, __velarRuntimeKey, {
|
|
1234
|
+
value: runtime,
|
|
1235
|
+
enumerable: false,
|
|
1236
|
+
configurable: false,
|
|
1237
|
+
writable: false,
|
|
1238
|
+
});
|
|
1239
|
+
return runtime;
|
|
1240
|
+
})();
|
|
1241
|
+
`.trimStart();
|
|
1242
|
+
}
|
|
1243
|
+
export const WEB_RUNTIME_FOUNDATION = webRuntimeFoundation(WEB_ERROR_HOST_RUNTIME);
|
|
1244
|
+
export const WEB_RUNTIME_FOUNDATION_SHARED_ERROR = webRuntimeFoundation(WEB_ERROR_HOST_RUNTIME_BODY);
|
|
1245
|
+
//# sourceMappingURL=runtime-foundation.js.map
|