maplibre-gl-geoagent 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -0
- package/dist/{GeoAgentControl-Dpr36122.cjs → GeoAgentControl-Cc0HuUPf.cjs} +53 -14
- package/dist/{GeoAgentControl-Dpr36122.cjs.map → GeoAgentControl-Cc0HuUPf.cjs.map} +1 -1
- package/dist/{GeoAgentControl-C0NqjEWe.js → GeoAgentControl-CfSj1n01.js} +53 -14
- package/dist/{GeoAgentControl-C0NqjEWe.js.map → GeoAgentControl-CfSj1n01.js.map} +1 -1
- package/dist/{anthropic-B3q8CswR.js → anthropic-BVBhgJNP.js} +2 -2
- package/dist/{anthropic-B3q8CswR.js.map → anthropic-BVBhgJNP.js.map} +1 -1
- package/dist/{anthropic-BkJWRsGY.cjs → anthropic-BfFYVXzE.cjs} +2 -2
- package/dist/{anthropic-BkJWRsGY.cjs.map → anthropic-BfFYVXzE.cjs.map} +1 -1
- package/dist/{browser-D6gmHQqD.cjs → browser-BtMWNaZj.cjs} +2 -2
- package/dist/{browser-D6gmHQqD.cjs.map → browser-BtMWNaZj.cjs.map} +1 -1
- package/dist/{browser-6nQo2Odo.js → browser-D437ICBx.js} +2 -2
- package/dist/{browser-6nQo2Odo.js.map → browser-D437ICBx.js.map} +1 -1
- package/dist/{index-Bi9NrqmL.js → index-CVvcPs8z.js} +2 -2
- package/dist/{index-Bi9NrqmL.js.map → index-CVvcPs8z.js.map} +1 -1
- package/dist/{index-DZcJF5D6.js → index-CeL5qxhv.js} +2 -2
- package/dist/{index-DZcJF5D6.js.map → index-CeL5qxhv.js.map} +1 -1
- package/dist/{index-CBRcDJl6.js → index-D0hzZEUn.js} +2 -2
- package/dist/{index-CBRcDJl6.js.map → index-D0hzZEUn.js.map} +1 -1
- package/dist/{index-B51VnjHA.cjs → index-DGr_aIvw.cjs} +2 -2
- package/dist/{index-B51VnjHA.cjs.map → index-DGr_aIvw.cjs.map} +1 -1
- package/dist/{index-CbFlyAAM.cjs → index-DaOfppi1.cjs} +2 -2
- package/dist/{index-CbFlyAAM.cjs.map → index-DaOfppi1.cjs.map} +1 -1
- package/dist/{index-CEnhCAzc.cjs → index-DumDV1aY.cjs} +2 -2
- package/dist/{index-CEnhCAzc.cjs.map → index-DumDV1aY.cjs.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.mjs +1 -1
- package/dist/types/lib/core/GeoAgentControl.d.ts.map +1 -1
- package/dist/types/lib/core/earth-engine.d.ts +5 -0
- package/dist/types/lib/core/earth-engine.d.ts.map +1 -1
- package/dist/types/lib/core/types.d.ts +3 -2
- package/dist/types/lib/core/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -154,6 +154,27 @@ The Earth Engine integration uses browser OAuth through the official
|
|
|
154
154
|
not supported in this browser-only package. Use a backend proxy if your
|
|
155
155
|
deployment needs service account access.
|
|
156
156
|
|
|
157
|
+
Host applications that already authenticate Earth Engine outside the browser
|
|
158
|
+
can provide a short-lived OAuth access token instead of launching browser
|
|
159
|
+
OAuth:
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
new GeoAgentControl({
|
|
163
|
+
earthEngine: {
|
|
164
|
+
accessToken: "SHORT_LIVED_EARTH_ENGINE_ACCESS_TOKEN",
|
|
165
|
+
tokenType: "Bearer",
|
|
166
|
+
tokenExpiresIn: 3600,
|
|
167
|
+
projectId: "your-earth-engine-project",
|
|
168
|
+
includeCommunityCatalog: true,
|
|
169
|
+
},
|
|
170
|
+
});
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Access tokens are passed to the browser JavaScript runtime and should be
|
|
174
|
+
short-lived. Do not persist them in page source, notebooks, local storage, or
|
|
175
|
+
session storage. For untrusted users or production deployments, prefer a
|
|
176
|
+
backend proxy.
|
|
177
|
+
|
|
157
178
|
## Browser Credentials
|
|
158
179
|
|
|
159
180
|
This package runs model SDKs directly in the browser. API keys entered in the
|
|
@@ -3519,7 +3519,7 @@ class HttpProtocol extends SerdeContext {
|
|
|
3519
3519
|
});
|
|
3520
3520
|
}
|
|
3521
3521
|
async loadEventStreamCapability() {
|
|
3522
|
-
const { EventStreamSerde } = await Promise.resolve().then(() => require("./index-
|
|
3522
|
+
const { EventStreamSerde } = await Promise.resolve().then(() => require("./index-DGr_aIvw.cjs"));
|
|
3523
3523
|
return new EventStreamSerde({
|
|
3524
3524
|
marshaller: this.getEventStreamMarshaller(),
|
|
3525
3525
|
serializer: this.serializer,
|
|
@@ -42585,6 +42585,10 @@ function normalizeOptionalString(value) {
|
|
|
42585
42585
|
const text2 = String(value ?? "").trim();
|
|
42586
42586
|
return text2 ? text2 : void 0;
|
|
42587
42587
|
}
|
|
42588
|
+
function normalizeTokenExpiresIn(value) {
|
|
42589
|
+
const seconds = Number(value);
|
|
42590
|
+
return Number.isFinite(seconds) && seconds > 0 ? seconds : 3600;
|
|
42591
|
+
}
|
|
42588
42592
|
class EarthEngineService {
|
|
42589
42593
|
constructor(options = {}) {
|
|
42590
42594
|
__publicField(this, "eePromise", null);
|
|
@@ -42599,10 +42603,12 @@ class EarthEngineService {
|
|
|
42599
42603
|
updateOptions(options) {
|
|
42600
42604
|
const previousOauthClientId = normalizeOptionalString(this.options.oauthClientId);
|
|
42601
42605
|
const previousProjectId = normalizeOptionalString(this.options.projectId);
|
|
42606
|
+
const previousAccessToken = normalizeOptionalString(this.options.accessToken);
|
|
42602
42607
|
const nextOauthClientId = normalizeOptionalString(options.oauthClientId);
|
|
42603
42608
|
const nextProjectId = normalizeOptionalString(options.projectId);
|
|
42609
|
+
const nextAccessToken = normalizeOptionalString(options.accessToken);
|
|
42604
42610
|
this.options = { ...this.options, ...options };
|
|
42605
|
-
if (previousOauthClientId !== nextOauthClientId || previousProjectId !== nextProjectId) {
|
|
42611
|
+
if (previousOauthClientId !== nextOauthClientId || previousProjectId !== nextProjectId || previousAccessToken !== nextAccessToken) {
|
|
42606
42612
|
this.initialized = false;
|
|
42607
42613
|
this.initializedProjectId = void 0;
|
|
42608
42614
|
this.tileUrlCache.clear();
|
|
@@ -42659,7 +42665,7 @@ class EarthEngineService {
|
|
|
42659
42665
|
}
|
|
42660
42666
|
async loadEe() {
|
|
42661
42667
|
if (!this.eePromise) {
|
|
42662
|
-
this.eePromise = Promise.resolve().then(() => require("./browser-
|
|
42668
|
+
this.eePromise = Promise.resolve().then(() => require("./browser-BtMWNaZj.cjs")).then((n) => n.browser).then((module2) => {
|
|
42663
42669
|
const imported = "default" in module2 ? module2.default : module2;
|
|
42664
42670
|
const ee = imported;
|
|
42665
42671
|
const scope2 = globalThis;
|
|
@@ -42723,6 +42729,11 @@ class EarthEngineService {
|
|
|
42723
42729
|
}
|
|
42724
42730
|
async ensureAuthenticated(ee, oauthClientId) {
|
|
42725
42731
|
var _a3, _b3, _c3, _d2, _e2, _f2;
|
|
42732
|
+
const configuredAccessToken = normalizeOptionalString(this.options.accessToken);
|
|
42733
|
+
if (configuredAccessToken) {
|
|
42734
|
+
await this.applyAccessToken(ee, oauthClientId, configuredAccessToken);
|
|
42735
|
+
return;
|
|
42736
|
+
}
|
|
42726
42737
|
const token = (_b3 = (_a3 = ee.data) == null ? void 0 : _a3.getAuthToken) == null ? void 0 : _b3.call(_a3);
|
|
42727
42738
|
const currentAuthClientId = normalizeOptionalString((_d2 = (_c3 = ee.data) == null ? void 0 : _c3.getAuthClientId) == null ? void 0 : _d2.call(_c3));
|
|
42728
42739
|
if (token) {
|
|
@@ -42767,6 +42778,32 @@ class EarthEngineService {
|
|
|
42767
42778
|
});
|
|
42768
42779
|
return this.authPromise;
|
|
42769
42780
|
}
|
|
42781
|
+
async applyAccessToken(ee, oauthClientId, accessToken) {
|
|
42782
|
+
var _a3;
|
|
42783
|
+
if (!((_a3 = ee.data) == null ? void 0 : _a3.setAuthToken)) {
|
|
42784
|
+
throw new Error("Earth Engine token authentication is unavailable.");
|
|
42785
|
+
}
|
|
42786
|
+
const clientId = oauthClientId ?? "";
|
|
42787
|
+
const tokenType = normalizeOptionalString(this.options.tokenType) ?? "Bearer";
|
|
42788
|
+
const expiresIn = normalizeTokenExpiresIn(this.options.tokenExpiresIn);
|
|
42789
|
+
await new Promise((resolve2, reject) => {
|
|
42790
|
+
var _a4, _b3;
|
|
42791
|
+
try {
|
|
42792
|
+
(_b3 = (_a4 = ee.data) == null ? void 0 : _a4.setAuthToken) == null ? void 0 : _b3.call(
|
|
42793
|
+
_a4,
|
|
42794
|
+
clientId,
|
|
42795
|
+
tokenType,
|
|
42796
|
+
accessToken,
|
|
42797
|
+
expiresIn,
|
|
42798
|
+
[],
|
|
42799
|
+
resolve2,
|
|
42800
|
+
false
|
|
42801
|
+
);
|
|
42802
|
+
} catch (error) {
|
|
42803
|
+
reject(new Error(eeErrorMessage(error)));
|
|
42804
|
+
}
|
|
42805
|
+
});
|
|
42806
|
+
}
|
|
42770
42807
|
async catalog(includeCommunity = this.options.includeCommunityCatalog ?? true) {
|
|
42771
42808
|
const key = includeCommunity ? "all" : "official";
|
|
42772
42809
|
const ttl = this.options.catalogCacheTtlMs ?? DEFAULT_CATALOG_CACHE_TTL_MS;
|
|
@@ -46371,7 +46408,7 @@ class GeoAgentControl {
|
|
|
46371
46408
|
}
|
|
46372
46409
|
}
|
|
46373
46410
|
setupEarthEngineControls() {
|
|
46374
|
-
var _a3, _b3;
|
|
46411
|
+
var _a3, _b3, _c3;
|
|
46375
46412
|
if (!this.ui) {
|
|
46376
46413
|
return;
|
|
46377
46414
|
}
|
|
@@ -46383,13 +46420,14 @@ class GeoAgentControl {
|
|
|
46383
46420
|
const oauthClientId = firstValue(
|
|
46384
46421
|
(_a3 = this.options.earthEngine) == null ? void 0 : _a3.oauthClientId
|
|
46385
46422
|
);
|
|
46423
|
+
const accessToken = firstValue((_b3 = this.options.earthEngine) == null ? void 0 : _b3.accessToken);
|
|
46386
46424
|
const projectId = firstValue(
|
|
46387
46425
|
storageGet(this.earthEngineProjectIdStorageKey()),
|
|
46388
|
-
(
|
|
46426
|
+
(_c3 = this.options.earthEngine) == null ? void 0 : _c3.projectId
|
|
46389
46427
|
);
|
|
46390
46428
|
this.ui.earthEngineClientIdInput.value = oauthClientId;
|
|
46391
46429
|
this.ui.earthEngineProjectIdInput.value = projectId;
|
|
46392
|
-
this.ui.earthEngineDetails.open = !oauthClientId || !projectId;
|
|
46430
|
+
this.ui.earthEngineDetails.open = !oauthClientId && !accessToken || !projectId;
|
|
46393
46431
|
this.applyEarthEngineSettings();
|
|
46394
46432
|
}
|
|
46395
46433
|
applyEarthEngineSettings() {
|
|
@@ -46414,15 +46452,16 @@ class GeoAgentControl {
|
|
|
46414
46452
|
this.emit("statechange");
|
|
46415
46453
|
}
|
|
46416
46454
|
updateEarthEngineStatus() {
|
|
46417
|
-
var _a3;
|
|
46455
|
+
var _a3, _b3, _c3;
|
|
46418
46456
|
if (!this.ui || this.ui.earthEngineDetails.hidden) {
|
|
46419
46457
|
return;
|
|
46420
46458
|
}
|
|
46421
46459
|
const oauthClientId = this.ui.earthEngineClientIdInput.value.trim();
|
|
46460
|
+
const accessToken = (_b3 = (_a3 = this.options.earthEngine) == null ? void 0 : _a3.accessToken) == null ? void 0 : _b3.trim();
|
|
46422
46461
|
const projectId = this.ui.earthEngineProjectIdInput.value.trim();
|
|
46423
|
-
const earthEngine = (
|
|
46424
|
-
if (!oauthClientId) {
|
|
46425
|
-
this.ui.earthEngineStatus.textContent = "OAuth Client ID is not configured by this app. Set VITE_GEE_OAUTH_CLIENT_ID before running Earth Engine tools.";
|
|
46462
|
+
const earthEngine = (_c3 = this.state.data) == null ? void 0 : _c3.earthEngine;
|
|
46463
|
+
if (!oauthClientId && !accessToken) {
|
|
46464
|
+
this.ui.earthEngineStatus.textContent = "OAuth Client ID or access token is not configured by this app. Set VITE_GEE_OAUTH_CLIENT_ID or provide earthEngine.accessToken before running Earth Engine tools.";
|
|
46426
46465
|
return;
|
|
46427
46466
|
}
|
|
46428
46467
|
if (!projectId) {
|
|
@@ -46803,7 +46842,7 @@ ${markdown.trim()}`;
|
|
|
46803
46842
|
}
|
|
46804
46843
|
async createProviderModel(providerId, modelId, apiKey, bedrockRegion) {
|
|
46805
46844
|
if (providerId === "openai-responses" || providerId === "openai-chat") {
|
|
46806
|
-
const { OpenAIModel } = await Promise.resolve().then(() => require("./index-
|
|
46845
|
+
const { OpenAIModel } = await Promise.resolve().then(() => require("./index-DaOfppi1.cjs"));
|
|
46807
46846
|
return new OpenAIModel({
|
|
46808
46847
|
api: providerId === "openai-responses" ? "responses" : "chat",
|
|
46809
46848
|
modelId,
|
|
@@ -46814,7 +46853,7 @@ ${markdown.trim()}`;
|
|
|
46814
46853
|
});
|
|
46815
46854
|
}
|
|
46816
46855
|
if (providerId === "anthropic") {
|
|
46817
|
-
const { AnthropicModel } = await Promise.resolve().then(() => require("./anthropic-
|
|
46856
|
+
const { AnthropicModel } = await Promise.resolve().then(() => require("./anthropic-BfFYVXzE.cjs"));
|
|
46818
46857
|
return new AnthropicModel({
|
|
46819
46858
|
modelId,
|
|
46820
46859
|
apiKey,
|
|
@@ -46824,7 +46863,7 @@ ${markdown.trim()}`;
|
|
|
46824
46863
|
});
|
|
46825
46864
|
}
|
|
46826
46865
|
if (providerId === "google") {
|
|
46827
|
-
const { GoogleModel } = await Promise.resolve().then(() => require("./index-
|
|
46866
|
+
const { GoogleModel } = await Promise.resolve().then(() => require("./index-DumDV1aY.cjs"));
|
|
46828
46867
|
return new GoogleModel({
|
|
46829
46868
|
modelId,
|
|
46830
46869
|
apiKey
|
|
@@ -47047,4 +47086,4 @@ exports.toJsonValue = toJsonValue;
|
|
|
47047
47086
|
exports.toMimeType = toMimeType;
|
|
47048
47087
|
exports.toUtf8 = toUtf8;
|
|
47049
47088
|
exports.warnOnce = warnOnce;
|
|
47050
|
-
//# sourceMappingURL=GeoAgentControl-
|
|
47089
|
+
//# sourceMappingURL=GeoAgentControl-Cc0HuUPf.cjs.map
|