@arcgis/coding-components 4.29.0-beta.4 → 4.29.0-beta.41
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.md +1 -1
- package/dist/arcgis-coding-components/arcgis-coding-components.esm.js +1 -1
- package/dist/arcgis-coding-components/assets/arcade-api/t9n/arcade-api.t9n.en.json +8 -8
- package/dist/arcgis-coding-components/assets/arcade-editor/t9n/arcade-editor.t9n.en.json +8 -8
- package/dist/arcgis-coding-components/assets/arcade-results/t9n/arcade-results.t9n.en.json +13 -13
- package/dist/arcgis-coding-components/assets/arcade-suggestions/t9n/arcade-suggestions.t9n.en.json +6 -6
- package/dist/arcgis-coding-components/assets/arcade-variables/t9n/arcade-variables.t9n.en.json +8 -8
- package/dist/arcgis-coding-components/assets/code-editor/arcade.worker.js +24 -22
- package/dist/arcgis-coding-components/assets/code-editor/css.worker.js +34 -35
- package/dist/arcgis-coding-components/assets/code-editor/editor.worker.js +7 -5
- package/dist/arcgis-coding-components/assets/code-editor/html.worker.js +41 -40
- package/dist/arcgis-coding-components/assets/code-editor/json.worker.js +24 -22
- package/dist/arcgis-coding-components/assets/code-editor/ts.worker.js +163 -161
- package/dist/arcgis-coding-components/index.esm.js +1 -1
- package/dist/arcgis-coding-components/{p-3eb641a2.js → p-15b09ea0.js} +2 -2
- package/dist/arcgis-coding-components/{p-74e0738d.js → p-2053efe5.js} +3 -3
- package/dist/arcgis-coding-components/{p-5fe913f0.js → p-4056fd39.js} +3 -3
- package/dist/arcgis-coding-components/p-5d670bd2.js +2 -0
- package/dist/arcgis-coding-components/p-6b0c537d.js +62 -0
- package/dist/arcgis-coding-components/{p-683e3dd4.js → p-739259a0.js} +1 -1
- package/dist/arcgis-coding-components/{p-96c3ebcb.js → p-8919c3fb.js} +2 -2
- package/dist/arcgis-coding-components/p-a67252ce.entry.js +1 -0
- package/dist/arcgis-coding-components/{p-7fb19e9b.js → p-a8cfb543.js} +2 -2
- package/dist/arcgis-coding-components/{p-27d03fb2.js → p-c66fdb0b.js} +2 -2
- package/dist/arcgis-coding-components/{p-98f0e116.js → p-cfff9500.js} +1 -1
- package/dist/arcgis-coding-components/{p-a152b643.js → p-f56ec2fe.js} +2 -2
- package/dist/cjs/{arcade-defaults-55c18abe.js → arcade-defaults-0bd884a4.js} +64439 -59097
- package/dist/cjs/{arcade-mode-bd1630dd.js → arcade-mode-7bc7978f.js} +2 -2
- package/dist/cjs/arcgis-arcade-api_6.cjs.entry.js +40 -32
- package/dist/cjs/arcgis-coding-components.cjs.js +3 -3
- package/dist/cjs/{css-3c67d381.js → css-7229b372.js} +1 -1
- package/dist/cjs/{cssMode-73d4ac47.js → cssMode-04695efd.js} +3 -3
- package/dist/cjs/{html-da599f39.js → html-4364b57b.js} +3 -3
- package/dist/cjs/{htmlMode-6f0883d3.js → htmlMode-3232d4d2.js} +3 -3
- package/dist/cjs/{index-f8a85eb8.js → index-6a382a34.js} +302 -64
- package/dist/cjs/index.cjs.js +2 -2
- package/dist/cjs/{javascript-92268a2f.js → javascript-1b17ffb0.js} +4 -4
- package/dist/cjs/{jsonMode-110ef3c9.js → jsonMode-85cfe5d7.js} +3 -3
- package/dist/cjs/loader.cjs.js +3 -12
- package/dist/cjs/{tsMode-8cb72aa2.js → tsMode-6ac3dd97.js} +3 -3
- package/dist/cjs/{typescript-edaad128.js → typescript-e8854a4f.js} +3 -3
- package/dist/components/arcade-api.js +10 -8
- package/dist/components/arcade-contribution.js +1 -1
- package/dist/components/arcade-results.js +13 -8
- package/dist/components/arcade-suggestions.js +11 -7
- package/dist/components/arcade-variables.js +10 -6
- package/dist/components/arcgis-arcade-editor.js +20 -14
- package/dist/components/code-editor.js +8 -4
- package/dist/components/index.d.ts +5 -8
- package/dist/components/index.js +1 -7
- package/dist/components/index2.js +2 -2
- package/dist/esm/{arcade-defaults-ac486973.js → arcade-defaults-145d902c.js} +64438 -59096
- package/dist/esm/{arcade-mode-fc719356.js → arcade-mode-4f74179e.js} +2 -2
- package/dist/esm/arcgis-arcade-api_6.entry.js +40 -32
- package/dist/esm/arcgis-coding-components.js +4 -4
- package/dist/esm/{css-9066b96a.js → css-ff1e9f8c.js} +1 -1
- package/dist/esm/{cssMode-f452e699.js → cssMode-93b88d81.js} +3 -3
- package/dist/esm/{html-7c0b7520.js → html-7d557330.js} +3 -3
- package/dist/esm/{htmlMode-200a28b3.js → htmlMode-e9b83ec7.js} +3 -3
- package/dist/esm/{index-d4ec142a.js → index-fd6b2fd8.js} +302 -64
- package/dist/esm/index.js +2 -2
- package/dist/esm/{javascript-44a7aba3.js → javascript-83c892dd.js} +4 -4
- package/dist/esm/{jsonMode-fb784fa5.js → jsonMode-5c5eb0e2.js} +3 -3
- package/dist/esm/loader.js +4 -13
- package/dist/esm/{tsMode-890f3141.js → tsMode-77877670.js} +3 -3
- package/dist/esm/{typescript-4b8bacca.js → typescript-dab44a94.js} +3 -3
- package/dist/loader/index.d.ts +2 -2
- package/dist/types/components/arcade-api/arcade-api.d.ts +3 -2
- package/dist/types/components/arcade-editor/arcade-editor.d.ts +3 -2
- package/dist/types/components/arcade-results/arcade-results.d.ts +3 -2
- package/dist/types/components/arcade-suggestions/arcade-suggestions.d.ts +3 -2
- package/dist/types/components/arcade-variables/arcade-variables.d.ts +3 -2
- package/dist/types/components.d.ts +78 -0
- package/dist/types/stencil-public-runtime.d.ts +53 -17
- package/package.json +26 -30
- package/dist/arcgis-coding-components/p-0fa0a06d.js +0 -2
- package/dist/arcgis-coding-components/p-2c5583d5.entry.js +0 -1
- package/dist/arcgis-coding-components/p-a388e974.js +0 -62
- package/dist/esm/polyfills/css-shim.js +0 -1
|
@@ -41,6 +41,13 @@ const XLINK_NS = 'http://www.w3.org/1999/xlink';
|
|
|
41
41
|
*/
|
|
42
42
|
const EMPTY_OBJ = {};
|
|
43
43
|
const isDef = (v) => v != null;
|
|
44
|
+
/**
|
|
45
|
+
* Check whether a value is a 'complex type', defined here as an object or a
|
|
46
|
+
* function.
|
|
47
|
+
*
|
|
48
|
+
* @param o the value to check
|
|
49
|
+
* @returns whether it's a complex type or not
|
|
50
|
+
*/
|
|
44
51
|
const isComplexType = (o) => {
|
|
45
52
|
// https://jsperf.com/typeof-fn-object/5
|
|
46
53
|
o = typeof o;
|
|
@@ -98,10 +105,10 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
98
105
|
};
|
|
99
106
|
walk(children);
|
|
100
107
|
if (vnodeData) {
|
|
101
|
-
// normalize class / classname attributes
|
|
102
108
|
if (vnodeData.key) {
|
|
103
109
|
key = vnodeData.key;
|
|
104
110
|
}
|
|
111
|
+
// normalize class / className attributes
|
|
105
112
|
{
|
|
106
113
|
const classData = vnodeData.className || vnodeData.class;
|
|
107
114
|
if (classData) {
|
|
@@ -299,9 +306,9 @@ const registerStyle = (scopeId, cssText, allowCS) => {
|
|
|
299
306
|
}
|
|
300
307
|
styles.set(scopeId, style);
|
|
301
308
|
};
|
|
302
|
-
const addStyle = (styleContainerNode, cmpMeta, mode
|
|
309
|
+
const addStyle = (styleContainerNode, cmpMeta, mode) => {
|
|
303
310
|
var _a;
|
|
304
|
-
|
|
311
|
+
const scopeId = getScopeId(cmpMeta);
|
|
305
312
|
const style = styles.get(scopeId);
|
|
306
313
|
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
307
314
|
// so the fallback is to always use the document for the root node in those cases
|
|
@@ -316,10 +323,8 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
|
316
323
|
}
|
|
317
324
|
if (!appliedStyles.has(scopeId)) {
|
|
318
325
|
{
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
styleElm.innerHTML = style;
|
|
322
|
-
}
|
|
326
|
+
styleElm = doc.createElement('style');
|
|
327
|
+
styleElm.innerHTML = style;
|
|
323
328
|
// Apply CSP nonce to the style tag if it exists
|
|
324
329
|
const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
|
|
325
330
|
if (nonce != null) {
|
|
@@ -366,6 +371,21 @@ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
|
366
371
|
*
|
|
367
372
|
* Modified for Stencil's compiler and vdom
|
|
368
373
|
*/
|
|
374
|
+
/**
|
|
375
|
+
* When running a VDom render set properties present on a VDom node onto the
|
|
376
|
+
* corresponding HTML element.
|
|
377
|
+
*
|
|
378
|
+
* Note that this function has special functionality for the `class`,
|
|
379
|
+
* `style`, `key`, and `ref` attributes, as well as event handlers (like
|
|
380
|
+
* `onClick`, etc). All others are just passed through as-is.
|
|
381
|
+
*
|
|
382
|
+
* @param elm the HTMLElement onto which attributes should be set
|
|
383
|
+
* @param memberName the name of the attribute to set
|
|
384
|
+
* @param oldValue the old value for the attribute
|
|
385
|
+
* @param newValue the new value for the attribute
|
|
386
|
+
* @param isSvg whether we're in an svg context or not
|
|
387
|
+
* @param flags bitflags for Vdom variables
|
|
388
|
+
*/
|
|
369
389
|
const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
370
390
|
if (oldValue !== newValue) {
|
|
371
391
|
let isProp = isMemberInElement(elm, memberName);
|
|
@@ -442,11 +462,19 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
442
462
|
// except for the first character, we keep the event name case
|
|
443
463
|
memberName = ln[2] + memberName.slice(3);
|
|
444
464
|
}
|
|
445
|
-
if (oldValue) {
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
465
|
+
if (oldValue || newValue) {
|
|
466
|
+
// Need to account for "capture" events.
|
|
467
|
+
// If the event name ends with "Capture", we'll update the name to remove
|
|
468
|
+
// the "Capture" suffix and make sure the event listener is setup to handle the capture event.
|
|
469
|
+
const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
|
|
470
|
+
// Make sure we only replace the last instance of "Capture"
|
|
471
|
+
memberName = memberName.replace(CAPTURE_EVENT_REGEX, '');
|
|
472
|
+
if (oldValue) {
|
|
473
|
+
plt.rel(elm, memberName, oldValue, capture);
|
|
474
|
+
}
|
|
475
|
+
if (newValue) {
|
|
476
|
+
plt.ael(elm, memberName, newValue, capture);
|
|
477
|
+
}
|
|
450
478
|
}
|
|
451
479
|
}
|
|
452
480
|
else {
|
|
@@ -508,6 +536,8 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
508
536
|
};
|
|
509
537
|
const parseClassListRegex = /\s/;
|
|
510
538
|
const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
|
|
539
|
+
const CAPTURE_EVENT_SUFFIX = 'Capture';
|
|
540
|
+
const CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + '$');
|
|
511
541
|
const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
|
512
542
|
// if the element passed in is a shadow root, which is a document fragment
|
|
513
543
|
// then we want to be adding attrs/props to the shadow root's "host" element
|
|
@@ -617,16 +647,17 @@ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) =>
|
|
|
617
647
|
* @param vnodes a list of virtual DOM nodes to remove
|
|
618
648
|
* @param startIdx the index at which to start removing nodes (inclusive)
|
|
619
649
|
* @param endIdx the index at which to stop removing nodes (inclusive)
|
|
620
|
-
* @param vnode a VNode
|
|
621
|
-
* @param elm an element
|
|
622
650
|
*/
|
|
623
|
-
const removeVnodes = (vnodes, startIdx, endIdx
|
|
624
|
-
for (
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
elm
|
|
651
|
+
const removeVnodes = (vnodes, startIdx, endIdx) => {
|
|
652
|
+
for (let index = startIdx; index <= endIdx; ++index) {
|
|
653
|
+
const vnode = vnodes[index];
|
|
654
|
+
if (vnode) {
|
|
655
|
+
const elm = vnode.$elm$;
|
|
656
|
+
nullifyVNodeRefs(vnode);
|
|
657
|
+
if (elm) {
|
|
658
|
+
// remove the vnode's element from the dom
|
|
659
|
+
elm.remove();
|
|
660
|
+
}
|
|
630
661
|
}
|
|
631
662
|
}
|
|
632
663
|
};
|
|
@@ -914,10 +945,17 @@ const patch = (oldVNode, newVNode) => {
|
|
|
914
945
|
elm.data = text;
|
|
915
946
|
}
|
|
916
947
|
};
|
|
917
|
-
|
|
948
|
+
/**
|
|
949
|
+
* 'Nullify' any VDom `ref` callbacks on a VDom node or its children by calling
|
|
950
|
+
* them with `null`. This signals that the DOM element corresponding to the VDom
|
|
951
|
+
* node has been removed from the DOM.
|
|
952
|
+
*
|
|
953
|
+
* @param vNode a virtual DOM node
|
|
954
|
+
*/
|
|
955
|
+
const nullifyVNodeRefs = (vNode) => {
|
|
918
956
|
{
|
|
919
957
|
vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
|
|
920
|
-
vNode.$children$ && vNode.$children$.map(
|
|
958
|
+
vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
|
|
921
959
|
}
|
|
922
960
|
};
|
|
923
961
|
/**
|
|
@@ -931,17 +969,44 @@ const callNodeRefs = (vNode) => {
|
|
|
931
969
|
* @param hostRef data needed to root and render the virtual DOM tree, such as
|
|
932
970
|
* the DOM node into which it should be rendered.
|
|
933
971
|
* @param renderFnResults the virtual DOM nodes to be rendered
|
|
972
|
+
* @param isInitialLoad whether or not this is the first call after page load
|
|
934
973
|
*/
|
|
935
|
-
const renderVdom = (hostRef, renderFnResults) => {
|
|
974
|
+
const renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
|
|
936
975
|
const hostElm = hostRef.$hostElement$;
|
|
937
976
|
const cmpMeta = hostRef.$cmpMeta$;
|
|
938
977
|
const oldVNode = hostRef.$vnode$ || newVNode(null, null);
|
|
978
|
+
// if `renderFnResults` is a Host node then we can use it directly. If not,
|
|
979
|
+
// we need to call `h` again to wrap the children of our component in a
|
|
980
|
+
// 'dummy' Host node (well, an empty vnode) since `renderVdom` assumes
|
|
981
|
+
// implicitly that the top-level vdom node is 1) an only child and 2)
|
|
982
|
+
// contains attrs that need to be set on the host element.
|
|
939
983
|
const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
|
|
940
984
|
hostTagName = hostElm.tagName;
|
|
941
985
|
if (cmpMeta.$attrsToReflect$) {
|
|
942
986
|
rootVnode.$attrs$ = rootVnode.$attrs$ || {};
|
|
943
987
|
cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
|
|
944
988
|
}
|
|
989
|
+
// On the first render and *only* on the first render we want to check for
|
|
990
|
+
// any attributes set on the host element which are also set on the vdom
|
|
991
|
+
// node. If we find them, we override the value on the VDom node attrs with
|
|
992
|
+
// the value from the host element, which allows developers building apps
|
|
993
|
+
// with Stencil components to override e.g. the `role` attribute on a
|
|
994
|
+
// component even if it's already set on the `Host`.
|
|
995
|
+
if (isInitialLoad && rootVnode.$attrs$) {
|
|
996
|
+
for (const key of Object.keys(rootVnode.$attrs$)) {
|
|
997
|
+
// We have a special implementation in `setAccessor` for `style` and
|
|
998
|
+
// `class` which reconciles values coming from the VDom with values
|
|
999
|
+
// already present on the DOM element, so we don't want to override those
|
|
1000
|
+
// attributes on the VDom tree with values from the host element if they
|
|
1001
|
+
// are present.
|
|
1002
|
+
//
|
|
1003
|
+
// Likewise, `ref` and `key` are special internal values for the Stencil
|
|
1004
|
+
// runtime and we don't want to override those either.
|
|
1005
|
+
if (hostElm.hasAttribute(key) && !['key', 'ref', 'style', 'class'].includes(key)) {
|
|
1006
|
+
rootVnode.$attrs$[key] = hostElm[key];
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
945
1010
|
rootVnode.$tag$ = null;
|
|
946
1011
|
rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
|
|
947
1012
|
hostRef.$vnode$ = rootVnode;
|
|
@@ -972,20 +1037,86 @@ const scheduleUpdate = (hostRef, isInitialLoad) => {
|
|
|
972
1037
|
const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
|
|
973
1038
|
return writeTask(dispatch) ;
|
|
974
1039
|
};
|
|
1040
|
+
/**
|
|
1041
|
+
* Dispatch initial-render and update lifecycle hooks, enqueuing calls to
|
|
1042
|
+
* component lifecycle methods like `componentWillLoad` as well as
|
|
1043
|
+
* {@link updateComponent}, which will kick off the virtual DOM re-render.
|
|
1044
|
+
*
|
|
1045
|
+
* @param hostRef a reference to a host DOM node
|
|
1046
|
+
* @param isInitialLoad whether we're on the initial load or not
|
|
1047
|
+
* @returns an empty Promise which is used to enqueue a series of operations for
|
|
1048
|
+
* the component
|
|
1049
|
+
*/
|
|
975
1050
|
const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
976
1051
|
const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
|
|
977
1052
|
const instance = hostRef.$lazyInstance$ ;
|
|
978
|
-
|
|
1053
|
+
// We're going to use this variable together with `enqueue` to implement a
|
|
1054
|
+
// little promise-based queue. We start out with it `undefined`. When we add
|
|
1055
|
+
// the first function to the queue we'll set this variable to be that
|
|
1056
|
+
// function's return value. When we attempt to add subsequent values to the
|
|
1057
|
+
// queue we'll check that value and, if it was a `Promise`, we'll then chain
|
|
1058
|
+
// the new function off of that `Promise` using `.then()`. This will give our
|
|
1059
|
+
// queue two nice properties:
|
|
1060
|
+
//
|
|
1061
|
+
// 1. If all functions added to the queue are synchronous they'll be called
|
|
1062
|
+
// synchronously right away.
|
|
1063
|
+
// 2. If all functions added to the queue are asynchronous they'll all be
|
|
1064
|
+
// called in order after `dispatchHooks` exits.
|
|
1065
|
+
let maybePromise;
|
|
979
1066
|
if (isInitialLoad) {
|
|
980
1067
|
{
|
|
981
|
-
|
|
1068
|
+
// If `componentWillLoad` returns a `Promise` then we want to wait on
|
|
1069
|
+
// whatever's going on in that `Promise` before we launch into
|
|
1070
|
+
// rendering the component, doing other lifecycle stuff, etc. So
|
|
1071
|
+
// in that case we assign the returned promise to the variable we
|
|
1072
|
+
// declared above to hold a possible 'queueing' Promise
|
|
1073
|
+
maybePromise = safeCall(instance, 'componentWillLoad');
|
|
982
1074
|
}
|
|
983
1075
|
}
|
|
984
1076
|
endSchedule();
|
|
985
|
-
return
|
|
1077
|
+
return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
|
|
986
1078
|
};
|
|
1079
|
+
/**
|
|
1080
|
+
* This function uses a Promise to implement a simple first-in, first-out queue
|
|
1081
|
+
* of functions to be called.
|
|
1082
|
+
*
|
|
1083
|
+
* The queue is ordered on the basis of the first argument. If it's
|
|
1084
|
+
* `undefined`, then nothing is on the queue yet, so the provided function can
|
|
1085
|
+
* be called synchronously (although note that this function may return a
|
|
1086
|
+
* `Promise`). The idea is that then the return value of that enqueueing
|
|
1087
|
+
* operation is kept around, so that if it was a `Promise` then subsequent
|
|
1088
|
+
* functions can be enqueued by calling this function again with that `Promise`
|
|
1089
|
+
* as the first argument.
|
|
1090
|
+
*
|
|
1091
|
+
* @param maybePromise either a `Promise` which should resolve before the next function is called or an 'empty' sentinel
|
|
1092
|
+
* @param fn a function to enqueue
|
|
1093
|
+
* @returns either a `Promise` or the return value of the provided function
|
|
1094
|
+
*/
|
|
1095
|
+
const enqueue = (maybePromise, fn) => isPromisey(maybePromise) ? maybePromise.then(fn) : fn();
|
|
1096
|
+
/**
|
|
1097
|
+
* Check that a value is a `Promise`. To check, we first see if the value is an
|
|
1098
|
+
* instance of the `Promise` global. In a few circumstances, in particular if
|
|
1099
|
+
* the global has been overwritten, this is could be misleading, so we also do
|
|
1100
|
+
* a little 'duck typing' check to see if the `.then` property of the value is
|
|
1101
|
+
* defined and a function.
|
|
1102
|
+
*
|
|
1103
|
+
* @param maybePromise it might be a promise!
|
|
1104
|
+
* @returns whether it is or not
|
|
1105
|
+
*/
|
|
1106
|
+
const isPromisey = (maybePromise) => maybePromise instanceof Promise ||
|
|
1107
|
+
(maybePromise && maybePromise.then && typeof maybePromise.then === 'function');
|
|
1108
|
+
/**
|
|
1109
|
+
* Update a component given reference to its host elements and so on.
|
|
1110
|
+
*
|
|
1111
|
+
* @param hostRef an object containing references to the element's host node,
|
|
1112
|
+
* VDom nodes, and other metadata
|
|
1113
|
+
* @param instance a reference to the underlying host element where it will be
|
|
1114
|
+
* rendered
|
|
1115
|
+
* @param isInitialLoad whether or not this function is being called as part of
|
|
1116
|
+
* the first render cycle
|
|
1117
|
+
*/
|
|
987
1118
|
const updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
988
|
-
|
|
1119
|
+
var _a;
|
|
989
1120
|
const elm = hostRef.$hostElement$;
|
|
990
1121
|
const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
|
|
991
1122
|
const rc = elm['s-rc'];
|
|
@@ -995,7 +1126,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
|
995
1126
|
}
|
|
996
1127
|
const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
|
|
997
1128
|
{
|
|
998
|
-
callRender(hostRef, instance);
|
|
1129
|
+
callRender(hostRef, instance, elm, isInitialLoad);
|
|
999
1130
|
}
|
|
1000
1131
|
if (rc) {
|
|
1001
1132
|
// ok, so turns out there are some child host elements
|
|
@@ -1007,7 +1138,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
|
1007
1138
|
endRender();
|
|
1008
1139
|
endUpdate();
|
|
1009
1140
|
{
|
|
1010
|
-
const childrenPromises = elm['s-p'];
|
|
1141
|
+
const childrenPromises = (_a = elm['s-p']) !== null && _a !== void 0 ? _a : [];
|
|
1011
1142
|
const postUpdate = () => postUpdateComponent(hostRef);
|
|
1012
1143
|
if (childrenPromises.length === 0) {
|
|
1013
1144
|
postUpdate();
|
|
@@ -1019,8 +1150,24 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
|
1019
1150
|
}
|
|
1020
1151
|
}
|
|
1021
1152
|
};
|
|
1022
|
-
|
|
1153
|
+
/**
|
|
1154
|
+
* Handle making the call to the VDom renderer with the proper context given
|
|
1155
|
+
* various build variables
|
|
1156
|
+
*
|
|
1157
|
+
* @param hostRef an object containing references to the element's host node,
|
|
1158
|
+
* VDom nodes, and other metadata
|
|
1159
|
+
* @param instance a reference to the underlying host element where it will be
|
|
1160
|
+
* rendered
|
|
1161
|
+
* @param elm the Host element for the component
|
|
1162
|
+
* @param isInitialLoad whether or not this function is being called as part of
|
|
1163
|
+
* @returns an empty promise
|
|
1164
|
+
*/
|
|
1165
|
+
const callRender = (hostRef, instance, elm, isInitialLoad) => {
|
|
1023
1166
|
try {
|
|
1167
|
+
/**
|
|
1168
|
+
* minification optimization: `allRenderFn` is `true` if all components have a `render`
|
|
1169
|
+
* method, so we can call the method immediately. If not, check before calling it.
|
|
1170
|
+
*/
|
|
1024
1171
|
instance = instance.render() ;
|
|
1025
1172
|
{
|
|
1026
1173
|
hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
|
|
@@ -1034,7 +1181,7 @@ const callRender = (hostRef, instance, elm) => {
|
|
|
1034
1181
|
// or we need to update the css class/attrs on the host element
|
|
1035
1182
|
// DOM WRITE!
|
|
1036
1183
|
{
|
|
1037
|
-
renderVdom(hostRef, instance);
|
|
1184
|
+
renderVdom(hostRef, instance, isInitialLoad);
|
|
1038
1185
|
}
|
|
1039
1186
|
}
|
|
1040
1187
|
}
|
|
@@ -1097,6 +1244,16 @@ const appDidLoad = (who) => {
|
|
|
1097
1244
|
}
|
|
1098
1245
|
nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
|
|
1099
1246
|
};
|
|
1247
|
+
/**
|
|
1248
|
+
* Allows to safely call a method, e.g. `componentDidLoad`, on an instance,
|
|
1249
|
+
* e.g. custom element node. If a build figures out that e.g. no component
|
|
1250
|
+
* has a `componentDidLoad` method, the instance method gets removed from the
|
|
1251
|
+
* output bundle and this function returns `undefined`.
|
|
1252
|
+
* @param instance any object that may or may not contain methods
|
|
1253
|
+
* @param method method name
|
|
1254
|
+
* @param arg single arbitrary argument
|
|
1255
|
+
* @returns result of method call if it exists, otherwise `undefined`
|
|
1256
|
+
*/
|
|
1100
1257
|
const safeCall = (instance, method, arg) => {
|
|
1101
1258
|
if (instance && instance[method]) {
|
|
1102
1259
|
try {
|
|
@@ -1108,9 +1265,6 @@ const safeCall = (instance, method, arg) => {
|
|
|
1108
1265
|
}
|
|
1109
1266
|
return undefined;
|
|
1110
1267
|
};
|
|
1111
|
-
const then = (promise, thenFn) => {
|
|
1112
|
-
return promise && promise.then ? promise.then(thenFn) : thenFn();
|
|
1113
|
-
};
|
|
1114
1268
|
const addHydratedFlag = (elm) => elm.setAttribute('hydrated', '')
|
|
1115
1269
|
;
|
|
1116
1270
|
const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
|
|
@@ -1167,6 +1321,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
1167
1321
|
* @returns a reference to the same constructor passed in (but now mutated)
|
|
1168
1322
|
*/
|
|
1169
1323
|
const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
1324
|
+
var _a;
|
|
1170
1325
|
if (cmpMeta.$members$) {
|
|
1171
1326
|
if (Cstr.watchers) {
|
|
1172
1327
|
cmpMeta.$watchers$ = Cstr.watchers;
|
|
@@ -1204,7 +1359,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1204
1359
|
});
|
|
1205
1360
|
if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
|
|
1206
1361
|
const attrNameToPropName = new Map();
|
|
1207
|
-
prototype.attributeChangedCallback = function (attrName,
|
|
1362
|
+
prototype.attributeChangedCallback = function (attrName, oldValue, newValue) {
|
|
1208
1363
|
plt.jmp(() => {
|
|
1209
1364
|
const propName = attrNameToPropName.get(attrName);
|
|
1210
1365
|
// In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
|
|
@@ -1227,12 +1382,12 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1227
1382
|
// customElements.define('my-component', MyComponent);
|
|
1228
1383
|
// </script>
|
|
1229
1384
|
// ```
|
|
1230
|
-
// In this case if we do not
|
|
1385
|
+
// In this case if we do not un-shadow here and use the value of the shadowing property, attributeChangedCallback
|
|
1231
1386
|
// will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
|
|
1232
1387
|
// to the value that was set inline i.e. "some-value" from above example. When
|
|
1233
|
-
// the connectedCallback attempts to
|
|
1388
|
+
// the connectedCallback attempts to un-shadow it will use "some-value" as the initial value rather than "another-value"
|
|
1234
1389
|
//
|
|
1235
|
-
// The case where the attribute was NOT set inline but was not set programmatically shall be handled/
|
|
1390
|
+
// The case where the attribute was NOT set inline but was not set programmatically shall be handled/un-shadowed
|
|
1236
1391
|
// by connectedCallback as this attributeChangedCallback will not fire.
|
|
1237
1392
|
//
|
|
1238
1393
|
// https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
|
|
@@ -1252,31 +1407,70 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1252
1407
|
// `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
|
|
1253
1408
|
return;
|
|
1254
1409
|
}
|
|
1410
|
+
else if (propName == null) {
|
|
1411
|
+
// At this point we should know this is not a "member", so we can treat it like watching an attribute
|
|
1412
|
+
// on a vanilla web component
|
|
1413
|
+
const hostRef = getHostRef(this);
|
|
1414
|
+
const flags = hostRef === null || hostRef === void 0 ? void 0 : hostRef.$flags$;
|
|
1415
|
+
// We only want to trigger the callback(s) if:
|
|
1416
|
+
// 1. The instance is ready
|
|
1417
|
+
// 2. The watchers are ready
|
|
1418
|
+
// 3. The value has changed
|
|
1419
|
+
if (!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) &&
|
|
1420
|
+
flags & 128 /* HOST_FLAGS.isWatchReady */ &&
|
|
1421
|
+
newValue !== oldValue) {
|
|
1422
|
+
const instance = hostRef.$lazyInstance$ ;
|
|
1423
|
+
const entry = cmpMeta.$watchers$[attrName];
|
|
1424
|
+
entry === null || entry === void 0 ? void 0 : entry.forEach((callbackName) => {
|
|
1425
|
+
if (instance[callbackName] != null) {
|
|
1426
|
+
instance[callbackName].call(instance, newValue, oldValue, attrName);
|
|
1427
|
+
}
|
|
1428
|
+
});
|
|
1429
|
+
}
|
|
1430
|
+
return;
|
|
1431
|
+
}
|
|
1255
1432
|
this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
|
|
1256
1433
|
});
|
|
1257
1434
|
};
|
|
1258
|
-
//
|
|
1259
|
-
//
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1435
|
+
// Create an array of attributes to observe
|
|
1436
|
+
// This list in comprised of all strings used within a `@Watch()` decorator
|
|
1437
|
+
// on a component as well as any Stencil-specific "members" (`@Prop()`s and `@State()`s).
|
|
1438
|
+
// As such, there is no way to guarantee type-safety here that a user hasn't entered
|
|
1439
|
+
// an invalid attribute.
|
|
1440
|
+
Cstr.observedAttributes = Array.from(new Set([
|
|
1441
|
+
...Object.keys((_a = cmpMeta.$watchers$) !== null && _a !== void 0 ? _a : {}),
|
|
1442
|
+
...members
|
|
1443
|
+
.filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */)
|
|
1444
|
+
.map(([propName, m]) => {
|
|
1445
|
+
const attrName = m[1] || propName;
|
|
1446
|
+
attrNameToPropName.set(attrName, propName);
|
|
1447
|
+
if (m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
|
|
1448
|
+
cmpMeta.$attrsToReflect$.push([propName, attrName]);
|
|
1449
|
+
}
|
|
1450
|
+
return attrName;
|
|
1451
|
+
}),
|
|
1452
|
+
]));
|
|
1270
1453
|
}
|
|
1271
1454
|
}
|
|
1272
1455
|
return Cstr;
|
|
1273
1456
|
};
|
|
1274
|
-
|
|
1457
|
+
/**
|
|
1458
|
+
* Initialize a Stencil component given a reference to its host element, its
|
|
1459
|
+
* runtime bookkeeping data structure, runtime metadata about the component,
|
|
1460
|
+
* and (optionally) an HMR version ID.
|
|
1461
|
+
*
|
|
1462
|
+
* @param elm a host element
|
|
1463
|
+
* @param hostRef the element's runtime bookkeeping object
|
|
1464
|
+
* @param cmpMeta runtime metadata for the Stencil component
|
|
1465
|
+
* @param hmrVersionId an (optional) HMR version ID
|
|
1466
|
+
*/
|
|
1467
|
+
const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
1468
|
+
let Cstr;
|
|
1275
1469
|
// initializeComponent
|
|
1276
1470
|
if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
|
|
1471
|
+
// Let the runtime know that the component has been initialized
|
|
1472
|
+
hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
|
|
1277
1473
|
{
|
|
1278
|
-
// we haven't initialized this element yet
|
|
1279
|
-
hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
|
|
1280
1474
|
// lazy loaded components
|
|
1281
1475
|
// request the component's implementation to be
|
|
1282
1476
|
// wired up with the host element
|
|
@@ -1349,6 +1543,8 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1349
1543
|
schedule();
|
|
1350
1544
|
}
|
|
1351
1545
|
};
|
|
1546
|
+
const fireConnectedCallback = (instance) => {
|
|
1547
|
+
};
|
|
1352
1548
|
const connectedCallback = (elm) => {
|
|
1353
1549
|
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
1354
1550
|
const hostRef = getHostRef(elm);
|
|
@@ -1387,15 +1583,29 @@ const connectedCallback = (elm) => {
|
|
|
1387
1583
|
initializeComponent(elm, hostRef, cmpMeta);
|
|
1388
1584
|
}
|
|
1389
1585
|
}
|
|
1586
|
+
else {
|
|
1587
|
+
// fire off connectedCallback() on component instance
|
|
1588
|
+
if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$lazyInstance$) ;
|
|
1589
|
+
else if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$onReadyPromise$) {
|
|
1590
|
+
hostRef.$onReadyPromise$.then(() => fireConnectedCallback());
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1390
1593
|
endConnected();
|
|
1391
1594
|
}
|
|
1392
1595
|
};
|
|
1393
|
-
const
|
|
1596
|
+
const disconnectInstance = (instance) => {
|
|
1597
|
+
{
|
|
1598
|
+
safeCall(instance, 'disconnectedCallback');
|
|
1599
|
+
}
|
|
1600
|
+
};
|
|
1601
|
+
const disconnectedCallback = async (elm) => {
|
|
1394
1602
|
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
1395
1603
|
const hostRef = getHostRef(elm);
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1604
|
+
if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$lazyInstance$) {
|
|
1605
|
+
disconnectInstance(hostRef.$lazyInstance$);
|
|
1606
|
+
}
|
|
1607
|
+
else if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$onReadyPromise$) {
|
|
1608
|
+
hostRef.$onReadyPromise$.then(() => disconnectInstance(hostRef.$lazyInstance$));
|
|
1399
1609
|
}
|
|
1400
1610
|
}
|
|
1401
1611
|
};
|
|
@@ -1415,6 +1625,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1415
1625
|
plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
|
|
1416
1626
|
lazyBundles.map((lazyBundle) => {
|
|
1417
1627
|
lazyBundle[1].map((compactMeta) => {
|
|
1628
|
+
var _a;
|
|
1418
1629
|
const cmpMeta = {
|
|
1419
1630
|
$flags$: compactMeta[0],
|
|
1420
1631
|
$tagName$: compactMeta[1],
|
|
@@ -1428,7 +1639,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1428
1639
|
cmpMeta.$attrsToReflect$ = [];
|
|
1429
1640
|
}
|
|
1430
1641
|
{
|
|
1431
|
-
cmpMeta.$watchers$ = {};
|
|
1642
|
+
cmpMeta.$watchers$ = (_a = compactMeta[4]) !== null && _a !== void 0 ? _a : {};
|
|
1432
1643
|
}
|
|
1433
1644
|
const tagName = cmpMeta.$tagName$;
|
|
1434
1645
|
const HostElement = class extends HTMLElement {
|
|
@@ -1508,13 +1719,40 @@ const Fragment = (_, children) => children;
|
|
|
1508
1719
|
* @returns void
|
|
1509
1720
|
*/
|
|
1510
1721
|
const setNonce = (nonce) => (plt.$nonce$ = nonce);
|
|
1722
|
+
/**
|
|
1723
|
+
* A WeakMap mapping runtime component references to their corresponding host reference
|
|
1724
|
+
* instances.
|
|
1725
|
+
*/
|
|
1511
1726
|
const hostRefs = /*@__PURE__*/ new WeakMap();
|
|
1727
|
+
/**
|
|
1728
|
+
* Given a {@link d.RuntimeRef} retrieve the corresponding {@link d.HostRef}
|
|
1729
|
+
*
|
|
1730
|
+
* @param ref the runtime ref of interest
|
|
1731
|
+
* @returns the Host reference (if found) or undefined
|
|
1732
|
+
*/
|
|
1512
1733
|
const getHostRef = (ref) => hostRefs.get(ref);
|
|
1734
|
+
/**
|
|
1735
|
+
* Register a lazy instance with the {@link hostRefs} object so it's
|
|
1736
|
+
* corresponding {@link d.HostRef} can be retrieved later.
|
|
1737
|
+
*
|
|
1738
|
+
* @param lazyInstance the lazy instance of interest
|
|
1739
|
+
* @param hostRef that instances `HostRef` object
|
|
1740
|
+
* @returns a reference to the host ref WeakMap
|
|
1741
|
+
*/
|
|
1513
1742
|
const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
|
|
1514
|
-
|
|
1743
|
+
/**
|
|
1744
|
+
* Register a host element for a Stencil component, setting up various metadata
|
|
1745
|
+
* and callbacks based on {@link BUILD} flags as well as the component's runtime
|
|
1746
|
+
* metadata.
|
|
1747
|
+
*
|
|
1748
|
+
* @param hostElement the host element to register
|
|
1749
|
+
* @param cmpMeta runtime metadata for that component
|
|
1750
|
+
* @returns a reference to the host ref WeakMap
|
|
1751
|
+
*/
|
|
1752
|
+
const registerHost = (hostElement, cmpMeta) => {
|
|
1515
1753
|
const hostRef = {
|
|
1516
1754
|
$flags$: 0,
|
|
1517
|
-
$hostElement$:
|
|
1755
|
+
$hostElement$: hostElement,
|
|
1518
1756
|
$cmpMeta$: cmpMeta,
|
|
1519
1757
|
$instanceValues$: new Map(),
|
|
1520
1758
|
};
|
|
@@ -1523,10 +1761,10 @@ const registerHost = (elm, cmpMeta) => {
|
|
|
1523
1761
|
}
|
|
1524
1762
|
{
|
|
1525
1763
|
hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
|
|
1526
|
-
|
|
1527
|
-
|
|
1764
|
+
hostElement['s-p'] = [];
|
|
1765
|
+
hostElement['s-rc'] = [];
|
|
1528
1766
|
}
|
|
1529
|
-
return hostRefs.set(
|
|
1767
|
+
return hostRefs.set(hostElement, hostRef);
|
|
1530
1768
|
};
|
|
1531
1769
|
const isMemberInElement = (elm, memberName) => memberName in elm;
|
|
1532
1770
|
const consoleError = (e, el) => (0, console.error)(e, el);
|
package/dist/esm/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { a as arcade } from './arcade-defaults-
|
|
2
|
-
import './index-
|
|
1
|
+
export { a as arcade } from './arcade-defaults-145d902c.js';
|
|
2
|
+
import './index-fd6b2fd8.js';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { conf as conf$1, language as language$1 } from './typescript-
|
|
2
|
-
import './arcade-defaults-
|
|
3
|
-
import './index-
|
|
1
|
+
import { conf as conf$1, language as language$1 } from './typescript-dab44a94.js';
|
|
2
|
+
import './arcade-defaults-145d902c.js';
|
|
3
|
+
import './index-fd6b2fd8.js';
|
|
4
4
|
|
|
5
5
|
/*!-----------------------------------------------------------------------------
|
|
6
6
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7
|
-
* Version: 0.
|
|
7
|
+
* Version: 0.44.0(3e047efd345ff102c8c61b5398fb30845aaac166)
|
|
8
8
|
* Released under the MIT license
|
|
9
9
|
* https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
|
|
10
10
|
*-----------------------------------------------------------------------------*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import './index-
|
|
1
|
+
import { n as monaco_editor_core_star } from './arcade-defaults-145d902c.js';
|
|
2
|
+
import './index-fd6b2fd8.js';
|
|
3
3
|
|
|
4
4
|
/*!-----------------------------------------------------------------------------
|
|
5
5
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6
|
-
* Version: 0.
|
|
6
|
+
* Version: 0.44.0(3e047efd345ff102c8c61b5398fb30845aaac166)
|
|
7
7
|
* Released under the MIT license
|
|
8
8
|
* https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
|
|
9
9
|
*-----------------------------------------------------------------------------*/
|