@arcgis/coding-components 4.30.0-next.47 → 4.30.0-next.49
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-833b0216.js → p-00583f5a.js} +2 -2
- package/dist/arcgis-coding-components/{p-4fd5a02d.js → p-384b88cc.js} +3 -3
- package/dist/arcgis-coding-components/{p-a0704d86.js → p-523db1e4.js} +10 -10
- package/dist/arcgis-coding-components/{p-a412be74.js → p-59f2dedc.js} +2 -2
- package/dist/arcgis-coding-components/{p-1a627096.js → p-82321ce1.js} +3 -3
- package/dist/arcgis-coding-components/{p-6fd22ff7.js → p-82c4966b.js} +3 -3
- package/dist/arcgis-coding-components/{p-621187ef.js → p-8d013f83.js} +2 -2
- package/dist/arcgis-coding-components/{p-0fee5174.js → p-9054397c.js} +3 -3
- package/dist/arcgis-coding-components/p-905b1583.js +7 -0
- package/dist/arcgis-coding-components/{p-29207f1e.js → p-9859037c.js} +1 -1
- package/dist/arcgis-coding-components/{p-ab7e89c0.js → p-d32ebf93.js} +2 -2
- package/dist/arcgis-coding-components/p-fe90777a.entry.js +6 -0
- package/dist/cjs/{arcade-defaults-4e0664fb.js → arcade-defaults-c09aa6ca.js} +10 -26
- package/dist/cjs/{arcade-mode-61a07430.js → arcade-mode-f43455a9.js} +3 -3
- package/dist/cjs/arcgis-arcade-api_6.cjs.entry.js +257 -283
- package/dist/cjs/arcgis-coding-components.cjs.js +2 -2
- package/dist/cjs/{css-fac19960.js → css-d565ba31.js} +1 -1
- package/dist/cjs/{cssMode-22d917f0.js → cssMode-0c9ea16a.js} +3 -3
- package/dist/cjs/{html-5bc24648.js → html-bbac75a5.js} +3 -3
- package/dist/cjs/{htmlMode-f09628e1.js → htmlMode-275dad7c.js} +3 -3
- package/dist/cjs/{index-02749111.js → index-97b5c264.js} +2 -9
- package/dist/cjs/index.cjs.js +3 -3
- package/dist/cjs/{javascript-29521fd3.js → javascript-3bc3e94b.js} +4 -4
- package/dist/cjs/{jsonMode-99606370.js → jsonMode-358b250b.js} +3 -3
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/{tsMode-e34432d7.js → tsMode-10794c88.js} +3 -3
- package/dist/cjs/{typescript-8ce06335.js → typescript-a3afcaae.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 +6 -5
- 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-36QZLGG2.js → chunk-27DTPISK.js} +250 -282
- package/dist/components/code-editor.js +5 -5
- 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-fdba0972.js → arcade-defaults-0903c8e4.js} +11 -25
- package/dist/esm/{arcade-mode-0d144d92.js → arcade-mode-6bc35b9a.js} +3 -3
- package/dist/esm/arcgis-arcade-api_6.entry.js +256 -282
- package/dist/esm/arcgis-coding-components.js +3 -3
- package/dist/esm/{css-58b4c966.js → css-549e7ecd.js} +1 -1
- package/dist/esm/{cssMode-f5916932.js → cssMode-63059930.js} +3 -3
- package/dist/esm/{html-7c8fbcc5.js → html-03b9ab7d.js} +3 -3
- package/dist/esm/{htmlMode-d7755346.js → htmlMode-ae2b0579.js} +3 -3
- package/dist/esm/{index-c6b28dae.js → index-88cb51ca.js} +3 -9
- package/dist/esm/index.js +3 -3
- package/dist/esm/{javascript-9ac36865.js → javascript-df9e60b6.js} +4 -4
- package/dist/esm/{jsonMode-ef328849.js → jsonMode-e0f3f4e6.js} +3 -3
- package/dist/esm/loader.js +3 -3
- package/dist/esm/{tsMode-0daf7dc9.js → tsMode-4477deb0.js} +3 -3
- package/dist/esm/{typescript-a34ba038.js → typescript-4ca85521.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-suggestions/arcade-suggestions.d.ts +1 -1
- 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-2b6dab4b.entry.js +0 -6
- package/dist/arcgis-coding-components/p-d5df8d73.js +0 -7
|
@@ -1,23 +1,32 @@
|
|
|
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.49
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"Failed to retrieve internal component meta. Make sure you have the useComponentsControllers() Rollup Plugin for Stencil Controllers configured in your Stencil config."
|
|
6
|
+
// src/framework.ts
|
|
7
|
+
function retrieveComponentMembers(component, isLit) {
|
|
8
|
+
if (isLit) {
|
|
9
|
+
const elementProperties = getLitProperties(component);
|
|
10
|
+
component.manager.internals.members = Object.fromEntries(
|
|
11
|
+
Array.from(elementProperties, ([name, { state, type }]) => [
|
|
12
|
+
name,
|
|
13
|
+
[
|
|
14
|
+
state ? 32 /* State */ : type === Number ? 2 /* Number */ : type === Boolean ? 4 /* Boolean */ : 1 /* String */
|
|
15
|
+
]
|
|
16
|
+
])
|
|
18
17
|
);
|
|
19
|
-
|
|
18
|
+
} else {
|
|
19
|
+
const constructor = component.constructor;
|
|
20
|
+
const members = constructor.__registerControllers?.(component) ?? void 0;
|
|
21
|
+
constructor.__registerControllers = void 0;
|
|
22
|
+
if (typeof members !== "object")
|
|
23
|
+
throw new Error(
|
|
24
|
+
"Failed to retrieve internal component meta. Make sure you have the useComponentsControllers() Rollup Plugin for Stencil Controllers configured in your Stencil config."
|
|
25
|
+
);
|
|
26
|
+
component.manager.internals.members = members;
|
|
27
|
+
}
|
|
20
28
|
}
|
|
29
|
+
var getLitProperties = (component) => component.constructor.elementProperties;
|
|
21
30
|
function parsePropertyValue(value, type = 8 /* Any */) {
|
|
22
31
|
const isComplex = value == null || typeof value === "object" || typeof value === "function";
|
|
23
32
|
if (isComplex)
|
|
@@ -25,7 +34,7 @@ function parsePropertyValue(value, type = 8 /* Any */) {
|
|
|
25
34
|
if ((type & 4 /* Boolean */) !== 0)
|
|
26
35
|
return value === "false" ? false : value === "" || !!value;
|
|
27
36
|
else if ((type & 2 /* Number */) !== 0)
|
|
28
|
-
return Number.parseFloat(value
|
|
37
|
+
return Number.parseFloat(value);
|
|
29
38
|
else if ((type & 1 /* String */) !== 0)
|
|
30
39
|
return String(value);
|
|
31
40
|
else
|
|
@@ -47,6 +56,21 @@ function getPropType(component, name) {
|
|
|
47
56
|
return "prop";
|
|
48
57
|
}
|
|
49
58
|
|
|
59
|
+
// src/types.ts
|
|
60
|
+
var controllerSymbol = Symbol("controller");
|
|
61
|
+
|
|
62
|
+
// src/utils.ts
|
|
63
|
+
function extendObject(base, extend) {
|
|
64
|
+
Object.entries(extend).forEach(([key, value]) => {
|
|
65
|
+
if (key in base)
|
|
66
|
+
throw new Error(`Unable to extend object because property "${key}" is already defined`);
|
|
67
|
+
const thisBase = base;
|
|
68
|
+
thisBase[key] = value;
|
|
69
|
+
});
|
|
70
|
+
return base;
|
|
71
|
+
}
|
|
72
|
+
var isController = (value) => typeof value === "object" && value !== null && (controllerSymbol in value || "hostConnected" in value || "hostDisconnected" in value || "hostUpdate" in value || "hostUpdated" in value);
|
|
73
|
+
|
|
50
74
|
// ../components-utils/dist/index.js
|
|
51
75
|
var Deferred = class {
|
|
52
76
|
/**
|
|
@@ -151,6 +175,7 @@ async function safeAsyncCall(callback) {
|
|
|
151
175
|
}
|
|
152
176
|
return void 0;
|
|
153
177
|
}
|
|
178
|
+
var camelToKebab = (string) => string.replace(upperBeforeLower, (upper, remainder) => `${remainder === 0 ? "" : "-"}${upper.toLowerCase()}`);
|
|
154
179
|
var upperBeforeLower = /[A-Z]+(?![a-z])|[A-Z]/gu;
|
|
155
180
|
var capitalize = (string) => string.charAt(0).toUpperCase() + string.slice(1);
|
|
156
181
|
var camelToHuman = (string) => capitalize(string.replace(upperBeforeLower, (upper, remainder) => `${remainder === 0 ? "" : " "}${upper}`));
|
|
@@ -250,21 +275,6 @@ async function updateComponentLocateState(element, assetsPath, assetName = eleme
|
|
|
250
275
|
return { lang, t9nLocale, t9nStrings };
|
|
251
276
|
}
|
|
252
277
|
|
|
253
|
-
// src/types.ts
|
|
254
|
-
var controllerSymbol = Symbol("controller");
|
|
255
|
-
|
|
256
|
-
// src/utils.ts
|
|
257
|
-
function extendObject(base, extend) {
|
|
258
|
-
Object.entries(extend).forEach(([key, value]) => {
|
|
259
|
-
if (key in base)
|
|
260
|
-
throw new Error(`Unable to extend object because property "${key}" is already defined`);
|
|
261
|
-
const thisBase = base;
|
|
262
|
-
thisBase[key] = value;
|
|
263
|
-
});
|
|
264
|
-
return base;
|
|
265
|
-
}
|
|
266
|
-
var isController = (value) => typeof value === "object" && value !== null && (controllerSymbol in value || "hostConnected" in value || "hostDisconnected" in value || "hostUpdate" in value || "hostUpdated" in value);
|
|
267
|
-
|
|
268
278
|
// src/ControllerInternals.ts
|
|
269
279
|
var ControllerInternals = class {
|
|
270
280
|
constructor() {
|
|
@@ -429,26 +439,23 @@ var _Controller = class _Controller {
|
|
|
429
439
|
value: resolvedComponent
|
|
430
440
|
});
|
|
431
441
|
this.component.addController(this);
|
|
432
|
-
const manager = this.component.manager;
|
|
433
|
-
this.connected = manager?.connected;
|
|
434
|
-
this.internals = manager?.internals;
|
|
435
442
|
_Controller.internals.setParentController(this);
|
|
436
443
|
if ("hostDestroy" in this)
|
|
437
444
|
this.component.manager.ensureHasDestroy();
|
|
438
|
-
|
|
445
|
+
const manager = this.component.manager;
|
|
446
|
+
const isInControllerManager = manager === void 0;
|
|
447
|
+
if (!isInControllerManager)
|
|
439
448
|
queueMicrotask(() => this.catchUpLifecycle());
|
|
440
|
-
const controller = this;
|
|
449
|
+
const controller = isInControllerManager ? {} : this;
|
|
441
450
|
this._callbacks = {
|
|
442
|
-
hostConnected: "hostConnected" in
|
|
443
|
-
hostDisconnected: "hostDisconnected" in
|
|
444
|
-
hostLoad: "hostLoad" in
|
|
445
|
-
hostLoaded: "hostLoaded" in
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
hostDestroy: "hostDestroy" in this ? [() => controller.hostDestroy?.()] : [],
|
|
451
|
-
hostLifecycle: "hostLifecycle" in this ? [() => controller.hostLifecycle?.()] : []
|
|
451
|
+
hostConnected: "hostConnected" in controller ? [() => controller.hostConnected?.()] : [],
|
|
452
|
+
hostDisconnected: "hostDisconnected" in controller ? [() => controller.hostDisconnected?.()] : [],
|
|
453
|
+
hostLoad: "hostLoad" in controller ? [() => controller.hostLoad?.()] : [],
|
|
454
|
+
hostLoaded: "hostLoaded" in controller ? [() => controller.hostLoaded?.()] : [],
|
|
455
|
+
hostUpdate: "hostUpdate" in controller ? [() => controller.hostUpdate?.()] : [],
|
|
456
|
+
hostUpdated: "hostUpdated" in controller ? [() => controller.hostUpdated?.()] : [],
|
|
457
|
+
hostDestroy: "hostDestroy" in controller ? [() => controller.hostDestroy?.()] : [],
|
|
458
|
+
hostLifecycle: "hostLifecycle" in controller ? [() => controller.hostLifecycle?.()] : []
|
|
452
459
|
};
|
|
453
460
|
}
|
|
454
461
|
/**
|
|
@@ -573,7 +580,7 @@ var _Controller = class _Controller {
|
|
|
573
580
|
}
|
|
574
581
|
/**
|
|
575
582
|
* Property reads inside of this function will bypass any custom getter you
|
|
576
|
-
* may have, and read the value directly from what's stored in Stencil.
|
|
583
|
+
* may have, and read the value directly from what's stored in Stencil/Lit.
|
|
577
584
|
*
|
|
578
585
|
* This also bypasses reactiveUtils integration - reading a property inside of
|
|
579
586
|
* bypassGetter won't make that property tracked.
|
|
@@ -612,28 +619,30 @@ var _Controller = class _Controller {
|
|
|
612
619
|
genericGetSet(property, getSet) {
|
|
613
620
|
var _a2, _b;
|
|
614
621
|
const genericGetSet = getSet;
|
|
622
|
+
const internals = this.component.manager.internals;
|
|
615
623
|
if (genericGetSet.get !== void 0) {
|
|
616
|
-
(_a2 =
|
|
617
|
-
|
|
624
|
+
(_a2 = internals.getters)[property] ?? (_a2[property] = []);
|
|
625
|
+
internals.getters[property].unshift(genericGetSet.get);
|
|
618
626
|
}
|
|
619
627
|
if (genericGetSet.set !== void 0) {
|
|
620
|
-
(_b =
|
|
621
|
-
|
|
628
|
+
(_b = internals.setters)[property] ?? (_b[property] = []);
|
|
629
|
+
internals.setters[property].unshift(genericGetSet.set);
|
|
622
630
|
}
|
|
623
631
|
}
|
|
624
632
|
// FEATURE: improve typings
|
|
625
633
|
/**
|
|
626
|
-
* Dynamically set a watcher for any
|
|
634
|
+
* Dynamically set a watcher for any reactive property
|
|
627
635
|
*/
|
|
628
636
|
watch(property, callback) {
|
|
629
637
|
var _a2;
|
|
630
638
|
const type = getMemberType(this.component, property);
|
|
631
639
|
if (type === void 0)
|
|
632
640
|
throw new Error(
|
|
633
|
-
`Trying to watch a non-@
|
|
641
|
+
`Trying to watch a non-@property, non-@state property "${property}". Either convert it into a @state() or use get/set syntax`
|
|
634
642
|
);
|
|
635
|
-
|
|
636
|
-
|
|
643
|
+
const internals = this.component.manager.internals;
|
|
644
|
+
(_a2 = internals.allWatchers)[property] ?? (_a2[property] = []);
|
|
645
|
+
const watchers = internals.allWatchers[property];
|
|
637
646
|
const genericCallback = callback;
|
|
638
647
|
const safeCallback = (newValue, oldValue, propertyName) => safeCall(() => genericCallback(newValue, oldValue, propertyName));
|
|
639
648
|
watchers.push(safeCallback);
|
|
@@ -656,12 +665,6 @@ var _Controller = class _Controller {
|
|
|
656
665
|
onLoaded(callback) {
|
|
657
666
|
this._callbacks.hostLoaded.push(callback);
|
|
658
667
|
}
|
|
659
|
-
onRender(callback) {
|
|
660
|
-
this._callbacks.hostRender.push(callback);
|
|
661
|
-
}
|
|
662
|
-
onRendered(callback) {
|
|
663
|
-
this._callbacks.hostRendered.push(callback);
|
|
664
|
-
}
|
|
665
668
|
onUpdate(callback) {
|
|
666
669
|
this._callbacks.hostUpdate.push(callback);
|
|
667
670
|
}
|
|
@@ -702,16 +705,8 @@ var _Controller = class _Controller {
|
|
|
702
705
|
this._callbacks.hostLoaded.forEach(safeCall);
|
|
703
706
|
this.didLoadCalled = true;
|
|
704
707
|
}
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
await Promise.allSettled(this._callbacks.hostRender.map(safeAsyncCall));
|
|
708
|
-
}
|
|
709
|
-
triggerRendered() {
|
|
710
|
-
this._callbacks.hostRendered.forEach(safeCall);
|
|
711
|
-
}
|
|
712
|
-
async triggerUpdate() {
|
|
713
|
-
if (this._callbacks.hostUpdate.length > 0)
|
|
714
|
-
await Promise.allSettled(this._callbacks.hostUpdate.map(safeAsyncCall));
|
|
708
|
+
triggerUpdate() {
|
|
709
|
+
this._callbacks.hostUpdate.forEach(safeCall);
|
|
715
710
|
}
|
|
716
711
|
triggerUpdated() {
|
|
717
712
|
this._callbacks.hostUpdated.forEach(safeCall);
|
|
@@ -723,6 +718,7 @@ var _Controller = class _Controller {
|
|
|
723
718
|
this._callbacks.hostLifecycle.forEach((callback) => this._callLifecycle(callback));
|
|
724
719
|
}
|
|
725
720
|
_callLifecycle(callback) {
|
|
721
|
+
_Controller.internals.setAmbientComponent(this.component);
|
|
726
722
|
const cleanupRaw = safeCall(callback);
|
|
727
723
|
const cleanup = Array.isArray(cleanupRaw) ? cleanupRaw : [cleanupRaw];
|
|
728
724
|
cleanup.forEach((cleanup2) => {
|
|
@@ -748,12 +744,6 @@ var GenericController = class extends Controller {
|
|
|
748
744
|
callback
|
|
749
745
|
);
|
|
750
746
|
}
|
|
751
|
-
/**
|
|
752
|
-
* Silence "Property 'dynamicGetSet' in type
|
|
753
|
-
* 'GenericController<Exports, Requires>' is not assignable to the same
|
|
754
|
-
* property in base type 'Controller<Exports>'", as TypeScript is being overly
|
|
755
|
-
* conservative here with what it allows
|
|
756
|
-
*/
|
|
757
747
|
dynamicGetSet(property, getSet) {
|
|
758
748
|
super.genericGetSet(property, getSet);
|
|
759
749
|
}
|
|
@@ -761,9 +751,9 @@ var GenericController = class extends Controller {
|
|
|
761
751
|
function makeProvisionalValue(base) {
|
|
762
752
|
if (typeof base !== "object" && typeof base !== "function" || base === null)
|
|
763
753
|
return base;
|
|
764
|
-
const
|
|
754
|
+
const proxy2 = new Proxy(base, {
|
|
765
755
|
get(target, prop, receiver) {
|
|
766
|
-
if (cyclical.has(prop) && prop in target && target[prop] ===
|
|
756
|
+
if (cyclical.has(prop) && prop in target && target[prop] === proxy2)
|
|
767
757
|
return void 0;
|
|
768
758
|
if (prop in target || prop in Promise.prototype || typeof prop === "symbol")
|
|
769
759
|
return typeof target === "function" ? target[prop] : Reflect.get(target, prop, receiver);
|
|
@@ -775,16 +765,10 @@ function makeProvisionalValue(base) {
|
|
|
775
765
|
return Reflect.set(target, prop, newValue, receiver);
|
|
776
766
|
}
|
|
777
767
|
});
|
|
778
|
-
return
|
|
768
|
+
return proxy2;
|
|
779
769
|
}
|
|
780
770
|
var cyclical = /* @__PURE__ */ new Set(["exports", "_exports"]);
|
|
781
|
-
var accessBeforeLoad =
|
|
782
|
-
"This might be the case if you are trying to access an async controller in ",
|
|
783
|
-
"connectedCallback(). Or, if you are using it inside of ",
|
|
784
|
-
"componentWillLoad()/another controller without controller.use. Example correct ",
|
|
785
|
-
"usage:\n",
|
|
786
|
-
"makeController(async (component, controller)=>{ await controller.use(someOtherController); });"
|
|
787
|
-
].join("");
|
|
771
|
+
var accessBeforeLoad = "" ;
|
|
788
772
|
function toControllerHost(component) {
|
|
789
773
|
if ("addController" in component)
|
|
790
774
|
return component;
|
|
@@ -794,6 +778,82 @@ function toControllerHost(component) {
|
|
|
794
778
|
);
|
|
795
779
|
}
|
|
796
780
|
|
|
781
|
+
// src/proxyExports.ts
|
|
782
|
+
var proxyExports = (Class) => (...args) => {
|
|
783
|
+
const ambientControllers = Controller.internals.retrieveParentControllers();
|
|
784
|
+
const instance = new Class(...args);
|
|
785
|
+
const initialExports = instance.exports;
|
|
786
|
+
Controller.internals.setParentController(ambientControllers.at(-1));
|
|
787
|
+
const internals = instance.component.manager.internals;
|
|
788
|
+
internals.markExports(instance, initialExports);
|
|
789
|
+
instance.watchExports((exports) => internals.markExports(instance, exports));
|
|
790
|
+
Controller.internals.setAmbientChildController(instance);
|
|
791
|
+
const hostCandidates = [instance.component, ...ambientControllers].reverse();
|
|
792
|
+
return internals.trackKey(
|
|
793
|
+
hostCandidates,
|
|
794
|
+
(resolution) => resolution === void 0 ? void 0 : setProxy(instance, resolution.host, resolution.key, initialExports),
|
|
795
|
+
initialExports
|
|
796
|
+
);
|
|
797
|
+
};
|
|
798
|
+
function setProxy(controller, host, key, initialExports) {
|
|
799
|
+
const genericHost = host;
|
|
800
|
+
const controllerValueChanged = genericHost[key] !== controller.exports;
|
|
801
|
+
const hostValueChanged = genericHost[key] !== initialExports;
|
|
802
|
+
const controllerUpdatedExports = initialExports !== controller.exports;
|
|
803
|
+
if (controllerValueChanged && !hostValueChanged && controllerUpdatedExports)
|
|
804
|
+
genericHost[key] = controller.exports;
|
|
805
|
+
controller.watchExports(() => {
|
|
806
|
+
if (genericHost[key] === controller.exports)
|
|
807
|
+
return;
|
|
808
|
+
const manager = controller.component.manager;
|
|
809
|
+
const isReadOnly = manager.internals.readonlyProps?.has(key) === true;
|
|
810
|
+
if (isReadOnly)
|
|
811
|
+
manager.bypassReadonly(() => {
|
|
812
|
+
genericHost[key] = controller.exports;
|
|
813
|
+
});
|
|
814
|
+
else
|
|
815
|
+
genericHost[key] = controller.exports;
|
|
816
|
+
});
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
// src/functional.ts
|
|
820
|
+
var makeController = (constructor) => proxy(void 0, constructor);
|
|
821
|
+
var FunctionalController = class extends Controller {
|
|
822
|
+
constructor(component, constructor) {
|
|
823
|
+
super(component);
|
|
824
|
+
const originalExports = this.exports;
|
|
825
|
+
try {
|
|
826
|
+
Controller.internals.setAmbientComponent(this.component);
|
|
827
|
+
const value = constructor(this.component, this);
|
|
828
|
+
const constructorChangedExports = this.exports !== originalExports;
|
|
829
|
+
if (value instanceof Promise) {
|
|
830
|
+
if (!constructorChangedExports)
|
|
831
|
+
this.setProvisionalExports(value);
|
|
832
|
+
const resolved = value.then((result) => {
|
|
833
|
+
this.exports = result;
|
|
834
|
+
super.catchUpLifecycle();
|
|
835
|
+
}).catch((error) => {
|
|
836
|
+
this._ready.reject(error);
|
|
837
|
+
console.error(error);
|
|
838
|
+
});
|
|
839
|
+
this.onLoad(async () => await resolved);
|
|
840
|
+
} else {
|
|
841
|
+
if (!constructorChangedExports || value !== void 0)
|
|
842
|
+
this.exports = value;
|
|
843
|
+
queueMicrotask(() => super.catchUpLifecycle());
|
|
844
|
+
}
|
|
845
|
+
} catch (error) {
|
|
846
|
+
this._ready.reject(error);
|
|
847
|
+
console.error(error);
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
/** Noop - will be called in the constructor instead */
|
|
851
|
+
catchUpLifecycle() {
|
|
852
|
+
return;
|
|
853
|
+
}
|
|
854
|
+
};
|
|
855
|
+
var proxy = proxyExports(FunctionalController);
|
|
856
|
+
|
|
797
857
|
// src/trackPropertyKey.ts
|
|
798
858
|
function trackPropertyKey(object, onResolved, defaultValue) {
|
|
799
859
|
const keys = Object.keys(object);
|
|
@@ -884,16 +944,14 @@ var ComponentInternals = class {
|
|
|
884
944
|
}, defaultValue);
|
|
885
945
|
return defaultValue;
|
|
886
946
|
};
|
|
887
|
-
this.trackPropKey = (onResolved, defaultValue
|
|
947
|
+
this.trackPropKey = (onResolved, defaultValue) => {
|
|
888
948
|
if (this._trackedValue !== nothing && this._trackedValue !== defaultValue)
|
|
889
949
|
this._firePropertyTrackers(void 0, void 0, void 0);
|
|
890
950
|
if (this._keyTrackers.length === 0)
|
|
891
951
|
queueMicrotask(() => this._firePropertyTrackers(void 0, void 0, void 0));
|
|
892
952
|
this._trackedValue = defaultValue;
|
|
893
953
|
this._keyTrackers.push(
|
|
894
|
-
(key, value, previousValue) => safeCall(
|
|
895
|
-
() => onResolved(defaultValue === value || ignoreDefaultValueMismatch ? key : void 0, previousValue)
|
|
896
|
-
)
|
|
954
|
+
(key, value, previousValue) => safeCall(() => onResolved(defaultValue === value ? key : void 0, previousValue))
|
|
897
955
|
);
|
|
898
956
|
return defaultValue;
|
|
899
957
|
};
|
|
@@ -927,9 +985,12 @@ var ComponentInternals = class {
|
|
|
927
985
|
* to apply the changes to the prototype
|
|
928
986
|
*/
|
|
929
987
|
getSetProxy(property, hasGetter, hasSetter) {
|
|
930
|
-
const
|
|
988
|
+
const component = this.component;
|
|
989
|
+
const classPrototype = component.constructor.prototype;
|
|
931
990
|
this._getSetProxy(classPrototype, property, hasGetter, hasSetter, "class");
|
|
932
|
-
|
|
991
|
+
if (component.manager.isLit)
|
|
992
|
+
return;
|
|
993
|
+
const htmlPrototype = component.el.constructor.prototype;
|
|
933
994
|
if (classPrototype !== htmlPrototype)
|
|
934
995
|
this._getSetProxy(htmlPrototype, property, hasGetter, hasSetter, "html");
|
|
935
996
|
}
|
|
@@ -941,7 +1002,7 @@ var ComponentInternals = class {
|
|
|
941
1002
|
if (descriptor?.set === void 0 || descriptor.get === void 0)
|
|
942
1003
|
if (descriptor !== void 0 && "value" in descriptor)
|
|
943
1004
|
throw new Error(
|
|
944
|
-
`getSet() should only be used on
|
|
1005
|
+
`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}`
|
|
945
1006
|
);
|
|
946
1007
|
else if (tolerateNotFound)
|
|
947
1008
|
return;
|
|
@@ -968,12 +1029,12 @@ var ComponentInternals = class {
|
|
|
968
1029
|
} : originalGet;
|
|
969
1030
|
const finalSetter = shouldOverwriteSet ? function setter(rawNewValue) {
|
|
970
1031
|
const oldValue = originalGet.call(this);
|
|
971
|
-
let newValue = parsePropertyValue(rawNewValue, propType);
|
|
972
1032
|
const component2 = Controller.internals.elementToInstance.get(this);
|
|
973
1033
|
if (component2 === void 0) {
|
|
974
1034
|
originalSet.call(this, rawNewValue);
|
|
975
1035
|
return;
|
|
976
1036
|
}
|
|
1037
|
+
let newValue = component2.manager.isLit ? rawNewValue : parsePropertyValue(rawNewValue, propType);
|
|
977
1038
|
const internals = component2.manager.internals;
|
|
978
1039
|
if (newValue === oldValue)
|
|
979
1040
|
originalSet.call(this, rawNewValue);
|
|
@@ -1017,59 +1078,30 @@ var ComponentInternals = class {
|
|
|
1017
1078
|
var emptyArray = [];
|
|
1018
1079
|
var customAccessor = Symbol("controllersCustomAccessor");
|
|
1019
1080
|
var nothing = Symbol("nothing");
|
|
1020
|
-
var accessorPromise = Promise.all([importCoreAccessor(), importCoreAccessorSupportDecorators()]);
|
|
1021
|
-
function reactiveUtilsIntegration(component) {
|
|
1022
|
-
const members = getPropLikeMembers(component);
|
|
1023
|
-
const internals = component.manager.internals;
|
|
1024
|
-
members.forEach((name) => {
|
|
1025
|
-
internals.accessorGetter[name] = defaultGetterSetter;
|
|
1026
|
-
internals.accessorSetter[name] = defaultGetterSetter;
|
|
1027
|
-
internals.getSetProxy(name, true, true);
|
|
1028
|
-
});
|
|
1029
|
-
return async (enabledMembers = members) => {
|
|
1030
|
-
const [Accessor, { subclass, property }] = await accessorPromise;
|
|
1031
|
-
class AccessorSubclass extends Accessor {
|
|
1032
|
-
}
|
|
1033
|
-
const getter = (_value, propertyName) => accessor[propertyName];
|
|
1034
|
-
function setter(newValue, _oldValue, propertyName) {
|
|
1035
|
-
if (accessor !== void 0)
|
|
1036
|
-
accessor[propertyName] = newValue;
|
|
1037
|
-
return newValue;
|
|
1038
|
-
}
|
|
1039
|
-
component.manager.bypassGetter(
|
|
1040
|
-
() => enabledMembers.forEach((name) => {
|
|
1041
|
-
internals.accessorGetter[name] = getter;
|
|
1042
|
-
internals.accessorSetter[name] = setter;
|
|
1043
|
-
property({
|
|
1044
|
-
value: component[name]
|
|
1045
|
-
})(AccessorSubclass.prototype, name);
|
|
1046
|
-
})
|
|
1047
|
-
);
|
|
1048
|
-
const Subclass = subclass(component.el.tagName)(AccessorSubclass);
|
|
1049
|
-
const accessor = new Subclass();
|
|
1050
|
-
};
|
|
1051
|
-
}
|
|
1052
|
-
var defaultGetterSetter = (value) => value;
|
|
1053
1081
|
|
|
1054
1082
|
// src/ControllerManager.ts
|
|
1055
|
-
var useControllerManager = (component) => new ControllerManager(component);
|
|
1083
|
+
var useControllerManager = (component, forceUpdate) => new ControllerManager(component, forceUpdate);
|
|
1056
1084
|
var ControllerManager = class extends GenericController {
|
|
1057
|
-
constructor(component) {
|
|
1085
|
+
constructor(component, forceUpdate) {
|
|
1086
|
+
const isLit = "addController" in component;
|
|
1058
1087
|
const controllers = /* @__PURE__ */ new Set();
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1088
|
+
function addController(controller) {
|
|
1089
|
+
controllers.add(controller);
|
|
1090
|
+
if (isLit && !(controllerSymbol in controller) && component.el.isConnected)
|
|
1091
|
+
controller.hostConnected?.();
|
|
1092
|
+
}
|
|
1093
|
+
const removeController = (controller) => void controllers.delete(controller);
|
|
1094
|
+
if (!isLit) {
|
|
1095
|
+
const update = forceUpdate ?? component.constructor.__forceUpdate;
|
|
1096
|
+
const controllerHost = {
|
|
1097
|
+
addController,
|
|
1098
|
+
removeController,
|
|
1099
|
+
requestUpdate: () => update(component)
|
|
1100
|
+
};
|
|
1101
|
+
extendObject(component, controllerHost);
|
|
1102
|
+
}
|
|
1069
1103
|
super(component);
|
|
1070
|
-
this._connected = new Deferred();
|
|
1071
1104
|
this.internals = new ComponentInternals(this.component);
|
|
1072
|
-
this.connected = this._connected.promise;
|
|
1073
1105
|
this.destroyed = false;
|
|
1074
1106
|
this._updatePromise = new Deferred();
|
|
1075
1107
|
this._originalLifecycles = {};
|
|
@@ -1116,14 +1148,25 @@ var ControllerManager = class extends GenericController {
|
|
|
1116
1148
|
* \@Prop() decorator or not
|
|
1117
1149
|
*/
|
|
1118
1150
|
this.trackKey = this.internals.trackKey;
|
|
1119
|
-
this._readonlySetter = (newValue,
|
|
1151
|
+
this._readonlySetter = (newValue, oldValue, property) => {
|
|
1120
1152
|
if (Controller.internals.shouldBypassReadonly)
|
|
1121
1153
|
return newValue;
|
|
1122
|
-
const
|
|
1123
|
-
|
|
1124
|
-
|
|
1154
|
+
const component = this.component;
|
|
1155
|
+
const isProp = getPropType(component, property) === "prop";
|
|
1156
|
+
if (isProp) {
|
|
1157
|
+
if (this.isLit) {
|
|
1158
|
+
const details = getLitProperties(component).get(property);
|
|
1159
|
+
if (details && details?.attribute !== false)
|
|
1160
|
+
component.el.setAttribute(
|
|
1161
|
+
typeof details.attribute === "string" ? details.attribute : camelToKebab(property),
|
|
1162
|
+
// Not using converter.toAttribute to keep this unlikely case simpler
|
|
1163
|
+
String(oldValue)
|
|
1164
|
+
);
|
|
1165
|
+
} else
|
|
1166
|
+
component.requestUpdate();
|
|
1167
|
+
}
|
|
1125
1168
|
throw new Error(
|
|
1126
|
-
`Cannot assign to read-only property "${property}" of ${
|
|
1169
|
+
`Cannot assign to read-only property "${property}" of ${component.el.tagName.toLowerCase()}. Trying to assign "${String(
|
|
1127
1170
|
newValue
|
|
1128
1171
|
)}"`
|
|
1129
1172
|
);
|
|
@@ -1136,18 +1179,30 @@ var ControllerManager = class extends GenericController {
|
|
|
1136
1179
|
*/
|
|
1137
1180
|
this.devOnlySetPersistentControllerData = void 0 ;
|
|
1138
1181
|
this.devOnlyGetPersistentControllerData = void 0 ;
|
|
1182
|
+
if (isLit) {
|
|
1183
|
+
component.addController = addController;
|
|
1184
|
+
component.removeController = removeController;
|
|
1185
|
+
}
|
|
1186
|
+
this.isLit = isLit;
|
|
1139
1187
|
this.component.manager = this;
|
|
1140
|
-
|
|
1188
|
+
retrieveComponentMembers(component, isLit);
|
|
1141
1189
|
this._controllers = controllers;
|
|
1142
1190
|
this.exports = void 0;
|
|
1143
1191
|
this.hasDestroy = "autoDestroyDisabled" in this.component && typeof this.component.destroy === "function";
|
|
1144
1192
|
if (this.hasDestroy)
|
|
1145
1193
|
this.watch("autoDestroyDisabled", () => this._autoDestroyDisabledWatcher());
|
|
1146
1194
|
this._bindLifecycleMethods();
|
|
1147
|
-
|
|
1148
|
-
|
|
1195
|
+
if (!isLit)
|
|
1196
|
+
Object.defineProperty(component, "updateComplete", {
|
|
1197
|
+
get: async () => await this._updatePromise.promise
|
|
1198
|
+
});
|
|
1199
|
+
const members = getPropLikeMembers(component);
|
|
1200
|
+
const internals = component.manager.internals;
|
|
1201
|
+
members.forEach((name) => {
|
|
1202
|
+
internals.accessorGetter[name] = defaultGetterSetter;
|
|
1203
|
+
internals.accessorSetter[name] = defaultGetterSetter;
|
|
1204
|
+
internals.getSetProxy(name, true, true);
|
|
1149
1205
|
});
|
|
1150
|
-
this.internals.reactiveUtilsIntegration = reactiveUtilsIntegration(this.component);
|
|
1151
1206
|
Controller.internals.setParentController(void 0);
|
|
1152
1207
|
Controller.internals.setAmbientComponent(component);
|
|
1153
1208
|
Controller.internals.elementToInstance.set(component.el, component);
|
|
@@ -1155,25 +1210,25 @@ var ControllerManager = class extends GenericController {
|
|
|
1155
1210
|
}
|
|
1156
1211
|
_bindLifecycleMethods() {
|
|
1157
1212
|
const component = this.component;
|
|
1213
|
+
const isLit = this.isLit;
|
|
1158
1214
|
this._originalLifecycles = {
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
componentDidUpdate: component.componentDidUpdate,
|
|
1215
|
+
// These callbacks will be called by Lit, so we don't have to
|
|
1216
|
+
connectedCallback: isLit ? void 0 : component.connectedCallback,
|
|
1217
|
+
disconnectedCallback: isLit ? void 0 : component.disconnectedCallback,
|
|
1218
|
+
componentWillLoad: isLit ? void 0 : component.componentWillLoad,
|
|
1219
|
+
componentDidLoad: isLit ? void 0 : component.componentDidLoad,
|
|
1220
|
+
componentWillUpdate: isLit ? void 0 : component.componentWillUpdate,
|
|
1221
|
+
componentDidUpdate: isLit ? void 0 : component.componentDidUpdate,
|
|
1167
1222
|
destroy: component.destroy
|
|
1168
1223
|
};
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1224
|
+
if (!isLit) {
|
|
1225
|
+
component.connectedCallback = this.hostConnected.bind(this);
|
|
1226
|
+
component.disconnectedCallback = this.hostDisconnected.bind(this);
|
|
1227
|
+
component.componentWillLoad = this.hostLoad.bind(this);
|
|
1228
|
+
component.componentDidLoad = this.hostLoaded.bind(this);
|
|
1229
|
+
component.componentWillUpdate = this.hostUpdate.bind(this);
|
|
1230
|
+
component.componentDidUpdate = this.hostUpdated.bind(this);
|
|
1231
|
+
}
|
|
1177
1232
|
if (this.hasDestroy)
|
|
1178
1233
|
component.destroy = this.destroy.bind(this);
|
|
1179
1234
|
}
|
|
@@ -1190,7 +1245,7 @@ var ControllerManager = class extends GenericController {
|
|
|
1190
1245
|
* Instead, _bindLifecycleMethods will take care of that. Otherwise, you risk
|
|
1191
1246
|
* calling lifecycle methods twice.
|
|
1192
1247
|
*/
|
|
1193
|
-
|
|
1248
|
+
hostConnected() {
|
|
1194
1249
|
if (this.destroyed) {
|
|
1195
1250
|
const tagName = this.component.el.tagName.toLowerCase();
|
|
1196
1251
|
this.component.el.remove();
|
|
@@ -1202,13 +1257,12 @@ var ControllerManager = class extends GenericController {
|
|
|
1202
1257
|
clearTimeout(this._autoDestroyTimeout);
|
|
1203
1258
|
this.internals.enabledWatchers = this.internals.allWatchers;
|
|
1204
1259
|
keyTrackResolve();
|
|
1205
|
-
this._connected.resolve();
|
|
1206
1260
|
this._controllers.forEach(
|
|
1207
1261
|
(controller) => "triggerConnected" in controller ? controller.triggerConnected() : safeCall(() => controller.hostConnected?.())
|
|
1208
1262
|
);
|
|
1209
1263
|
this._originalLifecycles.connectedCallback?.call(this.component);
|
|
1210
1264
|
}
|
|
1211
|
-
|
|
1265
|
+
hostDisconnected() {
|
|
1212
1266
|
if (this.destroyed)
|
|
1213
1267
|
return;
|
|
1214
1268
|
this._controllers.forEach(
|
|
@@ -1218,8 +1272,10 @@ var ControllerManager = class extends GenericController {
|
|
|
1218
1272
|
if (this.hasDestroy)
|
|
1219
1273
|
this._autoDestroyDisabledWatcher();
|
|
1220
1274
|
}
|
|
1221
|
-
async
|
|
1222
|
-
|
|
1275
|
+
// REFACTOR: don't force async if there are no async load controllers?
|
|
1276
|
+
async hostLoad() {
|
|
1277
|
+
if (typeof this.internals.reactiveUtilsIntegration === "function")
|
|
1278
|
+
await this.internals.reactiveUtilsIntegration();
|
|
1223
1279
|
await Promise.allSettled(
|
|
1224
1280
|
Array.from(
|
|
1225
1281
|
this._controllers,
|
|
@@ -1228,44 +1284,28 @@ var ControllerManager = class extends GenericController {
|
|
|
1228
1284
|
);
|
|
1229
1285
|
await this._originalLifecycles.componentWillLoad?.call(this.component);
|
|
1230
1286
|
}
|
|
1231
|
-
|
|
1287
|
+
hostLoaded() {
|
|
1232
1288
|
this._controllers.forEach(
|
|
1233
1289
|
(controller) => "triggerLoaded" in controller ? controller.triggerLoaded() : safeCall(() => controller.hostLoaded?.())
|
|
1234
1290
|
);
|
|
1235
1291
|
this._originalLifecycles.componentDidLoad?.call(this.component);
|
|
1236
1292
|
}
|
|
1237
|
-
|
|
1238
|
-
await Promise.allSettled(
|
|
1239
|
-
Array.from(
|
|
1240
|
-
this._controllers,
|
|
1241
|
-
async (controller) => "triggerRender" in controller ? await controller.triggerRender() : await safeAsyncCall(async () => await controller.hostRender?.())
|
|
1242
|
-
)
|
|
1243
|
-
);
|
|
1244
|
-
await this._originalLifecycles.componentWillRender?.call(this.component);
|
|
1245
|
-
}
|
|
1246
|
-
_componentDidRender() {
|
|
1293
|
+
hostUpdate() {
|
|
1247
1294
|
this._controllers.forEach(
|
|
1248
|
-
(controller) => "
|
|
1295
|
+
(controller) => "triggerUpdate" in controller ? controller.triggerUpdate() : safeCall(() => controller.hostUpdate?.())
|
|
1249
1296
|
);
|
|
1250
|
-
this._originalLifecycles.
|
|
1297
|
+
void this._originalLifecycles.componentWillUpdate?.call(this.component);
|
|
1251
1298
|
}
|
|
1252
|
-
|
|
1253
|
-
await Promise.allSettled(
|
|
1254
|
-
Array.from(
|
|
1255
|
-
this._controllers,
|
|
1256
|
-
async (controller) => "triggerUpdate" in controller ? await controller.triggerUpdate() : await safeAsyncCall(async () => await controller.hostUpdate?.())
|
|
1257
|
-
)
|
|
1258
|
-
);
|
|
1259
|
-
await this._originalLifecycles.componentWillUpdate?.call(this.component);
|
|
1260
|
-
}
|
|
1261
|
-
_componentDidUpdate() {
|
|
1299
|
+
hostUpdated() {
|
|
1262
1300
|
this._controllers.forEach(
|
|
1263
1301
|
(controller) => "triggerUpdated" in controller ? controller.triggerUpdated() : safeCall(() => controller.hostUpdated?.())
|
|
1264
1302
|
);
|
|
1265
1303
|
this._originalLifecycles.componentDidUpdate?.call(this.component);
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1304
|
+
if (!this.isLit) {
|
|
1305
|
+
const updatePromise = this._updatePromise;
|
|
1306
|
+
this._updatePromise = new Deferred();
|
|
1307
|
+
updatePromise.resolve(true);
|
|
1308
|
+
}
|
|
1269
1309
|
}
|
|
1270
1310
|
async destroy() {
|
|
1271
1311
|
this.ensureHasDestroy();
|
|
@@ -1284,6 +1324,7 @@ var ControllerManager = class extends GenericController {
|
|
|
1284
1324
|
this._controllers.forEach(
|
|
1285
1325
|
(controller) => "triggerDestroy" in controller ? controller.triggerDestroy() : safeCall(() => controller.hostDestroy?.())
|
|
1286
1326
|
);
|
|
1327
|
+
this._controllers.clear();
|
|
1287
1328
|
await this._originalLifecycles.destroy?.call(this.component);
|
|
1288
1329
|
}
|
|
1289
1330
|
_autoDestroyDisabledWatcher() {
|
|
@@ -1294,6 +1335,7 @@ var ControllerManager = class extends GenericController {
|
|
|
1294
1335
|
this._autoDestroyTimeout = setTimeout(destroy, autoDestroyOnDisconnectTimeout);
|
|
1295
1336
|
}
|
|
1296
1337
|
}
|
|
1338
|
+
// REFACTOR: replace this with a readonly:true option in @property()
|
|
1297
1339
|
/**
|
|
1298
1340
|
* Make a @Prop() or @State() readonly (prevent overwriting default value).
|
|
1299
1341
|
*
|
|
@@ -1313,6 +1355,7 @@ var ControllerManager = class extends GenericController {
|
|
|
1313
1355
|
readonly(value) {
|
|
1314
1356
|
return this.getSet(value, { set: this._readonlySetter });
|
|
1315
1357
|
}
|
|
1358
|
+
// REFACTOR: remove this in Lit in favor of native get/set
|
|
1316
1359
|
/**
|
|
1317
1360
|
* Listen for any component's @State()/@Prop() change, and mutate it's
|
|
1318
1361
|
* value before it is set.
|
|
@@ -1339,13 +1382,13 @@ var ControllerManager = class extends GenericController {
|
|
|
1339
1382
|
*/
|
|
1340
1383
|
getSet(defaultValue, getSet) {
|
|
1341
1384
|
return this.component.manager.trackPropKey((name) => {
|
|
1342
|
-
var
|
|
1385
|
+
var _a;
|
|
1343
1386
|
if (name === void 0)
|
|
1344
1387
|
throw new Error(
|
|
1345
1388
|
"Unable to resolve get/set's prop name. Make sure you are using it like @Prop() someProp = this.manager.getSet(defaultValue,{get,set})"
|
|
1346
1389
|
);
|
|
1347
1390
|
if (getSet.set === this._readonlySetter) {
|
|
1348
|
-
(
|
|
1391
|
+
(_a = this.internals).readonlyProps ?? (_a.readonlyProps = /* @__PURE__ */ new Set());
|
|
1349
1392
|
this.internals.readonlyProps.add(name);
|
|
1350
1393
|
}
|
|
1351
1394
|
const genericComponent = this.component;
|
|
@@ -1366,87 +1409,12 @@ ${// Don't expose internal code in production, and keep bundle smaller:
|
|
|
1366
1409
|
`autoDestroyDisabled and destroy` }
|
|
1367
1410
|
`.trim();
|
|
1368
1411
|
var autoDestroyOnDisconnectTimeout = 1e3;
|
|
1412
|
+
var defaultGetterSetter = (value) => value;
|
|
1369
1413
|
|
|
1370
|
-
// src/
|
|
1371
|
-
var
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
const initialExports = instance.exports;
|
|
1375
|
-
Controller.internals.setParentController(ambientControllers.at(-1));
|
|
1376
|
-
const internals = instance.component.manager.internals;
|
|
1377
|
-
internals.markExports(instance, initialExports);
|
|
1378
|
-
instance.watchExports((exports) => internals.markExports(instance, exports));
|
|
1379
|
-
Controller.internals.setAmbientChildController(instance);
|
|
1380
|
-
const hostCandidates = [instance.component, ...ambientControllers].reverse();
|
|
1381
|
-
return internals.trackKey(
|
|
1382
|
-
hostCandidates,
|
|
1383
|
-
(resolution) => resolution === void 0 ? void 0 : setProxy(instance, resolution.host, resolution.key, initialExports),
|
|
1384
|
-
initialExports
|
|
1385
|
-
);
|
|
1386
|
-
};
|
|
1387
|
-
function setProxy(controller, host, key, initialExports) {
|
|
1388
|
-
const genericHost = host;
|
|
1389
|
-
const controllerValueChanged = genericHost[key] !== controller.exports;
|
|
1390
|
-
const hostValueChanged = genericHost[key] !== initialExports;
|
|
1391
|
-
const controllerUpdatedExports = initialExports !== controller.exports;
|
|
1392
|
-
if (controllerValueChanged && !hostValueChanged && controllerUpdatedExports)
|
|
1393
|
-
genericHost[key] = controller.exports;
|
|
1394
|
-
controller.watchExports(() => {
|
|
1395
|
-
if (genericHost[key] === controller.exports)
|
|
1396
|
-
return;
|
|
1397
|
-
const manager = controller.component.manager;
|
|
1398
|
-
const isReadOnly = manager.internals.readonlyProps?.has(key) === true;
|
|
1399
|
-
if (isReadOnly)
|
|
1400
|
-
manager.bypassReadonly(() => {
|
|
1401
|
-
genericHost[key] = controller.exports;
|
|
1402
|
-
});
|
|
1403
|
-
else
|
|
1404
|
-
genericHost[key] = controller.exports;
|
|
1405
|
-
});
|
|
1406
|
-
}
|
|
1407
|
-
|
|
1408
|
-
// src/functional.ts
|
|
1409
|
-
var makeController = (constructor) => proxy(void 0, constructor);
|
|
1410
|
-
var FunctionalController = class extends Controller {
|
|
1411
|
-
constructor(component, constructor) {
|
|
1412
|
-
super(component);
|
|
1413
|
-
const originalExports = this.exports;
|
|
1414
|
-
try {
|
|
1415
|
-
Controller.internals.setAmbientComponent(this.component);
|
|
1416
|
-
const value = constructor(this.component, this);
|
|
1417
|
-
const constructorChangedExports = this.exports !== originalExports;
|
|
1418
|
-
if (value instanceof Promise) {
|
|
1419
|
-
if (!constructorChangedExports)
|
|
1420
|
-
this.setProvisionalExports(value);
|
|
1421
|
-
const resolved = value.then((result) => {
|
|
1422
|
-
this.exports = result;
|
|
1423
|
-
super.catchUpLifecycle();
|
|
1424
|
-
}).catch((error) => {
|
|
1425
|
-
this._ready.reject(error);
|
|
1426
|
-
console.error(error);
|
|
1427
|
-
});
|
|
1428
|
-
this.onLoad(async () => await resolved);
|
|
1429
|
-
} else {
|
|
1430
|
-
if (!constructorChangedExports || value !== void 0)
|
|
1431
|
-
this.exports = value;
|
|
1432
|
-
queueMicrotask(() => super.catchUpLifecycle());
|
|
1433
|
-
}
|
|
1434
|
-
} catch (error) {
|
|
1435
|
-
this._ready.reject(error);
|
|
1436
|
-
console.error(error);
|
|
1437
|
-
}
|
|
1438
|
-
}
|
|
1439
|
-
/** Noop - will be called in the constructor instead */
|
|
1440
|
-
catchUpLifecycle() {
|
|
1441
|
-
return;
|
|
1442
|
-
}
|
|
1443
|
-
};
|
|
1444
|
-
var proxy = proxyExports(FunctionalController);
|
|
1445
|
-
function useT9n({
|
|
1446
|
-
blocking = false,
|
|
1447
|
-
name
|
|
1448
|
-
} = {}) {
|
|
1449
|
-
return makeController((component, controller) => {
|
|
1414
|
+
// src/useT9n.ts
|
|
1415
|
+
var makeT9nController = (getAssetPath) => ({ blocking = false, name } = {}) => (
|
|
1416
|
+
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
1417
|
+
makeController((component, controller) => {
|
|
1450
1418
|
controller.onLifecycle(
|
|
1451
1419
|
() => startLocaleObserver(
|
|
1452
1420
|
component.el,
|
|
@@ -1464,7 +1432,7 @@ function useT9n({
|
|
|
1464
1432
|
return controller.ready;
|
|
1465
1433
|
const locale = getElementLocales(component.el);
|
|
1466
1434
|
return { _lang: locale.lang, _t9nLocale: locale.t9nLocale };
|
|
1467
|
-
})
|
|
1468
|
-
|
|
1435
|
+
})
|
|
1436
|
+
);
|
|
1469
1437
|
|
|
1470
|
-
export {
|
|
1438
|
+
export { makeT9nController as m, useControllerManager as u };
|