Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
breck7 committed Feb 2, 2025
1 parent 771df4e commit e6fdc48
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scrollsdk",
"version": "101.1.0",
"version": "101.1.1",
"description": "This npm package includes the Particles class, the Parsers compiler-compiler, a Parsers IDE, and more, all implemented in Particles, Parsers, and TypeScript.",
"types": "./built/scrollsdk.node.d.ts",
"main": "./products/Particle.js",
Expand Down
2 changes: 1 addition & 1 deletion particle/Particle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3122,7 +3122,7 @@ class Particle extends AbstractParticle {
return str ? indent + str.replace(/\n/g, indent) : ""
}

static getVersion = () => "101.1.0"
static getVersion = () => "101.1.1"

static fromDisk(path: string): Particle {
const format = this._getFileFormat(path)
Expand Down
5 changes: 3 additions & 2 deletions products/Fusion.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,17 +322,17 @@ class Fusion {
if (_expandedImportCache[absoluteFilePathOrUrl]) return _expandedImportCache[absoluteFilePathOrUrl]
const [code, exists] = await Promise.all([this.read(absoluteFilePathOrUrl), this.exists(absoluteFilePathOrUrl)])
const isImportOnly = importOnlyRegex.test(code)
const lineCount = code.split("\n").length
// Perf hack
// If its a parsers file, it will have no content, just parsers (and maybe imports).
// The parsers will already have been processed. We can skip them
const stripParsers = absoluteFilePathOrUrl.endsWith(PARSERS_EXTENSION)
const processedCode = stripParsers
let processedCode = stripParsers
? code
.split("\n")
.filter(line => importRegex.test(line))
.join("\n")
: code
const lineCount = processedCode.split("\n").length
const filepathsWithParserDefinitions = []
if (await this._doesFileHaveParsersDefinitions(absoluteFilePathOrUrl)) {
filepathsWithParserDefinitions.push(absoluteFilePathOrUrl)
Expand Down Expand Up @@ -406,6 +406,7 @@ class Fusion {
importFilePaths,
isImportOnly,
fused: particle.toString(),
lineCount,
footers,
circularImportError: hasCircularImportError,
exists: allImportsExist,
Expand Down
5 changes: 3 additions & 2 deletions products/Fusion.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,17 +330,17 @@ class Fusion {
if (_expandedImportCache[absoluteFilePathOrUrl]) return _expandedImportCache[absoluteFilePathOrUrl]
const [code, exists] = await Promise.all([this.read(absoluteFilePathOrUrl), this.exists(absoluteFilePathOrUrl)])
const isImportOnly = importOnlyRegex.test(code)
const lineCount = code.split("\n").length
// Perf hack
// If its a parsers file, it will have no content, just parsers (and maybe imports).
// The parsers will already have been processed. We can skip them
const stripParsers = absoluteFilePathOrUrl.endsWith(PARSERS_EXTENSION)
const processedCode = stripParsers
let processedCode = stripParsers
? code
.split("\n")
.filter(line => importRegex.test(line))
.join("\n")
: code
const lineCount = processedCode.split("\n").length
const filepathsWithParserDefinitions = []
if (await this._doesFileHaveParsersDefinitions(absoluteFilePathOrUrl)) {
filepathsWithParserDefinitions.push(absoluteFilePathOrUrl)
Expand Down Expand Up @@ -414,6 +414,7 @@ class Fusion {
importFilePaths,
isImportOnly,
fused: particle.toString(),
lineCount,
footers,
circularImportError: hasCircularImportError,
exists: allImportsExist,
Expand Down
6 changes: 4 additions & 2 deletions products/Particle.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1383,6 +1383,7 @@ class Particle extends AbstractParticle {
}
_setSubparticles(content, circularCheckArray) {
this._clearSubparticles()
// todo: is this correct? seems like `new Particle("").length` should be 1, not 0.
if (!content) return this
// set from string
if (typeof content === "string") {
Expand Down Expand Up @@ -1445,7 +1446,8 @@ class Particle extends AbstractParticle {
}
_insertLines(lines, index = this.length) {
const parser = this.constructor
const newParticle = new parser(lines)
const newParticle = new parser()
if (typeof lines === "string") newParticle._appendSubparticlesFromString(lines)
const adjustedIndex = index < 0 ? this.length + index : index
this._getSubparticlesArray().splice(adjustedIndex, 0, ...newParticle.getSubparticles())
if (this._cueIndex) this._makeCueIndex(adjustedIndex)
Expand Down Expand Up @@ -2623,7 +2625,7 @@ Particle.iris = `sepal_length,sepal_width,petal_length,petal_width,species
4.9,2.5,4.5,1.7,virginica
5.1,3.5,1.4,0.2,setosa
5,3.4,1.5,0.2,setosa`
Particle.getVersion = () => "101.1.0"
Particle.getVersion = () => "101.1.1"
class AbstractExtendibleParticle extends Particle {
_getFromExtended(cuePath) {
const hit = this._getParticleFromExtended(cuePath)
Expand Down
6 changes: 4 additions & 2 deletions products/Particle.js
Original file line number Diff line number Diff line change
Expand Up @@ -1373,6 +1373,7 @@ class Particle extends AbstractParticle {
}
_setSubparticles(content, circularCheckArray) {
this._clearSubparticles()
// todo: is this correct? seems like `new Particle("").length` should be 1, not 0.
if (!content) return this
// set from string
if (typeof content === "string") {
Expand Down Expand Up @@ -1435,7 +1436,8 @@ class Particle extends AbstractParticle {
}
_insertLines(lines, index = this.length) {
const parser = this.constructor
const newParticle = new parser(lines)
const newParticle = new parser()
if (typeof lines === "string") newParticle._appendSubparticlesFromString(lines)
const adjustedIndex = index < 0 ? this.length + index : index
this._getSubparticlesArray().splice(adjustedIndex, 0, ...newParticle.getSubparticles())
if (this._cueIndex) this._makeCueIndex(adjustedIndex)
Expand Down Expand Up @@ -2613,7 +2615,7 @@ Particle.iris = `sepal_length,sepal_width,petal_length,petal_width,species
4.9,2.5,4.5,1.7,virginica
5.1,3.5,1.4,0.2,setosa
5,3.4,1.5,0.2,setosa`
Particle.getVersion = () => "101.1.0"
Particle.getVersion = () => "101.1.1"
class AbstractExtendibleParticle extends Particle {
_getFromExtended(cuePath) {
const hit = this._getParticleFromExtended(cuePath)
Expand Down
7 changes: 7 additions & 0 deletions products/Particle.test.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1890,11 +1890,18 @@ testParticles.insert = equal => {
testParticles.insertLinesAfter = equal => {
// Arrange
const particle = new Particle("hello world")
// Assert
equal(particle.length, 1)
// Act
particle.getParticle("hello").insertLinesAfter(`config
score 2`)
// Assert
equal(particle.get("config score"), "2", "Expected 2")
equal(particle.length, 2)
// Empty
// Act
particle.getParticle("hello").insertLinesAfter(``)
equal(particle.length, 3)
}
testParticles.last = equal => {
// Arrange
Expand Down

0 comments on commit e6fdc48

Please sign in to comment.