@shopify/react-html
Version:
A component to render your react app with no static HTML.
49 lines (48 loc) • 1.57 kB
JavaScript
;
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spread = (this && this.__spread) || function () {
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
return ar;
};
Object.defineProperty(exports, "__esModule", { value: true });
var utilities_1 = require("./utilities");
var Manager = /** @class */ (function () {
function Manager() {
this.isServer = typeof document === 'undefined';
this.serializations = utilities_1.getSerializationsFromDocument();
}
Manager.prototype.set = function (id, data) {
if (this.isServer) {
this.serializations.set(id, data);
}
};
Manager.prototype.get = function (id) {
return this.serializations.get(id);
};
Manager.prototype.extract = function () {
return __spread(this.serializations.entries()).map(function (_a) {
var _b = __read(_a, 2), id = _b[0], data = _b[1];
return ({
id: id,
data: data,
});
});
};
return Manager;
}());
exports.default = Manager;