@plasmicapp/data-sources 1.0.3 → 1.0.4

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/index.js CHANGED
@@ -43,6 +43,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
43
43
  mod
44
44
  ));
45
45
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
46
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
46
47
  var __async = (__this, __arguments, generator) => {
47
48
  return new Promise((resolve, reject) => {
48
49
  var fulfilled = (value) => {
@@ -65,8 +66,8 @@ var __async = (__this, __arguments, generator) => {
65
66
  };
66
67
 
67
68
  // src/index.tsx
68
- var src_exports = {};
69
- __export(src_exports, {
69
+ var index_exports = {};
70
+ __export(index_exports, {
70
71
  Fetcher: () => Fetcher,
71
72
  FetcherMeta: () => FetcherMeta,
72
73
  _StatefulQueryResult: () => StatefulQueryResult,
@@ -84,7 +85,7 @@ __export(src_exports, {
84
85
  usePlasmicDataOp: () => usePlasmicDataOp,
85
86
  usePlasmicInvalidate: () => usePlasmicInvalidate
86
87
  });
87
- module.exports = __toCommonJS(src_exports);
88
+ module.exports = __toCommonJS(index_exports);
88
89
 
89
90
  // src/serverQueries/client.ts
90
91
  var import_query2 = require("@plasmicapp/query");
@@ -324,7 +325,9 @@ function createDollarQueries(queryNames) {
324
325
  }
325
326
  var StatefulQueryResult = class {
326
327
  constructor() {
327
- this.listeners = /* @__PURE__ */ new Set();
328
+ __publicField(this, "current");
329
+ __publicField(this, "settable");
330
+ __publicField(this, "listeners", /* @__PURE__ */ new Set());
328
331
  this.current = { state: "initial", key: null };
329
332
  this.settable = new SettablePromise();
330
333
  tagPlasmicUndefinedDataErrorPromise(this.settable.promise);
@@ -470,8 +473,8 @@ function resolveParams(params) {
470
473
  function wrapDollarQueriesForMetadata($queries, ifUndefined, ifError) {
471
474
  return wrapDollarQueriesWithFallbacks(
472
475
  $queries,
473
- ifUndefined != null ? ifUndefined : () => "\u2026",
474
- ifError != null ? ifError : () => "[ERROR]"
476
+ ifUndefined != null ? ifUndefined : (() => "\u2026"),
477
+ ifError != null ? ifError : (() => "[ERROR]")
475
478
  );
476
479
  }
477
480
  function wrapDollarQueriesWithFallbacks($queries, ifUndefined, ifError) {
@@ -482,9 +485,9 @@ function wrapDollarQueriesWithFallbacks($queries, ifUndefined, ifError) {
482
485
  }
483
486
  var FallbackQueryResult = class {
484
487
  constructor($query, ifUndefined, ifError) {
485
- this.$query = $query;
486
- this.ifUndefined = ifUndefined;
487
- this.ifError = ifError;
488
+ __publicField(this, "$query", $query);
489
+ __publicField(this, "ifUndefined", ifUndefined);
490
+ __publicField(this, "ifError", ifError);
488
491
  }
489
492
  get key() {
490
493
  return this.$query.key;
@@ -513,8 +516,8 @@ function createConstantProxy(constant) {
513
516
  }
514
517
  var SyncPromise = class {
515
518
  constructor(promise) {
516
- this.promise = promise;
517
- this.result = void 0;
519
+ __publicField(this, "promise", promise);
520
+ __publicField(this, "result");
518
521
  promise.then(
519
522
  (value) => {
520
523
  this.result = {
@@ -546,6 +549,9 @@ function shallowEqualRecords(a, b) {
546
549
  }
547
550
  var SettablePromise = class {
548
551
  constructor() {
552
+ __publicField(this, "promise");
553
+ __publicField(this, "_resolve");
554
+ __publicField(this, "_reject");
549
555
  this.promise = new Promise((resolve, reject) => {
550
556
  this._resolve = resolve;
551
557
  this._reject = reject;
@@ -699,7 +705,7 @@ function usePlasmicQueries(tree, $props, $ctx, $state) {
699
705
  }
700
706
  }
701
707
  let cleanup = false;
702
- const loop = () => __async(this, null, function* () {
708
+ const loop = () => __async(null, null, function* () {
703
709
  while (true) {
704
710
  initPlasmicQueriesSync(
705
711
  $queryStates,
@@ -1250,7 +1256,7 @@ function makeCacheKey(dataOp, opts) {
1250
1256
  }
1251
1257
  function usePlasmicInvalidate() {
1252
1258
  const { cache, fallback, mutate } = (0, import_query4.usePlasmicDataConfig)();
1253
- return (invalidatedKeys) => __async(this, null, function* () {
1259
+ return (invalidatedKeys) => __async(null, null, function* () {
1254
1260
  const getKeysToInvalidate = () => {
1255
1261
  var _a, _b;
1256
1262
  if (!invalidatedKeys) {
@@ -1288,7 +1294,7 @@ function usePlasmicInvalidate() {
1288
1294
  if (keys.length === 0) {
1289
1295
  return;
1290
1296
  }
1291
- const invalidateKey = (key) => __async(this, null, function* () {
1297
+ const invalidateKey = (key) => __async(null, null, function* () {
1292
1298
  const studioInvalidate = globalThis.__PLASMIC_MUTATE_DATA_OP;
1293
1299
  if (studioInvalidate) {
1294
1300
  yield studioInvalidate(key);
@@ -1344,8 +1350,8 @@ function usePlasmicDataOp(dataOp, opts) {
1344
1350
  function usePlasmicDataMutationOp(dataOp) {
1345
1351
  const ctx = (0, import_data_sources_context.usePlasmicDataSourceContext)();
1346
1352
  const userToken = ctx == null ? void 0 : ctx.userAuthToken;
1347
- const getRealDataOp = React4.useCallback(() => __async(this, null, function* () {
1348
- const tryGetRealDataOp = () => __async(this, null, function* () {
1353
+ const getRealDataOp = React4.useCallback(() => __async(null, null, function* () {
1354
+ const tryGetRealDataOp = () => __async(null, null, function* () {
1349
1355
  const resolved = resolveDataOp(dataOp);
1350
1356
  if (!resolved) {
1351
1357
  return null;
@@ -1358,7 +1364,7 @@ function usePlasmicDataMutationOp(dataOp) {
1358
1364
  });
1359
1365
  return yield tryGetRealDataOp();
1360
1366
  }), [dataOp]);
1361
- return React4.useCallback(() => __async(this, null, function* () {
1367
+ return React4.useCallback(() => __async(null, null, function* () {
1362
1368
  var _a;
1363
1369
  const { sourceId, opId, userArgs } = (_a = yield getRealDataOp()) != null ? _a : {};
1364
1370
  if (!sourceId || !opId) {