PageSourceSearch

https://dorsetcountymuseum.org/packages/reload.js?hash=54bb13070bdab735454f824bc9203d9a45b63b94

js dorsetcountymuseum.org collected 2026-09-24 09:57:10 UTC 10,810 bytes, 333 lines download raw bytes

1//////////////////////////////////////////////////////////////////////////
2//                                                                      //
3// This is a generated file. You can view the original                  //
4// source in your browser if your browser supports source maps.         //
5// Source maps are supported by all recent versions of Chrome, Safari,  //
6// and Firefox, and by Internet Explorer 11.                            //
7//                                                                      //
8//////////////////////////////////////////////////////////////////////////
9
10
11Package["core-runtime"].queue("reload",function () {/* Imports */
12var Meteor = Package.meteor.Meteor;
13var global = Package.meteor.global;
14var meteorEnv = Package.meteor.meteorEnv;
15var meteorInstall = Package.modules.meteorInstall;
16var meteorBabelHelpers = Package.modules.meteorBabelHelpers;
17var Promise = Package.promise.Promise;
18var Symbol = Package['ecmascript-runtime-client'].Symbol;
19var Map = Package['ecmascript-runtime-client'].Map;
20var Set = Package['ecmascript-runtime-client'].Set;
21
22/* Package-scope variables */
23var Reload;
24
25var require = meteorInstall({"node_modules":{"meteor":{"reload":{
25"reload.js":function module(require,exports,module){
26
27//////////////////////////////////////////////////////////////////////////////////////////////////////////
28//                                                                                                      //
29// packages/reload/reload.js                                                                            //
30//                                                                                                      //
31//////////////////////////////////////////////////////////////////////////////////////////////////////////
32                                                                                                        //
33var _slicedToArray;
34module.link("@babel/runtime/helpers/slicedToArray", {
35  default: function (v) {
36    _slicedToArray = v;
37  }
38}, 0);
39var _typeof;
40module.link("@babel/runtime/helpers/typeof", {
41  default: function (v) {
42    _typeof = v;
43  }
44}, 1);
45module.export({
46  Reload: function () {
47    return Reload;
48  }
49});
50var Reload = {};
51var reloadSettings = Meteor.settings && Meteor.settings.public && Meteor.settings.public.packages && Meteor.settings.public.packages.reload || {};
52function debug(message, context) {
53  if (!reloadSettings.debug) {
54    return;
55  }
56  // eslint-disable-next-line no-console
57  console.log("[reload] " + message, JSON.stringify(context));
58}
59var KEY_NAME = 'Meteor_Reload';
60var old_data = {};
61// read in old data at startup.
62var old_json;
63
64// This logic for sessionStorage detection is based on browserstate/history.js
65var safeSessionStorage = null;
66try {
67  // This throws a SecurityError on Chrome if cookies & localStorage are
68  // explicitly disabled
69  //
70  // On Firefox with dom.storage.enabled set to false, sessionStorage is null
71  //
72  // We can't even do (typeof sessionStorage) on Chrome, it throws.  So we rely
73  // on the throw if sessionStorage == null; the alternative is browser
74  // detection, but this seems better.
75  safeSessionStorage = window.sessionStorage;
76
77  // Check we can actually use it
78  if (safeSessionStorage) {
79    safeSessionStorage.setItem('__dummy__', '1');
80    safeSessionStorage.removeItem('__dummy__');
81  } else {
82    // Be consistently null, for safety
83    safeSessionStorage = null;
84  }
85} catch (e) {
86  // Expected on chrome with strict security, or if sessionStorage not supported
87  safeSessionStorage = null;
88}
89
90// Exported for test.
91Reload._getData = function () {
92  return safeSessionStorage && safeSessionStorage.getItem(KEY_NAME);
93};
94if (safeSessionStorage) {
95  old_json = Reload._getData();
96  safeSessionStorage.removeItem(KEY_NAME);
97} else {
98  // Unsupported browser (IE 6,7) or locked down security settings.
99  // No session resumption.
100  // Meteor._debug("XXX UNSUPPORTED BROWSER/SETTINGS");
101}
102if (!old_json) old_json = '{}';
103var old_parsed = {};
104try {
105  old_parsed = JSON.parse(old_json);
106  if (_typeof(old_parsed) !== 'object') {
107    Meteor._debug('Got bad data on reload. Ignoring.');
108    old_parsed = {};
109  }
110} catch (err) {
111  Meteor._debug('Got invalid JSON on reload. Ignoring.');
112}
113if (old_parsed.reload && _typeof(old_parsed.data) === 'object') {
114  // Meteor._debug("Restoring reload data.");
115  old_data = old_parsed.data;
116}
117var providers = [];
118
119////////// External API //////////
120
121// Packages that support migration should register themselves by calling
122// this function. When it's time to migrate, callback will be called
123// with one argument, the "retry function," and an optional 'option'
124// argument (containing a key 'immediateMigration'). If the package
125// is ready to migrate, it should return [true, data], where data is
126// its migration data, an arbitrary JSON value (or [true] if it has
127// no migration data this time). If the package needs more time
128// before it is ready to migrate, it should return false. Then, once
129// it is ready to migrating again, it should call the retry
130// function. The retry function will return immediately, but will
131// schedule the migration to be retried, meaning that every package
132// will be polled once again for its migration data. If they are all
133// ready this time, then the migration will happen. name must be set if there
134// is migration data. If 'immediateMigration' is set in the options
135// argument, then it doesn't matter whether the package is ready to
136// migrate or not; the reload will happen immediately without waiting
137// (used for OAuth redirect login).
138//
139Reload._onMigrate = function (name, callback) {
140  debug('_onMigrate', {
141    name: name
142  });
143  if (!callback) {
144    // name not provided, so first arg is callback.
145    callback = name;
146    name = undefined;
147    debug('_onMigrate no callback');
148  }
149  providers.push({
150    name: name,
151    callback: callback
152  });
153};
154
155// Called by packages when they start up.
156// Returns the object that was saved, or undefined if none saved.
157//
158Reload._migrationData = function (name) {
159  debug('_migrationData', {
160    name: name
161  });
162  return old_data[name];
163};
164
165// Options are the same as for `Reload._migrate`.
166var pollProviders = function (tryReload, options) {
167  debug('pollProviders', {
168    options: options
169  });
170  tryReload = tryReload || function () {};
171  options = options || {};
172  var _options = options,
173    immediateMigration = _options.immediateMigration;
174  debug("pollProviders is " + (immediateMigration ? '' : 'NOT ') + "immediateMigration", {
175    options: options
176  });
177  var migrationData = {};
178  var allReady = true;
179  providers.forEach(function (p) {
180    var _ref = p || {},
181      callback = _ref.callback,
182      name = _ref.name;
183    var _ref2 = callback(tryReload, options) || [],
184      _ref3 = _slicedToArray(_ref2, 2),
185      ready = _ref3[0],
186      data = _ref3[1];
187    debug("pollProviders provider " + (name || 'unknown') + " is " + (ready ? 'ready' : 'NOT ready'), {
188      options: options
189    });
190    if (!ready) {
191      allReady = false;
192    }
193    if (data !== undefined && name) {
194      migrationData[name] = data;
195    }
196  });
197  if (allReady) {
198    debug('pollProviders allReady', {
199      options: options,
200      migrationData: migrationData
201    });
202    return migrationData;
203  }
204  if (immediateMigration) {
205    debug('pollProviders immediateMigration', {
206      options: options,
207      migrationData: migrationData
208    });
209    return migrationData;
210  }
211  return null;
212};
213
214// Options are:
215//  - immediateMigration: true if the page will be reloaded immediately
216//    regardless of whether packages report that they are ready or not.
217Reload._migrate = function (tryReload, options) {
218  debug('_migrate', {
219    options: options
220  });
221  // Make sure each package is ready to go, and collect their
222  // migration data
223  var migrationData = pollProviders(tryReload, options);
224  if (migrationData === null) {
225    return false; // not ready yet..
226  }
227  var json;
228  try {
229    // Persist the migration data
230    json = JSON.stringify({
231      data: migrationData,
232      reload: true
233    });
234  } catch (err) {
235    Meteor._debug("Couldn't serialize data for migration", migrationData);
236    throw err;
237  }
238  if (safeSessionStorage) {
239    try {
240      safeSessionStorage.setItem(KEY_NAME, json);
241    } catch (err) {
242      // We should have already checked this, but just log - don't throw
243      Meteor._debug("Couldn't save data for migration to sessionStorage", err);
244    }
245  } else {
246    Meteor._debug('Browser does not support sessionStorage. Not saving migration state.');
247  }
248  return true;
249};
250
251// Allows tests to isolate the list of providers.
252Reload._withFreshProvidersForTest = function (f) {
253  var originalProviders = providers.slice(0);
254  providers = [];
255  try {
256    f();
257  } finally {
258    providers = originalProviders;
259  }
260};
261
262// Migrating reload: reload this page (presumably to pick up a new
263// version of the code or assets), but save the program state and
264// migrate it over. This function returns immediately. The reload
265// will happen at some point in the future once all of the packages
266// are ready to migrate.
267//
268var reloading = false;
269Reload._reload = function (options) {
270  debug('_reload', {
271    options: options
272  });
273  options = options || {};
274  if (reloading) {
275    debug('reloading in progress already', {
276      options: options
277    });
278    return;
279  }
280  reloading = true;
281  function tryReload() {
282    debug('tryReload');
283    setTimeout(reload, 1);
284  }
285  function forceBrowserReload() {
286    debug('forceBrowserReload');
287    // We'd like to make the browser reload the page using location.replace()
288    // instead of location.reload(), because this avoids validating assets
289    // with the server if we still have a valid cached copy. This doesn't work
290    // when the location contains a hash however, because that wouldn't reload
291    // the page and just scroll to the hash location instead.
292    if (window.location.hash || window.location.href.endsWith('#')) {
293      window.location.reload();
294      return;
295    }
296    window.location.replace(window.location.href);
297  }
298  function reload() {
299    debug('reload');
300    if (!Reload._migrate(tryReload, options)) {
301      return;
302    }
303    if (Meteor.isCordova) {
304      WebAppLocalServer.switchToPendingVersion(function () {
305        forceBrowserReload();
306      });
307      return;
308    }
309    forceBrowserReload();
310  }
311  tryReload();
312};
313//////////////////////////////////////////////////////////////////////////////////////////////////////////
314
315}
315}}}},{
316  "extensions": [
317    ".js",
318    ".json"
319  ]
320});
321
322
323/* Exports */
324return {
325  export: function () { return {
326      Reload: Reload
327    };},
328  require: require,
329  eagerModulePaths: [
330    "/node_modules/meteor/reload/reload.js"
331  ],
332  mainModulePath: "/node_modules/meteor/reload/reload.js"
333}});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.