Next.js website for Rocky Mountain Vending company featuring: - Product catalog with Stripe integration - Service areas and parts pages - Admin dashboard with Clerk authentication - SEO optimized pages with JSON-LD structured data Co-authored-by: Cursor <cursoragent@cursor.com>
51 lines
No EOL
1.2 KiB
Text
51 lines
No EOL
1.2 KiB
Text
/**
|
|
* @license
|
|
* Copyright 2024 Google Inc.
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
import { source as injectedSource } from '../generated/injected.js';
|
|
/**
|
|
* @internal
|
|
*/
|
|
export class ScriptInjector {
|
|
#updated = false;
|
|
#amendments = new Set();
|
|
// Appends a statement of the form `(PuppeteerUtil) => {...}`.
|
|
append(statement) {
|
|
this.#update(() => {
|
|
this.#amendments.add(statement);
|
|
});
|
|
}
|
|
pop(statement) {
|
|
this.#update(() => {
|
|
this.#amendments.delete(statement);
|
|
});
|
|
}
|
|
inject(inject, force = false) {
|
|
if (this.#updated || force) {
|
|
inject(this.#get());
|
|
}
|
|
this.#updated = false;
|
|
}
|
|
#update(callback) {
|
|
callback();
|
|
this.#updated = true;
|
|
}
|
|
#get() {
|
|
return `(() => {
|
|
const module = {};
|
|
${injectedSource}
|
|
${[...this.#amendments]
|
|
.map(statement => {
|
|
return `(${statement})(module.exports.default);`;
|
|
})
|
|
.join('')}
|
|
return module.exports.default;
|
|
})()`;
|
|
}
|
|
}
|
|
/**
|
|
* @internal
|
|
*/
|
|
export const scriptInjector = new ScriptInjector();
|
|
//# sourceMappingURL=ScriptInjector.js.map |