@arcgis/coding-components 4.30.0-next.46 → 4.30.0-next.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/arcgis-coding-components/arcgis-coding-components.esm.js +2 -2
- package/dist/arcgis-coding-components/index.esm.js +2 -2
- package/dist/arcgis-coding-components/{p-aa672cd9.js → p-01053433.js} +3 -3
- package/dist/arcgis-coding-components/{p-eb83782e.js → p-1db5201d.js} +2 -2
- package/dist/arcgis-coding-components/{p-18c03356.js → p-28b2dc74.js} +3 -3
- package/dist/arcgis-coding-components/{p-f6784d16.js → p-44e721ed.js} +1 -1
- package/dist/arcgis-coding-components/{p-6eb6e8f4.js → p-47052799.js} +2 -2
- package/dist/arcgis-coding-components/{p-42693ecc.js → p-836e6d3b.js} +3 -3
- package/dist/arcgis-coding-components/{p-c595c17c.js → p-8d7149fa.js} +2 -2
- package/dist/arcgis-coding-components/{p-c6853dc2.js → p-9fe5cc32.js} +2 -2
- package/dist/arcgis-coding-components/{p-cf08aaa7.js → p-ab093966.js} +3 -3
- package/dist/arcgis-coding-components/p-ca924bde.entry.js +6 -0
- package/dist/arcgis-coding-components/{p-77e30a82.js → p-e5196615.js} +2 -2
- package/dist/arcgis-coding-components/{p-7704534b.js → p-fb2e7a5f.js} +10 -10
- package/dist/cjs/{arcade-defaults-c2d9ee63.js → arcade-defaults-21ac6e84.js} +10 -26
- package/dist/cjs/{arcade-mode-df790d78.js → arcade-mode-fac05e67.js} +3 -3
- package/dist/cjs/arcgis-arcade-api_6.cjs.entry.js +335 -341
- package/dist/cjs/arcgis-coding-components.cjs.js +3 -3
- package/dist/cjs/{css-6cf982a2.js → css-8ad7537c.js} +1 -1
- package/dist/cjs/{cssMode-2aac2bd5.js → cssMode-eea8b359.js} +3 -3
- package/dist/cjs/{html-2b04b1a3.js → html-0de324ee.js} +3 -3
- package/dist/cjs/{htmlMode-3e08f577.js → htmlMode-98762d04.js} +3 -3
- package/dist/cjs/{index-d8bdd589.js → index-dbf19c86.js} +7 -3
- package/dist/cjs/index.cjs.js +3 -3
- package/dist/cjs/{javascript-153d4a21.js → javascript-225afafb.js} +4 -4
- package/dist/cjs/{jsonMode-de534cc0.js → jsonMode-b9e23277.js} +3 -3
- package/dist/cjs/loader.cjs.js +3 -3
- package/dist/cjs/{tsMode-9a00f595.js → tsMode-0d391a5b.js} +3 -3
- package/dist/cjs/{typescript-85db784c.js → typescript-5f82ee9a.js} +3 -3
- package/dist/components/arcade-api.js +6 -5
- package/dist/components/arcade-contribution.js +3 -2
- package/dist/components/arcade-defaults.js +3 -3
- package/dist/components/arcade-mode.js +2 -2
- package/dist/components/arcade-results.js +7 -6
- package/dist/components/arcade-suggestions.js +8 -7
- package/dist/components/arcade-variables.js +6 -5
- package/dist/components/arcgis-arcade-api.js +1 -1
- package/dist/components/arcgis-arcade-editor.js +18 -14
- package/dist/components/arcgis-arcade-results.js +1 -1
- package/dist/components/arcgis-arcade-suggestions.js +1 -1
- package/dist/components/arcgis-arcade-variables.js +1 -1
- package/dist/components/arcgis-assets.d.ts +1 -1
- package/dist/components/arcgis-assets.js +1 -1
- package/dist/components/arcgis-code-editor.js +1 -1
- package/dist/components/{chunk-HXHHCYA6.js → chunk-754TVXIU.js} +268 -289
- package/dist/components/code-editor.js +56 -63
- package/dist/components/fields.js +62 -2
- package/dist/components/index.js +1 -1
- package/dist/components/index2.js +2 -76
- package/dist/components/markdown.js +1 -1
- package/dist/components/useT9n.js +11 -0
- package/dist/components/utilities.js +2 -2
- package/dist/esm/{arcade-defaults-48c8832f.js → arcade-defaults-f8cd9e18.js} +11 -25
- package/dist/esm/{arcade-mode-1f2ea7da.js → arcade-mode-e6822415.js} +3 -3
- package/dist/esm/arcgis-arcade-api_6.entry.js +334 -340
- package/dist/esm/arcgis-coding-components.js +4 -4
- package/dist/esm/{css-b5f0f74b.js → css-f5040596.js} +1 -1
- package/dist/esm/{cssMode-265b57f6.js → cssMode-3557d5fc.js} +3 -3
- package/dist/esm/{html-c4501640.js → html-6b076c4a.js} +3 -3
- package/dist/esm/{htmlMode-36324801.js → htmlMode-6b689aeb.js} +3 -3
- package/dist/esm/{index-56d42c6b.js → index-0b35a7aa.js} +8 -3
- package/dist/esm/index.js +3 -3
- package/dist/esm/{javascript-25150788.js → javascript-e4c1e8ff.js} +4 -4
- package/dist/esm/{jsonMode-141814de.js → jsonMode-b9ebc4da.js} +3 -3
- package/dist/esm/loader.js +4 -4
- package/dist/esm/{tsMode-d3956e42.js → tsMode-ed4400fc.js} +3 -3
- package/dist/esm/{typescript-7e8d8a9a.js → typescript-ec6348b6.js} +3 -3
- package/dist/loader/cdn.js +1 -1
- package/dist/loader/index.cjs.js +1 -1
- package/dist/loader/index.es2017.js +1 -1
- package/dist/loader/index.js +1 -1
- package/dist/types/components/arcade-editor/arcade-editor.d.ts +9 -5
- package/dist/types/components/arcade-suggestions/arcade-suggestions.d.ts +1 -1
- package/dist/types/components/code-editor/code-editor.d.ts +14 -12
- package/dist/types/components.d.ts +22 -11
- package/dist/types/controllers/useT9n.d.ts +1 -0
- package/dist/types/data/actions-runner-1/_work/arcgis-web-components/arcgis-web-components/packages/coding-packages/coding-components/.stencil/stencil.config.d.ts +3 -0
- package/dist/types/data/actions-runner-1/_work/arcgis-web-components/arcgis-web-components/packages/coding-packages/coding-components/.stencil/support/sass-inline-url-importer.d.ts +9 -0
- package/dist/types/data/actions-runner-1/_work/arcgis-web-components/arcgis-web-components/packages/coding-packages/coding-components/.stencil/support/sass-json-importer.d.ts +19 -0
- package/dist/types/data/actions-runner-1/_work/arcgis-web-components/arcgis-web-components/packages/coding-packages/coding-components/.stencil/support/stencil-monaco-plugins.d.ts +6 -0
- package/package.json +9 -9
- package/dist/arcgis-coding-components/p-873cb602.entry.js +0 -6
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
* See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
|
-
* v4.30.0-next.
|
|
4
|
+
* v4.30.0-next.48
|
|
5
5
|
*/
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
9
9
|
|
|
10
|
-
const index = require('./index-
|
|
11
|
-
const arcadeDefaults = require('./arcade-defaults-
|
|
10
|
+
const index = require('./index-dbf19c86.js');
|
|
11
|
+
const arcadeDefaults = require('./arcade-defaults-21ac6e84.js');
|
|
12
12
|
|
|
13
13
|
async function colorizeCode(code) {
|
|
14
14
|
return await arcadeDefaults.editor.colorize(code, "arcade", { tabSize: 2 });
|
|
@@ -2939,17 +2939,30 @@ function convertMarkdownString(value) {
|
|
|
2939
2939
|
return marked_umd.marked.parse(typeof value === "string" ? value : value.value);
|
|
2940
2940
|
}
|
|
2941
2941
|
|
|
2942
|
-
// src/
|
|
2943
|
-
function
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2942
|
+
// src/framework.ts
|
|
2943
|
+
function retrieveComponentMembers(component, isLit) {
|
|
2944
|
+
if (isLit) {
|
|
2945
|
+
const elementProperties = getLitProperties(component);
|
|
2946
|
+
component.manager.internals.members = Object.fromEntries(
|
|
2947
|
+
Array.from(elementProperties, ([name, { state, type }]) => [
|
|
2948
|
+
name,
|
|
2949
|
+
[
|
|
2950
|
+
state ? 32 /* State */ : type === Number ? 2 /* Number */ : type === Boolean ? 4 /* Boolean */ : 1 /* String */
|
|
2951
|
+
]
|
|
2952
|
+
])
|
|
2950
2953
|
);
|
|
2951
|
-
|
|
2954
|
+
} else {
|
|
2955
|
+
const constructor = component.constructor;
|
|
2956
|
+
const members = constructor.__registerControllers?.(component) ?? void 0;
|
|
2957
|
+
constructor.__registerControllers = void 0;
|
|
2958
|
+
if (typeof members !== "object")
|
|
2959
|
+
throw new Error(
|
|
2960
|
+
"Failed to retrieve internal component meta. Make sure you have the useComponentsControllers() Rollup Plugin for Stencil Controllers configured in your Stencil config."
|
|
2961
|
+
);
|
|
2962
|
+
component.manager.internals.members = members;
|
|
2963
|
+
}
|
|
2952
2964
|
}
|
|
2965
|
+
var getLitProperties = (component) => component.constructor.elementProperties;
|
|
2953
2966
|
function parsePropertyValue(value, type = 8 /* Any */) {
|
|
2954
2967
|
const isComplex = value == null || typeof value === "object" || typeof value === "function";
|
|
2955
2968
|
if (isComplex)
|
|
@@ -2957,7 +2970,7 @@ function parsePropertyValue(value, type = 8 /* Any */) {
|
|
|
2957
2970
|
if ((type & 4 /* Boolean */) !== 0)
|
|
2958
2971
|
return value === "false" ? false : value === "" || !!value;
|
|
2959
2972
|
else if ((type & 2 /* Number */) !== 0)
|
|
2960
|
-
return Number.parseFloat(value
|
|
2973
|
+
return Number.parseFloat(value);
|
|
2961
2974
|
else if ((type & 1 /* String */) !== 0)
|
|
2962
2975
|
return String(value);
|
|
2963
2976
|
else
|
|
@@ -2979,6 +2992,21 @@ function getPropType(component, name) {
|
|
|
2979
2992
|
return "prop";
|
|
2980
2993
|
}
|
|
2981
2994
|
|
|
2995
|
+
// src/types.ts
|
|
2996
|
+
var controllerSymbol = Symbol("controller");
|
|
2997
|
+
|
|
2998
|
+
// src/utils.ts
|
|
2999
|
+
function extendObject(base, extend) {
|
|
3000
|
+
Object.entries(extend).forEach(([key, value]) => {
|
|
3001
|
+
if (key in base)
|
|
3002
|
+
throw new Error(`Unable to extend object because property "${key}" is already defined`);
|
|
3003
|
+
const thisBase = base;
|
|
3004
|
+
thisBase[key] = value;
|
|
3005
|
+
});
|
|
3006
|
+
return base;
|
|
3007
|
+
}
|
|
3008
|
+
var isController = (value) => typeof value === "object" && value !== null && (controllerSymbol in value || "hostConnected" in value || "hostDisconnected" in value || "hostUpdate" in value || "hostUpdated" in value);
|
|
3009
|
+
|
|
2982
3010
|
// ../components-utils/dist/index.js
|
|
2983
3011
|
var Deferred = class {
|
|
2984
3012
|
/**
|
|
@@ -3083,6 +3111,7 @@ async function safeAsyncCall(callback) {
|
|
|
3083
3111
|
}
|
|
3084
3112
|
return void 0;
|
|
3085
3113
|
}
|
|
3114
|
+
var camelToKebab = (string) => string.replace(upperBeforeLower, (upper, remainder) => `${remainder === 0 ? "" : "-"}${upper.toLowerCase()}`);
|
|
3086
3115
|
var upperBeforeLower = /[A-Z]+(?![a-z])|[A-Z]/gu;
|
|
3087
3116
|
var capitalize = (string) => string.charAt(0).toUpperCase() + string.slice(1);
|
|
3088
3117
|
var camelToHuman = (string) => capitalize(string.replace(upperBeforeLower, (upper, remainder) => `${remainder === 0 ? "" : " "}${upper}`));
|
|
@@ -3182,21 +3211,6 @@ async function updateComponentLocateState(element, assetsPath, assetName = eleme
|
|
|
3182
3211
|
return { lang, t9nLocale, t9nStrings };
|
|
3183
3212
|
}
|
|
3184
3213
|
|
|
3185
|
-
// src/types.ts
|
|
3186
|
-
var controllerSymbol = Symbol("controller");
|
|
3187
|
-
|
|
3188
|
-
// src/utils.ts
|
|
3189
|
-
function extendObject(base, extend) {
|
|
3190
|
-
Object.entries(extend).forEach(([key, value]) => {
|
|
3191
|
-
if (key in base)
|
|
3192
|
-
throw new Error(`Unable to extend object because property "${key}" is already defined`);
|
|
3193
|
-
const thisBase = base;
|
|
3194
|
-
thisBase[key] = value;
|
|
3195
|
-
});
|
|
3196
|
-
return base;
|
|
3197
|
-
}
|
|
3198
|
-
var isController = (value) => typeof value === "object" && value !== null && (controllerSymbol in value || "hostConnected" in value || "hostDisconnected" in value || "hostUpdate" in value || "hostUpdated" in value);
|
|
3199
|
-
|
|
3200
3214
|
// src/ControllerInternals.ts
|
|
3201
3215
|
var ControllerInternals = class {
|
|
3202
3216
|
constructor() {
|
|
@@ -3361,26 +3375,23 @@ var _Controller = class _Controller {
|
|
|
3361
3375
|
value: resolvedComponent
|
|
3362
3376
|
});
|
|
3363
3377
|
this.component.addController(this);
|
|
3364
|
-
const manager = this.component.manager;
|
|
3365
|
-
this.connected = manager?.connected;
|
|
3366
|
-
this.internals = manager?.internals;
|
|
3367
3378
|
_Controller.internals.setParentController(this);
|
|
3368
3379
|
if ("hostDestroy" in this)
|
|
3369
3380
|
this.component.manager.ensureHasDestroy();
|
|
3370
|
-
|
|
3381
|
+
const manager = this.component.manager;
|
|
3382
|
+
const isInControllerManager = manager === void 0;
|
|
3383
|
+
if (!isInControllerManager)
|
|
3371
3384
|
queueMicrotask(() => this.catchUpLifecycle());
|
|
3372
|
-
const controller = this;
|
|
3385
|
+
const controller = isInControllerManager ? {} : this;
|
|
3373
3386
|
this._callbacks = {
|
|
3374
|
-
hostConnected: "hostConnected" in
|
|
3375
|
-
hostDisconnected: "hostDisconnected" in
|
|
3376
|
-
hostLoad: "hostLoad" in
|
|
3377
|
-
hostLoaded: "hostLoaded" in
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
hostDestroy: "hostDestroy" in this ? [() => controller.hostDestroy?.()] : [],
|
|
3383
|
-
hostLifecycle: "hostLifecycle" in this ? [() => controller.hostLifecycle?.()] : []
|
|
3387
|
+
hostConnected: "hostConnected" in controller ? [() => controller.hostConnected?.()] : [],
|
|
3388
|
+
hostDisconnected: "hostDisconnected" in controller ? [() => controller.hostDisconnected?.()] : [],
|
|
3389
|
+
hostLoad: "hostLoad" in controller ? [() => controller.hostLoad?.()] : [],
|
|
3390
|
+
hostLoaded: "hostLoaded" in controller ? [() => controller.hostLoaded?.()] : [],
|
|
3391
|
+
hostUpdate: "hostUpdate" in controller ? [() => controller.hostUpdate?.()] : [],
|
|
3392
|
+
hostUpdated: "hostUpdated" in controller ? [() => controller.hostUpdated?.()] : [],
|
|
3393
|
+
hostDestroy: "hostDestroy" in controller ? [() => controller.hostDestroy?.()] : [],
|
|
3394
|
+
hostLifecycle: "hostLifecycle" in controller ? [() => controller.hostLifecycle?.()] : []
|
|
3384
3395
|
};
|
|
3385
3396
|
}
|
|
3386
3397
|
/**
|
|
@@ -3505,7 +3516,7 @@ var _Controller = class _Controller {
|
|
|
3505
3516
|
}
|
|
3506
3517
|
/**
|
|
3507
3518
|
* Property reads inside of this function will bypass any custom getter you
|
|
3508
|
-
* may have, and read the value directly from what's stored in Stencil.
|
|
3519
|
+
* may have, and read the value directly from what's stored in Stencil/Lit.
|
|
3509
3520
|
*
|
|
3510
3521
|
* This also bypasses reactiveUtils integration - reading a property inside of
|
|
3511
3522
|
* bypassGetter won't make that property tracked.
|
|
@@ -3544,28 +3555,30 @@ var _Controller = class _Controller {
|
|
|
3544
3555
|
genericGetSet(property, getSet) {
|
|
3545
3556
|
var _a2, _b;
|
|
3546
3557
|
const genericGetSet = getSet;
|
|
3558
|
+
const internals = this.component.manager.internals;
|
|
3547
3559
|
if (genericGetSet.get !== void 0) {
|
|
3548
|
-
(_a2 =
|
|
3549
|
-
|
|
3560
|
+
(_a2 = internals.getters)[property] ?? (_a2[property] = []);
|
|
3561
|
+
internals.getters[property].unshift(genericGetSet.get);
|
|
3550
3562
|
}
|
|
3551
3563
|
if (genericGetSet.set !== void 0) {
|
|
3552
|
-
(_b =
|
|
3553
|
-
|
|
3564
|
+
(_b = internals.setters)[property] ?? (_b[property] = []);
|
|
3565
|
+
internals.setters[property].unshift(genericGetSet.set);
|
|
3554
3566
|
}
|
|
3555
3567
|
}
|
|
3556
3568
|
// FEATURE: improve typings
|
|
3557
3569
|
/**
|
|
3558
|
-
* Dynamically set a watcher for any
|
|
3570
|
+
* Dynamically set a watcher for any reactive property
|
|
3559
3571
|
*/
|
|
3560
3572
|
watch(property, callback) {
|
|
3561
3573
|
var _a2;
|
|
3562
3574
|
const type = getMemberType(this.component, property);
|
|
3563
3575
|
if (type === void 0)
|
|
3564
3576
|
throw new Error(
|
|
3565
|
-
`Trying to watch a non-@
|
|
3577
|
+
`Trying to watch a non-@property, non-@state property "${property}". Either convert it into a @state() or use get/set syntax`
|
|
3566
3578
|
);
|
|
3567
|
-
|
|
3568
|
-
|
|
3579
|
+
const internals = this.component.manager.internals;
|
|
3580
|
+
(_a2 = internals.allWatchers)[property] ?? (_a2[property] = []);
|
|
3581
|
+
const watchers = internals.allWatchers[property];
|
|
3569
3582
|
const genericCallback = callback;
|
|
3570
3583
|
const safeCallback = (newValue, oldValue, propertyName) => safeCall(() => genericCallback(newValue, oldValue, propertyName));
|
|
3571
3584
|
watchers.push(safeCallback);
|
|
@@ -3588,12 +3601,6 @@ var _Controller = class _Controller {
|
|
|
3588
3601
|
onLoaded(callback) {
|
|
3589
3602
|
this._callbacks.hostLoaded.push(callback);
|
|
3590
3603
|
}
|
|
3591
|
-
onRender(callback) {
|
|
3592
|
-
this._callbacks.hostRender.push(callback);
|
|
3593
|
-
}
|
|
3594
|
-
onRendered(callback) {
|
|
3595
|
-
this._callbacks.hostRendered.push(callback);
|
|
3596
|
-
}
|
|
3597
3604
|
onUpdate(callback) {
|
|
3598
3605
|
this._callbacks.hostUpdate.push(callback);
|
|
3599
3606
|
}
|
|
@@ -3634,16 +3641,8 @@ var _Controller = class _Controller {
|
|
|
3634
3641
|
this._callbacks.hostLoaded.forEach(safeCall);
|
|
3635
3642
|
this.didLoadCalled = true;
|
|
3636
3643
|
}
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
await Promise.allSettled(this._callbacks.hostRender.map(safeAsyncCall));
|
|
3640
|
-
}
|
|
3641
|
-
triggerRendered() {
|
|
3642
|
-
this._callbacks.hostRendered.forEach(safeCall);
|
|
3643
|
-
}
|
|
3644
|
-
async triggerUpdate() {
|
|
3645
|
-
if (this._callbacks.hostUpdate.length > 0)
|
|
3646
|
-
await Promise.allSettled(this._callbacks.hostUpdate.map(safeAsyncCall));
|
|
3644
|
+
triggerUpdate() {
|
|
3645
|
+
this._callbacks.hostUpdate.forEach(safeCall);
|
|
3647
3646
|
}
|
|
3648
3647
|
triggerUpdated() {
|
|
3649
3648
|
this._callbacks.hostUpdated.forEach(safeCall);
|
|
@@ -3655,6 +3654,7 @@ var _Controller = class _Controller {
|
|
|
3655
3654
|
this._callbacks.hostLifecycle.forEach((callback) => this._callLifecycle(callback));
|
|
3656
3655
|
}
|
|
3657
3656
|
_callLifecycle(callback) {
|
|
3657
|
+
_Controller.internals.setAmbientComponent(this.component);
|
|
3658
3658
|
const cleanupRaw = safeCall(callback);
|
|
3659
3659
|
const cleanup = Array.isArray(cleanupRaw) ? cleanupRaw : [cleanupRaw];
|
|
3660
3660
|
cleanup.forEach((cleanup2) => {
|
|
@@ -3680,12 +3680,6 @@ var GenericController = class extends Controller {
|
|
|
3680
3680
|
callback
|
|
3681
3681
|
);
|
|
3682
3682
|
}
|
|
3683
|
-
/**
|
|
3684
|
-
* Silence "Property 'dynamicGetSet' in type
|
|
3685
|
-
* 'GenericController<Exports, Requires>' is not assignable to the same
|
|
3686
|
-
* property in base type 'Controller<Exports>'", as TypeScript is being overly
|
|
3687
|
-
* conservative here with what it allows
|
|
3688
|
-
*/
|
|
3689
3683
|
dynamicGetSet(property, getSet) {
|
|
3690
3684
|
super.genericGetSet(property, getSet);
|
|
3691
3685
|
}
|
|
@@ -3693,9 +3687,9 @@ var GenericController = class extends Controller {
|
|
|
3693
3687
|
function makeProvisionalValue(base) {
|
|
3694
3688
|
if (typeof base !== "object" && typeof base !== "function" || base === null)
|
|
3695
3689
|
return base;
|
|
3696
|
-
const
|
|
3690
|
+
const proxy2 = new Proxy(base, {
|
|
3697
3691
|
get(target, prop, receiver) {
|
|
3698
|
-
if (cyclical.has(prop) && prop in target && target[prop] ===
|
|
3692
|
+
if (cyclical.has(prop) && prop in target && target[prop] === proxy2)
|
|
3699
3693
|
return void 0;
|
|
3700
3694
|
if (prop in target || prop in Promise.prototype || typeof prop === "symbol")
|
|
3701
3695
|
return typeof target === "function" ? target[prop] : Reflect.get(target, prop, receiver);
|
|
@@ -3707,16 +3701,10 @@ function makeProvisionalValue(base) {
|
|
|
3707
3701
|
return Reflect.set(target, prop, newValue, receiver);
|
|
3708
3702
|
}
|
|
3709
3703
|
});
|
|
3710
|
-
return
|
|
3704
|
+
return proxy2;
|
|
3711
3705
|
}
|
|
3712
3706
|
var cyclical = /* @__PURE__ */ new Set(["exports", "_exports"]);
|
|
3713
|
-
var accessBeforeLoad =
|
|
3714
|
-
"This might be the case if you are trying to access an async controller in ",
|
|
3715
|
-
"connectedCallback(). Or, if you are using it inside of ",
|
|
3716
|
-
"componentWillLoad()/another controller without controller.use. Example correct ",
|
|
3717
|
-
"usage:\n",
|
|
3718
|
-
"makeController(async (component, controller)=>{ await controller.use(someOtherController); });"
|
|
3719
|
-
].join("");
|
|
3707
|
+
var accessBeforeLoad = "" ;
|
|
3720
3708
|
function toControllerHost(component) {
|
|
3721
3709
|
if ("addController" in component)
|
|
3722
3710
|
return component;
|
|
@@ -3726,6 +3714,82 @@ function toControllerHost(component) {
|
|
|
3726
3714
|
);
|
|
3727
3715
|
}
|
|
3728
3716
|
|
|
3717
|
+
// src/proxyExports.ts
|
|
3718
|
+
var proxyExports = (Class) => (...args) => {
|
|
3719
|
+
const ambientControllers = Controller.internals.retrieveParentControllers();
|
|
3720
|
+
const instance = new Class(...args);
|
|
3721
|
+
const initialExports = instance.exports;
|
|
3722
|
+
Controller.internals.setParentController(ambientControllers.at(-1));
|
|
3723
|
+
const internals = instance.component.manager.internals;
|
|
3724
|
+
internals.markExports(instance, initialExports);
|
|
3725
|
+
instance.watchExports((exports) => internals.markExports(instance, exports));
|
|
3726
|
+
Controller.internals.setAmbientChildController(instance);
|
|
3727
|
+
const hostCandidates = [instance.component, ...ambientControllers].reverse();
|
|
3728
|
+
return internals.trackKey(
|
|
3729
|
+
hostCandidates,
|
|
3730
|
+
(resolution) => resolution === void 0 ? void 0 : setProxy(instance, resolution.host, resolution.key, initialExports),
|
|
3731
|
+
initialExports
|
|
3732
|
+
);
|
|
3733
|
+
};
|
|
3734
|
+
function setProxy(controller, host, key, initialExports) {
|
|
3735
|
+
const genericHost = host;
|
|
3736
|
+
const controllerValueChanged = genericHost[key] !== controller.exports;
|
|
3737
|
+
const hostValueChanged = genericHost[key] !== initialExports;
|
|
3738
|
+
const controllerUpdatedExports = initialExports !== controller.exports;
|
|
3739
|
+
if (controllerValueChanged && !hostValueChanged && controllerUpdatedExports)
|
|
3740
|
+
genericHost[key] = controller.exports;
|
|
3741
|
+
controller.watchExports(() => {
|
|
3742
|
+
if (genericHost[key] === controller.exports)
|
|
3743
|
+
return;
|
|
3744
|
+
const manager = controller.component.manager;
|
|
3745
|
+
const isReadOnly = manager.internals.readonlyProps?.has(key) === true;
|
|
3746
|
+
if (isReadOnly)
|
|
3747
|
+
manager.bypassReadonly(() => {
|
|
3748
|
+
genericHost[key] = controller.exports;
|
|
3749
|
+
});
|
|
3750
|
+
else
|
|
3751
|
+
genericHost[key] = controller.exports;
|
|
3752
|
+
});
|
|
3753
|
+
}
|
|
3754
|
+
|
|
3755
|
+
// src/functional.ts
|
|
3756
|
+
var makeController = (constructor) => proxy(void 0, constructor);
|
|
3757
|
+
var FunctionalController = class extends Controller {
|
|
3758
|
+
constructor(component, constructor) {
|
|
3759
|
+
super(component);
|
|
3760
|
+
const originalExports = this.exports;
|
|
3761
|
+
try {
|
|
3762
|
+
Controller.internals.setAmbientComponent(this.component);
|
|
3763
|
+
const value = constructor(this.component, this);
|
|
3764
|
+
const constructorChangedExports = this.exports !== originalExports;
|
|
3765
|
+
if (value instanceof Promise) {
|
|
3766
|
+
if (!constructorChangedExports)
|
|
3767
|
+
this.setProvisionalExports(value);
|
|
3768
|
+
const resolved = value.then((result) => {
|
|
3769
|
+
this.exports = result;
|
|
3770
|
+
super.catchUpLifecycle();
|
|
3771
|
+
}).catch((error) => {
|
|
3772
|
+
this._ready.reject(error);
|
|
3773
|
+
console.error(error);
|
|
3774
|
+
});
|
|
3775
|
+
this.onLoad(async () => await resolved);
|
|
3776
|
+
} else {
|
|
3777
|
+
if (!constructorChangedExports || value !== void 0)
|
|
3778
|
+
this.exports = value;
|
|
3779
|
+
queueMicrotask(() => super.catchUpLifecycle());
|
|
3780
|
+
}
|
|
3781
|
+
} catch (error) {
|
|
3782
|
+
this._ready.reject(error);
|
|
3783
|
+
console.error(error);
|
|
3784
|
+
}
|
|
3785
|
+
}
|
|
3786
|
+
/** Noop - will be called in the constructor instead */
|
|
3787
|
+
catchUpLifecycle() {
|
|
3788
|
+
return;
|
|
3789
|
+
}
|
|
3790
|
+
};
|
|
3791
|
+
var proxy = proxyExports(FunctionalController);
|
|
3792
|
+
|
|
3729
3793
|
// src/trackPropertyKey.ts
|
|
3730
3794
|
function trackPropertyKey(object, onResolved, defaultValue) {
|
|
3731
3795
|
const keys = Object.keys(object);
|
|
@@ -3859,9 +3923,12 @@ var ComponentInternals = class {
|
|
|
3859
3923
|
* to apply the changes to the prototype
|
|
3860
3924
|
*/
|
|
3861
3925
|
getSetProxy(property, hasGetter, hasSetter) {
|
|
3862
|
-
const
|
|
3926
|
+
const component = this.component;
|
|
3927
|
+
const classPrototype = component.constructor.prototype;
|
|
3863
3928
|
this._getSetProxy(classPrototype, property, hasGetter, hasSetter, "class");
|
|
3864
|
-
|
|
3929
|
+
if (component.manager.isLit)
|
|
3930
|
+
return;
|
|
3931
|
+
const htmlPrototype = component.el.constructor.prototype;
|
|
3865
3932
|
if (classPrototype !== htmlPrototype)
|
|
3866
3933
|
this._getSetProxy(htmlPrototype, property, hasGetter, hasSetter, "html");
|
|
3867
3934
|
}
|
|
@@ -3873,7 +3940,7 @@ var ComponentInternals = class {
|
|
|
3873
3940
|
if (descriptor?.set === void 0 || descriptor.get === void 0)
|
|
3874
3941
|
if (descriptor !== void 0 && "value" in descriptor)
|
|
3875
3942
|
throw new Error(
|
|
3876
|
-
`getSet() should only be used on
|
|
3943
|
+
`getSet() should only be used on @Prop/@property/@State/@state properties. For internal component properties, use regular get/set syntax. Tried to use it on "${name}" in ${component.el.tagName}`
|
|
3877
3944
|
);
|
|
3878
3945
|
else if (tolerateNotFound)
|
|
3879
3946
|
return;
|
|
@@ -3900,12 +3967,12 @@ var ComponentInternals = class {
|
|
|
3900
3967
|
} : originalGet;
|
|
3901
3968
|
const finalSetter = shouldOverwriteSet ? function setter(rawNewValue) {
|
|
3902
3969
|
const oldValue = originalGet.call(this);
|
|
3903
|
-
let newValue = parsePropertyValue(rawNewValue, propType);
|
|
3904
3970
|
const component2 = Controller.internals.elementToInstance.get(this);
|
|
3905
3971
|
if (component2 === void 0) {
|
|
3906
3972
|
originalSet.call(this, rawNewValue);
|
|
3907
3973
|
return;
|
|
3908
3974
|
}
|
|
3975
|
+
let newValue = component2.manager.isLit ? rawNewValue : parsePropertyValue(rawNewValue, propType);
|
|
3909
3976
|
const internals = component2.manager.internals;
|
|
3910
3977
|
if (newValue === oldValue)
|
|
3911
3978
|
originalSet.call(this, rawNewValue);
|
|
@@ -3949,60 +4016,30 @@ var ComponentInternals = class {
|
|
|
3949
4016
|
var emptyArray = [];
|
|
3950
4017
|
var customAccessor = Symbol("controllersCustomAccessor");
|
|
3951
4018
|
var nothing = Symbol("nothing");
|
|
3952
|
-
var accessorPromise = Promise.all([arcadeDefaults.importCoreAccessor(), arcadeDefaults.importCoreAccessorSupportDecorators()]);
|
|
3953
|
-
function reactiveUtilsIntegration(component) {
|
|
3954
|
-
const members = getPropLikeMembers(component);
|
|
3955
|
-
const internals = component.manager.internals;
|
|
3956
|
-
members.forEach((name) => {
|
|
3957
|
-
internals.accessorGetter[name] = defaultGetterSetter;
|
|
3958
|
-
internals.accessorSetter[name] = defaultGetterSetter;
|
|
3959
|
-
internals.getSetProxy(name, true, true);
|
|
3960
|
-
});
|
|
3961
|
-
return async (enabledMembers = members) => {
|
|
3962
|
-
const [Accessor, { subclass, property }] = await accessorPromise;
|
|
3963
|
-
class AccessorSubclass extends Accessor {
|
|
3964
|
-
}
|
|
3965
|
-
const getter = (_value, propertyName) => accessor[propertyName];
|
|
3966
|
-
function setter(newValue, _oldValue, propertyName) {
|
|
3967
|
-
if (accessor !== void 0)
|
|
3968
|
-
accessor[propertyName] = newValue;
|
|
3969
|
-
return newValue;
|
|
3970
|
-
}
|
|
3971
|
-
component.manager.bypassGetter(
|
|
3972
|
-
() => enabledMembers.forEach((name) => {
|
|
3973
|
-
internals.accessorGetter[name] = getter;
|
|
3974
|
-
internals.accessorSetter[name] = setter;
|
|
3975
|
-
property({
|
|
3976
|
-
value: component[name]
|
|
3977
|
-
})(AccessorSubclass.prototype, name);
|
|
3978
|
-
})
|
|
3979
|
-
);
|
|
3980
|
-
const Subclass = subclass(component.el.tagName)(AccessorSubclass);
|
|
3981
|
-
const accessor = new Subclass();
|
|
3982
|
-
};
|
|
3983
|
-
}
|
|
3984
|
-
var defaultGetterSetter = (value) => value;
|
|
3985
4019
|
|
|
3986
4020
|
// src/ControllerManager.ts
|
|
3987
|
-
var useControllerManager = (component) => new ControllerManager(component);
|
|
4021
|
+
var useControllerManager = (component, forceUpdate) => new ControllerManager(component, forceUpdate);
|
|
3988
4022
|
var ControllerManager = class extends GenericController {
|
|
3989
|
-
constructor(component) {
|
|
4023
|
+
constructor(component, forceUpdate) {
|
|
4024
|
+
const isLit = "addController" in component;
|
|
3990
4025
|
const controllers = /* @__PURE__ */ new Set();
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4026
|
+
function addController(controller) {
|
|
4027
|
+
controllers.add(controller);
|
|
4028
|
+
if (isLit && !(controllerSymbol in controller) && component.el.isConnected)
|
|
4029
|
+
controller.hostConnected?.();
|
|
4030
|
+
}
|
|
4031
|
+
const removeController = (controller) => void controllers.delete(controller);
|
|
4032
|
+
if (!isLit) {
|
|
4033
|
+
const update = forceUpdate ?? component.constructor.__forceUpdate;
|
|
4034
|
+
const controllerHost = {
|
|
4035
|
+
addController,
|
|
4036
|
+
removeController,
|
|
4037
|
+
requestUpdate: () => update(component)
|
|
4038
|
+
};
|
|
4039
|
+
extendObject(component, controllerHost);
|
|
4040
|
+
}
|
|
4001
4041
|
super(component);
|
|
4002
|
-
this._connected = new Deferred();
|
|
4003
4042
|
this.internals = new ComponentInternals(this.component);
|
|
4004
|
-
this.connected = this._connected.promise;
|
|
4005
|
-
this.hasDestroy = false;
|
|
4006
4043
|
this.destroyed = false;
|
|
4007
4044
|
this._updatePromise = new Deferred();
|
|
4008
4045
|
this._originalLifecycles = {};
|
|
@@ -4049,14 +4086,25 @@ var ControllerManager = class extends GenericController {
|
|
|
4049
4086
|
* \@Prop() decorator or not
|
|
4050
4087
|
*/
|
|
4051
4088
|
this.trackKey = this.internals.trackKey;
|
|
4052
|
-
this._readonlySetter = (newValue,
|
|
4089
|
+
this._readonlySetter = (newValue, oldValue, property) => {
|
|
4053
4090
|
if (Controller.internals.shouldBypassReadonly)
|
|
4054
4091
|
return newValue;
|
|
4055
|
-
const
|
|
4056
|
-
|
|
4057
|
-
|
|
4092
|
+
const component = this.component;
|
|
4093
|
+
const isProp = getPropType(component, property) === "prop";
|
|
4094
|
+
if (isProp) {
|
|
4095
|
+
if (this.isLit) {
|
|
4096
|
+
const details = getLitProperties(component).get(property);
|
|
4097
|
+
if (details && details?.attribute !== false)
|
|
4098
|
+
component.el.setAttribute(
|
|
4099
|
+
typeof details.attribute === "string" ? details.attribute : camelToKebab(property),
|
|
4100
|
+
// Not using converter.toAttribute to keep this unlikely case simpler
|
|
4101
|
+
String(oldValue)
|
|
4102
|
+
);
|
|
4103
|
+
} else
|
|
4104
|
+
component.requestUpdate();
|
|
4105
|
+
}
|
|
4058
4106
|
throw new Error(
|
|
4059
|
-
`Cannot assign to read-only property "${property}" of ${
|
|
4107
|
+
`Cannot assign to read-only property "${property}" of ${component.el.tagName.toLowerCase()}. Trying to assign "${String(
|
|
4060
4108
|
newValue
|
|
4061
4109
|
)}"`
|
|
4062
4110
|
);
|
|
@@ -4069,18 +4117,30 @@ var ControllerManager = class extends GenericController {
|
|
|
4069
4117
|
*/
|
|
4070
4118
|
this.devOnlySetPersistentControllerData = void 0 ;
|
|
4071
4119
|
this.devOnlyGetPersistentControllerData = void 0 ;
|
|
4120
|
+
if (isLit) {
|
|
4121
|
+
component.addController = addController;
|
|
4122
|
+
component.removeController = removeController;
|
|
4123
|
+
}
|
|
4124
|
+
this.isLit = isLit;
|
|
4072
4125
|
this.component.manager = this;
|
|
4073
|
-
|
|
4126
|
+
retrieveComponentMembers(component, isLit);
|
|
4074
4127
|
this._controllers = controllers;
|
|
4075
4128
|
this.exports = void 0;
|
|
4076
|
-
this.hasDestroy = "
|
|
4129
|
+
this.hasDestroy = "autoDestroyDisabled" in this.component && typeof this.component.destroy === "function";
|
|
4077
4130
|
if (this.hasDestroy)
|
|
4078
|
-
this.watch("
|
|
4131
|
+
this.watch("autoDestroyDisabled", () => this._autoDestroyDisabledWatcher());
|
|
4079
4132
|
this._bindLifecycleMethods();
|
|
4080
|
-
|
|
4081
|
-
|
|
4133
|
+
if (!isLit)
|
|
4134
|
+
Object.defineProperty(component, "updateComplete", {
|
|
4135
|
+
get: async () => await this._updatePromise.promise
|
|
4136
|
+
});
|
|
4137
|
+
const members = getPropLikeMembers(component);
|
|
4138
|
+
const internals = component.manager.internals;
|
|
4139
|
+
members.forEach((name) => {
|
|
4140
|
+
internals.accessorGetter[name] = defaultGetterSetter;
|
|
4141
|
+
internals.accessorSetter[name] = defaultGetterSetter;
|
|
4142
|
+
internals.getSetProxy(name, true, true);
|
|
4082
4143
|
});
|
|
4083
|
-
this.internals.reactiveUtilsIntegration = reactiveUtilsIntegration(this.component);
|
|
4084
4144
|
Controller.internals.setParentController(void 0);
|
|
4085
4145
|
Controller.internals.setAmbientComponent(component);
|
|
4086
4146
|
Controller.internals.elementToInstance.set(component.el, component);
|
|
@@ -4088,25 +4148,25 @@ var ControllerManager = class extends GenericController {
|
|
|
4088
4148
|
}
|
|
4089
4149
|
_bindLifecycleMethods() {
|
|
4090
4150
|
const component = this.component;
|
|
4151
|
+
const isLit = this.isLit;
|
|
4091
4152
|
this._originalLifecycles = {
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
componentDidUpdate: component.componentDidUpdate,
|
|
4153
|
+
// These callbacks will be called by Lit, so we don't have to
|
|
4154
|
+
connectedCallback: isLit ? void 0 : component.connectedCallback,
|
|
4155
|
+
disconnectedCallback: isLit ? void 0 : component.disconnectedCallback,
|
|
4156
|
+
componentWillLoad: isLit ? void 0 : component.componentWillLoad,
|
|
4157
|
+
componentDidLoad: isLit ? void 0 : component.componentDidLoad,
|
|
4158
|
+
componentWillUpdate: isLit ? void 0 : component.componentWillUpdate,
|
|
4159
|
+
componentDidUpdate: isLit ? void 0 : component.componentDidUpdate,
|
|
4100
4160
|
destroy: component.destroy
|
|
4101
4161
|
};
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4162
|
+
if (!isLit) {
|
|
4163
|
+
component.connectedCallback = this.hostConnected.bind(this);
|
|
4164
|
+
component.disconnectedCallback = this.hostDisconnected.bind(this);
|
|
4165
|
+
component.componentWillLoad = this.hostLoad.bind(this);
|
|
4166
|
+
component.componentDidLoad = this.hostLoaded.bind(this);
|
|
4167
|
+
component.componentWillUpdate = this.hostUpdate.bind(this);
|
|
4168
|
+
component.componentDidUpdate = this.hostUpdated.bind(this);
|
|
4169
|
+
}
|
|
4110
4170
|
if (this.hasDestroy)
|
|
4111
4171
|
component.destroy = this.destroy.bind(this);
|
|
4112
4172
|
}
|
|
@@ -4123,23 +4183,24 @@ var ControllerManager = class extends GenericController {
|
|
|
4123
4183
|
* Instead, _bindLifecycleMethods will take care of that. Otherwise, you risk
|
|
4124
4184
|
* calling lifecycle methods twice.
|
|
4125
4185
|
*/
|
|
4126
|
-
|
|
4186
|
+
hostConnected() {
|
|
4127
4187
|
if (this.destroyed) {
|
|
4128
4188
|
const tagName = this.component.el.tagName.toLowerCase();
|
|
4129
4189
|
this.component.el.remove();
|
|
4130
4190
|
throw new Error(
|
|
4131
|
-
`The ${tagName} component has already been destroyed. It can not be used again. If you meant to disconnect and reconnect a component without automatic destroy, set the
|
|
4191
|
+
`The ${tagName} component has already been destroyed. It can not be used again. If you meant to disconnect and reconnect a component without automatic destroy, set the autoDestroyDisabled prop.`
|
|
4132
4192
|
);
|
|
4133
4193
|
}
|
|
4194
|
+
if (this._autoDestroyTimeout !== void 0)
|
|
4195
|
+
clearTimeout(this._autoDestroyTimeout);
|
|
4134
4196
|
this.internals.enabledWatchers = this.internals.allWatchers;
|
|
4135
4197
|
keyTrackResolve();
|
|
4136
|
-
this._connected.resolve();
|
|
4137
4198
|
this._controllers.forEach(
|
|
4138
4199
|
(controller) => "triggerConnected" in controller ? controller.triggerConnected() : safeCall(() => controller.hostConnected?.())
|
|
4139
4200
|
);
|
|
4140
4201
|
this._originalLifecycles.connectedCallback?.call(this.component);
|
|
4141
4202
|
}
|
|
4142
|
-
|
|
4203
|
+
hostDisconnected() {
|
|
4143
4204
|
if (this.destroyed)
|
|
4144
4205
|
return;
|
|
4145
4206
|
this._controllers.forEach(
|
|
@@ -4147,10 +4208,12 @@ var ControllerManager = class extends GenericController {
|
|
|
4147
4208
|
);
|
|
4148
4209
|
this._originalLifecycles.disconnectedCallback?.call(this.component);
|
|
4149
4210
|
if (this.hasDestroy)
|
|
4150
|
-
this.
|
|
4211
|
+
this._autoDestroyDisabledWatcher();
|
|
4151
4212
|
}
|
|
4152
|
-
async
|
|
4153
|
-
|
|
4213
|
+
// REFACTOR: don't force async if there are no async load controllers?
|
|
4214
|
+
async hostLoad() {
|
|
4215
|
+
if (typeof this.internals.reactiveUtilsIntegration === "function")
|
|
4216
|
+
await this.internals.reactiveUtilsIntegration();
|
|
4154
4217
|
await Promise.allSettled(
|
|
4155
4218
|
Array.from(
|
|
4156
4219
|
this._controllers,
|
|
@@ -4159,44 +4222,28 @@ var ControllerManager = class extends GenericController {
|
|
|
4159
4222
|
);
|
|
4160
4223
|
await this._originalLifecycles.componentWillLoad?.call(this.component);
|
|
4161
4224
|
}
|
|
4162
|
-
|
|
4225
|
+
hostLoaded() {
|
|
4163
4226
|
this._controllers.forEach(
|
|
4164
4227
|
(controller) => "triggerLoaded" in controller ? controller.triggerLoaded() : safeCall(() => controller.hostLoaded?.())
|
|
4165
4228
|
);
|
|
4166
4229
|
this._originalLifecycles.componentDidLoad?.call(this.component);
|
|
4167
4230
|
}
|
|
4168
|
-
|
|
4169
|
-
await Promise.allSettled(
|
|
4170
|
-
Array.from(
|
|
4171
|
-
this._controllers,
|
|
4172
|
-
async (controller) => "triggerRender" in controller ? await controller.triggerRender() : await safeAsyncCall(async () => await controller.hostRender?.())
|
|
4173
|
-
)
|
|
4174
|
-
);
|
|
4175
|
-
await this._originalLifecycles.componentWillRender?.call(this.component);
|
|
4176
|
-
}
|
|
4177
|
-
_componentDidRender() {
|
|
4231
|
+
hostUpdate() {
|
|
4178
4232
|
this._controllers.forEach(
|
|
4179
|
-
(controller) => "
|
|
4180
|
-
);
|
|
4181
|
-
this._originalLifecycles.componentDidRender?.call(this.component);
|
|
4182
|
-
}
|
|
4183
|
-
async _componentWillUpdate() {
|
|
4184
|
-
await Promise.allSettled(
|
|
4185
|
-
Array.from(
|
|
4186
|
-
this._controllers,
|
|
4187
|
-
async (controller) => "triggerUpdate" in controller ? await controller.triggerUpdate() : await safeAsyncCall(async () => await controller.hostUpdate?.())
|
|
4188
|
-
)
|
|
4233
|
+
(controller) => "triggerUpdate" in controller ? controller.triggerUpdate() : safeCall(() => controller.hostUpdate?.())
|
|
4189
4234
|
);
|
|
4190
|
-
|
|
4235
|
+
void this._originalLifecycles.componentWillUpdate?.call(this.component);
|
|
4191
4236
|
}
|
|
4192
|
-
|
|
4237
|
+
hostUpdated() {
|
|
4193
4238
|
this._controllers.forEach(
|
|
4194
4239
|
(controller) => "triggerUpdated" in controller ? controller.triggerUpdated() : safeCall(() => controller.hostUpdated?.())
|
|
4195
4240
|
);
|
|
4196
4241
|
this._originalLifecycles.componentDidUpdate?.call(this.component);
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4242
|
+
if (!this.isLit) {
|
|
4243
|
+
const updatePromise = this._updatePromise;
|
|
4244
|
+
this._updatePromise = new Deferred();
|
|
4245
|
+
updatePromise.resolve(true);
|
|
4246
|
+
}
|
|
4200
4247
|
}
|
|
4201
4248
|
async destroy() {
|
|
4202
4249
|
this.ensureHasDestroy();
|
|
@@ -4204,19 +4251,28 @@ var ControllerManager = class extends GenericController {
|
|
|
4204
4251
|
return;
|
|
4205
4252
|
if (this.component.el.isConnected) {
|
|
4206
4253
|
this.hasDestroy = false;
|
|
4207
|
-
|
|
4208
|
-
|
|
4254
|
+
try {
|
|
4255
|
+
this.component.el.remove();
|
|
4256
|
+
} finally {
|
|
4257
|
+
this.hasDestroy = true;
|
|
4258
|
+
}
|
|
4209
4259
|
}
|
|
4260
|
+
this._autoDestroyTimeout = void 0;
|
|
4210
4261
|
this.destroyed = true;
|
|
4211
4262
|
this._controllers.forEach(
|
|
4212
4263
|
(controller) => "triggerDestroy" in controller ? controller.triggerDestroy() : safeCall(() => controller.hostDestroy?.())
|
|
4213
4264
|
);
|
|
4214
4265
|
await this._originalLifecycles.destroy?.call(this.component);
|
|
4215
4266
|
}
|
|
4216
|
-
|
|
4217
|
-
if (!this.component.el.isConnected && !this.component.
|
|
4218
|
-
|
|
4267
|
+
_autoDestroyDisabledWatcher() {
|
|
4268
|
+
if (!this.component.el.isConnected && !this.component.autoDestroyDisabled) {
|
|
4269
|
+
if (this._autoDestroyTimeout !== void 0)
|
|
4270
|
+
clearTimeout(this._autoDestroyTimeout);
|
|
4271
|
+
const destroy = () => void this.destroy().catch(console.error);
|
|
4272
|
+
this._autoDestroyTimeout = setTimeout(destroy, autoDestroyOnDisconnectTimeout);
|
|
4273
|
+
}
|
|
4219
4274
|
}
|
|
4275
|
+
// REFACTOR: replace this with a readonly:true option in @property()
|
|
4220
4276
|
/**
|
|
4221
4277
|
* Make a @Prop() or @State() readonly (prevent overwriting default value).
|
|
4222
4278
|
*
|
|
@@ -4236,6 +4292,7 @@ var ControllerManager = class extends GenericController {
|
|
|
4236
4292
|
readonly(value) {
|
|
4237
4293
|
return this.getSet(value, { set: this._readonlySetter });
|
|
4238
4294
|
}
|
|
4295
|
+
// REFACTOR: remove this in Lit in favor of native get/set
|
|
4239
4296
|
/**
|
|
4240
4297
|
* Listen for any component's @State()/@Prop() change, and mutate it's
|
|
4241
4298
|
* value before it is set.
|
|
@@ -4262,13 +4319,13 @@ var ControllerManager = class extends GenericController {
|
|
|
4262
4319
|
*/
|
|
4263
4320
|
getSet(defaultValue, getSet) {
|
|
4264
4321
|
return this.component.manager.trackPropKey((name) => {
|
|
4265
|
-
var
|
|
4322
|
+
var _a;
|
|
4266
4323
|
if (name === void 0)
|
|
4267
4324
|
throw new Error(
|
|
4268
4325
|
"Unable to resolve get/set's prop name. Make sure you are using it like @Prop() someProp = this.manager.getSet(defaultValue,{get,set})"
|
|
4269
4326
|
);
|
|
4270
4327
|
if (getSet.set === this._readonlySetter) {
|
|
4271
|
-
(
|
|
4328
|
+
(_a = this.internals).readonlyProps ?? (_a.readonlyProps = /* @__PURE__ */ new Set());
|
|
4272
4329
|
this.internals.readonlyProps.add(name);
|
|
4273
4330
|
}
|
|
4274
4331
|
const genericComponent = this.component;
|
|
@@ -4286,93 +4343,19 @@ var destroyErrorMessage = `
|
|
|
4286
4343
|
If the component uses a controller that uses destroy() method, then the
|
|
4287
4344
|
component must have the following properties:
|
|
4288
4345
|
${// Don't expose internal code in production, and keep bundle smaller:
|
|
4289
|
-
`
|
|
4346
|
+
`autoDestroyDisabled and destroy` }
|
|
4290
4347
|
`.trim();
|
|
4348
|
+
var autoDestroyOnDisconnectTimeout = 1e3;
|
|
4349
|
+
var defaultGetterSetter = (value) => value;
|
|
4291
4350
|
|
|
4292
|
-
// src/
|
|
4293
|
-
var
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
const initialExports = instance.exports;
|
|
4297
|
-
Controller.internals.setParentController(ambientControllers.at(-1));
|
|
4298
|
-
const internals = instance.component.manager.internals;
|
|
4299
|
-
internals.markExports(instance, initialExports);
|
|
4300
|
-
instance.watchExports((exports) => internals.markExports(instance, exports));
|
|
4301
|
-
Controller.internals.setAmbientChildController(instance);
|
|
4302
|
-
const hostCandidates = [instance.component, ...ambientControllers].reverse();
|
|
4303
|
-
return internals.trackKey(
|
|
4304
|
-
hostCandidates,
|
|
4305
|
-
(resolution) => resolution === void 0 ? void 0 : setProxy(instance, resolution.host, resolution.key, initialExports),
|
|
4306
|
-
initialExports
|
|
4307
|
-
);
|
|
4308
|
-
};
|
|
4309
|
-
function setProxy(controller, host, key, initialExports) {
|
|
4310
|
-
const genericHost = host;
|
|
4311
|
-
const controllerValueChanged = genericHost[key] !== controller.exports;
|
|
4312
|
-
const hostValueChanged = genericHost[key] !== initialExports;
|
|
4313
|
-
const controllerUpdatedExports = initialExports !== controller.exports;
|
|
4314
|
-
if (controllerValueChanged && !hostValueChanged && controllerUpdatedExports)
|
|
4315
|
-
genericHost[key] = controller.exports;
|
|
4316
|
-
controller.watchExports(() => {
|
|
4317
|
-
if (genericHost[key] === controller.exports)
|
|
4318
|
-
return;
|
|
4319
|
-
const manager = controller.component.manager;
|
|
4320
|
-
const isReadOnly = manager.internals.readonlyProps?.has(key) === true;
|
|
4321
|
-
if (isReadOnly)
|
|
4322
|
-
manager.bypassReadonly(() => {
|
|
4323
|
-
genericHost[key] = controller.exports;
|
|
4324
|
-
});
|
|
4325
|
-
else
|
|
4326
|
-
genericHost[key] = controller.exports;
|
|
4327
|
-
});
|
|
4328
|
-
}
|
|
4329
|
-
|
|
4330
|
-
// src/functional.ts
|
|
4331
|
-
var makeController = (constructor) => proxy(void 0, constructor);
|
|
4332
|
-
var FunctionalController = class extends Controller {
|
|
4333
|
-
constructor(component, constructor) {
|
|
4334
|
-
super(component);
|
|
4335
|
-
const originalExports = this.exports;
|
|
4336
|
-
try {
|
|
4337
|
-
Controller.internals.setAmbientComponent(this.component);
|
|
4338
|
-
const value = constructor(this.component, this);
|
|
4339
|
-
const constructorChangedExports = this.exports !== originalExports;
|
|
4340
|
-
if (value instanceof Promise) {
|
|
4341
|
-
if (!constructorChangedExports)
|
|
4342
|
-
this.setProvisionalExports(value);
|
|
4343
|
-
const resolved = value.then((result) => {
|
|
4344
|
-
this.exports = result;
|
|
4345
|
-
super.catchUpLifecycle();
|
|
4346
|
-
}).catch((error) => {
|
|
4347
|
-
this._ready.reject(error);
|
|
4348
|
-
console.error(error);
|
|
4349
|
-
});
|
|
4350
|
-
this.onLoad(async () => await resolved);
|
|
4351
|
-
} else {
|
|
4352
|
-
if (!constructorChangedExports || value !== void 0)
|
|
4353
|
-
this.exports = value;
|
|
4354
|
-
queueMicrotask(() => super.catchUpLifecycle());
|
|
4355
|
-
}
|
|
4356
|
-
} catch (error) {
|
|
4357
|
-
this._ready.reject(error);
|
|
4358
|
-
console.error(error);
|
|
4359
|
-
}
|
|
4360
|
-
}
|
|
4361
|
-
/** Noop - will be called in the constructor instead */
|
|
4362
|
-
catchUpLifecycle() {
|
|
4363
|
-
return;
|
|
4364
|
-
}
|
|
4365
|
-
};
|
|
4366
|
-
var proxy = proxyExports(FunctionalController);
|
|
4367
|
-
function useT9n({
|
|
4368
|
-
blocking = false,
|
|
4369
|
-
name
|
|
4370
|
-
} = {}) {
|
|
4371
|
-
return makeController((component, controller) => {
|
|
4351
|
+
// src/useT9n.ts
|
|
4352
|
+
var makeT9nController = (getAssetPath) => ({ blocking = false, name } = {}) => (
|
|
4353
|
+
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
4354
|
+
makeController((component, controller) => {
|
|
4372
4355
|
controller.onLifecycle(
|
|
4373
4356
|
() => startLocaleObserver(
|
|
4374
4357
|
component.el,
|
|
4375
|
-
|
|
4358
|
+
getAssetPath("./assets"),
|
|
4376
4359
|
({ t9nLocale, t9nStrings, lang }) => {
|
|
4377
4360
|
controller.exports = { ...t9nStrings, _lang: lang, _t9nLocale: t9nLocale };
|
|
4378
4361
|
const label = t9nStrings.componentLabel ?? t9nStrings.widgetLabel;
|
|
@@ -4386,8 +4369,8 @@ function useT9n({
|
|
|
4386
4369
|
return controller.ready;
|
|
4387
4370
|
const locale = getElementLocales(component.el);
|
|
4388
4371
|
return { _lang: locale.lang, _t9nLocale: locale.t9nLocale };
|
|
4389
|
-
})
|
|
4390
|
-
|
|
4372
|
+
})
|
|
4373
|
+
);
|
|
4391
4374
|
|
|
4392
4375
|
function isMonacoEnvironmentSetup() {
|
|
4393
4376
|
return !!window.MonacoEnvironment?.getWorkerUrl;
|
|
@@ -4536,7 +4519,7 @@ async function getArcadeWorker(uri) {
|
|
|
4536
4519
|
* @returns arcade mode module
|
|
4537
4520
|
*/
|
|
4538
4521
|
async function getMode() {
|
|
4539
|
-
return await Promise.resolve().then(function () { return require('./arcade-mode-
|
|
4522
|
+
return await Promise.resolve().then(function () { return require('./arcade-mode-fac05e67.js'); });
|
|
4540
4523
|
}
|
|
4541
4524
|
// Register the language in Monaco
|
|
4542
4525
|
arcadeDefaults.languages.register({
|
|
@@ -4559,6 +4542,8 @@ arcadeDefaults.languages.onLanguage(arcadeDefaults.arcadeDefaults.languageId, ()
|
|
|
4559
4542
|
});
|
|
4560
4543
|
});
|
|
4561
4544
|
|
|
4545
|
+
const useT9n = makeT9nController(index.getAssetPath);
|
|
4546
|
+
|
|
4562
4547
|
const arcadeApiCss = ":host{background-color:var(--calcite-color-foreground-1)}:host .notice-container{margin:var(--calcite-spacing-xxs);padding:var(--calcite-spacing-sm);background-color:var(--calcite-color-foreground-1)}:host .sticky{position:sticky;top:0px;z-index:10}:host calcite-flow{height:100%}:host calcite-block p:first-of-type{margin-top:0}:host calcite-block code{font-family:var(--calcite-code-family)}:host calcite-block pre{direction:ltr;overflow-x:auto;background-color:var(--calcite-color-foreground-2);padding:var(--calcite-spacing-sm)}:host calcite-block pre code{font-size:var(--calcite-font-size--2)}";
|
|
4563
4548
|
|
|
4564
4549
|
const ArcgisArcadeApi = class {
|
|
@@ -4981,8 +4966,9 @@ const ArcgisArcadeEditor = class {
|
|
|
4981
4966
|
}
|
|
4982
4967
|
};
|
|
4983
4968
|
this._openArcadeHelp = () => void window.open(DevelopersWebSitePath, "Arcade Help");
|
|
4984
|
-
this.
|
|
4969
|
+
this._onCodeEditorValueChange = (e) => {
|
|
4985
4970
|
e.stopPropagation();
|
|
4971
|
+
this.script = e.detail;
|
|
4986
4972
|
this.arcgisScriptChange.emit(e.detail);
|
|
4987
4973
|
};
|
|
4988
4974
|
this._insertAsSnippet = (e) => void this._codeEditorElt?.insertSnippet(e.detail).catch(console.error);
|
|
@@ -5008,6 +4994,10 @@ const ArcgisArcadeEditor = class {
|
|
|
5008
4994
|
this.sideActionBarExpanded = false;
|
|
5009
4995
|
this.openedSidePanel = "none";
|
|
5010
4996
|
this.editorOptions = undefined;
|
|
4997
|
+
this.editorInstance = this.manager.getSet(undefined, {
|
|
4998
|
+
get: () => this._codeEditorElt?.editorInstance,
|
|
4999
|
+
set: (_value, prevValue) => prevValue,
|
|
5000
|
+
});
|
|
5011
5001
|
}
|
|
5012
5002
|
_profileChanged() {
|
|
5013
5003
|
this._updateEditorProfile().catch(console.error);
|
|
@@ -5026,12 +5016,11 @@ const ArcgisArcadeEditor = class {
|
|
|
5026
5016
|
// #endregion
|
|
5027
5017
|
// #region Public methods API
|
|
5028
5018
|
/**
|
|
5029
|
-
*
|
|
5030
|
-
* @returns {Promise<string>}
|
|
5019
|
+
* @deprecated Use `script` property instead.
|
|
5031
5020
|
*/
|
|
5032
5021
|
async getScript() {
|
|
5033
5022
|
await this._componentReadyDefer.promise;
|
|
5034
|
-
return
|
|
5023
|
+
return this._codeEditorElt?.value;
|
|
5035
5024
|
}
|
|
5036
5025
|
/**
|
|
5037
5026
|
* Set the focus on the element.
|
|
@@ -5042,12 +5031,11 @@ const ArcgisArcadeEditor = class {
|
|
|
5042
5031
|
}
|
|
5043
5032
|
/**
|
|
5044
5033
|
* @internal
|
|
5045
|
-
*
|
|
5046
|
-
* @returns {Promise<IStandaloneCodeEditor>} - The monaco editor instance
|
|
5034
|
+
* @deprecated Use `editorInstance` property instead.
|
|
5047
5035
|
*/
|
|
5048
5036
|
async getEditorInstance() {
|
|
5049
5037
|
await this._componentReadyDefer.promise;
|
|
5050
|
-
return
|
|
5038
|
+
return this._codeEditorElt?.editorInstance;
|
|
5051
5039
|
}
|
|
5052
5040
|
/**
|
|
5053
5041
|
* Returns the Arcade result for the script for the provided test data.
|
|
@@ -5166,7 +5154,7 @@ const ArcgisArcadeEditor = class {
|
|
|
5166
5154
|
//#endregion
|
|
5167
5155
|
//#region Render Main Panel
|
|
5168
5156
|
renderMainPanel() {
|
|
5169
|
-
return (index.h("arcgis-code-editor", { class: "flex-adjustable", language: arcadeDefaults.arcadeDefaults.languageId, value: this.script ?? "", modelId: this._modelId, options: this.editorOptions, onArcgisValueChange: this.
|
|
5157
|
+
return (index.h("arcgis-code-editor", { class: "flex-adjustable", language: arcadeDefaults.arcadeDefaults.languageId, value: this.script ?? "", modelId: this._modelId, options: this.editorOptions, onArcgisValueChange: this._onCodeEditorValueChange, ref: (e) => (this._codeEditorElt = e) }));
|
|
5170
5158
|
}
|
|
5171
5159
|
//#endregion
|
|
5172
5160
|
//#region Rendering the Action Bar
|
|
@@ -5538,11 +5526,11 @@ const ArcgisArcadeSuggestions = class {
|
|
|
5538
5526
|
// #region Component lifecycle events
|
|
5539
5527
|
async componentWillLoad() {
|
|
5540
5528
|
this._colorizeStyle = generateColorizeStyles();
|
|
5541
|
-
this.
|
|
5529
|
+
this._themeChangedListener = onColorizeThemeChanged(() => (this._colorizeStyle = generateColorizeStyles()));
|
|
5542
5530
|
}
|
|
5543
5531
|
disconnectedCallback() {
|
|
5544
5532
|
this._flowObserver?.disconnect();
|
|
5545
|
-
this.
|
|
5533
|
+
this._themeChangedListener?.dispose();
|
|
5546
5534
|
}
|
|
5547
5535
|
// #endregion
|
|
5548
5536
|
//#region Private Methods
|
|
@@ -5767,65 +5755,66 @@ const ArcgisCodeEditor = class {
|
|
|
5767
5755
|
index.registerInstance(this, hostRef);
|
|
5768
5756
|
this.arcgisValueChange = index.createEvent(this, "arcgisValueChange", 3);
|
|
5769
5757
|
this.arcgisSelectionChange = index.createEvent(this, "arcgisSelectionChange", 3);
|
|
5758
|
+
this.manager = useControllerManager(this);
|
|
5770
5759
|
this._componentReadyDefer = new arcadeDefaults.Deferred();
|
|
5771
5760
|
this._disposables = [];
|
|
5772
|
-
this.value =
|
|
5761
|
+
this.value = this.manager.getSet("", {
|
|
5762
|
+
get: () => this._editorInstance?.getValue() ?? "",
|
|
5763
|
+
set: (newValue, oldValue) => {
|
|
5764
|
+
if (!this._editorInstance) {
|
|
5765
|
+
return "";
|
|
5766
|
+
}
|
|
5767
|
+
const model = this._editorInstance.getModel();
|
|
5768
|
+
if (!model) {
|
|
5769
|
+
return "";
|
|
5770
|
+
}
|
|
5771
|
+
if (model.getValue() === newValue) {
|
|
5772
|
+
return newValue;
|
|
5773
|
+
}
|
|
5774
|
+
// Set the value and preserve the undo stack
|
|
5775
|
+
const range = model.getFullModelRange();
|
|
5776
|
+
this._editorInstance.executeEdits("", [{ range, text: newValue ?? "", forceMoveMarkers: true }]);
|
|
5777
|
+
this._editorInstance.pushUndoStop();
|
|
5778
|
+
// By returning oldValue we are preventing a re-render.
|
|
5779
|
+
// The getter will return the new value anyway.
|
|
5780
|
+
return oldValue;
|
|
5781
|
+
},
|
|
5782
|
+
});
|
|
5773
5783
|
this.language = undefined;
|
|
5774
5784
|
this.modelId = arcadeDefaults.generateGuid();
|
|
5775
5785
|
this.options = undefined;
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
|
|
5779
|
-
|
|
5780
|
-
}
|
|
5781
|
-
this._editorInstance.setValue(newValue ?? "");
|
|
5786
|
+
this.editorInstance = this.manager.getSet(undefined, {
|
|
5787
|
+
get: () => this._editorInstance,
|
|
5788
|
+
set: (_value, prevValue) => prevValue,
|
|
5789
|
+
});
|
|
5782
5790
|
}
|
|
5783
5791
|
languagePropChange() {
|
|
5784
|
-
if (!this._editorInstance) {
|
|
5785
|
-
return;
|
|
5786
|
-
}
|
|
5787
5792
|
this.updateModel();
|
|
5788
5793
|
}
|
|
5789
5794
|
modelIdPropChange() {
|
|
5790
|
-
if (!this._editorInstance) {
|
|
5791
|
-
return;
|
|
5792
|
-
}
|
|
5793
5795
|
this.updateModel();
|
|
5794
5796
|
}
|
|
5795
5797
|
optionsPropChange(newValue) {
|
|
5796
|
-
if (!
|
|
5798
|
+
if (!newValue) {
|
|
5797
5799
|
return;
|
|
5798
5800
|
}
|
|
5799
|
-
this._editorInstance
|
|
5801
|
+
this._editorInstance?.updateOptions(newValue);
|
|
5800
5802
|
}
|
|
5801
5803
|
//#endregion
|
|
5802
5804
|
// #region Public methods API
|
|
5803
5805
|
/**
|
|
5804
|
-
*
|
|
5805
|
-
* @returns {Promise<string>}
|
|
5806
|
+
* @deprecated Use `value` property instead.
|
|
5806
5807
|
*/
|
|
5807
5808
|
async getValue() {
|
|
5808
5809
|
await this._componentReadyDefer.promise;
|
|
5809
|
-
return this.
|
|
5810
|
+
return this.value;
|
|
5810
5811
|
}
|
|
5811
5812
|
/**
|
|
5812
|
-
*
|
|
5813
|
-
* on the model to preserve undo/redo stack.
|
|
5814
|
-
* @param text
|
|
5815
|
-
* @returns {Promise<void>}
|
|
5813
|
+
* @deprecated Use `value` property instead.
|
|
5816
5814
|
*/
|
|
5817
5815
|
async setValue(text) {
|
|
5818
5816
|
await this._componentReadyDefer.promise;
|
|
5819
|
-
|
|
5820
|
-
return;
|
|
5821
|
-
}
|
|
5822
|
-
const model = this._editorInstance.getModel();
|
|
5823
|
-
if (!model) {
|
|
5824
|
-
return;
|
|
5825
|
-
}
|
|
5826
|
-
const range = model.getFullModelRange();
|
|
5827
|
-
this._editorInstance.executeEdits("", [{ range, text: text ?? "", forceMoveMarkers: true }]);
|
|
5828
|
-
this._editorInstance.pushUndoStop();
|
|
5817
|
+
this.value = text ?? "";
|
|
5829
5818
|
}
|
|
5830
5819
|
/**
|
|
5831
5820
|
* Inserts a text at the current position in the editor.
|
|
@@ -5860,8 +5849,7 @@ const ArcgisCodeEditor = class {
|
|
|
5860
5849
|
}
|
|
5861
5850
|
/**
|
|
5862
5851
|
* @internal
|
|
5863
|
-
*
|
|
5864
|
-
* @returns {Promise<IStandaloneCodeEditor>} - The monaco editor instance
|
|
5852
|
+
* @deprecated Use `editorInstance` property instead.
|
|
5865
5853
|
*/
|
|
5866
5854
|
async getEditorInstance() {
|
|
5867
5855
|
await this._componentReadyDefer.promise;
|
|
@@ -5895,7 +5883,7 @@ const ArcgisCodeEditor = class {
|
|
|
5895
5883
|
const model = arcadeDefaults.editor.createModel("", this.language, this.getUri());
|
|
5896
5884
|
// Create the editor for the host element.
|
|
5897
5885
|
// This will not trigger a diagnostic.
|
|
5898
|
-
this._editorInstance = arcadeDefaults.editor.create(this.
|
|
5886
|
+
this._editorInstance = arcadeDefaults.editor.create(this.el, {
|
|
5899
5887
|
...(this.options ?? {}),
|
|
5900
5888
|
model,
|
|
5901
5889
|
fixedOverflowWidgets: true,
|
|
@@ -5908,19 +5896,19 @@ const ArcgisCodeEditor = class {
|
|
|
5908
5896
|
this._componentReadyDefer.resolve();
|
|
5909
5897
|
this._editorInstance.updateOptions(EditorOptionsDefaults);
|
|
5910
5898
|
this._editorInstance.onDidChangeModelContent(() => {
|
|
5911
|
-
|
|
5912
|
-
this.arcgisValueChange.emit(
|
|
5899
|
+
this.value = this._editorInstance?.getValue() ?? "";
|
|
5900
|
+
this.arcgisValueChange.emit(this.value);
|
|
5913
5901
|
});
|
|
5914
5902
|
this._editorInstance.onDidChangeCursorSelection((e) => {
|
|
5915
5903
|
this.arcgisSelectionChange.emit({ selection: e.selection, model: this._editorInstance?.getModel() });
|
|
5916
5904
|
});
|
|
5917
5905
|
// Detect if the host element or its ancestors got a theme attribute mutation
|
|
5918
|
-
this._themeObserver = arcadeDefaults.observeAncestorsMutation(this.
|
|
5906
|
+
this._themeObserver = arcadeDefaults.observeAncestorsMutation(this.el, ["class"], () => this.updateTheme());
|
|
5919
5907
|
// Update the theme of the Monaco Editor
|
|
5920
5908
|
this.updateTheme();
|
|
5921
5909
|
// Creates a resize observer to re-layout the editor on size changing
|
|
5922
5910
|
const resizeObserver = new ResizeObserver(() => this._editorInstance?.layout());
|
|
5923
|
-
resizeObserver.observe(this.
|
|
5911
|
+
resizeObserver.observe(this.el);
|
|
5924
5912
|
// Add common actions to the Monaco Editor's context menu and command palette
|
|
5925
5913
|
this.addCommonEditorActions();
|
|
5926
5914
|
}
|
|
@@ -5930,6 +5918,13 @@ const ArcgisCodeEditor = class {
|
|
|
5930
5918
|
}
|
|
5931
5919
|
this._themeObserver?.remove();
|
|
5932
5920
|
}
|
|
5921
|
+
componentShouldUpdate(_newVal, _oldVal, propName) {
|
|
5922
|
+
if (propName === "value" || propName === "language" || propName === "modelId" || propName === "options") {
|
|
5923
|
+
// These are properties that we directly pass to the editor
|
|
5924
|
+
return false;
|
|
5925
|
+
}
|
|
5926
|
+
return true;
|
|
5927
|
+
}
|
|
5933
5928
|
//#endregion
|
|
5934
5929
|
// #region Private methods API
|
|
5935
5930
|
updateModel() {
|
|
@@ -5937,7 +5932,7 @@ const ArcgisCodeEditor = class {
|
|
|
5937
5932
|
return;
|
|
5938
5933
|
}
|
|
5939
5934
|
this._editorInstance.getModel()?.dispose();
|
|
5940
|
-
this._editorInstance.setModel(arcadeDefaults.editor.createModel(this.value
|
|
5935
|
+
this._editorInstance.setModel(arcadeDefaults.editor.createModel(this.value, this.language, this.getUri()));
|
|
5941
5936
|
}
|
|
5942
5937
|
getUri() {
|
|
5943
5938
|
return this.modelId ? arcadeDefaults.Uri.parse(this.modelId) : arcadeDefaults.Uri.parse("");
|
|
@@ -5946,7 +5941,7 @@ const ArcgisCodeEditor = class {
|
|
|
5946
5941
|
// This is called the first time and subsequently by the Mutation Observer
|
|
5947
5942
|
// Figure out the theme by walking the ancestor path.
|
|
5948
5943
|
// If no theme is found then default to light.
|
|
5949
|
-
const theme = arcadeDefaults.getElementTheme(this.
|
|
5944
|
+
const theme = arcadeDefaults.getElementTheme(this.el) === "light" ? "vs" : "vs-dark";
|
|
5950
5945
|
if (theme === this._currentTheme) {
|
|
5951
5946
|
return;
|
|
5952
5947
|
}
|
|
@@ -5988,9 +5983,8 @@ const ArcgisCodeEditor = class {
|
|
|
5988
5983
|
return index.h(index.Host, null);
|
|
5989
5984
|
}
|
|
5990
5985
|
static get assetsDirs() { return ["assets"]; }
|
|
5991
|
-
get
|
|
5986
|
+
get el() { return index.getElement(this); }
|
|
5992
5987
|
static get watchers() { return {
|
|
5993
|
-
"value": ["valuePropChange"],
|
|
5994
5988
|
"language": ["languagePropChange"],
|
|
5995
5989
|
"modelId": ["modelIdPropChange"],
|
|
5996
5990
|
"options": ["optionsPropChange"]
|