@slicemachine/adapter-next 0.3.85-beta.2 → 0.3.85-beta.3
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/_node_modules/lru-cache/index.cjs +267 -0
- package/dist/_node_modules/lru-cache/index.cjs.map +1 -0
- package/dist/_node_modules/lru-cache/index.js +267 -0
- package/dist/_node_modules/lru-cache/index.js.map +1 -0
- package/dist/_node_modules/yallist/iterator.cjs +18 -0
- package/dist/_node_modules/yallist/iterator.cjs.map +1 -0
- package/dist/_node_modules/yallist/iterator.js +18 -0
- package/dist/_node_modules/yallist/iterator.js.map +1 -0
- package/dist/_node_modules/yallist/yallist.cjs +367 -0
- package/dist/_node_modules/yallist/yallist.cjs.map +1 -0
- package/dist/_node_modules/yallist/yallist.js +367 -0
- package/dist/_node_modules/yallist/yallist.js.map +1 -0
- package/dist/_virtual/_commonjsHelpers.cjs +7 -0
- package/dist/_virtual/_commonjsHelpers.cjs.map +1 -0
- package/dist/_virtual/_commonjsHelpers.js +7 -0
- package/dist/_virtual/_commonjsHelpers.js.map +1 -0
- package/dist/_virtual/re.cjs +5 -0
- package/dist/_virtual/re.cjs.map +1 -0
- package/dist/_virtual/re.js +5 -0
- package/dist/_virtual/re.js.map +1 -0
- package/dist/hooks/project-init.cjs +5 -1
- package/dist/hooks/project-init.cjs.map +1 -1
- package/dist/hooks/project-init.js +5 -1
- package/dist/hooks/project-init.js.map +1 -1
- package/dist/lib/getNextJSVersion.cjs +34 -0
- package/dist/lib/getNextJSVersion.cjs.map +1 -0
- package/dist/lib/getNextJSVersion.d.ts +1 -0
- package/dist/lib/getNextJSVersion.js +12 -0
- package/dist/lib/getNextJSVersion.js.map +1 -0
- package/dist/lib/requireResolve.cjs +16 -0
- package/dist/lib/requireResolve.cjs.map +1 -0
- package/dist/lib/requireResolve.d.ts +10 -0
- package/dist/lib/requireResolve.js +16 -0
- package/dist/lib/requireResolve.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/classes/comparator.cjs +122 -0
- package/dist/packages/adapter-next/_node_modules/semver/classes/comparator.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/classes/comparator.js +122 -0
- package/dist/packages/adapter-next/_node_modules/semver/classes/comparator.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/classes/range.cjs +373 -0
- package/dist/packages/adapter-next/_node_modules/semver/classes/range.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/classes/range.js +373 -0
- package/dist/packages/adapter-next/_node_modules/semver/classes/range.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/classes/semver.cjs +243 -0
- package/dist/packages/adapter-next/_node_modules/semver/classes/semver.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/classes/semver.js +243 -0
- package/dist/packages/adapter-next/_node_modules/semver/classes/semver.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/clean.cjs +11 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/clean.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/clean.js +11 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/clean.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/cmp.cjs +53 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/cmp.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/cmp.js +53 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/cmp.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/coerce.cjs +40 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/coerce.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/coerce.js +40 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/coerce.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/compare-build.cjs +12 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/compare-build.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/compare-build.js +12 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/compare-build.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/compare-loose.cjs +8 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/compare-loose.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/compare-loose.js +8 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/compare-loose.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/compare.cjs +8 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/compare.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/compare.js +8 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/compare.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/diff.cjs +39 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/diff.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/diff.js +39 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/diff.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/eq.cjs +8 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/eq.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/eq.js +8 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/eq.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/gt.cjs +8 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/gt.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/gt.js +8 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/gt.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/gte.cjs +8 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/gte.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/gte.js +8 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/gte.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/inc.cjs +22 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/inc.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/inc.js +22 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/inc.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/lt.cjs +8 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/lt.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/lt.js +8 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/lt.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/lte.cjs +8 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/lte.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/lte.js +8 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/lte.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/major.cjs +8 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/major.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/major.js +8 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/major.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/minor.cjs +8 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/minor.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/minor.js +8 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/minor.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/neq.cjs +8 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/neq.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/neq.js +8 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/neq.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/parse.cjs +20 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/parse.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/parse.js +20 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/parse.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/patch.cjs +8 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/patch.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/patch.js +8 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/patch.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/prerelease.cjs +11 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/prerelease.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/prerelease.js +11 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/prerelease.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/rcompare.cjs +8 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/rcompare.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/rcompare.js +8 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/rcompare.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/rsort.cjs +8 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/rsort.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/rsort.js +8 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/rsort.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/satisfies.cjs +15 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/satisfies.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/satisfies.js +15 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/satisfies.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/sort.cjs +8 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/sort.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/sort.js +8 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/sort.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/valid.cjs +11 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/valid.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/valid.js +11 -0
- package/dist/packages/adapter-next/_node_modules/semver/functions/valid.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/index.cjs +134 -0
- package/dist/packages/adapter-next/_node_modules/semver/index.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/index.js +135 -0
- package/dist/packages/adapter-next/_node_modules/semver/index.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/internal/constants.cjs +27 -0
- package/dist/packages/adapter-next/_node_modules/semver/internal/constants.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/internal/constants.js +27 -0
- package/dist/packages/adapter-next/_node_modules/semver/internal/constants.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/internal/debug.cjs +7 -0
- package/dist/packages/adapter-next/_node_modules/semver/internal/debug.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/internal/debug.js +7 -0
- package/dist/packages/adapter-next/_node_modules/semver/internal/debug.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/internal/identifiers.cjs +19 -0
- package/dist/packages/adapter-next/_node_modules/semver/internal/identifiers.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/internal/identifiers.js +19 -0
- package/dist/packages/adapter-next/_node_modules/semver/internal/identifiers.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/internal/parse-options.cjs +16 -0
- package/dist/packages/adapter-next/_node_modules/semver/internal/parse-options.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/internal/parse-options.js +16 -0
- package/dist/packages/adapter-next/_node_modules/semver/internal/parse-options.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/internal/re.cjs +67 -0
- package/dist/packages/adapter-next/_node_modules/semver/internal/re.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/internal/re.js +67 -0
- package/dist/packages/adapter-next/_node_modules/semver/internal/re.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/gtr.cjs +8 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/gtr.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/gtr.js +8 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/gtr.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/intersects.cjs +12 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/intersects.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/intersects.js +12 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/intersects.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/ltr.cjs +8 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/ltr.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/ltr.js +8 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/ltr.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/max-satisfying.cjs +28 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/max-satisfying.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/max-satisfying.js +28 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/max-satisfying.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/min-satisfying.cjs +28 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/min-satisfying.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/min-satisfying.js +28 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/min-satisfying.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/min-version.cjs +57 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/min-version.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/min-version.js +57 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/min-version.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/outside.cjs +74 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/outside.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/outside.js +74 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/outside.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/simplify.cjs +49 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/simplify.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/simplify.js +49 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/simplify.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/subset.cjs +163 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/subset.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/subset.js +163 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/subset.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/to-comparators.cjs +8 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/to-comparators.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/to-comparators.js +8 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/to-comparators.js.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/valid.cjs +14 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/valid.cjs.map +1 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/valid.js +14 -0
- package/dist/packages/adapter-next/_node_modules/semver/ranges/valid.js.map +1 -0
- package/dist/plugin.cjs +1 -1
- package/dist/plugin.js +1 -1
- package/package.json +6 -6
- package/src/hooks/project-init.ts +6 -1
- package/src/lib/getNextJSVersion.ts +16 -0
- package/src/lib/requireResolve.ts +30 -0
- /package/dist/{package.json.cjs → packages/adapter-next/package.json.cjs} +0 -0
- /package/dist/{package.json.cjs.map → packages/adapter-next/package.json.cjs.map} +0 -0
- /package/dist/{package.json.js → packages/adapter-next/package.json.js} +0 -0
- /package/dist/{package.json.js.map → packages/adapter-next/package.json.js.map} +0 -0
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
import { __require as requireIterator } from "./iterator.js";
|
|
2
|
+
var yallist = Yallist;
|
|
3
|
+
Yallist.Node = Node;
|
|
4
|
+
Yallist.create = Yallist;
|
|
5
|
+
function Yallist(list) {
|
|
6
|
+
var self = this;
|
|
7
|
+
if (!(self instanceof Yallist)) {
|
|
8
|
+
self = new Yallist();
|
|
9
|
+
}
|
|
10
|
+
self.tail = null;
|
|
11
|
+
self.head = null;
|
|
12
|
+
self.length = 0;
|
|
13
|
+
if (list && typeof list.forEach === "function") {
|
|
14
|
+
list.forEach(function(item) {
|
|
15
|
+
self.push(item);
|
|
16
|
+
});
|
|
17
|
+
} else if (arguments.length > 0) {
|
|
18
|
+
for (var i = 0, l = arguments.length; i < l; i++) {
|
|
19
|
+
self.push(arguments[i]);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return self;
|
|
23
|
+
}
|
|
24
|
+
Yallist.prototype.removeNode = function(node) {
|
|
25
|
+
if (node.list !== this) {
|
|
26
|
+
throw new Error("removing node which does not belong to this list");
|
|
27
|
+
}
|
|
28
|
+
var next = node.next;
|
|
29
|
+
var prev = node.prev;
|
|
30
|
+
if (next) {
|
|
31
|
+
next.prev = prev;
|
|
32
|
+
}
|
|
33
|
+
if (prev) {
|
|
34
|
+
prev.next = next;
|
|
35
|
+
}
|
|
36
|
+
if (node === this.head) {
|
|
37
|
+
this.head = next;
|
|
38
|
+
}
|
|
39
|
+
if (node === this.tail) {
|
|
40
|
+
this.tail = prev;
|
|
41
|
+
}
|
|
42
|
+
node.list.length--;
|
|
43
|
+
node.next = null;
|
|
44
|
+
node.prev = null;
|
|
45
|
+
node.list = null;
|
|
46
|
+
return next;
|
|
47
|
+
};
|
|
48
|
+
Yallist.prototype.unshiftNode = function(node) {
|
|
49
|
+
if (node === this.head) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (node.list) {
|
|
53
|
+
node.list.removeNode(node);
|
|
54
|
+
}
|
|
55
|
+
var head = this.head;
|
|
56
|
+
node.list = this;
|
|
57
|
+
node.next = head;
|
|
58
|
+
if (head) {
|
|
59
|
+
head.prev = node;
|
|
60
|
+
}
|
|
61
|
+
this.head = node;
|
|
62
|
+
if (!this.tail) {
|
|
63
|
+
this.tail = node;
|
|
64
|
+
}
|
|
65
|
+
this.length++;
|
|
66
|
+
};
|
|
67
|
+
Yallist.prototype.pushNode = function(node) {
|
|
68
|
+
if (node === this.tail) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (node.list) {
|
|
72
|
+
node.list.removeNode(node);
|
|
73
|
+
}
|
|
74
|
+
var tail = this.tail;
|
|
75
|
+
node.list = this;
|
|
76
|
+
node.prev = tail;
|
|
77
|
+
if (tail) {
|
|
78
|
+
tail.next = node;
|
|
79
|
+
}
|
|
80
|
+
this.tail = node;
|
|
81
|
+
if (!this.head) {
|
|
82
|
+
this.head = node;
|
|
83
|
+
}
|
|
84
|
+
this.length++;
|
|
85
|
+
};
|
|
86
|
+
Yallist.prototype.push = function() {
|
|
87
|
+
for (var i = 0, l = arguments.length; i < l; i++) {
|
|
88
|
+
push(this, arguments[i]);
|
|
89
|
+
}
|
|
90
|
+
return this.length;
|
|
91
|
+
};
|
|
92
|
+
Yallist.prototype.unshift = function() {
|
|
93
|
+
for (var i = 0, l = arguments.length; i < l; i++) {
|
|
94
|
+
unshift(this, arguments[i]);
|
|
95
|
+
}
|
|
96
|
+
return this.length;
|
|
97
|
+
};
|
|
98
|
+
Yallist.prototype.pop = function() {
|
|
99
|
+
if (!this.tail) {
|
|
100
|
+
return void 0;
|
|
101
|
+
}
|
|
102
|
+
var res = this.tail.value;
|
|
103
|
+
this.tail = this.tail.prev;
|
|
104
|
+
if (this.tail) {
|
|
105
|
+
this.tail.next = null;
|
|
106
|
+
} else {
|
|
107
|
+
this.head = null;
|
|
108
|
+
}
|
|
109
|
+
this.length--;
|
|
110
|
+
return res;
|
|
111
|
+
};
|
|
112
|
+
Yallist.prototype.shift = function() {
|
|
113
|
+
if (!this.head) {
|
|
114
|
+
return void 0;
|
|
115
|
+
}
|
|
116
|
+
var res = this.head.value;
|
|
117
|
+
this.head = this.head.next;
|
|
118
|
+
if (this.head) {
|
|
119
|
+
this.head.prev = null;
|
|
120
|
+
} else {
|
|
121
|
+
this.tail = null;
|
|
122
|
+
}
|
|
123
|
+
this.length--;
|
|
124
|
+
return res;
|
|
125
|
+
};
|
|
126
|
+
Yallist.prototype.forEach = function(fn, thisp) {
|
|
127
|
+
thisp = thisp || this;
|
|
128
|
+
for (var walker = this.head, i = 0; walker !== null; i++) {
|
|
129
|
+
fn.call(thisp, walker.value, i, this);
|
|
130
|
+
walker = walker.next;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
Yallist.prototype.forEachReverse = function(fn, thisp) {
|
|
134
|
+
thisp = thisp || this;
|
|
135
|
+
for (var walker = this.tail, i = this.length - 1; walker !== null; i--) {
|
|
136
|
+
fn.call(thisp, walker.value, i, this);
|
|
137
|
+
walker = walker.prev;
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
Yallist.prototype.get = function(n) {
|
|
141
|
+
for (var i = 0, walker = this.head; walker !== null && i < n; i++) {
|
|
142
|
+
walker = walker.next;
|
|
143
|
+
}
|
|
144
|
+
if (i === n && walker !== null) {
|
|
145
|
+
return walker.value;
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
Yallist.prototype.getReverse = function(n) {
|
|
149
|
+
for (var i = 0, walker = this.tail; walker !== null && i < n; i++) {
|
|
150
|
+
walker = walker.prev;
|
|
151
|
+
}
|
|
152
|
+
if (i === n && walker !== null) {
|
|
153
|
+
return walker.value;
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
Yallist.prototype.map = function(fn, thisp) {
|
|
157
|
+
thisp = thisp || this;
|
|
158
|
+
var res = new Yallist();
|
|
159
|
+
for (var walker = this.head; walker !== null; ) {
|
|
160
|
+
res.push(fn.call(thisp, walker.value, this));
|
|
161
|
+
walker = walker.next;
|
|
162
|
+
}
|
|
163
|
+
return res;
|
|
164
|
+
};
|
|
165
|
+
Yallist.prototype.mapReverse = function(fn, thisp) {
|
|
166
|
+
thisp = thisp || this;
|
|
167
|
+
var res = new Yallist();
|
|
168
|
+
for (var walker = this.tail; walker !== null; ) {
|
|
169
|
+
res.push(fn.call(thisp, walker.value, this));
|
|
170
|
+
walker = walker.prev;
|
|
171
|
+
}
|
|
172
|
+
return res;
|
|
173
|
+
};
|
|
174
|
+
Yallist.prototype.reduce = function(fn, initial) {
|
|
175
|
+
var acc;
|
|
176
|
+
var walker = this.head;
|
|
177
|
+
if (arguments.length > 1) {
|
|
178
|
+
acc = initial;
|
|
179
|
+
} else if (this.head) {
|
|
180
|
+
walker = this.head.next;
|
|
181
|
+
acc = this.head.value;
|
|
182
|
+
} else {
|
|
183
|
+
throw new TypeError("Reduce of empty list with no initial value");
|
|
184
|
+
}
|
|
185
|
+
for (var i = 0; walker !== null; i++) {
|
|
186
|
+
acc = fn(acc, walker.value, i);
|
|
187
|
+
walker = walker.next;
|
|
188
|
+
}
|
|
189
|
+
return acc;
|
|
190
|
+
};
|
|
191
|
+
Yallist.prototype.reduceReverse = function(fn, initial) {
|
|
192
|
+
var acc;
|
|
193
|
+
var walker = this.tail;
|
|
194
|
+
if (arguments.length > 1) {
|
|
195
|
+
acc = initial;
|
|
196
|
+
} else if (this.tail) {
|
|
197
|
+
walker = this.tail.prev;
|
|
198
|
+
acc = this.tail.value;
|
|
199
|
+
} else {
|
|
200
|
+
throw new TypeError("Reduce of empty list with no initial value");
|
|
201
|
+
}
|
|
202
|
+
for (var i = this.length - 1; walker !== null; i--) {
|
|
203
|
+
acc = fn(acc, walker.value, i);
|
|
204
|
+
walker = walker.prev;
|
|
205
|
+
}
|
|
206
|
+
return acc;
|
|
207
|
+
};
|
|
208
|
+
Yallist.prototype.toArray = function() {
|
|
209
|
+
var arr = new Array(this.length);
|
|
210
|
+
for (var i = 0, walker = this.head; walker !== null; i++) {
|
|
211
|
+
arr[i] = walker.value;
|
|
212
|
+
walker = walker.next;
|
|
213
|
+
}
|
|
214
|
+
return arr;
|
|
215
|
+
};
|
|
216
|
+
Yallist.prototype.toArrayReverse = function() {
|
|
217
|
+
var arr = new Array(this.length);
|
|
218
|
+
for (var i = 0, walker = this.tail; walker !== null; i++) {
|
|
219
|
+
arr[i] = walker.value;
|
|
220
|
+
walker = walker.prev;
|
|
221
|
+
}
|
|
222
|
+
return arr;
|
|
223
|
+
};
|
|
224
|
+
Yallist.prototype.slice = function(from, to) {
|
|
225
|
+
to = to || this.length;
|
|
226
|
+
if (to < 0) {
|
|
227
|
+
to += this.length;
|
|
228
|
+
}
|
|
229
|
+
from = from || 0;
|
|
230
|
+
if (from < 0) {
|
|
231
|
+
from += this.length;
|
|
232
|
+
}
|
|
233
|
+
var ret = new Yallist();
|
|
234
|
+
if (to < from || to < 0) {
|
|
235
|
+
return ret;
|
|
236
|
+
}
|
|
237
|
+
if (from < 0) {
|
|
238
|
+
from = 0;
|
|
239
|
+
}
|
|
240
|
+
if (to > this.length) {
|
|
241
|
+
to = this.length;
|
|
242
|
+
}
|
|
243
|
+
for (var i = 0, walker = this.head; walker !== null && i < from; i++) {
|
|
244
|
+
walker = walker.next;
|
|
245
|
+
}
|
|
246
|
+
for (; walker !== null && i < to; i++, walker = walker.next) {
|
|
247
|
+
ret.push(walker.value);
|
|
248
|
+
}
|
|
249
|
+
return ret;
|
|
250
|
+
};
|
|
251
|
+
Yallist.prototype.sliceReverse = function(from, to) {
|
|
252
|
+
to = to || this.length;
|
|
253
|
+
if (to < 0) {
|
|
254
|
+
to += this.length;
|
|
255
|
+
}
|
|
256
|
+
from = from || 0;
|
|
257
|
+
if (from < 0) {
|
|
258
|
+
from += this.length;
|
|
259
|
+
}
|
|
260
|
+
var ret = new Yallist();
|
|
261
|
+
if (to < from || to < 0) {
|
|
262
|
+
return ret;
|
|
263
|
+
}
|
|
264
|
+
if (from < 0) {
|
|
265
|
+
from = 0;
|
|
266
|
+
}
|
|
267
|
+
if (to > this.length) {
|
|
268
|
+
to = this.length;
|
|
269
|
+
}
|
|
270
|
+
for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) {
|
|
271
|
+
walker = walker.prev;
|
|
272
|
+
}
|
|
273
|
+
for (; walker !== null && i > from; i--, walker = walker.prev) {
|
|
274
|
+
ret.push(walker.value);
|
|
275
|
+
}
|
|
276
|
+
return ret;
|
|
277
|
+
};
|
|
278
|
+
Yallist.prototype.splice = function(start, deleteCount, ...nodes) {
|
|
279
|
+
if (start > this.length) {
|
|
280
|
+
start = this.length - 1;
|
|
281
|
+
}
|
|
282
|
+
if (start < 0) {
|
|
283
|
+
start = this.length + start;
|
|
284
|
+
}
|
|
285
|
+
for (var i = 0, walker = this.head; walker !== null && i < start; i++) {
|
|
286
|
+
walker = walker.next;
|
|
287
|
+
}
|
|
288
|
+
var ret = [];
|
|
289
|
+
for (var i = 0; walker && i < deleteCount; i++) {
|
|
290
|
+
ret.push(walker.value);
|
|
291
|
+
walker = this.removeNode(walker);
|
|
292
|
+
}
|
|
293
|
+
if (walker === null) {
|
|
294
|
+
walker = this.tail;
|
|
295
|
+
}
|
|
296
|
+
if (walker !== this.head && walker !== this.tail) {
|
|
297
|
+
walker = walker.prev;
|
|
298
|
+
}
|
|
299
|
+
for (var i = 0; i < nodes.length; i++) {
|
|
300
|
+
walker = insert(this, walker, nodes[i]);
|
|
301
|
+
}
|
|
302
|
+
return ret;
|
|
303
|
+
};
|
|
304
|
+
Yallist.prototype.reverse = function() {
|
|
305
|
+
var head = this.head;
|
|
306
|
+
var tail = this.tail;
|
|
307
|
+
for (var walker = head; walker !== null; walker = walker.prev) {
|
|
308
|
+
var p = walker.prev;
|
|
309
|
+
walker.prev = walker.next;
|
|
310
|
+
walker.next = p;
|
|
311
|
+
}
|
|
312
|
+
this.head = tail;
|
|
313
|
+
this.tail = head;
|
|
314
|
+
return this;
|
|
315
|
+
};
|
|
316
|
+
function insert(self, node, value) {
|
|
317
|
+
var inserted = node === self.head ? new Node(value, null, node, self) : new Node(value, node, node.next, self);
|
|
318
|
+
if (inserted.next === null) {
|
|
319
|
+
self.tail = inserted;
|
|
320
|
+
}
|
|
321
|
+
if (inserted.prev === null) {
|
|
322
|
+
self.head = inserted;
|
|
323
|
+
}
|
|
324
|
+
self.length++;
|
|
325
|
+
return inserted;
|
|
326
|
+
}
|
|
327
|
+
function push(self, item) {
|
|
328
|
+
self.tail = new Node(item, self.tail, null, self);
|
|
329
|
+
if (!self.head) {
|
|
330
|
+
self.head = self.tail;
|
|
331
|
+
}
|
|
332
|
+
self.length++;
|
|
333
|
+
}
|
|
334
|
+
function unshift(self, item) {
|
|
335
|
+
self.head = new Node(item, null, self.head, self);
|
|
336
|
+
if (!self.tail) {
|
|
337
|
+
self.tail = self.head;
|
|
338
|
+
}
|
|
339
|
+
self.length++;
|
|
340
|
+
}
|
|
341
|
+
function Node(value, prev, next, list) {
|
|
342
|
+
if (!(this instanceof Node)) {
|
|
343
|
+
return new Node(value, prev, next, list);
|
|
344
|
+
}
|
|
345
|
+
this.list = list;
|
|
346
|
+
this.value = value;
|
|
347
|
+
if (prev) {
|
|
348
|
+
prev.next = this;
|
|
349
|
+
this.prev = prev;
|
|
350
|
+
} else {
|
|
351
|
+
this.prev = null;
|
|
352
|
+
}
|
|
353
|
+
if (next) {
|
|
354
|
+
next.prev = this;
|
|
355
|
+
this.next = next;
|
|
356
|
+
} else {
|
|
357
|
+
this.next = null;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
try {
|
|
361
|
+
requireIterator()(Yallist);
|
|
362
|
+
} catch (er) {
|
|
363
|
+
}
|
|
364
|
+
export {
|
|
365
|
+
yallist as y
|
|
366
|
+
};
|
|
367
|
+
//# sourceMappingURL=yallist.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yallist.js","sources":["../../../../../node_modules/yallist/yallist.js"],"sourcesContent":["'use strict'\nmodule.exports = Yallist\n\nYallist.Node = Node\nYallist.create = Yallist\n\nfunction Yallist (list) {\n var self = this\n if (!(self instanceof Yallist)) {\n self = new Yallist()\n }\n\n self.tail = null\n self.head = null\n self.length = 0\n\n if (list && typeof list.forEach === 'function') {\n list.forEach(function (item) {\n self.push(item)\n })\n } else if (arguments.length > 0) {\n for (var i = 0, l = arguments.length; i < l; i++) {\n self.push(arguments[i])\n }\n }\n\n return self\n}\n\nYallist.prototype.removeNode = function (node) {\n if (node.list !== this) {\n throw new Error('removing node which does not belong to this list')\n }\n\n var next = node.next\n var prev = node.prev\n\n if (next) {\n next.prev = prev\n }\n\n if (prev) {\n prev.next = next\n }\n\n if (node === this.head) {\n this.head = next\n }\n if (node === this.tail) {\n this.tail = prev\n }\n\n node.list.length--\n node.next = null\n node.prev = null\n node.list = null\n\n return next\n}\n\nYallist.prototype.unshiftNode = function (node) {\n if (node === this.head) {\n return\n }\n\n if (node.list) {\n node.list.removeNode(node)\n }\n\n var head = this.head\n node.list = this\n node.next = head\n if (head) {\n head.prev = node\n }\n\n this.head = node\n if (!this.tail) {\n this.tail = node\n }\n this.length++\n}\n\nYallist.prototype.pushNode = function (node) {\n if (node === this.tail) {\n return\n }\n\n if (node.list) {\n node.list.removeNode(node)\n }\n\n var tail = this.tail\n node.list = this\n node.prev = tail\n if (tail) {\n tail.next = node\n }\n\n this.tail = node\n if (!this.head) {\n this.head = node\n }\n this.length++\n}\n\nYallist.prototype.push = function () {\n for (var i = 0, l = arguments.length; i < l; i++) {\n push(this, arguments[i])\n }\n return this.length\n}\n\nYallist.prototype.unshift = function () {\n for (var i = 0, l = arguments.length; i < l; i++) {\n unshift(this, arguments[i])\n }\n return this.length\n}\n\nYallist.prototype.pop = function () {\n if (!this.tail) {\n return undefined\n }\n\n var res = this.tail.value\n this.tail = this.tail.prev\n if (this.tail) {\n this.tail.next = null\n } else {\n this.head = null\n }\n this.length--\n return res\n}\n\nYallist.prototype.shift = function () {\n if (!this.head) {\n return undefined\n }\n\n var res = this.head.value\n this.head = this.head.next\n if (this.head) {\n this.head.prev = null\n } else {\n this.tail = null\n }\n this.length--\n return res\n}\n\nYallist.prototype.forEach = function (fn, thisp) {\n thisp = thisp || this\n for (var walker = this.head, i = 0; walker !== null; i++) {\n fn.call(thisp, walker.value, i, this)\n walker = walker.next\n }\n}\n\nYallist.prototype.forEachReverse = function (fn, thisp) {\n thisp = thisp || this\n for (var walker = this.tail, i = this.length - 1; walker !== null; i--) {\n fn.call(thisp, walker.value, i, this)\n walker = walker.prev\n }\n}\n\nYallist.prototype.get = function (n) {\n for (var i = 0, walker = this.head; walker !== null && i < n; i++) {\n // abort out of the list early if we hit a cycle\n walker = walker.next\n }\n if (i === n && walker !== null) {\n return walker.value\n }\n}\n\nYallist.prototype.getReverse = function (n) {\n for (var i = 0, walker = this.tail; walker !== null && i < n; i++) {\n // abort out of the list early if we hit a cycle\n walker = walker.prev\n }\n if (i === n && walker !== null) {\n return walker.value\n }\n}\n\nYallist.prototype.map = function (fn, thisp) {\n thisp = thisp || this\n var res = new Yallist()\n for (var walker = this.head; walker !== null;) {\n res.push(fn.call(thisp, walker.value, this))\n walker = walker.next\n }\n return res\n}\n\nYallist.prototype.mapReverse = function (fn, thisp) {\n thisp = thisp || this\n var res = new Yallist()\n for (var walker = this.tail; walker !== null;) {\n res.push(fn.call(thisp, walker.value, this))\n walker = walker.prev\n }\n return res\n}\n\nYallist.prototype.reduce = function (fn, initial) {\n var acc\n var walker = this.head\n if (arguments.length > 1) {\n acc = initial\n } else if (this.head) {\n walker = this.head.next\n acc = this.head.value\n } else {\n throw new TypeError('Reduce of empty list with no initial value')\n }\n\n for (var i = 0; walker !== null; i++) {\n acc = fn(acc, walker.value, i)\n walker = walker.next\n }\n\n return acc\n}\n\nYallist.prototype.reduceReverse = function (fn, initial) {\n var acc\n var walker = this.tail\n if (arguments.length > 1) {\n acc = initial\n } else if (this.tail) {\n walker = this.tail.prev\n acc = this.tail.value\n } else {\n throw new TypeError('Reduce of empty list with no initial value')\n }\n\n for (var i = this.length - 1; walker !== null; i--) {\n acc = fn(acc, walker.value, i)\n walker = walker.prev\n }\n\n return acc\n}\n\nYallist.prototype.toArray = function () {\n var arr = new Array(this.length)\n for (var i = 0, walker = this.head; walker !== null; i++) {\n arr[i] = walker.value\n walker = walker.next\n }\n return arr\n}\n\nYallist.prototype.toArrayReverse = function () {\n var arr = new Array(this.length)\n for (var i = 0, walker = this.tail; walker !== null; i++) {\n arr[i] = walker.value\n walker = walker.prev\n }\n return arr\n}\n\nYallist.prototype.slice = function (from, to) {\n to = to || this.length\n if (to < 0) {\n to += this.length\n }\n from = from || 0\n if (from < 0) {\n from += this.length\n }\n var ret = new Yallist()\n if (to < from || to < 0) {\n return ret\n }\n if (from < 0) {\n from = 0\n }\n if (to > this.length) {\n to = this.length\n }\n for (var i = 0, walker = this.head; walker !== null && i < from; i++) {\n walker = walker.next\n }\n for (; walker !== null && i < to; i++, walker = walker.next) {\n ret.push(walker.value)\n }\n return ret\n}\n\nYallist.prototype.sliceReverse = function (from, to) {\n to = to || this.length\n if (to < 0) {\n to += this.length\n }\n from = from || 0\n if (from < 0) {\n from += this.length\n }\n var ret = new Yallist()\n if (to < from || to < 0) {\n return ret\n }\n if (from < 0) {\n from = 0\n }\n if (to > this.length) {\n to = this.length\n }\n for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) {\n walker = walker.prev\n }\n for (; walker !== null && i > from; i--, walker = walker.prev) {\n ret.push(walker.value)\n }\n return ret\n}\n\nYallist.prototype.splice = function (start, deleteCount, ...nodes) {\n if (start > this.length) {\n start = this.length - 1\n }\n if (start < 0) {\n start = this.length + start;\n }\n\n for (var i = 0, walker = this.head; walker !== null && i < start; i++) {\n walker = walker.next\n }\n\n var ret = []\n for (var i = 0; walker && i < deleteCount; i++) {\n ret.push(walker.value)\n walker = this.removeNode(walker)\n }\n if (walker === null) {\n walker = this.tail\n }\n\n if (walker !== this.head && walker !== this.tail) {\n walker = walker.prev\n }\n\n for (var i = 0; i < nodes.length; i++) {\n walker = insert(this, walker, nodes[i])\n }\n return ret;\n}\n\nYallist.prototype.reverse = function () {\n var head = this.head\n var tail = this.tail\n for (var walker = head; walker !== null; walker = walker.prev) {\n var p = walker.prev\n walker.prev = walker.next\n walker.next = p\n }\n this.head = tail\n this.tail = head\n return this\n}\n\nfunction insert (self, node, value) {\n var inserted = node === self.head ?\n new Node(value, null, node, self) :\n new Node(value, node, node.next, self)\n\n if (inserted.next === null) {\n self.tail = inserted\n }\n if (inserted.prev === null) {\n self.head = inserted\n }\n\n self.length++\n\n return inserted\n}\n\nfunction push (self, item) {\n self.tail = new Node(item, self.tail, null, self)\n if (!self.head) {\n self.head = self.tail\n }\n self.length++\n}\n\nfunction unshift (self, item) {\n self.head = new Node(item, null, self.head, self)\n if (!self.tail) {\n self.tail = self.head\n }\n self.length++\n}\n\nfunction Node (value, prev, next, list) {\n if (!(this instanceof Node)) {\n return new Node(value, prev, next, list)\n }\n\n this.list = list\n this.value = value\n\n if (prev) {\n prev.next = this\n this.prev = prev\n } else {\n this.prev = null\n }\n\n if (next) {\n next.prev = this\n this.next = next\n } else {\n this.next = null\n }\n}\n\ntry {\n // add if support for Symbol.iterator is present\n require('./iterator.js')(Yallist)\n} catch (er) {}\n"],"names":["require$$0"],"mappings":";AACA,IAAA,UAAiB;AAEjB,QAAQ,OAAO;AACf,QAAQ,SAAS;AAEjB,SAAS,QAAS,MAAM;AACtB,MAAI,OAAO;AACX,MAAI,EAAE,gBAAgB,UAAU;AAC9B,WAAO,IAAI,QAAO;AAAA,EACtB;AAEE,OAAK,OAAO;AACZ,OAAK,OAAO;AACZ,OAAK,SAAS;AAEd,MAAI,QAAQ,OAAO,KAAK,YAAY,YAAY;AAC9C,SAAK,QAAQ,SAAU,MAAM;AAC3B,WAAK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C,KAAK,MAAM;AACd,SAAK,OAAO,KAAK;AAAA,EACrB;AACE,OAAK;AACP;AAEA,SAAS,QAAS,MAAM,MAAM;AAC5B,OAAK,OAAO,IAAI,KAAK,MAAM,MAAM,KAAK,MAAM,IAAI;AAChD,MAAI,CAAC,KAAK,MAAM;AACd,SAAK,OAAO,KAAK;AAAA,EACrB;AACE,OAAK;AACP;AAEA,SAAS,KAAM,OAAO,MAAM,MAAM,MAAM;AACtC,MAAI,EAAE,gBAAgB,OAAO;AAC3B,WAAO,IAAI,KAAK,OAAO,MAAM,MAAM,IAAI;AAAA,EAC3C;AAEE,OAAK,OAAO;AACZ,OAAK,QAAQ;AAEb,MAAI,MAAM;AACR,SAAK,OAAO;AACZ,SAAK,OAAO;AAAA,EAChB,OAAS;AACL,SAAK,OAAO;AAAA,EAChB;AAEE,MAAI,MAAM;AACR,SAAK,OAAO;AACZ,SAAK,OAAO;AAAA,EAChB,OAAS;AACL,SAAK,OAAO;AAAA,EAChB;AACA;AAEA,IAAI;AAEFA,kBAAA,EAAyB,OAAO;AAClC,SAAS,IAAI;AAAA;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
function getDefaultExportFromCjs(x) {
|
|
4
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
5
|
+
}
|
|
6
|
+
exports.getDefaultExportFromCjs = getDefaultExportFromCjs;
|
|
7
|
+
//# sourceMappingURL=_commonjsHelpers.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_commonjsHelpers.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_commonjsHelpers.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"re.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"re.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const fs = require("@slicemachine/plugin-kit/fs");
|
|
4
4
|
const commonTags = require("common-tags");
|
|
5
|
+
const index = require('./../packages/adapter-next/_node_modules/semver/index.cjs');
|
|
5
6
|
const buildSrcPath = require("../lib/buildSrcPath.cjs");
|
|
6
7
|
const checkHasAppRouter = require("../lib/checkHasAppRouter.cjs");
|
|
7
8
|
const checkIsTypeScriptProject = require("../lib/checkIsTypeScriptProject.cjs");
|
|
@@ -9,6 +10,7 @@ const getJSFileExtension = require("../lib/getJSFileExtension.cjs");
|
|
|
9
10
|
const rejectIfNecessary = require("../lib/rejectIfNecessary.cjs");
|
|
10
11
|
const upsertSliceLibraryIndexFile = require("../lib/upsertSliceLibraryIndexFile.cjs");
|
|
11
12
|
const constants = require("../constants.cjs");
|
|
13
|
+
const getNextJSVersion = require("../lib/getNextJSVersion.cjs");
|
|
12
14
|
const installDependencies = async ({ installDependencies: installDependencies2 }) => {
|
|
13
15
|
await installDependencies2({
|
|
14
16
|
dependencies: {
|
|
@@ -451,6 +453,8 @@ const createRevalidateRoute = async ({ helpers, options }) => {
|
|
|
451
453
|
if (!hasAppRouter) {
|
|
452
454
|
return;
|
|
453
455
|
}
|
|
456
|
+
const nextJSVersion = await getNextJSVersion.getNextJSVersion();
|
|
457
|
+
const supportsCacheLife = index.gte(nextJSVersion, "16.0.0-beta.0");
|
|
454
458
|
const extension = await getJSFileExtension.getJSFileExtension({ helpers, options });
|
|
455
459
|
const filename = await buildSrcPath.buildSrcPath({
|
|
456
460
|
filename: `app/api/revalidate/route.${extension}`,
|
|
@@ -464,7 +468,7 @@ const createRevalidateRoute = async ({ helpers, options }) => {
|
|
|
464
468
|
import { revalidateTag } from "next/cache";
|
|
465
469
|
|
|
466
470
|
export async function POST() {
|
|
467
|
-
revalidateTag("prismic");
|
|
471
|
+
revalidateTag("prismic"${supportsCacheLife ? ', "max"' : ""});
|
|
468
472
|
|
|
469
473
|
return NextResponse.json({ revalidated: true, now: Date.now() });
|
|
470
474
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-init.cjs","sources":["../../../src/hooks/project-init.ts"],"sourcesContent":["import type {\n\tProjectInitHook,\n\tProjectInitHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport {\n\tcheckHasProjectFile,\n\twriteProjectFile,\n} from \"@slicemachine/plugin-kit/fs\";\nimport { source } from \"common-tags\";\n\nimport { buildSrcPath } from \"../lib/buildSrcPath\";\nimport { checkHasAppRouter } from \"../lib/checkHasAppRouter\";\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\nimport { getJSFileExtension } from \"../lib/getJSFileExtension\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { upsertSliceLibraryIndexFile } from \"../lib/upsertSliceLibraryIndexFile\";\n\nimport type { PluginOptions } from \"../types\";\nimport { PRISMIC_ENVIRONMENT_ENVIRONMENT_VARIABLE_NAME } from \"../constants\";\n\ntype InstallDependenciesArgs = {\n\tinstallDependencies: ProjectInitHookData[\"installDependencies\"];\n};\n\nconst installDependencies = async ({\n\tinstallDependencies,\n}: InstallDependenciesArgs) => {\n\tawait installDependencies({\n\t\tdependencies: {\n\t\t\t\"@prismicio/client\": \"latest\",\n\t\t\t\"@prismicio/react\": \"latest\",\n\t\t\t\"@prismicio/next\": \"latest\",\n\t\t},\n\t});\n};\n\ntype CreatePrismicIOFileArgs = SliceMachineContext<PluginOptions>;\n\nconst createPrismicIOFile = async ({\n\thelpers,\n\toptions,\n}: CreatePrismicIOFileArgs) => {\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\tconst hasSrcDirectory = await checkHasProjectFile({\n\t\tfilename: \"src\",\n\t\thelpers,\n\t});\n\tconst hasAppRouter = await checkHasAppRouter({ helpers });\n\n\tconst extension = await getJSFileExtension({ helpers, options });\n\tconst filename = await buildSrcPath({\n\t\tfilename: `prismicio.${extension}`,\n\t\thelpers,\n\t});\n\n\tif (await checkHasProjectFile({ filename, helpers })) {\n\t\treturn;\n\t}\n\n\tlet importsContents: string;\n\tlet createClientContents: string;\n\n\tif (hasAppRouter) {\n\t\tif (isTypeScriptProject) {\n\t\t\timportsContents = source`\n\t\t\t\timport {\n\t\t\t\t\tcreateClient as baseCreateClient,\n\t\t\t\t\ttype ClientConfig,\n\t\t\t\t\ttype Route,\n\t\t\t\t} from \"@prismicio/client\";\n\t\t\t\timport { enableAutoPreviews } from \"@prismicio/next\";\n\t\t\t\timport sm from \"${hasSrcDirectory ? \"..\" : \".\"}/slicemachine.config.json\";\n\t\t\t`;\n\n\t\t\tcreateClientContents = source`\n\t\t\t\t/**\n\t\t\t\t * Creates a Prismic client for the project's repository. The client is used to\n\t\t\t\t * query content from the Prismic API.\n\t\t\t\t *\n\t\t\t\t * @param config - Configuration for the Prismic client.\n\t\t\t\t */\n\t\t\t\texport const createClient = (config: ClientConfig = {}) => {\n\t\t\t\t\tconst client = baseCreateClient(repositoryName, {\n\t\t\t\t\t\troutes,\n\t\t\t\t\t\tfetchOptions:\n\t\t\t\t\t\t\tprocess.env.NODE_ENV === 'production'\n\t\t\t\t\t\t\t\t? { next: { tags: ['prismic'] }, cache: 'force-cache' }\n\t\t\t\t\t\t\t\t: { next: { revalidate: 5 } },\n\t\t\t\t\t\t...config,\n\t\t\t\t\t});\n\n\t\t\t\t\tenableAutoPreviews({ client });\n\n\t\t\t\t\treturn client;\n\t\t\t\t};\n\t\t\t`;\n\t\t} else {\n\t\t\timportsContents = source`\n\t\t\t\timport { createClient as baseCreateClient } from \"@prismicio/client\";\n\t\t\t\timport { enableAutoPreviews } from \"@prismicio/next\";\n\t\t\t\timport sm from \"${hasSrcDirectory ? \"..\" : \".\"}/slicemachine.config.json\";\n\t\t\t`;\n\n\t\t\tcreateClientContents = source`\n\t\t\t\t/**\n\t\t\t\t * Creates a Prismic client for the project's repository. The client is used to\n\t\t\t\t * query content from the Prismic API.\n\t\t\t\t *\n\t\t\t\t * @param {import(\"@prismicio/client\").ClientConfig} config - Configuration for the Prismic client.\n\t\t\t\t */\n\t\t\t\texport const createClient = (config = {}) => {\n\t\t\t\t\tconst client = baseCreateClient(repositoryName, {\n\t\t\t\t\t\troutes,\n\t\t\t\t\t\tfetchOptions:\n\t\t\t\t\t\t\tprocess.env.NODE_ENV === 'production'\n\t\t\t\t\t\t\t\t? { next: { tags: ['prismic'] }, cache: 'force-cache' }\n\t\t\t\t\t\t\t\t: { next: { revalidate: 5 } },\n\t\t\t\t\t\t...config,\n\t\t\t\t\t});\n\n\t\t\t\t\tenableAutoPreviews({ client });\n\n\t\t\t\t\treturn client;\n\t\t\t\t};\n\t\t\t`;\n\t\t}\n\t} else {\n\t\tif (isTypeScriptProject) {\n\t\t\timportsContents = source`\n\t\t\t\timport { createClient as baseCreateClient, type Routes } from \"@prismicio/client\";\n\t\t\t\timport { enableAutoPreviews, type CreateClientConfig } from \"@prismicio/next/pages\";\n\t\t\t\timport sm from \"${hasSrcDirectory ? \"..\" : \".\"}/slicemachine.config.json\";\n\t\t\t`;\n\n\t\t\tcreateClientContents = source`\n\t\t\t\t/**\n\t\t\t\t * Creates a Prismic client for the project's repository. The client is used to\n\t\t\t\t * query content from the Prismic API.\n\t\t\t\t *\n\t\t\t\t * @param config - Configuration for the Prismic client.\n\t\t\t\t */\n\t\t\t\texport const createClient = ({ previewData, req, ...config }: CreateClientConfig = {}) => {\n\t\t\t\t\tconst client = baseCreateClient(repositoryName, {\n\t\t\t\t\t\troutes,\n\t\t\t\t\t\t...config,\n\t\t\t\t\t});\n\n\t\t\t\t\tenableAutoPreviews({ client, previewData, req });\n\n\t\t\t\t\treturn client;\n\t\t\t\t};\n\t\t\t`;\n\t\t} else {\n\t\t\timportsContents = source`\n\t\t\t\timport { createClient as baseCreateClient } from \"@prismicio/client\";\n\t\t\t\timport { enableAutoPreviews } from \"@prismicio/next/pages\";\n\t\t\t\timport sm from \"${hasSrcDirectory ? \"..\" : \".\"}/slicemachine.config.json\";\n\t\t\t`;\n\n\t\t\tcreateClientContents = source`\n\t\t\t\t/**\n\t\t\t\t * Creates a Prismic client for the project's repository. The client is used to\n\t\t\t\t * query content from the Prismic API.\n\t\t\t\t *\n\t\t\t\t * @param {import(\"@prismicio/next/pages\").CreateClientConfig} config - Configuration for the Prismic client.\n\t\t\t\t */\n\t\t\t\texport const createClient = ({ previewData, req, ...config } = {}) => {\n\t\t\t\t\tconst client = baseCreateClient(repositoryName, {\n\t\t\t\t\t\troutes,\n\t\t\t\t\t\t...config,\n\t\t\t\t\t});\n\n\t\t\t\t\tenableAutoPreviews({ client, previewData, req });\n\n\t\t\t\t\treturn client;\n\t\t\t\t};\n\t\t\t`;\n\t\t}\n\t}\n\n\tlet contents: string;\n\n\tif (isTypeScriptProject) {\n\t\tcontents = source`\n\t\t\t${importsContents}\n\n\t\t\t/**\n\t\t\t * The project's Prismic repository name.\n\t\t\t */\n\t\t\texport const repositoryName =\n\t\t\t\tprocess.env.${PRISMIC_ENVIRONMENT_ENVIRONMENT_VARIABLE_NAME} || sm.repositoryName;\n\n\t\t\t/**\n\t\t\t * A list of Route Resolver objects that define how a document's \\`url\\` field is resolved.\n\t\t\t *\n\t\t\t * {@link https://prismic.io/docs/route-resolver#route-resolver}\n\t\t\t */\n\t\t\t// TODO: Update the routes array to match your project's route structure.\n\t\t\tconst routes: Route[] = [\n\t\t\t\t// Examples:\n\t\t\t\t// { type: \"homepage\", path: \"/\" },\n\t\t\t\t// { type: \"page\", path: \"/:uid\" },\n\t\t\t];\n\n\t\t\t${createClientContents}\n\t\t`;\n\t} else {\n\t\tcontents = source`\n\t\t\t${importsContents}\n\n\t\t\t/**\n\t\t\t * The project's Prismic repository name.\n\t\t\t */\n\t\t\texport const repositoryName =\n\t\t\t\tprocess.env.${PRISMIC_ENVIRONMENT_ENVIRONMENT_VARIABLE_NAME} || sm.repositoryName;\n\n\t\t\t/**\n\t\t\t * A list of Route Resolver objects that define how a document's \\`url\\` field is resolved.\n\t\t\t *\n\t\t\t * {@link https://prismic.io/docs/route-resolver#route-resolver}\n\t\t\t *\n\t\t\t * @type {import(\"@prismicio/client\").Route[]}\n\t\t\t */\n\t\t\t// TODO: Update the routes array to match your project's route structure.\n\t\t\tconst routes = [\n\t\t\t\t// Examples:\n\t\t\t\t// { type: \"homepage\", path: \"/\" },\n\t\t\t\t// { type: \"page\", path: \"/:uid\" },\n\t\t\t];\n\n\t\t\t${createClientContents}\n\t\t`;\n\t}\n\n\tawait writeProjectFile({\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\thelpers,\n\t});\n};\n\ntype CreateSliceSimulatorPageArgs = SliceMachineContext<PluginOptions>;\n\nconst createSliceSimulatorPage = async ({\n\thelpers,\n\toptions,\n}: CreateSliceSimulatorPageArgs) => {\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\tconst hasAppRouter = await checkHasAppRouter({ helpers });\n\n\tconst extension = await getJSFileExtension({ helpers, options, jsx: true });\n\tconst filename = await buildSrcPath({\n\t\tfilename: hasAppRouter\n\t\t\t? `app/slice-simulator/page.${extension}`\n\t\t\t: `pages/slice-simulator.${extension}`,\n\t\thelpers,\n\t});\n\n\tif (await checkHasProjectFile({ filename, helpers })) {\n\t\treturn;\n\t}\n\n\tlet contents;\n\n\tif (hasAppRouter) {\n\t\tif (isTypeScriptProject) {\n\t\t\tcontents = source`\n\t\t\t\timport {\n\t\t\t\t\tSliceSimulator,\n\t\t\t\t\tSliceSimulatorParams,\n\t\t\t\t\tgetSlices,\n\t\t\t\t} from \"@slicemachine/adapter-next/simulator\";\n\t\t\t\timport { SliceZone } from \"@prismicio/react\";\n\n\t\t\t\timport { components } from \"../../slices\";\n\n\t\t\t\texport default async function SliceSimulatorPage({\n\t\t\t\t\tsearchParams,\n\t\t\t\t}: SliceSimulatorParams) {\n\t\t\t\t\tconst { state } = await searchParams\n\t\t\t\t\tconst slices = getSlices(state);\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<SliceSimulator>\n\t\t\t\t\t\t\t<SliceZone slices={slices} components={components} />\n\t\t\t\t\t\t</SliceSimulator>\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t`;\n\t\t} else {\n\t\t\tcontents = source`\n\t\t\t\timport {\n\t\t\t\t\tSliceSimulator,\n\t\t\t\t\tgetSlices,\n\t\t\t\t} from \"@slicemachine/adapter-next/simulator\";\n\t\t\t\timport { SliceZone } from \"@prismicio/react\";\n\n\t\t\t\timport { components } from \"../../slices\";\n\n\t\t\t\texport default async function SliceSimulatorPage({ searchParams }) {\n\t\t\t\t\tconst { state } = await searchParams\n\t\t\t\t\tconst slices = getSlices(state);\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<SliceSimulator>\n\t\t\t\t\t\t\t<SliceZone slices={slices} components={components} />\n\t\t\t\t\t\t</SliceSimulator>\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t`;\n\t\t}\n\t} else {\n\t\tcontents = source`\n\t\t\timport { SliceSimulator } from \"@slicemachine/adapter-next/simulator\";\n\t\t\timport { SliceZone } from \"@prismicio/react\";\n\n\t\t\timport { components } from \"../slices\";\n\n\t\t\texport default function SliceSimulatorPage() {\n\t\t\t\treturn (\n\t\t\t\t\t<SliceSimulator\n\t\t\t\t\t\tsliceZone={(props) => <SliceZone {...props} components={components} />}\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t}\n\t\t`;\n\t}\n\n\tawait writeProjectFile({\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\thelpers,\n\t});\n};\n\nconst createPreviewRoute = async ({\n\thelpers,\n\toptions,\n}: SliceMachineContext<PluginOptions>) => {\n\tconst hasAppRouter = await checkHasAppRouter({ helpers });\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tconst extension = await getJSFileExtension({ helpers, options });\n\tconst filename = await buildSrcPath({\n\t\tfilename: hasAppRouter\n\t\t\t? `app/api/preview/route.${extension}`\n\t\t\t: `pages/api/preview.${extension}`,\n\t\thelpers,\n\t});\n\n\tif (await checkHasProjectFile({ filename, helpers })) {\n\t\treturn;\n\t}\n\n\tlet contents: string;\n\n\tif (hasAppRouter) {\n\t\tif (isTypeScriptProject) {\n\t\t\tcontents = source`\n\t\t\t\timport { NextRequest } from \"next/server\";\n\t\t\t\timport { redirectToPreviewURL } from \"@prismicio/next\";\n\n\t\t\t\timport { createClient } from \"../../../prismicio\";\n\n\t\t\t\texport async function GET(request: NextRequest) {\n\t\t\t\t\tconst client = createClient();\n\n\t\t\t\t\treturn await redirectToPreviewURL({ client, request });\n\t\t\t\t}\n\t\t\t`;\n\t\t} else {\n\t\t\tcontents = source`\n\t\t\t\timport { redirectToPreviewURL } from \"@prismicio/next\";\n\n\t\t\t\timport { createClient } from \"../../../prismicio\";\n\n\t\t\t\texport async function GET(request) {\n\t\t\t\t\tconst client = createClient();\n\n\t\t\t\t\treturn await redirectToPreviewURL({ client, request });\n\t\t\t\t}\n\t\t\t`;\n\t\t}\n\t} else {\n\t\tif (isTypeScriptProject) {\n\t\t\tcontents = source`\n\t\t\t\timport { NextApiRequest, NextApiResponse } from \"next\";\n\t\t\t\timport { setPreviewData, redirectToPreviewURL } from \"@prismicio/next/pages\";\n\n\t\t\t\timport { createClient } from \"../../prismicio\";\n\n\t\t\t\texport default async function handler(req: NextApiRequest, res: NextApiResponse) {\n\t\t\t\t\tconst client = createClient({ req });\n\n\t\t\t\t\tsetPreviewData({ req, res });\n\n\t\t\t\t\treturn await redirectToPreviewURL({ req, res, client });\n\t\t\t\t};\n\t\t\t`;\n\t\t} else {\n\t\t\tcontents = source`\n\t\t\t\timport { setPreviewData, redirectToPreviewURL } from \"@prismicio/next/pages\";\n\n\t\t\t\timport { createClient } from \"../../prismicio\";\n\n\t\t\t\texport default async function handler(req, res) {\n\t\t\t\t\tconst client = createClient({ req });\n\n\t\t\t\t\tsetPreviewData({ req, res });\n\n\t\t\t\t\treturn await redirectToPreviewURL({ req, res, client });\n\t\t\t\t};\n\t\t\t`;\n\t\t}\n\t}\n\n\tawait writeProjectFile({\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\thelpers,\n\t});\n};\n\nconst createExitPreviewRoute = async ({\n\thelpers,\n\toptions,\n}: SliceMachineContext<PluginOptions>) => {\n\tconst hasAppRouter = await checkHasAppRouter({ helpers });\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tconst extension = await getJSFileExtension({ helpers, options });\n\tconst filename = await buildSrcPath({\n\t\tfilename: hasAppRouter\n\t\t\t? `app/api/exit-preview/route.${extension}`\n\t\t\t: `pages/api/exit-preview.${extension}`,\n\t\thelpers,\n\t});\n\n\tif (await checkHasProjectFile({ filename, helpers })) {\n\t\treturn;\n\t}\n\n\tlet contents: string;\n\n\tif (hasAppRouter) {\n\t\tcontents = source`\n\t\t\timport { exitPreview } from \"@prismicio/next\";\n\n\t\t\texport function GET() {\n\t\t\t\treturn exitPreview();\n\t\t\t}\n\t\t`;\n\t} else {\n\t\tif (isTypeScriptProject) {\n\t\t\tcontents = source`\n\t\t\t\timport { NextApiRequest, NextApiResponse } from \"next\";\n\t\t\t\timport { exitPreview } from \"@prismicio/next/pages\";\n\n\t\t\t\texport default function handler(req: NextApiRequest, res: NextApiResponse) {\n\t\t\t\t\treturn exitPreview({ req, res });\n\t\t\t\t}\n\t\t\t`;\n\t\t} else {\n\t\t\tcontents = source`\n\t\t\t\timport { exitPreview } from \"@prismicio/next/pages\";\n\n\t\t\t\texport default function handler(req, res) {\n\t\t\t\t\treturn exitPreview({ req, res });\n\t\t\t\t}\n\t\t\t`;\n\t\t}\n\t}\n\n\tawait writeProjectFile({\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\thelpers,\n\t});\n};\n\nconst modifySliceMachineConfig = async ({\n\thelpers,\n\toptions,\n\tactions,\n}: SliceMachineContext<PluginOptions>) => {\n\tconst hasSrcDirectory = await checkHasProjectFile({\n\t\tfilename: \"src\",\n\t\thelpers,\n\t});\n\tconst project = await helpers.getProject();\n\n\t// Add Slice Simulator URL.\n\tproject.config.localSliceSimulatorURL ||=\n\t\t\"http://localhost:3000/slice-simulator\";\n\n\t// Nest the default Slice Library in the src directory if it exists and\n\t// is empty.\n\tif (\n\t\thasSrcDirectory &&\n\t\tproject.config.libraries &&\n\t\tJSON.stringify(project.config.libraries) === JSON.stringify([\"./slices\"])\n\t) {\n\t\tconst sliceLibrary = await actions.readSliceLibrary({\n\t\t\tlibraryID: project.config.libraries[0],\n\t\t});\n\n\t\tif (sliceLibrary.sliceIDs.length < 1) {\n\t\t\tproject.config.libraries = [\"./src/slices\"];\n\t\t}\n\t}\n\n\tawait helpers.updateSliceMachineConfig(project.config, {\n\t\tformat: options.format,\n\t});\n};\n\nconst createRevalidateRoute = async ({\n\thelpers,\n\toptions,\n}: SliceMachineContext<PluginOptions>) => {\n\tconst hasAppRouter = await checkHasAppRouter({ helpers });\n\n\tif (!hasAppRouter) {\n\t\treturn;\n\t}\n\n\tconst extension = await getJSFileExtension({ helpers, options });\n\tconst filename = await buildSrcPath({\n\t\tfilename: `app/api/revalidate/route.${extension}`,\n\t\thelpers,\n\t});\n\n\tif (await checkHasProjectFile({ filename, helpers })) {\n\t\treturn;\n\t}\n\n\tconst contents = source`\n\t\timport { NextResponse } from \"next/server\";\n\t\timport { revalidateTag } from \"next/cache\";\n\n\t\texport async function POST() {\n\t\t\trevalidateTag(\"prismic\");\n\n\t\t\treturn NextResponse.json({ revalidated: true, now: Date.now() });\n\t\t}\n\t`;\n\n\tawait writeProjectFile({\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\thelpers,\n\t});\n};\n\nconst upsertSliceLibraryIndexFiles = async (\n\tcontext: SliceMachineContext<PluginOptions>,\n) => {\n\t// We must use the `getProject()` helper to get the latest version of\n\t// the project config. The config may have been modified in\n\t// `modifySliceMachineConfig()` and will not be relfected in\n\t// `context.project`.\n\t// TODO: Automatically update the plugin runner's in-memory `project`\n\t// object when `updateSliceMachineConfig()` is called.\n\tconst project = await context.helpers.getProject();\n\n\tif (!project.config.libraries) {\n\t\treturn;\n\t}\n\n\tawait Promise.all(\n\t\tproject.config.libraries.map(async (libraryID) => {\n\t\t\tawait upsertSliceLibraryIndexFile({ libraryID, ...context });\n\t\t}),\n\t);\n};\n\nexport const projectInit: ProjectInitHook<PluginOptions> = async (\n\t{ installDependencies: _installDependencies },\n\tcontext,\n) => {\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tinstallDependencies({ installDependencies: _installDependencies }),\n\t\t\tmodifySliceMachineConfig(context),\n\t\t\tcreatePrismicIOFile(context),\n\t\t\tcreateSliceSimulatorPage(context),\n\t\t\tcreatePreviewRoute(context),\n\t\t\tcreateExitPreviewRoute(context),\n\t\t\tcreateRevalidateRoute(context),\n\t\t]),\n\t);\n\n\t// This must happen after `modifySliceMachineConfig()` since the\n\t// location of the default Slice library may change.\n\tawait upsertSliceLibraryIndexFiles(context);\n};\n"],"names":["installDependencies","checkIsTypeScriptProject","checkHasProjectFile","checkHasAppRouter","getJSFileExtension","buildSrcPath","source","PRISMIC_ENVIRONMENT_ENVIRONMENT_VARIABLE_NAME","writeProjectFile","upsertSliceLibraryIndexFile","rejectIfNecessary"],"mappings":";;;;;;;;;;;AAyBA,MAAM,sBAAsB,OAAO,EAClC,qBAAAA,2BAC6B;AAC7B,QAAMA,qBAAoB;AAAA,IACzB,cAAc;AAAA,MACb,qBAAqB;AAAA,MACrB,oBAAoB;AAAA,MACpB,mBAAmB;AAAA,IAA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AAS;AAAA,IAC/C;AAAA,EAAA,CACA;AAED,MAAI,MAAMH,GAAAA,oBAAoB,EAAE,UAAU,QAAA,CAAS,GAAG;AACrD;AAAA,EACD;AAEA,QAAM,WAAWI,WAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAWjB,QAAME,oBAAiB;AAAA,IACtB;AAAA,IACA;AAAA,IACA,QAAQ,QAAQ;AAAA,IAChB;AAAA,EAAA,CACA;AACF;AAEA,MAAM,+BAA+B,OACpC,YACG;AAOH,QAAM,UAAU,MAAM,QAAQ,QAAQ,WAAA;AAEtC,MAAI,CAAC,QAAQ,OAAO,WAAW;AAC9B;AAAA,EACD;AAEA,QAAM,QAAQ,IACb,QAAQ,OAAO,UAAU,IAAI,OAAO,cAAa;AAChD,UAAMC,wDAA4B,EAAE,WAAW,GAAG,SAAS;AAAA,EAC5D,CAAC,CAAC;AAEJ;AAEO,MAAM,cAA8C,OAC1D,EAAE,qBAAqB,qBAAA,GACvB,YACG;AACHC,sCACC,MAAM,QAAQ,WAAW;AAAA,IACxB,oBAAoB,EAAE,qBAAqB,sBAAsB;AAAA,IACjE,yBAAyB,OAAO;AAAA,IAChC,oBAAoB,OAAO;AAAA,IAC3B,yBAAyB,OAAO;AAAA,IAChC,mBAAmB,OAAO;AAAA,IAC1B,uBAAuB,OAAO;AAAA,IAC9B,sBAAsB,OAAO;AAAA,EAAA,CAC7B,CAAC;AAKH,QAAM,6BAA6B,OAAO;AAC3C;;"}
|
|
1
|
+
{"version":3,"file":"project-init.cjs","sources":["../../../src/hooks/project-init.ts"],"sourcesContent":["import type {\n\tProjectInitHook,\n\tProjectInitHookData,\n\tSliceMachineContext,\n} from \"@slicemachine/plugin-kit\";\nimport {\n\tcheckHasProjectFile,\n\twriteProjectFile,\n} from \"@slicemachine/plugin-kit/fs\";\nimport { source } from \"common-tags\";\nimport semver from \"semver\";\n\nimport { buildSrcPath } from \"../lib/buildSrcPath\";\nimport { checkHasAppRouter } from \"../lib/checkHasAppRouter\";\nimport { checkIsTypeScriptProject } from \"../lib/checkIsTypeScriptProject\";\nimport { getJSFileExtension } from \"../lib/getJSFileExtension\";\nimport { rejectIfNecessary } from \"../lib/rejectIfNecessary\";\nimport { upsertSliceLibraryIndexFile } from \"../lib/upsertSliceLibraryIndexFile\";\n\nimport type { PluginOptions } from \"../types\";\nimport { PRISMIC_ENVIRONMENT_ENVIRONMENT_VARIABLE_NAME } from \"../constants\";\nimport { getNextJSVersion } from \"../lib/getNextJSVersion\";\n\ntype InstallDependenciesArgs = {\n\tinstallDependencies: ProjectInitHookData[\"installDependencies\"];\n};\n\nconst installDependencies = async ({\n\tinstallDependencies,\n}: InstallDependenciesArgs) => {\n\tawait installDependencies({\n\t\tdependencies: {\n\t\t\t\"@prismicio/client\": \"latest\",\n\t\t\t\"@prismicio/react\": \"latest\",\n\t\t\t\"@prismicio/next\": \"latest\",\n\t\t},\n\t});\n};\n\ntype CreatePrismicIOFileArgs = SliceMachineContext<PluginOptions>;\n\nconst createPrismicIOFile = async ({\n\thelpers,\n\toptions,\n}: CreatePrismicIOFileArgs) => {\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\tconst hasSrcDirectory = await checkHasProjectFile({\n\t\tfilename: \"src\",\n\t\thelpers,\n\t});\n\tconst hasAppRouter = await checkHasAppRouter({ helpers });\n\n\tconst extension = await getJSFileExtension({ helpers, options });\n\tconst filename = await buildSrcPath({\n\t\tfilename: `prismicio.${extension}`,\n\t\thelpers,\n\t});\n\n\tif (await checkHasProjectFile({ filename, helpers })) {\n\t\treturn;\n\t}\n\n\tlet importsContents: string;\n\tlet createClientContents: string;\n\n\tif (hasAppRouter) {\n\t\tif (isTypeScriptProject) {\n\t\t\timportsContents = source`\n\t\t\t\timport {\n\t\t\t\t\tcreateClient as baseCreateClient,\n\t\t\t\t\ttype ClientConfig,\n\t\t\t\t\ttype Route,\n\t\t\t\t} from \"@prismicio/client\";\n\t\t\t\timport { enableAutoPreviews } from \"@prismicio/next\";\n\t\t\t\timport sm from \"${hasSrcDirectory ? \"..\" : \".\"}/slicemachine.config.json\";\n\t\t\t`;\n\n\t\t\tcreateClientContents = source`\n\t\t\t\t/**\n\t\t\t\t * Creates a Prismic client for the project's repository. The client is used to\n\t\t\t\t * query content from the Prismic API.\n\t\t\t\t *\n\t\t\t\t * @param config - Configuration for the Prismic client.\n\t\t\t\t */\n\t\t\t\texport const createClient = (config: ClientConfig = {}) => {\n\t\t\t\t\tconst client = baseCreateClient(repositoryName, {\n\t\t\t\t\t\troutes,\n\t\t\t\t\t\tfetchOptions:\n\t\t\t\t\t\t\tprocess.env.NODE_ENV === 'production'\n\t\t\t\t\t\t\t\t? { next: { tags: ['prismic'] }, cache: 'force-cache' }\n\t\t\t\t\t\t\t\t: { next: { revalidate: 5 } },\n\t\t\t\t\t\t...config,\n\t\t\t\t\t});\n\n\t\t\t\t\tenableAutoPreviews({ client });\n\n\t\t\t\t\treturn client;\n\t\t\t\t};\n\t\t\t`;\n\t\t} else {\n\t\t\timportsContents = source`\n\t\t\t\timport { createClient as baseCreateClient } from \"@prismicio/client\";\n\t\t\t\timport { enableAutoPreviews } from \"@prismicio/next\";\n\t\t\t\timport sm from \"${hasSrcDirectory ? \"..\" : \".\"}/slicemachine.config.json\";\n\t\t\t`;\n\n\t\t\tcreateClientContents = source`\n\t\t\t\t/**\n\t\t\t\t * Creates a Prismic client for the project's repository. The client is used to\n\t\t\t\t * query content from the Prismic API.\n\t\t\t\t *\n\t\t\t\t * @param {import(\"@prismicio/client\").ClientConfig} config - Configuration for the Prismic client.\n\t\t\t\t */\n\t\t\t\texport const createClient = (config = {}) => {\n\t\t\t\t\tconst client = baseCreateClient(repositoryName, {\n\t\t\t\t\t\troutes,\n\t\t\t\t\t\tfetchOptions:\n\t\t\t\t\t\t\tprocess.env.NODE_ENV === 'production'\n\t\t\t\t\t\t\t\t? { next: { tags: ['prismic'] }, cache: 'force-cache' }\n\t\t\t\t\t\t\t\t: { next: { revalidate: 5 } },\n\t\t\t\t\t\t...config,\n\t\t\t\t\t});\n\n\t\t\t\t\tenableAutoPreviews({ client });\n\n\t\t\t\t\treturn client;\n\t\t\t\t};\n\t\t\t`;\n\t\t}\n\t} else {\n\t\tif (isTypeScriptProject) {\n\t\t\timportsContents = source`\n\t\t\t\timport { createClient as baseCreateClient, type Routes } from \"@prismicio/client\";\n\t\t\t\timport { enableAutoPreviews, type CreateClientConfig } from \"@prismicio/next/pages\";\n\t\t\t\timport sm from \"${hasSrcDirectory ? \"..\" : \".\"}/slicemachine.config.json\";\n\t\t\t`;\n\n\t\t\tcreateClientContents = source`\n\t\t\t\t/**\n\t\t\t\t * Creates a Prismic client for the project's repository. The client is used to\n\t\t\t\t * query content from the Prismic API.\n\t\t\t\t *\n\t\t\t\t * @param config - Configuration for the Prismic client.\n\t\t\t\t */\n\t\t\t\texport const createClient = ({ previewData, req, ...config }: CreateClientConfig = {}) => {\n\t\t\t\t\tconst client = baseCreateClient(repositoryName, {\n\t\t\t\t\t\troutes,\n\t\t\t\t\t\t...config,\n\t\t\t\t\t});\n\n\t\t\t\t\tenableAutoPreviews({ client, previewData, req });\n\n\t\t\t\t\treturn client;\n\t\t\t\t};\n\t\t\t`;\n\t\t} else {\n\t\t\timportsContents = source`\n\t\t\t\timport { createClient as baseCreateClient } from \"@prismicio/client\";\n\t\t\t\timport { enableAutoPreviews } from \"@prismicio/next/pages\";\n\t\t\t\timport sm from \"${hasSrcDirectory ? \"..\" : \".\"}/slicemachine.config.json\";\n\t\t\t`;\n\n\t\t\tcreateClientContents = source`\n\t\t\t\t/**\n\t\t\t\t * Creates a Prismic client for the project's repository. The client is used to\n\t\t\t\t * query content from the Prismic API.\n\t\t\t\t *\n\t\t\t\t * @param {import(\"@prismicio/next/pages\").CreateClientConfig} config - Configuration for the Prismic client.\n\t\t\t\t */\n\t\t\t\texport const createClient = ({ previewData, req, ...config } = {}) => {\n\t\t\t\t\tconst client = baseCreateClient(repositoryName, {\n\t\t\t\t\t\troutes,\n\t\t\t\t\t\t...config,\n\t\t\t\t\t});\n\n\t\t\t\t\tenableAutoPreviews({ client, previewData, req });\n\n\t\t\t\t\treturn client;\n\t\t\t\t};\n\t\t\t`;\n\t\t}\n\t}\n\n\tlet contents: string;\n\n\tif (isTypeScriptProject) {\n\t\tcontents = source`\n\t\t\t${importsContents}\n\n\t\t\t/**\n\t\t\t * The project's Prismic repository name.\n\t\t\t */\n\t\t\texport const repositoryName =\n\t\t\t\tprocess.env.${PRISMIC_ENVIRONMENT_ENVIRONMENT_VARIABLE_NAME} || sm.repositoryName;\n\n\t\t\t/**\n\t\t\t * A list of Route Resolver objects that define how a document's \\`url\\` field is resolved.\n\t\t\t *\n\t\t\t * {@link https://prismic.io/docs/route-resolver#route-resolver}\n\t\t\t */\n\t\t\t// TODO: Update the routes array to match your project's route structure.\n\t\t\tconst routes: Route[] = [\n\t\t\t\t// Examples:\n\t\t\t\t// { type: \"homepage\", path: \"/\" },\n\t\t\t\t// { type: \"page\", path: \"/:uid\" },\n\t\t\t];\n\n\t\t\t${createClientContents}\n\t\t`;\n\t} else {\n\t\tcontents = source`\n\t\t\t${importsContents}\n\n\t\t\t/**\n\t\t\t * The project's Prismic repository name.\n\t\t\t */\n\t\t\texport const repositoryName =\n\t\t\t\tprocess.env.${PRISMIC_ENVIRONMENT_ENVIRONMENT_VARIABLE_NAME} || sm.repositoryName;\n\n\t\t\t/**\n\t\t\t * A list of Route Resolver objects that define how a document's \\`url\\` field is resolved.\n\t\t\t *\n\t\t\t * {@link https://prismic.io/docs/route-resolver#route-resolver}\n\t\t\t *\n\t\t\t * @type {import(\"@prismicio/client\").Route[]}\n\t\t\t */\n\t\t\t// TODO: Update the routes array to match your project's route structure.\n\t\t\tconst routes = [\n\t\t\t\t// Examples:\n\t\t\t\t// { type: \"homepage\", path: \"/\" },\n\t\t\t\t// { type: \"page\", path: \"/:uid\" },\n\t\t\t];\n\n\t\t\t${createClientContents}\n\t\t`;\n\t}\n\n\tawait writeProjectFile({\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\thelpers,\n\t});\n};\n\ntype CreateSliceSimulatorPageArgs = SliceMachineContext<PluginOptions>;\n\nconst createSliceSimulatorPage = async ({\n\thelpers,\n\toptions,\n}: CreateSliceSimulatorPageArgs) => {\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\tconst hasAppRouter = await checkHasAppRouter({ helpers });\n\n\tconst extension = await getJSFileExtension({ helpers, options, jsx: true });\n\tconst filename = await buildSrcPath({\n\t\tfilename: hasAppRouter\n\t\t\t? `app/slice-simulator/page.${extension}`\n\t\t\t: `pages/slice-simulator.${extension}`,\n\t\thelpers,\n\t});\n\n\tif (await checkHasProjectFile({ filename, helpers })) {\n\t\treturn;\n\t}\n\n\tlet contents;\n\n\tif (hasAppRouter) {\n\t\tif (isTypeScriptProject) {\n\t\t\tcontents = source`\n\t\t\t\timport {\n\t\t\t\t\tSliceSimulator,\n\t\t\t\t\tSliceSimulatorParams,\n\t\t\t\t\tgetSlices,\n\t\t\t\t} from \"@slicemachine/adapter-next/simulator\";\n\t\t\t\timport { SliceZone } from \"@prismicio/react\";\n\n\t\t\t\timport { components } from \"../../slices\";\n\n\t\t\t\texport default async function SliceSimulatorPage({\n\t\t\t\t\tsearchParams,\n\t\t\t\t}: SliceSimulatorParams) {\n\t\t\t\t\tconst { state } = await searchParams\n\t\t\t\t\tconst slices = getSlices(state);\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<SliceSimulator>\n\t\t\t\t\t\t\t<SliceZone slices={slices} components={components} />\n\t\t\t\t\t\t</SliceSimulator>\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t`;\n\t\t} else {\n\t\t\tcontents = source`\n\t\t\t\timport {\n\t\t\t\t\tSliceSimulator,\n\t\t\t\t\tgetSlices,\n\t\t\t\t} from \"@slicemachine/adapter-next/simulator\";\n\t\t\t\timport { SliceZone } from \"@prismicio/react\";\n\n\t\t\t\timport { components } from \"../../slices\";\n\n\t\t\t\texport default async function SliceSimulatorPage({ searchParams }) {\n\t\t\t\t\tconst { state } = await searchParams\n\t\t\t\t\tconst slices = getSlices(state);\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<SliceSimulator>\n\t\t\t\t\t\t\t<SliceZone slices={slices} components={components} />\n\t\t\t\t\t\t</SliceSimulator>\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t`;\n\t\t}\n\t} else {\n\t\tcontents = source`\n\t\t\timport { SliceSimulator } from \"@slicemachine/adapter-next/simulator\";\n\t\t\timport { SliceZone } from \"@prismicio/react\";\n\n\t\t\timport { components } from \"../slices\";\n\n\t\t\texport default function SliceSimulatorPage() {\n\t\t\t\treturn (\n\t\t\t\t\t<SliceSimulator\n\t\t\t\t\t\tsliceZone={(props) => <SliceZone {...props} components={components} />}\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t}\n\t\t`;\n\t}\n\n\tawait writeProjectFile({\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\thelpers,\n\t});\n};\n\nconst createPreviewRoute = async ({\n\thelpers,\n\toptions,\n}: SliceMachineContext<PluginOptions>) => {\n\tconst hasAppRouter = await checkHasAppRouter({ helpers });\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tconst extension = await getJSFileExtension({ helpers, options });\n\tconst filename = await buildSrcPath({\n\t\tfilename: hasAppRouter\n\t\t\t? `app/api/preview/route.${extension}`\n\t\t\t: `pages/api/preview.${extension}`,\n\t\thelpers,\n\t});\n\n\tif (await checkHasProjectFile({ filename, helpers })) {\n\t\treturn;\n\t}\n\n\tlet contents: string;\n\n\tif (hasAppRouter) {\n\t\tif (isTypeScriptProject) {\n\t\t\tcontents = source`\n\t\t\t\timport { NextRequest } from \"next/server\";\n\t\t\t\timport { redirectToPreviewURL } from \"@prismicio/next\";\n\n\t\t\t\timport { createClient } from \"../../../prismicio\";\n\n\t\t\t\texport async function GET(request: NextRequest) {\n\t\t\t\t\tconst client = createClient();\n\n\t\t\t\t\treturn await redirectToPreviewURL({ client, request });\n\t\t\t\t}\n\t\t\t`;\n\t\t} else {\n\t\t\tcontents = source`\n\t\t\t\timport { redirectToPreviewURL } from \"@prismicio/next\";\n\n\t\t\t\timport { createClient } from \"../../../prismicio\";\n\n\t\t\t\texport async function GET(request) {\n\t\t\t\t\tconst client = createClient();\n\n\t\t\t\t\treturn await redirectToPreviewURL({ client, request });\n\t\t\t\t}\n\t\t\t`;\n\t\t}\n\t} else {\n\t\tif (isTypeScriptProject) {\n\t\t\tcontents = source`\n\t\t\t\timport { NextApiRequest, NextApiResponse } from \"next\";\n\t\t\t\timport { setPreviewData, redirectToPreviewURL } from \"@prismicio/next/pages\";\n\n\t\t\t\timport { createClient } from \"../../prismicio\";\n\n\t\t\t\texport default async function handler(req: NextApiRequest, res: NextApiResponse) {\n\t\t\t\t\tconst client = createClient({ req });\n\n\t\t\t\t\tsetPreviewData({ req, res });\n\n\t\t\t\t\treturn await redirectToPreviewURL({ req, res, client });\n\t\t\t\t};\n\t\t\t`;\n\t\t} else {\n\t\t\tcontents = source`\n\t\t\t\timport { setPreviewData, redirectToPreviewURL } from \"@prismicio/next/pages\";\n\n\t\t\t\timport { createClient } from \"../../prismicio\";\n\n\t\t\t\texport default async function handler(req, res) {\n\t\t\t\t\tconst client = createClient({ req });\n\n\t\t\t\t\tsetPreviewData({ req, res });\n\n\t\t\t\t\treturn await redirectToPreviewURL({ req, res, client });\n\t\t\t\t};\n\t\t\t`;\n\t\t}\n\t}\n\n\tawait writeProjectFile({\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\thelpers,\n\t});\n};\n\nconst createExitPreviewRoute = async ({\n\thelpers,\n\toptions,\n}: SliceMachineContext<PluginOptions>) => {\n\tconst hasAppRouter = await checkHasAppRouter({ helpers });\n\tconst isTypeScriptProject = await checkIsTypeScriptProject({\n\t\thelpers,\n\t\toptions,\n\t});\n\n\tconst extension = await getJSFileExtension({ helpers, options });\n\tconst filename = await buildSrcPath({\n\t\tfilename: hasAppRouter\n\t\t\t? `app/api/exit-preview/route.${extension}`\n\t\t\t: `pages/api/exit-preview.${extension}`,\n\t\thelpers,\n\t});\n\n\tif (await checkHasProjectFile({ filename, helpers })) {\n\t\treturn;\n\t}\n\n\tlet contents: string;\n\n\tif (hasAppRouter) {\n\t\tcontents = source`\n\t\t\timport { exitPreview } from \"@prismicio/next\";\n\n\t\t\texport function GET() {\n\t\t\t\treturn exitPreview();\n\t\t\t}\n\t\t`;\n\t} else {\n\t\tif (isTypeScriptProject) {\n\t\t\tcontents = source`\n\t\t\t\timport { NextApiRequest, NextApiResponse } from \"next\";\n\t\t\t\timport { exitPreview } from \"@prismicio/next/pages\";\n\n\t\t\t\texport default function handler(req: NextApiRequest, res: NextApiResponse) {\n\t\t\t\t\treturn exitPreview({ req, res });\n\t\t\t\t}\n\t\t\t`;\n\t\t} else {\n\t\t\tcontents = source`\n\t\t\t\timport { exitPreview } from \"@prismicio/next/pages\";\n\n\t\t\t\texport default function handler(req, res) {\n\t\t\t\t\treturn exitPreview({ req, res });\n\t\t\t\t}\n\t\t\t`;\n\t\t}\n\t}\n\n\tawait writeProjectFile({\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\thelpers,\n\t});\n};\n\nconst modifySliceMachineConfig = async ({\n\thelpers,\n\toptions,\n\tactions,\n}: SliceMachineContext<PluginOptions>) => {\n\tconst hasSrcDirectory = await checkHasProjectFile({\n\t\tfilename: \"src\",\n\t\thelpers,\n\t});\n\tconst project = await helpers.getProject();\n\n\t// Add Slice Simulator URL.\n\tproject.config.localSliceSimulatorURL ||=\n\t\t\"http://localhost:3000/slice-simulator\";\n\n\t// Nest the default Slice Library in the src directory if it exists and\n\t// is empty.\n\tif (\n\t\thasSrcDirectory &&\n\t\tproject.config.libraries &&\n\t\tJSON.stringify(project.config.libraries) === JSON.stringify([\"./slices\"])\n\t) {\n\t\tconst sliceLibrary = await actions.readSliceLibrary({\n\t\t\tlibraryID: project.config.libraries[0],\n\t\t});\n\n\t\tif (sliceLibrary.sliceIDs.length < 1) {\n\t\t\tproject.config.libraries = [\"./src/slices\"];\n\t\t}\n\t}\n\n\tawait helpers.updateSliceMachineConfig(project.config, {\n\t\tformat: options.format,\n\t});\n};\n\nconst createRevalidateRoute = async ({\n\thelpers,\n\toptions,\n}: SliceMachineContext<PluginOptions>) => {\n\tconst hasAppRouter = await checkHasAppRouter({ helpers });\n\n\tif (!hasAppRouter) {\n\t\treturn;\n\t}\n\n\tconst nextJSVersion = await getNextJSVersion();\n\tconst supportsCacheLife = semver.gte(nextJSVersion, \"16.0.0-beta.0\");\n\n\tconst extension = await getJSFileExtension({ helpers, options });\n\tconst filename = await buildSrcPath({\n\t\tfilename: `app/api/revalidate/route.${extension}`,\n\t\thelpers,\n\t});\n\n\tif (await checkHasProjectFile({ filename, helpers })) {\n\t\treturn;\n\t}\n\n\tconst contents = source`\n\t\timport { NextResponse } from \"next/server\";\n\t\timport { revalidateTag } from \"next/cache\";\n\n\t\texport async function POST() {\n\t\t\trevalidateTag(\"prismic\"${supportsCacheLife ? ', \"max\"' : \"\"});\n\n\t\t\treturn NextResponse.json({ revalidated: true, now: Date.now() });\n\t\t}\n\t`;\n\n\tawait writeProjectFile({\n\t\tfilename,\n\t\tcontents,\n\t\tformat: options.format,\n\t\thelpers,\n\t});\n};\n\nconst upsertSliceLibraryIndexFiles = async (\n\tcontext: SliceMachineContext<PluginOptions>,\n) => {\n\t// We must use the `getProject()` helper to get the latest version of\n\t// the project config. The config may have been modified in\n\t// `modifySliceMachineConfig()` and will not be relfected in\n\t// `context.project`.\n\t// TODO: Automatically update the plugin runner's in-memory `project`\n\t// object when `updateSliceMachineConfig()` is called.\n\tconst project = await context.helpers.getProject();\n\n\tif (!project.config.libraries) {\n\t\treturn;\n\t}\n\n\tawait Promise.all(\n\t\tproject.config.libraries.map(async (libraryID) => {\n\t\t\tawait upsertSliceLibraryIndexFile({ libraryID, ...context });\n\t\t}),\n\t);\n};\n\nexport const projectInit: ProjectInitHook<PluginOptions> = async (\n\t{ installDependencies: _installDependencies },\n\tcontext,\n) => {\n\trejectIfNecessary(\n\t\tawait Promise.allSettled([\n\t\t\tinstallDependencies({ installDependencies: _installDependencies }),\n\t\t\tmodifySliceMachineConfig(context),\n\t\t\tcreatePrismicIOFile(context),\n\t\t\tcreateSliceSimulatorPage(context),\n\t\t\tcreatePreviewRoute(context),\n\t\t\tcreateExitPreviewRoute(context),\n\t\t\tcreateRevalidateRoute(context),\n\t\t]),\n\t);\n\n\t// This must happen after `modifySliceMachineConfig()` since the\n\t// location of the default Slice library may change.\n\tawait upsertSliceLibraryIndexFiles(context);\n};\n"],"names":["installDependencies","checkIsTypeScriptProject","checkHasProjectFile","checkHasAppRouter","getJSFileExtension","buildSrcPath","source","PRISMIC_ENVIRONMENT_ENVIRONMENT_VARIABLE_NAME","writeProjectFile","getNextJSVersion","semver","upsertSliceLibraryIndexFile","rejectIfNecessary"],"mappings":";;;;;;;;;;;;;AA2BA,MAAM,sBAAsB,OAAO,EAClC,qBAAAA,2BAC6B;AAC7B,QAAMA,qBAAoB;AAAA,IACzB,cAAc;AAAA,MACb,qBAAqB;AAAA,MACrB,oBAAoB;AAAA,MACpB,mBAAmB;AAAA,IAAA;AAAA,EACnB,CACD;AACF;AAIA,MAAM,sBAAsB,OAAO,EAClC,SACA,cAC6B;AAC7B,QAAM,sBAAsB,MAAMC,kDAAyB;AAAA,IAC1D;AAAA,IACA;AAAA,EAAA,CACA;AACD,QAAM,kBAAkB,MAAMC,uBAAoB;AAAA,IACjD,UAAU;AAAA,IACV;AAAA,EAAA,CACA;AACD,QAAM,eAAe,MAAMC,oCAAkB,EAAE,SAAS;AAExD,QAAM,YAAY,MAAMC,mBAAAA,mBAAmB,EAAE,SAAS,SAAS;AAC/D,QAAM,WAAW,MAAMC,0BAAa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ACA,QAAQ,QAAQ;AAAA,IAChB;AAAA,EAAA,CACA;AACF;AAEA,MAAM,+BAA+B,OACpC,YACG;AAOH,QAAM,UAAU,MAAM,QAAQ,QAAQ,WAAA;AAEtC,MAAI,CAAC,QAAQ,OAAO,WAAW;AAC9B;AAAA,EACD;AAEA,QAAM,QAAQ,IACb,QAAQ,OAAO,UAAU,IAAI,OAAO,cAAa;AAChD,UAAMG,wDAA4B,EAAE,WAAW,GAAG,SAAS;AAAA,EAC5D,CAAC,CAAC;AAEJ;AAEO,MAAM,cAA8C,OAC1D,EAAE,qBAAqB,qBAAA,GACvB,YACG;AACHC,sCACC,MAAM,QAAQ,WAAW;AAAA,IACxB,oBAAoB,EAAE,qBAAqB,sBAAsB;AAAA,IACjE,yBAAyB,OAAO;AAAA,IAChC,oBAAoB,OAAO;AAAA,IAC3B,yBAAyB,OAAO;AAAA,IAChC,mBAAmB,OAAO;AAAA,IAC1B,uBAAuB,OAAO;AAAA,IAC9B,sBAAsB,OAAO;AAAA,EAAA,CAC7B,CAAC;AAKH,QAAM,6BAA6B,OAAO;AAC3C;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { checkHasProjectFile, writeProjectFile } from "@slicemachine/plugin-kit/fs";
|
|
2
2
|
import { source } from "common-tags";
|
|
3
|
+
import semver from './../packages/adapter-next/_node_modules/semver/index.js';
|
|
3
4
|
import { buildSrcPath } from "../lib/buildSrcPath.js";
|
|
4
5
|
import { checkHasAppRouter } from "../lib/checkHasAppRouter.js";
|
|
5
6
|
import { checkIsTypeScriptProject } from "../lib/checkIsTypeScriptProject.js";
|
|
@@ -7,6 +8,7 @@ import { getJSFileExtension } from "../lib/getJSFileExtension.js";
|
|
|
7
8
|
import { rejectIfNecessary } from "../lib/rejectIfNecessary.js";
|
|
8
9
|
import { upsertSliceLibraryIndexFile } from "../lib/upsertSliceLibraryIndexFile.js";
|
|
9
10
|
import { PRISMIC_ENVIRONMENT_ENVIRONMENT_VARIABLE_NAME } from "../constants.js";
|
|
11
|
+
import { getNextJSVersion } from "../lib/getNextJSVersion.js";
|
|
10
12
|
const installDependencies = async ({ installDependencies: installDependencies2 }) => {
|
|
11
13
|
await installDependencies2({
|
|
12
14
|
dependencies: {
|
|
@@ -449,6 +451,8 @@ const createRevalidateRoute = async ({ helpers, options }) => {
|
|
|
449
451
|
if (!hasAppRouter) {
|
|
450
452
|
return;
|
|
451
453
|
}
|
|
454
|
+
const nextJSVersion = await getNextJSVersion();
|
|
455
|
+
const supportsCacheLife = semver.gte(nextJSVersion, "16.0.0-beta.0");
|
|
452
456
|
const extension = await getJSFileExtension({ helpers, options });
|
|
453
457
|
const filename = await buildSrcPath({
|
|
454
458
|
filename: `app/api/revalidate/route.${extension}`,
|
|
@@ -462,7 +466,7 @@ const createRevalidateRoute = async ({ helpers, options }) => {
|
|
|
462
466
|
import { revalidateTag } from "next/cache";
|
|
463
467
|
|
|
464
468
|
export async function POST() {
|
|
465
|
-
revalidateTag("prismic");
|
|
469
|
+
revalidateTag("prismic"${supportsCacheLife ? ', "max"' : ""});
|
|
466
470
|
|
|
467
471
|
return NextResponse.json({ revalidated: true, now: Date.now() });
|
|
468
472
|
}
|